instruction
stringlengths
34
53.1k
As someone who can't be bothered to look at their pentominos to see if it makes a rectangular shape, I've decided to make you write a program that does it. Your task Given some input split by newlines containing 12 unique characters, decide if it is a valid solution. A valid solution MUST Have 5 of each character (exc...
I'm retiling my kitchen with different coloured tiles. In fact, it's going to have at least 2 colours - and 26 colours as a maximum. But, I'm fussy. I want this wall to look random, but sometimes random isn't random enough. So, when I lay out my tiles, I don't want to have any the same colour next to each other in the ...
This is a rather simple challenge, but I couldn't find any question that was really similar to it. The challenge is to take a frequency in using STDIN or an equivalent, and then output a tone that matches that frequency, in Hz, for 5 seconds. For example Input: 400 Output: (a tone of 400 Hz with a duration of 5 seconds...
I came across SVGCaptcha, and immediately knew it was a bad idea. I would like you to show just how bad an idea this is by extracting the validation code from the SVG images that code produces. An example image looks like this: Here is the source of the example image: <?xml version="1.0" encoding="utf-8"?><!DOCTYPE s...
If you express some positive integer in binary with no leading zeros and replace every 1 with a ( and every 0 with a ), then will all the parentheses match? In most cases they won't. For example, 9 is 1001 in binary, which becomes ())(, where only the first two parentheses match. But sometimes they will match. For exam...
Given a properly-parenthesized string as input, output a list of all nonempty substrings within matching parentheses (or outside of all parentheses), with nested parentheses removed. Each substring should be the sequence of characters in exactly the same matching parentheses. Substrings should be listed in order of dep...
In this challenge, you need to parse morgue files from the roguelike game Dungeon Crawl Stone Soup and output it to STDOUT. What are these morgue files?? When you die, a text file is generated with that character's data inside. You can see what equipment the character had, what happened during the last few turns, and h...
The Task You are to write some ASCII Art Text as seen from this website for generating ASCII art! Rules Input will only be alphabetical text and spaces, and will be input as a single line. It is also case-insensitive. You needn't fix if the output text is longer than the terminal width. As long as it would be correct i...
Time for a new typography challenge! It’s a common problem when copy-pasting between various document formats: hyphenation. While it reduces the raggedness of a left-aligned layout or evens spacing in a justified layout, it’s a complete pain when your PDF is not properly constructed and retains the hyphens in the layou...
Write a program that fills in the paths of a grid of characters (ASCII 20-7E) according to the following rules. The path is governed by eight directional characters: -, |, /, \, &, @, %, and *, as specified in the table below. The direction of the path will change when it reaches one of the eight above characters. Note...
Starry is a funny esoteric programming language in which code consists only of +*.,`' where the actual command represented by each of those characters is determined by the number of spaces in front of it. That makes it tricky even to golf fixed-output challenges, because different commands can account for vastly differ...
Your task is to write a program that, on input n, outputs the minimal expression of each number 1 through n in order. The shortest program in bytes wins. A minimal expression combines 1's with addition and multiplication to result in the given number, using as few 1's as possible. For example, 23 is expressed as 23=((...
Set Theoretic Arithmetic Premise There have been a couple challenges already that involve multiplying without the multiplication operator ( here and here ) and this challenge is in the same vein (most similar to the second link). This challenge, unlike those previous, will use a set theoretic definition of the natural...
Write a program or function that given some text, a number of columns, and the column width, formats the text into columns. This is plain text typography. Rules Input The text will be a string of printable ASCII and may contain newlines and spaces (but not tabs). The number of columns will be a positive integer. The c...
This serves as a catalog for tips related to golfing in Burlesque. Burlesque is a lazy, esoteric programming language. It's mostly used on anarchy golf while popularity on Codegolf is not as high. However, this catalog is intended to be used by people golfing on anarchy golf as well. Please only mention tricks and not...
Objective Given an input of text that does not contain characters [ or ], perform the following actions: For every instance of Amen with at least one capital letter (so all instances of Amen excluding amen), output that same Amen (retain capitalization). For every instance of /all the people said[?: ]/i (that's a Regu...
Your task is to compile regexes... by specifying a substitution for each character in a regex. Regexes The regexes support these REGEX = (LITERAL REGEX / GROUP REGEX / STAR REGEX / ALTERNATIVE) LITERAL = 1 / 0 GROUP = '(' REGEX ')' STAR = (LITERAL / GROUP) '*' ALTERNATIVE = '('REGEX ('|' REGEX)*'...
I have been recently told to read an entire physics textbook by the new year (true story, unfortunately). I need your help to determine what chapters I should read each day. This is where you come in. Input Two dates, in any format. The second date will always be later than the first. A list of chapter numbers. This c...
I just had a lesson in school about alkanes and figured it would probably make for a great code golf challenge! Don't worry, it isn't as complicated as it may look! A Quick Rehash (Please Note: To keep this brief, not all information is 100% accurate.) Alkanes are strings of carbon and hydrogen. Every carbon atom has 4...
This is an Irregular Webcomic! themed task.* Death is a rather extensive orginization, and, although Head Death has had no trouble telling his employees apart, certain other entities connected to the orginization have had trouble keeping track of them all. Thus, your task here is to, given the title of one of the var...
Well, turns out Doorknob's username on GitHub, Reddit, and other sites is KeyboardFire. That gives me an idea... The task You work at KeyboardFire Inc., a company that makes special keyboards. And, by "special", I mean that, whenever you press a key, something in your house lights on fire! With the new KeyboardFire Doo...
There have been many other flag challenges posted but not one for the national flag of France. This week seems like an appropriate time. Produce this flag in the fewest bytes possible: The image must be in a ratio of 3:2, with size at least 78 pixels wide and 52 pixels tall. Each stripe takes up one third of the widt...
Write, in as few characters as possible, a program that takes zero or six command-line arguments menorah menorah YEAR MONTH DAY HOUR MINUTE SECOND (Both forms must be supported. The zero-argument version shall be equivalent to calling the six-argument version with the current system date and time in the local timezon...
Bounties No. 1 (awarded) I'll throw in 50 rep for the first valid answer No. 2 (awarded) I'll throw in another 100 rep for the shortest valid answer. No. 3 (open for submissions) I'll throw in 200 rep for the first one with a significant shorter valid answer. Significant being at most 45% of currently shortest a...
Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of b...
There are important differences between Python 2 and 3, so it's often useful to know which version of the interpreter is running your code. The straightforward method is something like this: def get_python_version(): import sys return sys.version_info.major But you can exploit other differences to come up with...
Given a string as input, output the US state whose capital it is if it is a state capital, the capital of the state if it is a state, or Arstotzka if it is neither. Examples: Austin -> Texas Alaska -> Juneau The Nineteenth Byte -> Arstotzka All the capitals and their respective states: Baton Rouge, Louisiana Indianapo...
My cell phone carrier charges a cent per character in a text! I need a program to shorten the words for me, while still being understandable. I will be texting this program to my friends, so it needs to be as short as possible. Your program will take a String (a word is separated by a non-alphanumeric character) of wor...
Write a program or function that takes in an odd positive integer N and a string of decimal digits (0123456789). The string represents a ten-state one-dimensional cellular automaton. Each digit occupies one cell and the update rule from one generation to the next is that every cell becomes the digit resulting from the ...
There are n boxes, numbered 1-n. Each box is locked, such that it can be opened by only one corresponding type of key (also numbered 1-n). These keys are randomly scattered in the boxes (one box may have any number of keys, one key may have any number of duplicates), and then all boxes are shut. A treasure (numbered 0)...
Inspired by this question: Make a function (or a full program) that receives a list of numbers and outputs the list rearranged, so that even-indexed numbers appear first, and odd-indexed numbers follow. The values of the numbers themselves don't affect ordering - only their indices do. All indices are zero-based. For e...
New Bonus! (See below) The cartography team of U.S. Republican presidential hopeful Ben Carson is having some trouble with their maps (image via Washington Post): The problem is they don't have the Right Tool For The Job™. They need the most compact and reliable program possible, so they never have to worry about maki...
Boustrophedon is a type of bi-directional text where successive lines alternate between reading left-to-right and right-to-left. Character direction was also mirrored with respect to reading direction. In reverse boustrophedon writing systems, characters were rotated 180 instead of mirrored. Challenge Write a program/f...
Given an image that has only black and white pixels and an (x,y) location that's a white pixel, color the white pixels based on their minimal Manhattan distance from (x,y) in a path that only involves traversing other white pixels. The hue of the colored pixels must be proportional to their distance from (x,y), so the ...
Requirements You need to make a smiley face go from smiling to frowning and back. There needs to the below faces in the code: Smiling, no expression, frowning, no expression, and then back to smiling. The new face needs to replace the old face flipbook style so that there's only one face on the screen at a time. There ...
Statement You are given a still of a series of balls falling in a 2D grid. This grid is surrounded by immutable and unbreakable walls so all the action is contained within them. Your task is to determine what the state of the scenario will be after gravity does all it's work. Elements inside grid - Floor, doesn't alt...
Write a program or function that takes in a string of the characters -=o. where the -=o's and .'s always alternate, character to character. The string will have an odd length greater than one and always start and end in one of -=o. Basically, the input will look like a line of emoticon faces that share eyes in various ...
Introduction BitShift is an esolang, created by me, to output strings. Sounds boring, is boring. However, the only instructions available to BitShift are 0 and 1. Therefore it can be challenging to golf in it. To make matters even more interesting, the language only supports 4 bitshifting instructions, a clear, a print...
Introduction One of the first things I learned in chemistry, was giving the formula for the combustion of alkanes. The most basic example was: 2CH4 + 4O2 -> 4H2O + 2CO2. Note that the equation could have been simplified by dividing every coefficient by 2, we would get CH4 + 2O2 -> 2H2O + CO2. To make things easier, we ...
(massive thanks to El'endia Starman and Sp3000 for helping me design test cases for this!) Given a positive integer n and a list of positive integer rotational periods for a number of clock hands (in seconds), output the smallest positive integer x where x seconds after starting the clock with all of the hands aligned,...
Background The Rearrangement Inequality is an inequality that is based on rearranging numbers. If I have two lists of numbers of the same length, x0, x1, x2...xn-1 and y0, y1, y2...yn-1 of the same length, where I am allowed to rearrange the numbers in the list, a way to maximize the sum x0y0+x1y1+x2y2+...+xn-1yn-1 is ...
A man from the stars has come to Earth! Luckily the president of the United States, Donald Trump, has an infinity-sided die. Using this die, he can conjure up a number which you, the mayor of Podunk, must use to determine who should be sent to stop the invader! But be careful, you can only send a limited amount of byte...
The popular webcomic Homestuck makes use of a programming language called ~ATH to destroy universes. While this code golf challenge is not to write a program to annihilate our existence, we will be destroying some more tame (albeit less interesting) entities: variables.  ~ATH (pronounced "til death," notice how ~ath is...
Take a look at this image. Specifically, at how the holes on the ends are arranged. (Image source) Notice how the pipes in this image are packed in a hexagonal pattern. It is known that in 2D, a hexagonal lattice is the densest packing of circles. In this challenge, we will be focusing on minimizing the perimeter of a...
This is the cops' thread. For the robbers' thread, go here. Introduction For this Cops/Robbers challenge, the cops will write output-producing programs and interweave them together. It is the robber's job to pick apart the cops' programs to produce the desired outputs. Cop rules The cops may use up to 256 bytes total t...
This is the robbers' thread. For the cops' thread, go here. Introduction For this Cops/Robbers challenge, the cops will write output-producing programs and interweave them together. It is the robber's job to pick apart the cops' programs to produce the desired outputs. Robber rules Robbers will try to find the differen...
Given a list of strings, output a single string formed by taking a character from each string at each position, sorting them by ASCII ordinal, and appending them in order to the output string. In other words, for n input strings, the first n characters of the output will be the first characters of each of the inputs so...
King Julian needs to get through the jungle, but he's feeling lazy. He wants a computer to be able to calculate a route through the jungle for him. Using STDIN get a map of the jungle for the computer to crack. It will follow the following format: 01001E 010110 000P00 1100J1 S00111 The way the jungle map works is: 0 i...
In the PPCG chatroom the Nineteenth Byte, using carets ^ (or carrots) is a way of indicating that you agree with one of the previously made comments just above yours. A caret message consists solely of N ^ characters (where N is a positive integer) and it means agreement with the Nth previous message. So a single ^ mea...
Recently, I have found a bijective mapping \$f\$ from positive integers to finite, nested sequences. The purpose of this challenge is to implement it in the language of your choice. The Mapping Consider a number \$n\$ with the factors \$2^{a_1}3^{a_2}5^{a_3}\cdots p^{a_i}\$ where \$a_i > 0\$ $$f(n) = \{f(a_2+1),f(a_3+1...
Your boss has found out that quite a bunch of his employees (including you) like to steal code from others. He ordered you to write him a program that he can use to find people who steal code from others. Task: Write a program/function that detects if somebody copied (part of) his code from somewhere else. The progra...
map is a very basic yet important function in functional programming. All FP programming languages have it built-in but it is always fun to see how shortly you can define it yourself. This will be scored in AST nodes, not bytes. A token is the second-smallest building block of a program, over characters. A token is: a...
Given a string of ASCII characters, output the character that is in the middle. If there is no middle character (when the string has an even length), output the ASCII character whose ordinal is the floored average of the two center characters. If the string is empty, an empty string should be output. Test cases: 12345 ...
Let's say I have a condition expression x and that I want to check if it is TRUE or FALSE depending on the value of a boolean y: y ? x : !x Is there a way to express it without repeating x expression? Something like how we can get a number or its opposite depending on a bool, without repeating the number in the expres...
Background Today (or Yesterday) is (or was) 11/23 or Fibonacci day! What better way to celebrate than to make a Fibonacci cake? Examples 3 ii i_i_ii_i_i </> 8 ii ii ii ii ii ...
Given a character, output (to the screen) the entire qwerty keyboard layout (with spaces and newlines) that follows the character. The examples make it clear. Input 1 f Output 1 g h j k l z x c v b n m Input 2 q Output 2 w e r t y u i o p a s d f g h j k l z x c v b n m Input 3 m Output 3 (Program terminates witho...
What is Toothpick Sequence? According to Wikipedia In geometry, the toothpick sequence is a sequence of 2-dimensional patterns which can be formed by repeatedly adding line segments ("toothpicks") to the previous pattern in the sequence. The first stage of the design is a single "toothpick", or line segment. Each stag...
There's a question on this site that is similar to this question, but I have added a twist. You have three inputs, the number of people in the circle n, the k-th person counted out at each step, and the q-th person that survives. The people in the circle are numbered 1 to n. For example, in a circle of 20 people, the 2...
A typo is said to have occurred if: A character is missing. A character is extra. A character is replaced with another wrong character. For the purpose of this challenge, only lowercase characters and spaces are used. Input will be a dictionary of words, followed by one line of input. You need to find the (minimum) n...
Why a Simulator? Kids these days don't have the time nor the ambition to actually go and stack boxes on the see-saw or play around with balancing physical objects. This leaves lots of room in the software market for a Lever Simulator which will, according to my models, sell like mad! Programming Help Wanted I've filed ...
These days, I watched on TV a Gay Pride parade; at the time, I was thinking about quines and how they're a bit queer, outputting themselves (out of the closet?) and, well, why not combine both things into a Quine Pride Parade? The challenge is to write a program that: Is a quine. Prints the sentence I am a quine writ...
A fun programming exercise is to write a program that quizzes the user from a set list of questions and answers. However, this task goes a level beyond that. Your task Write a program/func/etc. that takes two lists: A list of questions and a list of answers. Output a program that quizzes the user. The output program s...
I enjoy participating in math competitions run by Mu Alpha Theta, a mathematics honor society in the United States. At competitions, I take a 30-question multiple choice test. There are five choices per question, labeled A through E. My score on a test is four points for each correct answer, zero points for a question ...
Goal: Your goal is to print out numbers within a given range (Also including given values). Input Format: The input will look like: (int-int, int-int, ...) ... meaning the user can add as many int-int as they'd like. Other Info: You will only have to handle non-negative integer numbers. The first integer in int-int wi...
The goal of this challenge is to find the direction and area enclosed by a loop. Input: A rectangular grid consisting entirely of these characters: ^v<> (Optionally, you may also be given the dimensions of the grid before the grid itself in decimal with a prefix, suffix, and separator character of your choice.) A loop ...
You are given a set of positive integers. You must arrange them into pairs such that: Each pair contains 2 numbers, one of which is a multiple of another. For example, 8 is a multiple of 4, and 9 is a multiple of 9. If the same number occurs many times in the initial set, it can be used that many times in the pairs; a...
Come November 1, Programming Puzzles and Code Golf will graduate, so in the next 11 months, we'll want to save some memories from when we were ungraduated. Write a program that produces the PPCG favicon, seen below. The image must be at least 64x64 pixels. The blue must be the color #62B0DF. The background can be whi...
The goal of this challenge is to produce an animation of a chain drive system, comprised of a set of sprocket gears connected together by a chain. General Requirements Your program will be given a list of sprockets, specified as (x, y, radius) triplets. The resulting chain drive system is comprised of these sprockets, ...
Background Some holidays have fixed, easy-to-remember dates, like Oct 31, Dec 25, etc. Some, however, want to be troublesome. They're specified as things like "the first Monday in September" or "the fourth Thursday in November". How am I supposed to know when that is? All I know is that Thanksgiving is fast approaching...
Introduction You are the manager of the electronics department in a major retail store and the biggest sales day of the year is this Friday. To help manage the crowds, your store is implementing a ticket system for the biggest deals, where customers must present a ticket before purchasing an item. Your job is to write ...
Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers n == a^2 + b^2 (OEIS A004018). Note that a and b can be positive, negative, or zero, and their order matters. Fewest bytes wins. For example, n=25 gives 12 because 25 can be expressed as (5)^2 + (0)^2 (4)^2 + (...
Background You are bored in class, and having exhausted all the possible things to write on a standard calculator (Like 8008135) you turn to the periodic table. You want to figure out if you can write your message using the shorthand for chemical elements. This is the inverse of this challenge. The Challenge Input: A...
Background You are sitting in chemistry class and your friend keep sending you these strange letters. It is your job to decrypt the messages into words. This is the inverse of this challenge. The Challenge Input: A list or a string of integers from 1 to 118. Output: The words for each chemical element if possible. Ot...
dary! In events entirely unrelated to what will hopefully happen to me in the next couple of days, I task you to write code that does the following: Print Legen... wait for it... immediately, with a trailing newline. Wait until the next full hour (when the cron job for awarding the badge runs). Print dary! with an o...
(Hopefully it's still Thanksgiving for you) You got a turkey for your thanksgiving dinner but you don't know how to evenly distribute it. The problem is, some people eat more than others, so you need to find a solution Input There will be two inputs. The first will be an ascii art of various people. o o \|/ \|/ ...
You should write 3 programs and/or functions in one language. All of these programs should solve the same task but they all should give different (but valid) outputs. (I.e. for every pair of programs their should be some input which generates different (but valid) sets of output numbers.) The task You are given an int...
The goal of this challenge is to determine the angle of a line in a image. Rules on the image: The image background will be white (#FFFFFF) The stroke of the line will be black (#000000) The line will NOT be anti-aliased The image will be 100x100 pixels The line will start at the center of the image The line will sta...
Goal Write a full program that generates a map showing the local train stations and which train station is the closest to every point on the map. Requirements Input A set of tuples. The first is the (Width,Height) dimensions of the map. The following tuples are the (X,Y) coordinates of each train station. Coordinate...
One aspect of password strength testing is runs of adjacent letters on the keyboard. In this challenge, a program must be created that returns true if a string contains any runs of adjacent letters. What counts as a run of adjacent letters? For this simplified version of a password strength tester, a run of adjacent ch...
Introduction This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level. The Challenge Create a program or function that, given one strictly positive integer N, outputs or returns how many divisors it ha...
It's friday! Which means it's time for beer! Sadly though, today we will be golfing beer instead of drinking it. :( Challenge Output a beer and drink it. The amount of sips you take changes your output. Sips Your program should take one input string. This string can solely consist out of concatenated sips. If the input...
This challenge is based on a problem described in D. Parnas, On the criteria to be used in decomposing systems into modules, and elaborated upon in J. Morris, Real Programming in Functional Languages. Write a program or function which takes a list of book titles from stdin or as an argument, in a reasonable, convenient...
Challenge Make an error-checker in the least amount of possible bytes! If you received an HTML program as a string through standard input, your program will be able to find all the errors and return to standard output. If the program is over 2000 characters, return that as an error too. Errors As there has been discrep...
Challenge You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means: It must be in 24-hour or AM/PM format. If it is the former, it must be spaced out with colons (i.e. 15:47:36). If it is the latter, it must be spaced out with colons and have t...
Introduction The LaTeX typesetting system uses macros for defining accents. For example, the letter ê is produced by \hat{e}. In this challenge, your task is to implement an ASCII version of this functionality. Input Your input is a non-empty string of printable ASCII characters. It will not contain newlines. Output Yo...
A man has two devices. A time machine - He can control this machine by thinking. It allows him to travel from any point in time to another point in time in the past or future (or even the present point in time) in no time at all. Note that if he travels to the past from B to A, then all normal events (time machines, a...
Pretty simple challenge today: Write a program or function that takes in a positive integer N and prints or returns a sorted list of the unique numbers that appear in the multiplication table whose row and column multiplicands both range from 1 to N inclusive. The list may be sorted in ascending order (smallest to larg...
This one is inspired by Calvin's Hobbies recent multiplication table challenge. Write a function or program that takes an integer N as input and prints or returns a N-by-N unique multiplication spiral. The code must (in theory) work for N between 0 and 1000 (outputting this can be hard though). The output should be equ...
Whenever I search for the running length of a movie in IMDb, it is displayed in minutes. Immediately I would try to convert it into hour(s) and minute(s). It would be better if we could automate this. Input: 150 min Output: 2 hours 30 minutes Input: 90 min Output: 1 hour 30 minutes Input: 61 min Output: 1 hour 1 m...
Introduction By steganography we mean hiding a message along an existing text or image so the result would be unsuspicious of the existence of the original message. This challenge is about hiding data in Unicode variants of a grapheme called homoglyphs. For instance: cyrillic Е (ye) appears the same as latin E which ap...
Write a program or function that takes in three positive integers, W, H, and N. Print or return a W×H grid of .'s where every Nth . in normal English reading order is replaced with an X. For example, given W = 7, H = 3, N = 3, the grid is 7 characters wide and 3 high, and every third character reading from the top left...
Today your challenge is to produce all possible full parenthesizations of an expression. Your input is a single line of printable ASCII containing one or more terms separated by operators. The input might also contains spaces - you must ignore these. A term is [a-zA-Z0-9], an operator is [^ ()a-zA-Z0-9]. You may assume...
As part of a city planning project, you've gotten the assignment of creating a program or function that will display the city skyline, given some input from the architects. The project is only in the startup phase, so a very rough sketch is sufficient. The easiest approach is of course to simply draw the skyline in ASC...
Write a program or function that takes in a positive integer N. When N is 1, output /\ \/ When N is 2, output /\/\ \/ / / / \/ When N is 3, output /\/\/\ \/ / / / / / \/ / / / \/ When N is 4, output /\/\/\/\ \/ / / / / / / / \/ / / / / / \/ / / / \/ For larger N the pattern continues, a new layer is added every tim...
In this challenge you will compute numbers from a curious sequence. Your input is a single decimal nonnegative integer. Reverse the bits in this integer and then square the number to get the required output. When reversing the bits you must not use any leading zeroes in the input. For example: 26 (base 10) = 11010 (bas...
Implement a FUSE filesystem in minimum bytes. Your program must do three things: Mounting the virtual filesystem to a directory Handling requests to enumerate files in that directory (showing one file) Handling requests to read the file in that directory Rules: ls (a system program, you don't need to implement it) m...
Romanization of Japanese is converting Japanese text into Latin characters. In this challenge, you will be given a string of Japanese characters as input and expected to convert them to the correct ASCII string. What You'll Need To Know The Japanese language has three writing systems: hiragana (the curvy one used for s...
Count the number of sides on a polygon The polygon-side-counting robot has decided to travel the world without telling anyone before, but it is crucial that the process of polygon counting is not stopped for too long. So you have following task: Given a black and white image of a polygon, your program/functoin should r...
Write a program or function that takes in a string guaranteed to only contain printable ASCII characters except for space, and to be a positive triangular number (1, 3, 6, 10, 15, ...) in length. Print or return the same string, but shaped into a triangle using spaces. Some examples will best show what I mean: If the i...
Given two inputs q n determine if q is a quadratic residue of n. That is, is there an x where x**2 == q (mod n) or is q a square mod n? Input Two integers q and n, where q and n are any integers 0 <= q < n. Output A truthy or a falsey. Optionally, print any (or all) x that is x**2 == q (mod n) Examples >>> quadratic_re...