instruction
stringlengths
34
53.1k
The task is simple: consolidate an array of ints. Consolidating this array consists of the following: All instances of 0 need to be moved to the end of the array. There should be no 0s between the non-zero integers. All non-zero indices should retain their order. Challenge Consolidate an array in the least amount of ...
Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!. How strings are twisted The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It kinda loo...
We can roll up the natural numbers in a rectangular spiral: 17--16--15--14--13 | | 18 5---4---3 12 | | | | 19 6 1---2 11 | | | 20 7---8---9--10 | 21--22--23--24--25 But now that we have them on a rectangular grid we can unwind the spiral in a different order, ...
The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source code as input, outputs a program that reverses the twisting algorithm. How strings are twisted The twisting algorithm is v...
The "Look and say" or "Say what you see" sequence is a series of numbers where each describes the last. 1 11 (one one) 21 (two ones) 1211 (one two, one one) 111221 (one one, one two, two ones) 312211 (three ones, two twos, one one) and on and on... https://oeis.org/A005150 Anyway, this is a regular code golf challenge...
Your Challenge: For a golf Course Of Inputted 'n' length to hole where: 'n' is a whole number and a multiple of 5 between 150 and 500 and 1 integer in code = 1 metre You must calculate the least amount of swings it can be completed in using a combination of clubs and ranges. Here is a visual representation of what t...
You're going to replicate the 90's cup holder joke software. Here's what's it did, and you have to do: Display the message Do you need a cup holder? If the user confirms, enter an infinite loop that keeps opening the CDROM drive. If the user doesn't confirm, silently exit. You may display the message using either a ...
I know, the title cracks you up Given an amount of money, output the fewest number of coins that make up that amount. Examples 0.1 1 dime 0.01 1 penny 0.28 1 quarter 3 penny 0.56 2 quarter 1 nickel 1 penny 1.43 5 quarter 1 dime 1 nickel 3 penny Spec 100 cents in a dollar. The values of each type of coin is: pe...
Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with: class Tuple1 {public Object _0;} class Tuple2 {public Object _0,_1;} class Tuple3 {public Object _0,_1,_2;} class Tuple4 {public Object _0,_1,_2,_3;} class Tuple5 {public Object _0,_1,_2,_3,_4;...
Subleq is a programming language with only one instruction. Each instruction contains 3 parameters. Code and data space is the same. How it works: A B C A, B and C are signed ints. Instructions are executed in the next way: *B = *B - *A if(*B <= 0) goto C; One post is one tip. Write your tips for Subleq here! Online ...
Introduction Finally the movie company is financing your film. They have given you a maximum budget and they also set the running time of your movie. Now you can start with the pre-production. You have a bunch of scenes already planned, but not all of them will fit into the budget and the film would get way too long as...
Your boss wants you to write code like this: public static boolean isPowerOfTen(long input) { return input == 1L || input == 10L || input == 100L || input == 1000L || input == 10000L || input == 100000L || input == 1000000L || input == 10000000L || input == 100000000L || input == 1000000000L |...
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its own code page and its powerful chain system to succinctly express programs. Let’s collect some useful tips for golfing in...
Introduction Here in Germany the ruling on work times is very strict. If you work 6 or more hours a day, you have to take at least a 30 minute break. If you work 9 or more hours, you need to take a 45 minute break. If you work less than 6 hours, you don't have to take any breaks. Of course you can split those breaks, ...
While idly twisting my Rubik's cube around, my son noticed that it kept going back to the solved state. I'm pretty sure he thought this was some sort of voodoo magic at first, but I explained that if you keep repeating the same sequence of moves, it will always return to its original state. Eventually. Of course, being...
A "rhyme scheme" is a string of letters a to z, such that the first occurrences of the characters are in ascending order (without gaps), starting from a. For example (with first occurrences marked): abccdbebdcfa ^^^ ^ ^ ^ The number of rhyme schemes of length N is given by the Bell numbers B(N). (OEIS A000110) The C...
Introduction Let's observe the following sequence (non-negative integers): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... For example, let's take the first three numbers. These are 0, 1, 2. The numbers used in this sequence can be ordered in six different ways: 012 120 021 201 102 210 So, let's say that ...
The Collatz Sequence (also called the 3x + 1 problem) is where you start with any positive integer, for this example we will use 10, and apply this set of steps to it: if n is even: Divide it by 2 if n is odd: Multiply it by 3 and add 1 repeat until n = 1 10 is even, so we divide by 2 to get 5. 5 is odd, so we...
Given an input of a Pig, SickPig, DeadPig, QuinePig, or DeafPig program, choose one of those "languages" randomly and interpret the input as that "language." First, randomly choose between one of the five members of the "Pig series": Pig If the choice was Pig, mimic the reference interpreter by doing the following: F...
I've recently realized how vim works great for golfing, especially for kolmogorov-complexity. Also, according to meta vim is a perfectly acceptable 'programming language' at least, for the scope of this site, that is. What general tips do you have for golfing in Vim? I'm looking for ideas which can be applied to code-g...
Write some code that takes a single non-negative integer \$n\$ and outputs the \$n\$th power of phi (\$\phi\$, the Golden Ratio, approximately 1.61803398874989) with the same number of decimal digits as the \$n\$th Fibonacci number. Your code must produce the correct sequence of digits for all inputs up to at least 10 ...
This is a problem from NCPC 2005. Roy has an apartment with only one single electrical outlet, but he has a bunch of power strips. Compute the maximum number of outlets he can have using the power strips he has. The number of outlets per power strip is given as input. It turns out that if the number of outlets of the...
Your should write a program or function that determines the language of a given word. The task is to recognize some of the 5000 most common words in 4 languages: English German Italian Hungarian The word lists can be found in this GitHub repository. You are allowed to make mistakes in 40% of the provided test cases. ...
Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8*8) with the minimum amount of code. Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches. This can be made in a language of your choice, as long as you keep it vanilla, s...
As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg). With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit mo...
Given four RGB LEDs and 8 colors, your task is to light up each LED in order with a color, and cycle through the LEDs as you cycle through the colors; with only one LED lit up at a time. So for 8 colors across 4 RGB LEDs, it would look like this (at a hardware level (since there are three channels for each LED)): LED1 ...
For each row and then column of a matrix, we can add an extra entry with the sum of the last two entries in that row or column. For example with the following input matrix: [ 1 1 1 ] [ 2 3 4 ] The resulting matrix would be: [ 1 1 1 2 ] [ 2 3 4 7 ] [ 3 4 5 9 ] Given an input of an integer N and an [X,Y] matrix of siz...
Background I have a row of powerful magnets and a bunch of metal objects between them. Where will the magnets pull them? Input Your input is an array of non-negative integers, which will contain at least one 1. You can use any reasonable format. The 0s of the array represent empty space, and the 1s represent fixed magn...
Write a program or function that takes in a positive integer N. Output a list of all the distinct decimal numbers that can be written in exactly N characters using digits (0123456789), decimal points (.), and negative signs (-). For example, some numbers that would be in the N = 4 output list are 1337, 3.14, .999, -789...
The Task The task is very simple. Given an array containing only integers and strings, output the largest number and the smallest number. Test Cases Input: [1, 2, 3, 4, 5, 6, 7, 8] Output: 1, 8 Input: [5, 4, 2, 9, 1, 10, 5] Output: 1, 10 Input: [7, 8, 10, "Hello", 5, 5] Output: 5, 10 Numbers in strings are not consi...
Problem One day, you boss walks up to you and tells you he needs to know the time. He still insists after you pointing at the clock directly above your head, and confesses he has a severe case of dyscalculia, which causes him to not even be able to see numbers on a clock. While you're still left wondering how someone u...
Leonardo da Pisano a.k.a Fibonacci was instrumental in bringing the Hindu-Arabic numeral system into Europe. Before that, mathematicians there worked in base sixty with Roman numerals. For example, the square root of two might be approximated as: one and twenty-four parts of sixty and fifty-one parts of three-thousand-...
Your task is to find the length of the coastline of a map of islands provided in an ASCII map. The input map will consist of 1 or more # characters that indicate land, and spaces which indicate water. The coastline is considered to be any edge between land and water, including inland lakes and islands. Your solution sh...
Given an input of a single positive integer, output the "cross-alternate sum" that corresponds to that integer. Take the example of the input n=5. To find the cross-alternate sum, first create a square grid of width and height n that, reading from left to right and top to bottom, starts at 1 and increases by one each p...
Isn't it annoying when you're working with floating point numbers and your code doesn't work because two numbers are not equal by the least significant bit? Now you can fix that! Write some code that takes two floating point numbers in any IEEE 754 binary format and returns TRUE if: the two numbers are exactly equal f...
The other day my chemistry teacher was explaining to us about scientific notation (using a small number and multiplying it by powers of ten to express large numbers more easily), which brought me back a few years to when I first learnt it. After learning the basics, we had done a bunch of typical maths questions, some ...
Wouldn't it be neat if programming functions could be inverted, just like the mathematical function they implement? Write a function (or program) that takes one input x in any form, that outputs ln(x). When the bytes of the program are reordered/reversed so that the first byte now is the last byte, it should take one ...
This challenge is inspired by this other. The challenge Write a program or a function in any programming language that given as input a string representing a time in English (see below, for further details) it outputs or prints the equivalent in the 24 hours "digital" format HH:MM. Shortest code in bytes wins, standard...
I have a chocolate bar and I need help eating it so you'll be writing a program just to do that. Explanation The first line is the input. Examples are separated by an empty line. 7 ____ __|__| |__|__| |__|__| |__|__| 6 _______ |__|__| |__|__| |__|__| 5 ____ __|__| |__|__| |__|__| 0 1 ____ |__| Spec ...
In trigonometry, there are certain angles known as "special angles". This is because when you take sin, cos or tan of one of these angles, you get a result that is easy to remember because it is a square root of a rational number. These special angles are always multiples of either pi/6, or pi/4. Here is a visualizatio...
You are to approximate the value of: $$\int^I_0 \frac {e^x} {x^x} dx$$ Where your input is \$I\$. Rules You may not use any built-in integral functions. You may not use any built-in infinite summation functions. Your code must execute in a reasonable amount of time ( < 20 seconds on my machine) You may assume that inp...
Implement a function diff that takes as input three integers x, y, and z. It should return whether subtracting one of these numbers from another gives the third. Test cases: diff(5, 3, 2) yields True because 5 - 3 = 2 diff(2, 3, 5) yields True because 5 - 3 = 2 diff(2, 5, 3) yields True because 5 - 3 = 2 diff(-2, 3, 5)...
Kirchhoff's law says that when you sum up all the currents (positive for the currents going to a junction, and negative for current leaving a junction), you will always get as result 0. Look at the following diagram: Using Kirchhoff's law, you can see that i1 + i4 - i2 - i3 = 0, so i1 + i4 = i2 + i3. Given two lists, ...
I like making dank memes out of my own images. But all those so called "quick meme" sites just have too much code. I realized that the only way to make the dankest meme generator is to ask you guys at PPCG to golf one for me. So let me give you the low down on what you have to do. Specs Take an image as input as a fil...
The American football championship, Super Bowl 50, is happening today at 11:30pm UTC (and you can watch it live online). This challenge was made to celebrate it. In an American football game, two teams compete to get the most points and there are six ways to score these points. We'll give each an abbreviation: Field ...
You are given a single printable ASCII string containing no newlines, and a multiline "mold", containing spaces (), and hashes (#). You must go character by character in the string, and replace hashes using the characters from the string in left-right, top-bottom order. If the string is too short to fill the mold, you ...
Challenge Inspired by this SMBC comic, discussed on reddit, math.stackexchange, and calculus7, the challenge is to return the lowest base such that a number is "fouriest." Description [From the comic] "It's called a Fourier Transform when you take a number and convert it to the base system where it has more fours, thu...
The keypad on my office phone has the following layout: [1] [2] [3] /.@ ABC DEF [4] [5] [6] GHI JKL MNO [7] [8] [9] PQRS TUV WXYZ [*] [0] [#] + _ Task: Write a program that, given an input string, returns a list of instructions that my fingers need to follow in order the type/dial the message/number...
Background Most everyone is familiar with the Fibonacci numbers \$F(n)\$: \$0, 1, 1, 2, 3, 5, 8, 13, 21, ...\$ These are formed by the recursion function \$F(n) = F(n-1) + F(n-2)\$ with \$F(0)=0\$ and \$F(1)=1\$. A000045 A closely related sequence is the Lucas numbers \$L(m)\$: \$2, 1, 3, 4, 7, 11, 18, 29, ...\$ Th...
Given two inputs, a string \$s\$ and a decimal number \$n\$, output the string multiplied by that number. The catch is that the number can be a float or an integer. You should output the string \$\lfloor n \rfloor\$ times and then the first \$\lfloor (n - \lfloor n \rfloor) \cdot |\,s\,|)\rfloor\$ characters again. Oth...
Given an input of a string representing a function definition, output the string with newlines and spaces inserted so that the function's arguments are newline-separated and aligned. The input string will follow the following pattern: First, it will start with a prefix, which is always at least one character long and ...
The Enigma machine is a fairly complex cipher machine used by the Germans and others to encrypt their messages. It is your job to implement this machine*. Step 1, Rotation Our enigma machine has 3 slots for rotors, and 5 available rotors for each of these slots. Each rotor has 26 different possible positions (from A t...
One way to construct a regular heptadecagon starts with drawing a horizontal line of length 1 from the center to a vertex. Then the distance along that line from the center to the second vertex is cos(2π/17). All other vertices are easy to get. The goal of this challenge is to print (or produce in any other conventiona...
Suppose you have 2 languages, A and B. A string s is a semiquine in A and B if it satisfies the following conditions: s is a quine in language A. s is a polyglot in A and B. The output of running s as a B program is a different string s', which is a quine in B. The goal of this challenge is to write a semiquine in tw...
A Norwegian Birth Number consists of 11 digits, composed the following way: DDMMYYiiikk DD is the day (from 01-31) MM is the month (from 01-12) YY is the year (from 00-99). It's not differentiated between 1900 and 2000 iii is the "individual number" kk are two control digits iii is determined by birthyear and gender...
A simple challenge for your Monday evening (well, or Tuesday morning in the other half of the world...) You're given as input a nested, potentially ragged array of positive integers: [1, [[2, 3, [[4], 5], 6, [7, 8]], 9, [10, [[[11]]]], 12, 13], 14] Your task is to determine its depth, which is the greatest nesting-dep...
Write a square root function taking a single input – positive, negative or sign‑less (zero is sign‑less) – that outputs its approximate principal square root, correct up to six decimal places past the decimal point (truncate after the sixth decimal place). Employing scientific notation (1E3 = 1 × 10³ = 100) or similar ...
Challenge Your submission should consist of 2 or more programs each written in distinct languages. They can be arbitrarily numbered from 1 to k. Each program p, given a natural number n should print the next n prime numbers (initially, the next prime is the 0-th prime, 2) on a single line, followed by a single blank n...
You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list. For example if the input is 5 4 12 1 3 the multiplications will be 5*1=5 4*2=8 12*1=12 1*13=13 3*5=15 and the output will be the incre...
The van der Corput sequence is one of the simplest example of low-discrepancy sequence. Its n-th term is just 0.(n written in base 10 and mirrored), so its first terms are : 0.1, 0.2,0.3,0.4, 0.5,0.6,0.7, 0.8,0.9, 0.01, 0.11,0.21,0.31, 0.41,0.51,0.61, 0.71,0.81,0.91, 0.02, 0.12,0.22,0.32, 0.42,0.52,0.62, 0.72,0.82,0.92...
The determinant of a 2 by 2 matrix a b c d is given by ad - bc. Given a matrix of digits with dimensions 2n by 2n, n ≥ 1, output the result obtained by recursively computing the determinant of each 2 by 2 sub-block until we reach a single number. For example, given the input 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 After one ...
Introduction Note: this is not some kind of method to encourage cheating. As Cᴏɴᴏʀ O'Bʀɪᴇɴ already said, studying is the best solution for passing a test :3. Consider the following answers to the multiple choice test: ABCBCAAB Here is a table which indicates whether the answers match: A B C B C A A B A 1 0 0 0 ...
Football is the sport where players kick the ball, not carry it. Some confused individuals might call this soccer. A football team has one goalkeeper, and 10 players out on the pitch. There are many formations used in football, that dictates where each player should be (the player of course moves around, but it's the ...
The task This challenge is very simple. Your input is a rectangular 2D array of integers, sized at least 1×1. It can be taken in any reasonable format. Your output shall be the input array, but with all entries not on the first or last row or column set to 0. It must be in the same format as the input. For example, if ...
I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask. I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'. Cool languages have Range('a'..'z') or similar What can we come up with with JS that's as short as possible?? for(i=97,a='';i<123;){a+=String.fromCharCode(i++)} is longer tha...
What general tips do you have for golfing in Retina? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Retina (e.g. "remove comments" is not an answer). Please post one tip per answer. For reference, the online compiler is here. @Sp3000 pointed out there i...
A couple months ago, we had a discussion on meta about increasing the reputation awarded for upvotes on questions. Here's the basics of our current reputation system for votes:1 A question upvote U is worth 5 reputation. An answer upvote u is worth 10 reputation. A question or answer downvote d is worth -2 reputation....
While there are only a few users of the Vitsy programming language right now, I wish to create a place for tips for golfing in Vitsy. What general tips do you have for golfing in Vitsy? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Vitsy (e.g. "remove ...
Inspired by this. No avocados were harmed in the making of this challenge. Hello I have challenge I need help juic an avocado so I need program to tell me how long to juic avocad for Observe this ASCII art avocado: ###### # # # #### # # # p# # ## #### # # # ###### This avocado consists...
Given an image of a goat, your program should best try to identify whether the goat is upside down, or not. Examples These are examples of what the input may be. Not actual inputs Input: Output: Downgoat Spec Your program should be at most 30,000 bytes The input will contain the full goat The picture will always cont...
The Champernowne Constant is the irrational number 0.1234567891011... extending ad infinum. We've done a question about it before. But this question is about its reciprocal, known as the Inverse Champernowne Constant. This is approximately 8.10000007. Given a string of between one and three digits (every 3-digit stri...
Given an input of a positive integer, output the number of steps it takes to find the input via a binary search starting at 1. We are simulating a binary search for the integer that was given as input, in which the simulated searcher can repeatedly guess an integer and be told whether it is too high, too low, or correc...
Introduction Boardgames are a classic play between kids, but there are some kids that feel bored playing a boardgame step by step. Now they want the result to be shown before they put their hands on the board. Challenge Suppose this boardgame: >---#<---X---<X<--#-$ > means the start of the game - means a position w...
Aside of nursing my child, Vitsy, and dabbling in the art of code golf, I also am an avid dubstep fan, listening to all the new dubstep that Monstercat puts out as regularly as I can. I also share a random dubstep of the day, though not regularly, in the Nineteenth Byte. This last bit is what this challenge relates to;...
This challenge is similar to this other, however I made a restriction (see bold text below) that I think would made it much diffent and (I hope) fun either. The Challenge Write a program or a function in any programming language that takes as input the English name of a positive integer n not exceeding 100 and returns...
Here is a very simple language definition: A Variable is any string that does not contain ^, <, >, !, or ? The empty string is a valid variable identifier The value of every variable starts at 0. A Statement is one of (var is a Variable, P is a Program): var^ -> changes var to be equal to 1 more than itself v...
Goal As the title suggests, write a radix sort function (either MSB or LSB is fine) that accepts two parameters: an array of values of any type (you can assume that they are all of the same type / class, etc.) a function (or function pointer, depending on your language) that takes a single parameter of the same type a...
In the fewest bytes possible, determine whether the two values given each match one of the following: First value 2 string or integer - whichever you prefer to case insensitive too case insensitive two case insensitive t0 case insensitive (t zero) Second value b case insensitive be case ins...
The task The credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer, and the "Big Three" credit rating agencies use a similar (though not identical) tiered rating system. These have a clear, logical order - using the S&P tiers, AAA > AA+ > AA > AA- > A+ > ... > BBB > B > ... > C...
We will be implementing division for arbitrarily large integers. This is code-golf. The task is to write a program or function that implements arbitrary precision integers and Division on them. Note that many things that might make this very easy are disallowed, please make sure to read through the spec. Input You will...
Create a function or program that takes a number as input, and outputs a string where ASCII-code points for the lower and upper case alphabet are substituted by their character equivalents. The upper case alphabet use the code points: 65-90 The lower case alphabet use the code points: 97-122 If any adjacent digits i...
Introduction I have recently started playing clickerheroes again. In the recent patch they introduced a new mechanic to mercenaries: their lifetime. Instead of having a random chance at dying now they have a certain lifespan given by a geometric distribution of p = 0.2. They can be sent on quests to accumulate a premiu...
Introduction My grandpa is a fan of James Bond, but he is always unsure on how to rank his favourite actors. As such, he is always making lists, which is a lot of work. He asked me to produce a program that will make his life easier, but I do not have time for that, I have to work! So I will count on you guys. Challeng...
Based on an idea suggested by Zgarb. A spaceship is moving around a regular 3D grid. The cells of the grid are indexed with integers in a right-handed coordinate system, xyz. The spaceship starts at the origin, pointing along the positive x axis, with the positive z axis pointing upwards. The spaceship will fly along a...
Consider a permutation of the integer values from 1 to N. E.g. this example for N = 4: [1, 3, 4, 2] We'll consider this list to be cyclic, such that 1 and 2 are treated as adjacent. One quantity we can compute for such a list is the total squared difference of adjacent values: (1-3)² + (3-4)² + (4-2)² + (2-1)² = 10 Y...
Van der Waerden's theorem says that For any given positive integers r and k, there is some number N such that if the integers {1, 2, ..., N} are colored, each with one of r different colors, then there are at least k integers in arithmetic progression all of the same color. The least such N is the Van der Waer...
I wanted to ask this question: Convert to and from the factorial number system but I'm a couple of years too late! So, instead you must convert to and from the lairotcaf backwards-factorial number base! The way it works is that the first digit is always 0, the maximum value of the next digit is 1, then 2 and so on. If ...
Given an input of a list of numbers in the format of a shorthand increasing integer sequence, output the sequence in full. Shorthand increasing integer sequence format works by finding every number n with fewer digits than the number preceding it, m. With d as the number of digits in n, the last d digits of m are repla...
Task Write a program or function that will determine if a point in 3D space lies on a 2D parabolic curve. Input 3 points in 3D space vertex of a 2D parabolic curve arbitrary point on the curve arbitrary point in space Input may be taken in any form (string, array, etc.) provided no other data is passed. You may ass...
Challenge Find an expression, at most 100 bytes long, with the longest type signature. Rules Any statically typed language with type inference is allowed The type must be non-ambiguous, but otherwise may include types without defined instances. For example Num [a] and Eq [a] are allowed, even without a defined instanc...
You receive an input with a number and a string with a space in the middle. The string tells you what you need to do with the number, it can be: sqrt - square root of number sqr - square of number cube - cube of number abs - absolute of number round - rounded version of number You need to output the final result of the...
Task The task is very simple. Given a non-empty string containing numbers, uppercase and lowercase letters, output the sum of the remaining numbers. For example: a1wAD5qw45REs5Fw4eRQR33wqe4WE Filtering out all the letters would result into: 1 5 45 5 4 33 4 The sum of these numbers is 1 + 5 + 45 + 5 + 4 + ...
The ancient Greeks had these things called singly and doubly even numbers. An example of a singly even number is 14. It can be divided by 2 once, and has at that point become an odd number (7), after which it is not divisible by 2 anymore. A doubly even number is 20. It can be divided by 2 twice, and then becomes 5. Yo...
A metaquine is a program which is not a quine, but whose output, when run as a program in the same language, is a quine. The goal of this challenge is to write a metaquine. This is code-golf, so shortest code wins, with earliest answer used as a tiebreaker. Note that only full programs are acceptable, due to the defini...
Given a non-empty list/array containing only non-negative integers like this: [0, 0, 0, 8, 1, 4, 3, 5, 6, 4, 1, 2, 0, 0, 0, 0] Output the list with trailing and leading zeroes removed. The output for this would be: [8, 1, 4, 3, 5, 6, 4, 1, 2] Some other test cases: [0, 4, 1, 2, 0, 1, 2, 4, 0] > [4, 1, 2, 0, 1, 2, 4]...
Given 3 positive integers a, b, and n (whose maximum values are the maximum representable integer value in your language), output a truthy value if a ≡ b (mod n), and falsey otherwise. For those unfamiliar with congruency relations, a ≡ b (mod n) is true iff a mod n = b mod n (or, equivalently, (a - b) mod n = 0). Rest...
The task A string S is constructed with the following process: Start with S being the empty string. Insert at some position of S a string of the form ds, where d is a nonzero digit and s is a string of d lowercase ASCII letters. We say ds is a constituent of S. Go to step 2 or stop. Your task is to take such a string...
A variable number of bits is an array of 0 or more bits. So [0, 1] is a variable number of bits, but so is []. Write a function or program that, given an nonnegative integer returns a variable number of bits such that every integer has a one-to-one (bijective) mapping with an array. There are an infinite amount of such...
OEIS A000009 counts the number of strict partitions of the integers. A strict partition of a nonnegative integer n is a set of positive integers (so no repetition is allowed, and order does not matter) that sum to n. For example, 5 has three strict partitions: 5, 4,1, and 3,2. 10 has ten partitions: 10 9,1 8,2 7,3 6,4 ...
Given a series of os representing dots, connect them vertically or horizontally Examples Input: o o o Output: o---o | | o Input: o o o o Output: o---o----o | o Spec If you want the input padded with spaces to form a rectangle, please specify this in your answer There will only be o, spaces, a...