instruction
stringlengths
34
53.1k
Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the Electoral College. Write a full program or function, and take input and output through any default I/O method. A list of all inputs and outputs (source): [['Alabama', 9], ['Alaska', 3], ['Arizona', ...
You can determine the volume of objects based on a given set of dimensions: The volume of a sphere can be determined using a single number, the radius (r) The volume of a cylinder can be determined using two numbers, the radius (r) and the height (h) The volume of a box can be determined using three numbers, the lengt...
The Challenge Given a n x m matrix with n > 1 and m > 1 filled with integers 1 2 3 4 5 6 and a list of integers with exactly as many values as 2x2 blocks in the matrix ((n-1)*(m-1) if you need the exact number) [1, 2] Output the matrix with every 2x2 block rotated by the current value in the list in the given orde...
A simple pedometer can be modeled by a pendulum with two switches on opposite sides—one at x=0 and one at x=l. When the pendulum contacts the far switch, the ambulator can be assumed to have taken half a step. When it contacts the near switch, the step is completed. Given a list of integers representing positions of th...
ASCII boxes look like this: ++ +---+ +------+ +---+ +---+ ++ | | | | | | | | | | | | | | | | +-+ | | | | | | | | +-+ | | | | | | +---+ +---+ | | | | +--+ | | | | ++ | | ...
Ohm's law tells us that the current (I) in amps flowing through a resistance (R) in Ohms when a voltage (V) is applied across it is given as follows: V = I / R Similarly the power (P) in watts dissipated by that resistance is given by: P = V * I By rearrangement and substitution, formulae may be derived for calculati...
Given a black-and-white image in any reasonable lossless format as input, output ASCII art that is as close to the input image as possible. Rules Only linefeeds and ASCII bytes 32-127 may be used. The input image will be cropped so that there is no extraneous whitespace surrounding the image. Submissions must be able ...
Now that we're graduating, it's time to tally up the number of times someone suggested that PPCG was graduating, even before the annoucement! (see here) Your program will receive a list of chat messages. Each message has three pieces of data: the user (e.g. Geobits), the timestamp (e.g. Aug 19 '15 2:41 PM), and the mes...
A shape's volume is the measure of how much three-dimensional space that shape occupies. Challenge Given six integers: [L,W,H] as length, width and height of one container and [l,w,h] as length, width and height of some random item. You will need to calculate how many items would fit completely if the item was a liquid...
This is the 2-dimensional generalisation of this challenge. For our purposes, one matrix (or 2D array) A is considered a submatrix of another matrix B, if A can be obtained by completely removing a number of rows and columns from B. (Note: some sources have different/more restrictive definitions.) Here's an example: A ...
Your task is to print a number. Simple, right? It is simple, but not as simple as this. The first answer is to print the number 1, the second answer is to print the number 2, etc. Rules The first answer must print 1, and the nth answer must print n. The first answer may be of any length. Whitespace, comments, etc. are...
So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further. Your challenge There is a naming system for polygons above a few sides, so arbitrarily large polygons have a name. Your task is to write a program or ...
Resistors and other electronic components are typically manufactured with values that conform to one of the E-series of preferred numbers. IEC 60063 defines the following E-series: E6: 10 15 22 33 47 68 E12: 10 12 15 18 22 27 33 39 47 56 68 82 E24: 10 11 12 13 15 16 18 20 22 24 27 30 33 36 39 43 47 51 56 62 68 75 82 ...
Alphys, the Underground's Royal Scientist, has finished a prototype for a new puzzle. However, she can't seem to find anyone willing to test it. The rules of her puzzle are as follows: The goal is to get to the right side, starting from the centermost tile on the left side. For puzzles with even-numbered heights, star...
Inspired by an old manual... The challenge I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values. Write a program or function that, given a and b by any means, returns the ath suffix vector of b by any means. Now this may seem trivial, but here is the catch: Your score is the...
Before 1994, Spanish dictionaries used alphabetical order with a peculiarity: digraphs ll and ch were considered as if they were single letters. ch immediately followed c , and ll immediately followed l. Adding the letter ñ, which follows n in Spanish, the order was then: a, b, c, ch, d, e, f, g, h, i, j, k, l, ll, m, ...
Introduction I found this question that was closed because it was unclear, yet it was a nice idea. I'll do my best to make this into a clear challenge. The Riemann Zeta function is a special function that is defined as the analytical continuation of to the complex plane. There are many equivalent formulas for it which...
Introductions A 2×n Boolean matrix can be represented as a string of the four characters . ':. The string has an "upper row" and a "lower row", with dots representing 1s and empty spaces representing 0s. For example, the 2×6 matrix 1 0 1 0 0 1 0 0 0 1 0 1 can be represented as ' '. :. Your task is to take a matrix in ...
There is a great story to tell about regular hexagons found for example in honeycombs. But this busy bee needs your help in telling him which point is inside or outside his honeypot. So, given a regular hexagon as pictured below, centered at the origin and with edge size l, determine if a set of coordinates (x,y) are i...
I'm a teacher, and in a few days I have to give my students a test. Now, I'm always worried about my loveliest students being hurt by the least loveliest ones when they cheat, so I want to randomize the tests so no one can cheat off of anyone. Right now, I have my tests saved in this format: When was Java invented? W...
I've been doing word searches recently, and I thought it would be so much easier if all of the words read left-to-right. But rewriting all the lines takes a lot of effort! So I'm enlisting code golfers to help. (Disclaimer: The above story may or may not be remotely accurate.) Your code will take a rectangular grid and...
This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition. Let's take a random decimal number, say 727429805944311 and look at its binary representation: 10100101011001011111110011001011101010110111110111 Now split that binary representation into subsequences where the digits 0 and 1 a...
For those who wish a lot more challenge then the old Spanish alphabetical order, let's take a look at how the Hungarian alphabet is ordered. a, á, b, c, cs, d, dz, dzs, e, é, f, g, gy, h, i, í, j, k, l, ly, m, n, ny, o, ó, ö, ő, p, q, r, s, sz, t, ty, u, ú, ü, ű, v, w, x, y, z, zs actually, q, w, x and y are not used...
Introduction Let's take the number 180. This is an interesting number because the sum of digits of this number is equal to: 1 + 8 + 0 = 9 And the squared version of this number, or: 180² = 32400 > 3 + 2 + 4 + 0 + 0 = 9 These are both 9. The sum of digits of the original number and the squared number are the same. Of ...
The challenge is simple: Draw a rainbow in as few bytes as possible The specs for the rainbow are as follows: The figure must be exactly 400 pixels wide and 200 pixels high (optionally 401x201 if you want a single center pixel) The red ring should touch all borders of the figure (outer radius = 200 pixels) All rings s...
Minimum Scalar Product The inspiration for this code golf problem is from Google's code jam competition. The premise behind the problem is, given the input of two vectors of varying lengths, find the minimum possible scalar. A scalar can be found using the following formula: x1 * y1 + x2 * y2 + ... + xn * yn The probl...
This is not a challenge but a question, I figured it was on topic because of Non-challenge questions that are related to solving programming puzzles or a particular type of challenge are also on topic. Now on to the question: Is it possible to write any JavaScript code with only 5 letters? JSFuck already does this wi...
The Scenario You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can move vertically or horizontally, but can visit each spot only once. The goal is to cover as much area/spots as possible, avo...
If we have a list, say the list [9, 2, 4, 4, 5, 5, 7], we can do a moving average across it. Taking a window of say, 3 elements, each element is replaced by a window like such: [[9], [9, 2], [9, 2, 4], [2, 4, 4], [4, 4, 5], [4, 5, 5], [5, 5, 7]], and then taking averages, we get [9.0, 5.5, 5.0, 3.3333333333333335,...
The Scenario Given an input of ASCII lowercase letters and spaces, draw a spiral of characters that traces the original input of characters excluding spaces. The Rules 1) The characters shall spiral counterclockwise to the left in an outwardly fashion. If a left turn is not possible, then move straight. Given: abcdefg...
Objective Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must output the acronym of the input. Rules Your code cannot be case-sensitive(e.g. foo and Foo are the same) Your code must...
To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3.1416 must be obtained using today's date. Input 3 Output 9.4248 etc. Does not take the date as input. You do not have to ...
A standard, solved, 3×3×3 Rubik's Cube has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite orange, the blue opposite green, and when white points upward, red is to the left of blue: Imagine an ant sits on the center square of t...
Note, when I say "negate", I mean replace all ones with zeroes (i.e. a bitwise negation) The Thue-Morse sequence goes like 01101001 The way you generate it is: Start by taking 0. Negate what is left and append it to the end. So, take 0. Negate it and add that to the end - 01 Then take that and negate it and add that to...
So, recently, I found myself reformatting my code for Vitsy to using anonymous class instances for commands rather than the normal method approach. For those who don't know, anonymous class instance syntax looks something like this: ... private abstract static class SomeClass { public abstract void someMethod(); } ...
Input A single string, which contains no whitespace, as a command-line argument. Output If the string is not a valid algebraic notation pawn promotion, produce no output and exit. If the string is a valid pawn promotion, convert it to ICCF numeric notation and print the result, followed by a newline. A valid algebraic ...
Inspired by this little game. Challenge Given as input the initial position of a grid (always 5x5), like this: -ABCD -A--- ---C- ---BD --E-E You need to connect the letters (same letters all together), removing all empty - spaces. The letters will be always A,B,C,D and E. Every pair of letters must be connected by a s...
I have not laughed as much from Stack Exchange content as I have from this. I think you all will enjoy this challenge, as it is inspired by what is over there. You will write a function or program that is code-golf, i.e. it would have to be as short as you can make it. Given a text, return (both by any means) the text ...
I am in desperate need of some ear defenders, so I can program in peace. Unfortunately, I don't have ear defenders. But I do have a pair of headphones, a microphone and a microcontroller, so I thought I'd make some noise-cancelling headphones. However, there is one tiny problem. I can't program in noisy environments! S...
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take a matrix (not necessarily square) and return it in unrolled form. As an example: [1 2 3 4 5 6 7 8 9 1 2 3] should yield [1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3] Rule...
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take the unrolled vector along with the matrix dimensions and reconstruct the corresponding matrix. As an example: [1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3], 4, 3 should yiel...
Today (March 15) is the Ides of March, best known for being the date that Julius Caesar was assassinated. What's “Ides”? Well, the ancient Romans didn't simply number the days of month from 1 to 31 like we do. Instead, they had a more complex system of counting backwards to the Kalends, Nones, or Ides. Challenge Writ...
What general tips do you have for golfing in Factor? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Factor (e.g. "remove comments" is not an answer).
The inspiration for this code golf puzzle is the Bridge and Torch problem, in which d people at the start of a bridge must all cross it in the least amount of time. The catch is that at most two people can cross at once, otherwise the bridge will crush under their weight, and the group only has access to one torch, whi...
A repdigit is a natural number that can be written solely by repeating the same digit. For example, 777 is a repdigit, since it's solely composed of the digit 7 repeated three times. This isn't limited to simply decimal (base 10) numbers, however: Every Mersenne number (of the form Mn = 2n-1) is a repdigit when writte...
A room can be made up of connected rectangles, for instance an L-shaped room. Such a room can be described by a list of dimensions describing the size of each rectangle. Assume you have two input lists. The first contains the width of rectangles stacked vertically over each other. The second contains the height of the...
Your job will be to write a function or a program, that will take an integer n>0 as input and output a list of the edges of the n-dimensional hypercube. In graph theory an edge is defined as a 2-tuple of vertices (or corners, if you prefer), that are connected. Example 1 A 1-dimensional hypercube is a line and features...
There are many ways to generate random words. You can take random syllables from a set, you can use n-tuples, probably neural networks (what can't they do?), alternating between consonants and vowels, etc. The method this challenge is based off of is by far the worst. It uses a Markov chain to generate random words. If...
The three rows of the qwerty keyboard are qwertyuiop, asdfghjkl and zxcvbnm. Your task is to find the longest word that can be typed using only one row of the keyboard, from a given list of words. Sample input 1 artist home gas writer geology marine twerp Output writer (Of the given words, only gas, writer and twerp ...
Inspired by the C-directive #define. Challenge Given one phrase with some alias, and one array with each alias text. Output the initial phrase replacing each alias with its respective text. An alias is defined by one sharp # followed by its index in the array (the index may start at zero or one). Alias can contains ano...
Details Write a function or program that, given an array (or list), containing only integers, returns or output an array with all sub-elements reversed. That is, reverse all elements of the deepest array, then the second deepest, etc. The dimensions need not be specified, but the function or program must work for jagge...
Inspired by this question Another way to unroll a 2D image into a 1D string is to use an Hilbert Curve. There are many version of this curve, depending on the number of iterations used while computing it. Below follow example of Hilbert Curves from first order to fifth order. The way of computing this curve is the fol...
Introduction For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. Since the map moves upwards, you need to go downwards to survive longer. If you search for images, you probably know which ga...
Write a program or function that accepts an integer in the range 1..3999 as input and returns the number of line segments required to express that integer in standard Roman numerals (so you would use XL but not VM). Examples: 1 -> 1 4 -> 3 5 -> 2 9 -> 3 10 -> 2 40 -> 4 50 -> 2 90 -> 3 100 -> 1 400...
Write a program or function that will break ciphers, using as few bytes as possible. Task Given an encrypted message and a dictionary as input, output the decrypted message. The messages will be encrypted using a one-to-one character mapping, i.e. two characters can't both map to one, and vice versa. The message will o...
Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n. Example: Input: A = [1,2,2,4,4] n = 9 Output: [1,2,2,4] [1,4,4] Bonus: -50% if your code doesn't store duplicate subset (the same subset but in d...
Goal Sort a list of items ensuring that each item is listed after its specified dependencies. Input An array of arrays of integers, where each integer specifies the 0-based or 1-based index of another item that this item must come after. The input may be an array or string or anything else human readable. For example,...
Snakes look like this: >>>v @ ^ v ^ >>>^ v ^ v ^<<<<<<<<< The snake can cross over itself as in this case: @ ^ >^>v ^<< For a crossover to be valid, the characters on either side must be moving the same direction. The case of @ >^v ^< can be considered unclear and invalid. The output is a st...
Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the context of encryption, I wanted to provide some small insight how "calculating" on an elliptic curve actually works. Introduction Elliptic curves are set...
Imagine for a second that you can compose a tree out of dots. . ... ..... ....... ......... ........... ............. ............... ... ... This tree is 13 dots tall. Now imagine for a second that your filesystem looked like these dots. Your task in this challenge is to make a...
Introduction Imagine you are on a two dimensional cartesian plane and want to determine your position on it. You know 3 points on that plane and your distance to each of them. While it is always possible to calculate your position from that, doing that in your head is pretty hard. So you decide to write a program for t...
Write a program or function that checks if a variable name is valid and output 1 or True if it is valid, 0.5 if it is valid but starts with an underscore (_), and 0 or False if it is not valid. Rules A variable name in most languages is valid if it begins with an underscore or letter (a – z, A – Z, _) and the rest o...
I recently read up on graph theory, especially hypercubes and thought about interesting ways to construct paths on them. Here's what I came up with. As you might know, you can construct an n-dimensional hypercube by taking all n-tuples consisting of 1 and 0 as vertices and connect them, iff they differ in one digit. If...
A Diagonal Sudoku board is a special case of Latin squares. It has the following properties: The board is a 9-by-9 matrix Each row contains the numbers 1-9 Each column contains the numbers 1-9 Each 3-by-3 sub-region contains the numbers 1-9 Both diagonals contains the numbers 1-9 Challenge: Create a program or functi...
There is a virus inside a recipient of 5x5. As we know how it propagates its contamination, your mission is to output the last stage of the contamination. The recipient It will be representend as a two dimensional array of 5x5: 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 Where 1 means a position where the virus ...
Background The parity of a permutation, as defined by wikipedia, is as follows: The sign or signature of a permutation σ is denoted sgn(σ) and defined as +1 if σ is even and −1 if σ is odd. The sign of a permutation can be explicitly expressed as sgn(σ) = (−1)^N(σ) where N(σ) is the number of inversions in σ. Alternat...
This is a code-golf question. Given integers s and n the task is to output all arrays of length n which take values from -s to s. The only twist is that you must output them in the following order. The all zeros array of length n. All arrays of length n with elements from -1 to 1 excluding any array you have outputt...
Please note that this question is different from this question. This one asks for graphical output, while the other one asks for ascii art. Objective Help! Timmy's graphing calculator broke! His calculator cannot graph anymore. However, he has found a way to add new programs and functions to his calculator. Your job is...
Introduction Maximum-length sequences, usually known as m-sequences, are binary sequences with some interesting properties (pseudo-noise appeareance, optimal periodic autocorrelation) which make them suitable for many applications in telecommunications, such as spread-spectrum transmission, measurement of impulse respo...
Take a 2D region of space divided into axis aligned unit square elements with their centers aligned at integer intervals. An edge is said to be internal if it is shared by two elements, otherwise it is an external edge. Your goal is to find the minimum number of neighboring elements which must be traversed to reach an ...
Your program must contain all your language's keywords. Ideally, you should have each one exactly once (see Scoring). Of course, this means your language must actually have keywords, so esoteric languages are probably excluded, but just in case... Any language used must have a dedicated Wikipedia article created more ...
Suppose we use the following rules to pull a single string from another string, one containing only ASCII printable characters and called an *-string. If the string runs out before the process halts, that is an error, and the result of the process is undefined in that case: Start with d=1, s="" Whenever you encounter ...
You must write a program or function that sorts a nested list. Here are the rules for sorting a nested list: Let's take this list as an example: ((5, 2), 2, 7, (2, 1, (3, 4)), 9) Each element in this list has a "priority". An element counts as a number or a sublist. First, get the priority of each element at the same ...
Write a function that when given a buffer b (1 - 104857600 bytes long) and a number of bits n (1 <= n <= 64), splits the buffer into chunks of n bits. Right-pad the last chunk with 0s up to n bits. e.g. Given the buffer b = "f0oBaR" or equivalently [102,48,111,66,97,82] and n = 5, return [12, 24, 24, 6, 30, 16, 19, 1, ...
The Secretary Problem is a famous problem described as thus: You need a new secretary You have N applicants that you can interview one at a time You are able to score each applicant after the interview. Your scoring system will never give two applicants the same score After you interview an applicant, you must give a...
This is a code-golf question. Input A list of non-negative integers in whatever format is the most convenient. Output The same list in sorted order in whatever format is the most convenient. Restriction Your code must run in O(n log n) time in the worst case where nis the number of integers in the input. This means t...
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: F u l l w i d t h t e x t i s t e x t t h a t h a s a s p a c e a f t e r e v e r y c h a r a c t e r , i n c l u d i n g t h e l a s t o n e ....
Introduction Most code-golfers here add explanations to their submissions, so it's easier to understand what's going on. Usually the codelines go on the left and the corresponding explanation to the right with some kind of separator. To make it look pretty, the separators are all on the same column. Also long explanati...
Gaussian integers are complex numbers of the form a+bi where a and b are both integers. In base -1+i, all Gaussian integers can be uniquely represented using the digits 0 and 1, without the need for a symbol to denote sign. For instance, 1100 in base -1+i represents the decimal number 2, since 1*(-1+i)^3 + 1*(-1+i)^2 +...
Given a positive integer \$n\$ output the integers \$a\$ and \$b\$ (forming reduced fraction \$a/b\$) such that: $$\frac a b = \prod ^n _{k=1} \frac {p^2_k - 1} {p^2_k + 1}$$ Where \$p_k\$ is the \$k\$ th prime number (with \$p_1 = 2\$). Examples: 1 -> 3, 5 2 -> 12, 25 3 -> 144, 325 4 -> 3456, 8125 5 -> 41472...
When I was a child, I used to play this game a lot. Rules There are two players (let's call them A and B), and each player uses his hands as guns. There are three possible moves: Hands up to load ammunition to your gun. Each gun starts empty. Loading increases the ammunition by one. Hands pointing to the other player...
In music theory, an interval is the difference between two pitches. Each pitch is defined by the number of half-steps (The difference between C and C#) or whole steps (The difference between C and D). One whole step is the same as two half-steps. Here is a list of all the default intervals and the number of half-steps...
This challenge but with a better spec. Spec Your program will take a linear equation containing a single variable x and output the value of x. Input / Parsing The input will only contain numbers, operators, parenthesis (()), x, and an = sign (this means no whitespace). Parenthesis will always be balanced. There will a...
Given a matrix A, we can say that it is "sorted" if each row and column of A is sorted (ascending left-to-right for rows and top-to-bottom for columns). Thus, this matrix is sorted: [ 1 2 3 4 5 ] [ 2 2 3 4 5 ] [ 3 3 3 4 5 ] [ 4 4 4 4 5 ] [ 5 5 5 5 5 ] However, this matrix is not sorted: [ 1 2 3 4 5 ] [ 2 1 3 4 5 ] [ 3...
Introduction In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad. The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an ex...
Today is Purim on which one custom is to give out triangle-shaped cookies with filling called hamantaschen (singular: hamantasch). Another custom is to drink heavily. I'm not the most perfect baker.... I have so many irregularly-sized hamantaschen to give out and so many friends to give them to! If I sent you a pictur...
Draw the following in the fewest bytes possible: ------------------------- | | ABC | DEF | | 1 | 2 | 3 | ------------------------- | GHI | JKL | MNO | | 4 | 5 | 6 | ------------------------- | PQRS | TUV | WXYZ | | 7 | 8 | 9 | ------------------------- | | ...
I was answering one challenge here and this task was part of the challenge. I've got a 73 bytes solution in javascript. But I think it is too much for a simple thing. Challenge Given as input two integers: N the length of the expected array R the interval's range starting in one: 1..R, not 0..R-1 Output in each run o...
The Challenge Given 3 numbers X, Y and Z in base B, find a Base in which the addition of X and Y yields Z. The inputs x = 20, Y = 12 and Z = 32 could yield 5 because 20 + 12 = 32 in base 5. You may assume that there will always be a base in which the addition is correct (there are cases where no base exists, thanks t...
Introduction Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S. One example of a ternary function f is f(0) = 0; f(1) = 2; f(2) = 0 There are exactly 27 different ternary functions, and we represent them with integers...
In honor of recent news of Google developing a keyboard for iPhone... Your input (for simplicity, all input is case sensitive): Location of standard dictionary file. File format is 1 valid word per line; in alphabetical order. Example file: apple banana citrus domino durian orange tuna zabc Location of personal dicti...
Challenge Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial. For example, the input 1 2 represents this equation: (x-1)(x-2) And should output: x^2-3x+2 The exact format of output is not important, it can be: 1x^2+-3x^1+2x^0 or: 0 0 0 1x^3+0x^2+0x^1+0 or: 3 14...
At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java. For those who don't know Perl, the hash value can be a scalar or another hash, or technically speaking hash reference. Arbitrary depth. Additional feature offered by Perl is autovivification - assi...
You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base. Rules: You aren't allowed to use any conversion functions built into your language This is code-golf, the shortest answer in bytes wins!
This used to be an old Computer Olympiad Question, not sure what the actual source was. Assume function f: f(1) = 1 This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order. Number n has been repeated f(n) times Here is the sequence up to the fifteenth number: n : 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
The Challenge: Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n provided by the user, where n is an integer in the range 3 -> 10 including 3 and 10, in as few bytes as possible. For exampl...
Here is the 3rd ABACABA city: _ A|_| B|__| A|_|_ C|___| A|_| B|__| A|_| It is made out of the ABACABA sequence, which is basically: A (1st iteration) place B - AB repeat A - ABA (2nd iteration) Place C - ABAC Repeat ABA - ABACABA (3rd iteration) and you get the idea. The buildings have a height (corresponded by no...
Two distinct vertices in a directed graph are strongly connected if there is path in the graph from each to the other. A strongly connected component of the graph is a subset of the graph such that each pair of distinct vertices in the subset are strongly connected, and adding any more vertices to the subset would brea...
Write a full program with a source code of 256 bytes or less that looks at an image of a flag and determines what country that flag is from. A zip file containing the 196 different flags in the challenge can be downloaded from here. Source: [Flagpedia]. These 196 flag images are the only inputs your program has to hand...
Your task is to print the following ASCII Art: _ _ _______ _ | | | | (_______) _ | | | |__ | | ____ ____ ____ _ _ _____ ____ ___| |_ ____ ____| | | __)| |/ _ | _ \| _ \| | | | | ___) / _ |/___)...