instruction
stringlengths
34
53.1k
Dead code sits there doing nothing, staring at us knowing it will never be executed... but today we can take revenge. Specification The input will be a multiline string. Each line may either be an assignment or an expression . Assignment An assignment is of the form <name> = number where name is a sequence of letters, ...
This question is inspired by, and is the inverse of this one. Dennis (E), Doorknob (D), Martin (M) and Chris (C) have ordered a pizza. The rectangular pizza is divided into square pieces, each marked with their intended eater. Write a program or function that given a rectangular pizza consisting of 0 or more of each le...
Write code to figure out whether a run of Tetris pieces could be generated by the official Tetris algorithm. Fewest bytes wins. Official Tetris games generate the sequence of falling pieces in a special way. The seven pieces IJLOSTZ are dropped in a random order, then another random permutation is dropped, and so on. ...
Challenge Given two integers A and B as input, you must write a program which outputs if A>B, A==B or A<B. The integers will be in any reasonable range supported by your language which includes at least 256 values. Your program can be either a full program or a function, taking input via STDIN or function arguments. Ou...
First, some definitions. A Hadamard matrix is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal. The Hadamard conjecture proposes that a Hadamard matrix of order 4k exists for every positive integer k. A circulant matrix is a special kind of matrix where each row vector is rotate...
A common visual explanation of the Pythagorean theorem is as such: The squares are meant to represent the side length's squared, and the areas of a + b = c, just like the Pythagorean theorem says. This part is what you have to show. Your task You will get two integers as input, meant to represent sides a and b of a r...
Your task is to take a list of arguments that are either integers or operators, and parse them like so: There is a current operator, which starts as +. Each time an operator is found, the current operator will change to it. The possible operators are: "+", "-", "*", "/", and "%", which correspond to their meanings in ...
The picture below shows a RLC circuit. A RLC circuit is an electrical circuit consisting of a resistor (R), an inductor (L), and a capacitor (C), connected in series or in parallel. (1) In order to simplify computations, it's common to work in the frequency (Laplace) domain instead of the time domain. Your task is: Ta...
This question was inspired this question and @orlp's comment and a lot of the explanation was copied from there. Write a GOLF assembly program that given two arbitrary size decimal integers a, and b from stdin outputs two decimal integers to stdout, Q and R such that b * Q + R = a. In other words write divmod with arb...
The Task Given the positive value of unix timestamp output any of two valid ISO 8601 time formats: YYYY-MM-DDTHH:mm:SS or, alternatively, YYYY-MM-DD HH:mm:SS You may ignore any leap seconds, if you wish, as well as the timezone part of the date. Also, ignore the year 2038 problem. Rules You must not use any built-in...
This competition is over. Thanks for the interesting non-esolang entries, and congrats to Jakuje for his winning JavaScript submission. In the great tradition of ASCII Art Challenges on this site, here's another one. Given an input, draw a spiral. &>----v ||>--v| |||>v|| |||@||| ||^-<|| |^---<| ^-----< Simple, yeah?...
A tree is a connected, undirected graph with no cycles. Your task is to count how many distinct trees there are with a given number of vertices. Two trees are considered distinct if they are not isomorphic. Two graphs are isomorphic if their respective vertices can be paired up in such a way that there is an edge betwe...
In Pokémon there are 18 types: Normal Fighting Flying Poison Ground Rock Bug Ghost Steel Fire Water Grass Electric Psychic Ice Dragon Dark Fairy A Pokémon can have single or dual typing. For example, Pikachu is Electric, and Tyranitar is Rock/Dark. The order of the types does not ma...
Preamble In Stack Exchange markdown, we use ** to bold out text. For example, this markdown: The **quick brown fox jumps over the lazy** dog. Renders as: The quick brown fox jumps over the lazy dog. Of course, we use ** to close boldness as well. So less of the answer will be bold. For example: The **quick** brown f...
Make a plot (Poincare disk) of a tessellation on a hyperbolic plane, such as: The program takes four inputs: 1) How many edges/polygon (three in this example). 2) How many intersect at each vertex (seven in this example). 3) How many steps away from the center vertex to render (5 in this example, if you look closely)....
The spoak laugh For those who don't know, in Brazil some people laugh on chats like this: aposkpaoskaposkaposkpaokspaoskpaoksa. So here is the challenge: To make a program that generate this laugh in a natural way. How to produce this laugh programatticaly? When you laugh like this, you use one hand on the (a, s) part ...
The basic idea of a kolmogorov-complexity challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from Borromean Rings to The Gettysburg Address. ##Your Task This question is similar, except that it requires printing of a special text - the text of this q...
Challenge Write a program that, given a string x which is 10 characters long and a character y, outputs the number of times character y occurs in string x. The shortest program in bytes to do so wins. Example Input: tttggloyoi, t Output: 3 Input: onomatopoe, o Output: 4
I'm working on a golf for Java and I need an infinite loop. Obviously, I don't want to spend any more bytes than I have to, especially in such an expressive language. Assuming I have some code I want to run, obviously the baseline is set at while(1>0)/*stmt*/ or 10 additional characters for a single line and while(1>0)...
The Debian Linux distribution (and Debian-based distros, like Ubuntu, Kali and others) uses a package-manager called APT. To install program foo you would type into a terminal sudo apt-get install foo One little Easter Egg of APT is the following apt-get moo Which after typing will produce the following output ...
Background This is the first part of a 3-hole golf course on text processing. The over-arching idea is that if you take an input text and pipe it through the solutions to all three challenges (with a small amount of glue code), it will spit out a beautifully formatted paragraph. In this first challenge, your task is a ...
Note: all array references in this post are zero-indexed. When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference. The challenge is to take a space-sepa...
This is a challenge for the people using Swift 2.0 beta 6, it's not code golf, but it's a programming puzzle so I'm pretty sure this belongs here. The basic idea is: Make it compile. There are more details and a very nicely formatted playground at the Github project. Previous challenges are there as well, all set up to...
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this. Challenge You will have to write a program that when run in two different languages, will output the string: This program wasn't written in <language program compiled/inte...
Some people insist on using spaces for tabulation and indentation. For tabulation, that's indisputably wrong. By definition, tabulators must be used for tabulation. Even for indentation, tabulators are objectively superior: There's clear consensus in the Stack Exchange community. Using a single space for indentation i...
Consider three number sequences, \$A\$, \$B\$ and \$C\$: \$A\$: A sequence based on recurrence relations, \$f(n) = f(n-1)+f(n-2)\$, starting with \$f(1) = 3, f(2) = 4\$. So, the sequence begins like this: \$3, 4, 7, 11, 18, 29, 47, 76, ...\$ \$B\$: The composite numbers, that is all integers that aren't primes (or 1):...
This challenge was inspired by programming an Arduino microcontroller. I have 6 LEDs and 6 buttons connected to various pins on the board. In the code, each button and LED is assigned an ID number (1-6). Pin numbers (ranging from 0-13) corresponding to the ID numbers are looked up using a switch statement. Purely for a...
Background When playing an RPG such as Dungeons & Dragons, Pathfinder, or Paranoia, players each need a set of dice. You are hosting one such game this weekend, and some of the friends you invited have never played an RPG before. They don't want to commit to buying their own set of dice until they know they'll use them...
Similar figures Two rectangles are similar if the ratios of their sides are the same. Consider these two rectangles; a rectangle 5 lines tall and 11 chars wide: =========== =========== =========== =========== =========== and a rectangle 10 lines tall and 22 chars wide: ====================== ====================== ===...
Write a program (or function) that takes in a positive integer. If the input is 1, print (or return) two diamonds neighboring side-by-side, each with a side length of 1 slash: /\/\ \/\/ For every input N greater than 1, look at the output for N-1 and for each pair of neighboring diamonds, insert a new diamond in betwe...
The task Write a program or function that takes a traffic intersection structure and outputs the sequence, in which vehicles will pass. The output should contain at most four lines with the following format #. x->y\n, where # is a sequence number number, followed by the dot ., x and y are characters ["N", "E", "S", "W"...
Here's a simple one to stretch your compression muscles. Your code (a complete program) must output the spelled-out English representation of all the cardinal numbers from 1 to 100, and then all the ordinal numbers from 1 to 100. The numerals in each list should be delimited by commas and spaces and properly hyphenated...
Given the 95 printable characters in ASCII plus newline, break it apart into two equal, 48 character groups (hereafter called group A and group B). Create a one-to-one mapping of your choice (you have total discretion) between the two groups. In other words, A might map to a, and vice versa, but A might also map to > a...
This is my first challenge, so I'm keeping it fairly simple. If you've ever typed telnet towel.blinkenlights.nl on your command line and pressed enter, you will have experienced the joy of asciimation. Asciimation is, quite simply, doing an animation with ascii art. Today we will be doing a very basic asciimation of a ...
Every Unicode character has a name, like "LATIN CAPITAL LETTER A". A Unicode character name may contain only uppercase letters, white spaces, and the minus sign. Write a program that reads a text and outputs the names of each character on a new line. For example, if the input were "Hello, World!", the output would be L...
Background The official currency of the imaginary nation of Golfenistan is the foo, and there are only three kinds of coins in circulation: 3 foos, 7 foos and 8 foos. One can see that it's not possible to pay certain amounts, like 4 foos, using these coins. Nevertheless, all large enough amounts can be formed. Your job...
I read about circles somewhere, and just now learned about discs (it's actually a pretty common concept) and thought about codegolf. Your task is to randomize a point/several points on a disc with the radius 1. Rules: All points must have an equal probability to be generated Floating point coordinates must be used; t...
The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS: ��Û������������������ˆ��È���ˆB0�ˇ*,x�r�pH@NÆ˝T,�g�Œ$F(FIÏa®.GÏu0C˙íp%NÆ˝ÿJÄg�™,@"$<��ÌNÆˇ‚JÄg�í*�"�$&<��a®NÆˇ÷,�"NÆˇ‹F�k�r‹Ç*BA˙¸C˙Ra�ºª∆j��Úp�@�0j�^@�[f(¸A˙�8¸+(¸`�ˇ¯&Ã`‘@�]f8¸Nu c êàTÄ1@ˇ˛`º@�aj�T@�!kÆ@�{fª∆j��ö�}fÙ`ö@�"fB(¸...
This is a code-golf challenge whereby you need to devise a program that acts like a quine or a quine that modifies itself to illustrate machine learning. Background There is a basic artificial intelligence program called 'the pangolin game' which is described here. The basic ideas is that the program when run the first...
Input A list of words separated by any number of spaces. Output A horizontal ASCII art graph, where the n-th line is composed by as many asterisks (*) as the n-th word is long. Example usage The > signals user input, you should not input it when testing the program. > This is an example histogram of word length **** **...
In this challenge you are going to write an interpreter for a simple language I've made up. The language is based on a single accumulator A, which is exactly one byte in length. At the start of a program, A = 0. These are the languages instructions: !: Inversion This instruction simply inverts every bit of the accumula...
Challenge In this challenge, you are to code in any language a program or function that will take a string and replace certain characters within it with different characters. Input The input is the same for both functions and full programs: [string] [char1] [char2] string will be an indefinite line of characters surr...
As you should (hopefully) know, a radiation hardened quine is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you can only remove one character; otherwise everything breaks down. This is where this comes in; your goal is to build a r...
Introduction Some ASCII characters are just so expensive these days... To save money you've decided to write a program that encodes expensive characters using inexpensive ones. However, character prices change frequently and you don't want to modify your program every time you need to encode or decode a different chara...
Inspired by this question Given a positive integer \$n\$, your code must output the first \$n\$ composite numbers. Input / Output You may write a program or a function. Input is through STDIN or function argument and output is to STDOUT, or function return value. Output can be a List, Array, or String. Examples 0 -> ...
Introduction Last year was my birthday (really!) and sadly I had to organise my own party. Well, now you know, couldn't you at least make the cake? Challenge Given an integer n as input, write a full program to output a birthday cake with n candles on. Output A piece of cake with one candle on is: $ | --- ~~~ --- An...
In this challenge, we will together create a word-search containing many programs in different languages. I have started us off with a grid of 60-by-25 blanks (·), some of which are replaced by the characters of a Ruby program. To answer, choose a language that was not yet used. Using your chosen language, write a prog...
Background You are working as a programmer for a car sales company. Your task for this week is to program an XML parser that takes in data about available models from different car manufacturers, and pretty-prints information about the newest models. Luckily for you, the testing department has provided only one test ca...
Around the year 1637, Pierre de Fermat wrote in the margins of his copy of the Arithmetica: It is impossible to separate a cube into two cubes, or a fourth power into two fourth powers, or in general, any power higher than the second, into two like powers. I have discovered a truly marvelous proof of this, which t...
Introduction Yesterday I saw a birthday puzzle. Congrats!! Also this week I watched an episode of the TV show Bones where a dead body was found buried under a tree. To calculate the time of death, they counted the tree rings. Tree rings form because trees grow slower during the winter and faster during the summer. Thus...
This is what I thought this question was going to be, before I fully read it. A group of code golfers walk into The Nineteenth Bite Pizzeria and order a pizza. It comes in an irregular shape, made of unit squares. Your task is to help them cut it into identical slices. That is, the slices must have the exact same sha...
Space indentation users, unite! We must fight against all the lowly tab users! Your mission (should you choose to accept it) is to write a program or function that takes in two arguments: A string: This is the input. A positive integer: This the number of spaces per tab. You must go through every line of the string a...
Challenge Your goal is to write a program that prints another program. That printed program should print another program, and the new program should print another program, until the end. Rules Each program must less than 256 bytes. (If this needs to be changed, leave a comment) The last program must be an empty progra...
In this challenge your goal will be to output the lyrics to Daft Punk's Harder, Better, Faster, Stronger. Specifically, output this text: Work It Make It Do It Makes Us Harder Better Faster Stronger More Than Hour Our Never Ever After Work Is Over Work It Make It Do It Makes Us Harder Better Faster Stronger More Tha...
I honestly cannot believe that this is not a question yet on Code Golf, but.... Print the local time (with a.m. or p.m.) as a string to the console, preceded by "It's ". Example: Run code.... Output: It's 12:32p.m. Shortest code wins. Code away! Leaderboard var QUESTION_ID=57552,OVERRIDE_USER=42854;function answers...
You work for a company that wants to make a user-friendly calculator, and thus you have been tasked with adding the ability for users to use "numerical shorthands," that is, letters that represent numerical values, such as k for 1000. Because your company wants to save money on storage in said calculators, you must min...
The question uses C to formulate the problem, but solutions in any language can be accepted. At the end of the question you can find a pythonic version. As part of a bigger software, we have a C function: void wrapper(void* p); Which is a wrapper function around the C function: void handler(void* p); wrapper() is tri...
The Situation Suppose I allow "Shady Sam" admin access on my workstation to perform an important administrative task on my Mac Pro for me by giving them a temporary root login password. (Assume they were trustworthy, perhaps a systems admin for my company.) From a remote location (e.g. home), I use my MacBook Pro lapt...
Find the digit which occurs the most in a range of prime numbers. Input: Two numbers, p and q, specifying the range; the range includes both p and q. Output: The digit that occurs most frequently in that range of prime numbers. If two or more digits are tied, all of them should be outputted. Winning Criteria: Fastest c...
I hear somebody was very selfish on their birthday, demanding cake from everyone and there were no plans to share! 🎂 It's bound to be somebody's birthday today, so why not bake them a cake. Use your favourite programming language to make a delicious cake, with a nice "Happy Birthday" message as the output. (Might I s...
Write a program or function that transforms an input string into Zalgo text. For example, for an input string Zalgo, a possible output might look like: Z̗̄̀ȧ̛̛̭̣̖̇̀̚l̡̯̮̠̗̩̩̥̭̋̒̄̉̏̂̍̄̌ģ̨̭̭̪̯̫̒̇̌̂o̢̟̬̪̬̙̝̫̍̈̓̅̉̇ Zalgoification specs Each letter (upper or lower case) must be zalgoified, and nothing else (spaces, pun...
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages. Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Mil...
Your goal is to create a program that prints itself indefinitely, with a new line after each one. Thus, if your program is a one-liner, it would be repeated on every line of the output. Example Program: A Output: A A A ... Rules It must be a complete program, not a snippet or function. The program should loop fore...
Last year, there was a very popular challenge to create an image containing every 24-bit RGB colour. My challenge is to create a smooth animation (24 frames/s say), where the colour of every pixel of every frame is unique. I will also allow duplication of colours as long as every colour appears the same number of time...
Background Benford's Law is freaky! Of all the numbers in the world, roughly 30% of them start with a 1! 17.6% start with a 2, 12.5% start with a 3, and so on, and so on. For example, take a look at the following graph. Take the largest 120000 towns in the world, take their altitude, and voila - they obey Benford's law...
This challenge is a tribute to PPCG user Dennis for winning the robbers' part of The Programming Language Quiz. Looking at Dennis' PPCG profile page we can see some pretty impressive stuff: He currently has over sixty-eight thousand reputation, making him second in rep overall, surpassing third place by almost thirty ...
Challenge Write the shortest program that receives two signed integers n and i and for each i between 1 and 2^n - 1 returns the next ordered permutation based on the binary representation of the number. There is no specific order of the combinations but the number of 1s in the binary representation must always stay th...
I'm sure most of us have seen SQL results in a terminal, all neatly formatted into rows and columns. If you haven't, here's an example: +----------+-----------+----------------+ | column 1 | column 2 | column 3 | +----------+-----------+----------------+ | data | more data | even more data | | etc | jus...
Write a program that accepts as input an emoticon and ouputs if the emoticon is happy or sad. The program accepts a string as input or parameter, and should display the string "happy" if the input is in the happy emoticon list, or "sad" if the input is in the sad emoticon list. You can assume the input is always a vali...
Suppose this grid of spaces and X's represents the cross section of some strangely shaped empty ice cube trays: X X X X X X XX X XX X XXXXXX XXXXXXXXXXXXX Columns without X's represent holes or gaps in the trays that can't hold water, draining into an infinite capacity sink. Water falling off the l...
Task Your mission is to create a program that reviews Python code. The solution can be written in any language! It must take input that contains python code. The program must add # This is not pythonic! before each block of non-whitespace lines. Input The data can be entered via stdin. The data will contain at least 3...
Aligning Lines! Given a character and a multiline string, your job is to pad each line of the string so they line up among the given delimiter. Examples Input: , Programming, Puzzles And, Code golf Output: Programming, Puzzles And, Code golf Input The input will be a multiline string and a character (which yo...
Every 3 seconds, add a room to the house. A house with one room looks like this: |---| |[=]| |---| Two rooms: |---||---| |[=]||[=]| |---||---| Three rooms: |---| |[=]| |---| |---||---| |[=]||[=]| |---||---| Four rooms: |---||---| |[=]||[=]| |---||---| |---||---| |[=]||[=]| |---||---| Five rooms: |---||---| |[=]||[...
In xkcd 1047, Randall Munroe lists "slightly wrong" approximations of assorted quantities and numbers with varying precision and complexity, such as that the number of liters in a gallon is very close to 3 + π⁄4. In the middle of the comic, he gives an intermission: a way to estimate the world (and United States) popul...
Exchange the Stacks! Write a program that can exchange any character from two stacks. In this challenge, a stack is a tower of characters. An example stack is below: 1 a 4 d * c 3 There are two stacks involved in the challenge and both are inputted when the program runs. The program will also be given an argument of w...
Suppose you are stringing a strand of Froot Loops for a necklace, bracelet, shoelace, or whatever. There are 6 loop colors: red, orange, yellow, green, blue, and purple. You want your strand to start with red at the very left and cycle in rainbow order going right, ending with purple. That is, you want to make it so yo...
I've already made this in Python, but it seems that it could be shortened a lot: txt = input("Type something.. ") c = "#" b = " " print(c * (len(txt) + 4)) print(c, b * len(txt), c) print(c, txt, c) print(c, b * len(txt), c) print(c * (len(txt) + 4)) So if the user types: Hello World The program prints: #############...
If you haven't played golf before, here's a list of golf-related terms I use in this question Shot, also called a stroke: Every time the ball is hit, this is a shot. Hole: A golf course is split into holes, in which the goal is to hit a ball from one designated location to another in as few shots as possible. Tee: Whe...
This is code golf. Fewest bytes wins, only standard libraries, etc. Write code, in any language, to output all possible same-length permutations of all items of an array / list / object in the input format and any order, grouped in whatever way you like. The items can be of ANY type, as allowed by the programming langu...
This challenge is a tribute to our Legendary Challenge Writer™, Calvin's Hobbies — now renamed to Helka Homba —, in the same spirit as Generate Dennis Numbers. Calvin is a pretty impressive contributor to PPCG, with the 6th most reputation overall and probably indisputibly the best challenge writing skills out of all o...
In the esoteric programming language Curly, programs consist solely of curly braces {} and semicolons ;. Despite this humble toolset, Curly has literals that can represent any nonnegative integer. The format is a little hard for the uninitiated to read, though, so let's write some code to do the conversion for us. Form...
INTERCAL is a wonderful language, but it is not always easy to understand other people's code. This is particularly the case if they use the COME FROM statement. Challenge definition Write a program or function which take the source code of an INTERCAL program as a text/data stream. If you write a function it is reco...
Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible. Now I know the best way to do that: I'll be getting you to be writing this program. The challenge Write a program that when given a positive integer, outputs a program that prints it to stdout or equivale...
Challenge Write a program that reorders the ASCII characters! It should output a single string containing all of the printable ASCII characters exactly once. The first character of this string is assigned the value 1, the second character the value 2, and so on. If two characters are normally next to each other (the di...
Mayan pyramids were (and are) an important part of ancient architecture, that were generally used for religious purposes. They were usually step pyramids, but the steps on each were too steep to climb. Priests would climb to the tops of them via alternative staircases to perform ceremonies. The pyramids were also used ...
Where is the Arrow Pointing? In this challenge, your goal is to follow an arrow and output the character it is pointing to. Examples Input: d S------+ b | | c +--->a Output: a Input: S-----+---a->c | V b Output: b The arrow is not point...
Introduction Classes have started! And so does the boredom. I decided to doodle in my notebook and started to draw some dots in (IMO) an aesthetically pleasing way. I came up with these numbers: based on these conditions: Given (n, m) 1) There must be n dots 2) All dots must lie on an m by m lattice 3) The positio...
My high school, and many others implement a type of schedule called a Rotating Block Schedule. This is a way for people to have 8 classes, but on have 6 periods in a school day. There are four days in a block schedule that repeat over and over, and have nothing to do with the actual days of the week. Each are assigned ...
The hamburger joint maHburger has hired you to write a program for them. It is simple: make an ASCII hamburger, using the key. Sounds simple right? Well these customers are super picky, but one thing is for sure, they do love onions. Write a program that accepts the customer's orders, and prints a hamburger with as man...
Fed up with the reliability of flash storage, you decided to store all your programs on one of those good old 1,440 KiB floppies. However, after copying not even 3,000 programs, the disk was full. How's that even possible? Skilled in the art of code golf as you are, most of your programs aren't even 100 bytes long, so ...
Write a program that goes through a string of non-whitespace characters (you may assume that they are digits 0 to 9, but nothing in the way they are to be processed depends on this) and adds spaces according to the following rules. Let the current token be the empty string, and the previously emitted tokens be an empt...
Loves me, Loves me not This simple kids' game is old, but still popular. Since we are living in 21st century now, let's digitize it! Specification Program must take no input, unless you are using a language that can't generate random seed - in that case you are allowed to take the seed as an input. Your task is to writ...
Background LISP programmers have taken over the world! Parentheses have been declared as sacred characters, and from now on, they can only be used in LISP programs. It has been decided that parentheses in literary works shall be replaced by footnotes, and it's your job to automate this for simplified Markdown text. Inp...
Introduction Today is my birthday, Yes my parents spend a lot time at home during the cold December holidays as many others. So I also want my cake. But I have a problem: I just sent the invitations today so I'm not sure how many friends will come. Also I don't want to order a big cake because I have been on a diet si...
This is my first challenge! Background Perfect number is a positive integer, that is equal to the sum of all its divisors, except itself. So 6 is perfect number, since 1 + 2 + 3 = 6. On the other hand 12 is not, because 1 + 2 + 3 + 4 + 6 = 16 != 12. Task Your task is simple, write a program, which will, for given n, pr...
Some numbers like 64 can be expressed as a whole-number power in multiple ways: 64 ^ 1 8 ^ 2 4 ^ 3 2 ^ 6 Output a sorted array of all possible such powers (here, [1,2,3,6]) in as few bytes as possible. Input A positive whole number that's greater than 1 and less than 10000. Output An array of whole-number powers...
This challenge is inspired by a SO question about traversing a matrix by enumerating all its diagonal strips. Instead of a matrix, consider a block of text: ABCD EFGH IJKL Traversing this block's SW-NE diagonals from left to right, starting from the top left corner and ending in the bottom right, results in the follow...
This is my first question, so I hope it goes well. Background: It's not the rivers that you might be thinking about. The question revolves around the concept of digital rivers. A digital river is a sequence of numbers where the number following n is n plus the sum of its digits. Explanation: 12345 is followed by 12360 ...
Tony Stark is, as we know Ironman (that super awesome guy in metal suit and loads of weapons). However, without the metal suit, he can't claim that title. Tony Stark, having a great ego, wants to finish Norseman, which is considered to be the hardest triathlon in the world (for distances equivalent to those of an Ironm...
Background In some possible futures, the world will convert their numerical systems from decimal (base 10 or b10) to some other base (binary b2, octal b8, hexadecimal b16, or even unary b1, in which case we're screwed!). Thus, in preparation for this possible world-changing event, you decide to base-proof all of your p...