instruction stringlengths 34 53.1k |
|---|
You are little speck on a Cartesian plane. Pondering your existence, you decide to roam around your plane and touch things. You notice that every coordinate pair you visit has a light switch. To entertain yourself, you decide to toggle every switch that you come across.
The Challenge: Create a program that will take an... |
Challenge
In this challenge you have to take a number as input and output the corresponding letter of the alphabet, and vice versa. (1 <=> A, 2 <=> B) etc.
1 -> A
2 -> B
...
26 -> Z
A -> 1
B -> 2
...
Z -> 26
Rules
This is code-golf, so shortest code in bytes wins.
The input will only consist of either an uppercase l... |
The purpose of this challenge is to produce an ASCII version of the cover of this great album by the rock band Pink Floyd.
The brick junctions are made of characters _ and |. Bricks have width 7 and height 2 characters, excluding junctions. So the basic unit, including the junctions, is:
_________
| |
| |
_... |
Task
Your task is to print or output all positive numbers in which every multi-digit substring in its decimal representation is also prime. If the number has at least 2 digits, this would imply that the number itself also needs to be prime.
Example
6197 is in the sequence because every multi-digit substring in 6197 is... |
Introduction
I've previously created two challenges where the idea is to reconstruct an object using as few query-type operations as possible; this will be the third.
The task
Your inputs shall be a non-empty string S over the alphabet abc and its length, and your output shall be S.
With no restrictions, this would of ... |
"Fit Numbers"
Sam has a "brilliant" idea for compression! Can you help?
Here is a rundown of Sam's compression scheme. First take in a base 10 representation of any natural number strictly smaller than 2^16, and write it as a binary string without any leading zeros.
1 -> 1
9 -> 1001
15 ->1111
13 ->1101
16 -> 10000
17... |
Randall Munroe (author of XKCD) held a survey to give names to colors. The main outcome is a list of names for the 954 most common RGB monitor colors.
For ease of programming, here is the list in plain text: http://xkcd.com/color/rgb.txt. Beware, the first line is not data, but contains the license.
Write a program or ... |
Given an integer N as input, output the Nth permutapalindromic number.
A permutapalindromic number is a strictly positive integer such that there is at least one permutation of its digits that results in a palindrome (i.e. a number that is its own reverse).
For example, 117 is a permutapalindromic number since its digi... |
Definition
Here is the process to describe a number:
For each number from 0 to 9 that is present in the number:
Write down the frequency of that digit and then the digit.
For example, for the number 10213223:
There is 1 occurrence of 0,
2 occurrences of 1,
3 occurrences of 2,
2 occurrences of 3.
Therefore, the numb... |
See also: Parsing
Introduction
You're working on a government programming team, who have been programming the speed cameras. However, the group of people who have programmed the speed calculator have taken up too much space, so you have to make the number plate recognition software as small as possible.
Challenge
Given... |
Briefing
The difficulty of a Code Golf question can be calculated as such:
$$\text{clamp} \left( \left\lceil \left( \frac v a \div 700 \right) \times 10 \right\rceil, 0, 10 \right)$$
Where \$v\$ is the number of views a question has
and \$a\$ is the number of answers a question has
and \$⌈x⌉\$ is the ceiling operator.
... |
Inspired by Input ∩ Source Code.
Task
Your task is to determine whether the input is a permutation of the source code.
Input
A string. Input is flexible; it should be able to handle the character encoding used for the source code.
Output
You may only have two possible outputs, one when the input is a permutation ... |
Some people say curiosity killed the cat. Other say it was the box and poison. The RSPCA say Erwin Schrödinger needs to lose the right to own pets.
With animal rights activists outside his house. The cat murderer scientist Schrödinger has finally come up with his greatest invention. A special, radioactive mix of unobta... |
Write a program or function that takes as input three positive integers x, y, and a and returns or outputs the maximum number of whole a✕1 rectangles that can be packed (axis-aligned) into an x✕y rectangle. Although the result will always be an integer, the program need not give the result using an integer type; in pa... |
Task
Given positive integer n, output a(n) where a is the sequence defined below:
a(n) is the smallest positive integer not yet appeared so that the sum of the first n elements in the sequence is divisible by n.
Example
a(1) is 1 because it is the smallest positive integer that has not appeared in the sequence, and 1 ... |
Given two positive integers, 'a' and 'b', output an ascii-art "box" that is a characters wide and b characters tall. For example, with '4' and '6':
****
* *
* *
* *
* *
****
Simple right? Here's the twist: The border of the box must be the characters of "a" and "b" alternating. This starts at the top left corner, ... |
Write a program or function that takes in a 4×4 text grid consisting of exactly 4 A's, 4 B's, 4 C's, and 4 D's, such as:
ACDC
BBCA
BADD
ABCD
The ABCD's may be in any arrangement but there will always be 4 of each. You can assume the input is valid. If desired you can also assume it has a trailing newline and/or that i... |
Recently, I was introduced to a puzzle game known as Solitaire Chess. I'll summarize the rules here:
The board is a 4x4 checkerboard.
All pieces are the same color (no teams) and all pieces can capture any other piece.
Every move must be a capture. No moving to empty squares.
There must be exactly one piece remaining ... |
The Stern-Brocot sequence is a Fibonnaci-like sequence which can be constructed as follows:
Initialise the sequence with s(1) = s(2) = 1
Set counter n = 1
Append s(n) + s(n+1) to the sequence
Append s(n+1) to the sequence
Increment n, return to step 3
This is equivalent to:
Amongst other properties, the Stern-Brocot... |
Frank has been working IT his whole life. Each day he responds to tickets, organizes equipment, and reports to his boss. One day, near the closing time on friday, Frank is doing his final inventory and sorting come cables in the supply closet. Suddenly, the door closes and locks from the outside! Such audacity! Frank s... |
Description
We consider a slightly simplified version of Tetris where each move consists of:
rotating the piece clockwise, 0 to 3 times
positioning the piece at a given column
fast drop
The goal is to determine the number of completed lines, given a list of such Tetris moves.
Completed rows are removed as pieces are ... |
Extended Train Swapping Problem
Part 1: Normal Train Swapping Problem
In the 1996 CCC (Canadian Computing Competition), the first Stage 2 problem was a Train Swapping Problem. You can visit the link here. Essentially, you have a bunch of numbered trains, and you want to find out how many train swaps you need to get the... |
Intro:
A Frobenius number is a number which cannot be made from numbers in a set.
For example, 43 is the Frobenius number of the set {6, 9, 20}, because you cannot get 43 from those numbers, and it is the largest number which cannot be made.
42 is not a Frobenius number of the set {6, 9, 20}, because it can be made fro... |
I find it fascinating how the letters "H" and "I" are very similar. "H" is a horizontal stroke surrounded by two vertical strokes; "I" is a vertical stroke surrounded by two horizontal strokes (depending on your font). I bet this could be nested... You know what that reminds me of? Fractals!!!
Let's define the "IHIH" p... |
Implement this key cipher
Goal
Use the algorithm (explained in the Algorithm section) to implement a certain cipher.
The program must read input from STDIN or the closest available equivalent, use the algorithm to generate the ciphertext and a key.
The ciphertext and the key will be written to STDOUT or the closest ava... |
See Also: Recognition
Introduction
You've now been taken off the speed camera development team (let's face it, your code is nowhere near production code standards) and are now working on a program to extract information about the car from the number plates. Of course, you've caught the code golf bug and want to write t... |
In the following markup without changing it or using JS, implement the behavior to show only the ul element of div which name is clicked in the first ul (before div). Name is content of li in top ul and it matches the content of the first li in ul you want to show. Elements that have {content} are just fillers and have... |
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.
Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+006... |
Your task is to take an input, for example:
a,b,4,5
And produce an output, which per this example is aaaabbbbb
a,b,4,5 means: the lowercase character "a" is repeated 4 times, and is then followed by the lowercase character "b" repeated 5 times, making the total number of characters 4+5=9
Another example: the input a,B,... |
Olympic vine-swingers perform their routines in standard trees. In particular, Standard Tree n has vertices for 0 up through n-1 and edges linking each nonzero vertex a to the vertex n % a below it. So, for example, Standard Tree 5 looks like this:
3
|
2 4
\ /
1
|
0
because the remainder when 5 is divided b... |
Introduction
It's 2600 BC and people are building pyramids now. They already made the basis of the pyramid but don't know how to continue. So, they called you for help.
The rules of making a pyramid is quite simple. For the layer above the previous layer, all you need to do is follow this step-by-step hand guide:
Cut ... |
Slimes are cube shaped enemies in Minecraft that break into multiple smaller versions of themselves when killed. For the purposes of this challenge we'll depict them as an 8×8 pixel image with 3 colors:
← True 8×8 version.
The precise RGB colors are:
0, 0, 0 for the eyes and mouth
110, 170, 90 for the central, darke... |
Challenge
Write a program which, using the XML data from the site here, display the name of the programme which is currently showing on BBC 1.
Information
All times are given at London time (GMT+1 at the time of posting and GMT+0 after the 30th October). Therefore, you should convert your local time to London time.
Eac... |
Task
Your task is to print this exact text:
A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZ... |
Since this SE community is about golfing, I thought a golf-related challenge would be appropriate.
Explanation
Normally, the objective of golf is to finish a hole (and consequently, the entire round) with the least amount of strokes. This is a simple version of golf: Play until you hole the ball and sum up your score. ... |
I made my own sequence recently (called the Piggyback sequence), and it works like this:
P(1), P(2) and P(3) = 1.
For all P(n) where n>3, the sequence works like this:
P(n) = P(n-3) + P(n-2)/P(n-1)
So, continuing the sequence:
P(4) = 1 + 1/1 = 2
P(5) = 1 + 1/2 = 3/2
= 1.5
P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...
P(7) = 2... |
In a programming language of your choice, write 95 programs, each of which outputs a different one of the 95 printable ASCII characters without that character occurring anywhere in the program.
For example, if your language was Python, your program that outputs the character P might be
print(chr(80))
because P has ASC... |
I'm new to ES6 and code-golfing. Here's the original function:
function puzzle(n, x) {
return n * Math.pow(2, x);
}
And here's what I have so far:
let puzzle=(n,x)=>n*2<<(x-1)
But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread, but couldn't find a better way.
Any he... |
Task
Given integers x and y which are both at least 2, find the smallest positive number whose y-th power is divisible by x.
Example
Given x=96 and y=2, the output should be 24 since 24 is the smallest positive n satisfying n^2 is divisible by 96.
Testcases
x y output
26 2 26
96 2 24
32 3 4
64 9 2
27 3 3
Scoring
This... |
In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, the racer in the innermost lane would have a huge advantage).
Given the lengths of the major and minor axes (or semi-majo... |
Enterprise Quality Code!
TL;DR
Answers will consist of a full program (of length < 30k) prints the the first N Prime numbers (as a base 10 representation without leading zeros unless the chosen language only supports unary or other based output) separated by newlines (optional trailing linefeed).
You may post cracks ... |
For my CS class, my instructor has given us the assignment of creating a rectangle made of asterisks with diagonal lines drawn through it in Java.
He also told us to write it in as few bytes as possible. I've gotten it down to 190 bytes, but I need to find a few to simplify this code even more to decrease bytes. Can an... |
Introduction
Dice 10,000 is a dice game which can be played with 6 dice and something to write. Players roll the dice multiple times a turn and gain a score at the end of it. The player who reaches 10,000 point first wins the game. Calculating the score of one roll is your job in this challenge.
Look here for the full ... |
In Golfenhagen, The people are allowed, and encouraged, to melt down old coins for scrap metal, if the smelter can make a profit off of it. There are 5 coins that make the Golfenhagen mint. The half-penny(0.5)(H), the penny(1)(P), the tea (5)(T), the flag (10)(F), and the driver (25)(D). Golfenhagen also mints bills, i... |
Lets say you saw your friend enter his or her password into their Android phone. You don't remember how they made the pattern but you remember what the pattern looks like. Being the concerned friend that you are you want to know how secure their password is. Your job is to calculate all the ways that a particular pa... |
Here's a nice easy challenge:
Given a string that represents a number in an unknown base, determine the lowest possible base that number might be in. The string will only contain 0-9, a-z. If you like, you may choose to take uppercase letters instead of lowercase, but please specify this. You must output this lowest p... |
Working with old files from DOS, I found an ancient text animation format, that specify how much time each frame must be shown in the screen. It's very simple:
F1W5F2W3
This example above indicates that Frame 1 must be shown for 5 units of time, and frame 2 for 3 units more. Now I want to convert it to:
1, 1, 1, 1, ... |
Challenge
Your program will take in a string from stdin, and output multiple lines to stdout.
An example of input looks like this:
My favorite Chipotle order:
B1113YNNY
Let's break it down:
The first character is either A (burrito), or B (burrito bowl).
The second character is 1 (black beans), or 2 (pinto beans). ... |
You have been assigned the task of installing new locks to the company's building. However, the locks you use are quite unusual: they require some combination of keys to open. Now, you want to figure out which locks are the most secure, so you can prioritize the most important locations.
The keys you use are numbered b... |
Consider the standard equilateral triangle, with nodes labeled using barycentric coordinates:
We can turn this 3 node triangle into a 6 node triangle by adding a new line of 3 vertices (one more than was present on a side of the original 3 node triangle), remove any internal edges (but not internal nodes) and re-norma... |
Related
Introduction
As it happens, someone put forward the idea that, since PPCG has graduated, up votes on questions should be worth 10 rep. As a result, I started wondering how much rep I would have if it had always been 10 rep.
Challenge
Given a PPCG user's id as input, output how much total rep the user would have... |
Introduction
Alphabet challenges are in our DNA, so let's show it.
Challenge
Print the following the text exactly:
AaBbCc cCbBaA
BbCcDd dDcCbB
EeFfGg gGfFeE
HhIiJj jJiIhH
KkLlMm mMlLkK
NnOoPp pPoOnN
QqRrSs sSrRqQ
TtUuVv vVuUtT
WwXx xXwW
Yy yY
... |
In the game of sudoku, many players like to "pencil in" possible numbers that can go in each square:
The above row can be represented as an array:
[[1,2,9], [6], [5], [7], [1,2,9], [1,2,9], [3], [1,2,4], [8]]
Now, notice that there is only 1 place where a 4 can go. This effectively lets us simplify the above list to... |
Challenge
Given an array of integers, received from stdin, function arguments, program arguments, or some other method:
Output only the minimum and maximum numbers in the array, through a return value, stdout, or other fitting methods.
Example session
> minmax( {0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14} )
-14 18... |
A counterstring is some sort of self-describing test data that is used in software testing. Not sure it was actually invented by James Bach, but I know it from there.
The idea is as follows: the test data contains many asterisk (*). The number in front of the asterisk tells you how long the test data is at that point. ... |
Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you!
The Challenge:
As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list... |
In honor of how much rep I had several hours ago, when I first thought of this challenge:
Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find... |
Background:
Standard operation math like basic addition and multiplication in the real world work like these:
12 + 123 = 135
and
12 * 123 = 1476
That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring ma... |
(related: one, two, three)
An acrostic is a style of poem/writing where the beginning character of each line, when read vertically, also produces a word or message. For example,
Together
Everyone
Achieves
More
also spells out the word TEAM when the first column is read vertically.
Acrostics are a subset of mesostics, ... |
Write a function which takes a set of integers and prints every permutation of the set, and the swap performed in between each step
Input
a set of integers, for example (0, 1, 2)
Output
the list of permutations and swaps in the format
(set)
(swap)
(set)
...
Test case
Input:
(3, 1, 5)
Output:
(3, 1, 5)
(3, 1)
(1, 3, 5... |
Don't you love those exploded-view diagrams in which a machine or object is taken apart into its smallest pieces?
Let's do that to a string!
The challenge
Write a program or function that
inputs a string containing only printable ASCII characters;
dissects the string into groups of non-space equal characters (the "p... |
Given an expression, your task is to evaluate it. However, your answer cannot show more digits than necessary, as this gives the impression of having more precise measurements than reality.
The number of significant figures that a number has is how many digits it has when written in scientific notation, including zeros... |
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.
The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.
The input will never be a multiple of 10, bec... |
I am 2/3 twins with my brother, i.e. born on the same day of the same month but twelve years later. When I was 5, he was 17, both primes; the last pair of ages we can reasonably count on is [71, 83] with both of us being alive and able to celebrate this coincidental jubilee.
Task
Create a code that
takes two integer... |
You're given a rectangular grid of the characters . and #, like this:
..........
..#.......
....#..#..
...#......
..........
Your task is to fill the entire axis-aligned bounding box of the # with further #:
..........
..######..
..######..
..######..
..........
The axis-aligned bounding box is the smallest rectangle... |
Preface
There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the union Jack! I feel like this would be a harder flag to draw but it should still be possible.
Challenge
Draw the Union Jack. It can be outputted to a file in any freely available graphics file format or d... |
Creating a Crossed Square
You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.
The general idea is for the output to be a hollow square that has a diagonal cross through it.:
Input: 7
Output:
*******
*# #*
* # #... |
Inspired by Using LaTeX to compact a list of numbers, this challenge is to output a compact list of numbers, given a range, as follows:
Input: 1,2, 3,4,5,8,11, 12,13
Output: 1-5, 8, 11-13
Input: 20,21,45,56,75, 76,77,78
Output: 20-21, 45, 56, 75-78
Input: 4,5
Output: 4-5
Input is always comma separated numbers, some... |
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2). These numbers are listed on OEIS
For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12. None of these representations is palindromic, so the number is strictly non-palindromic.
For this ... |
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows:
Each member is the product of all previous members plus one. The first member of the sequence is 2.
Task
Create a program to calculate the nth term of Sylvester's Sequence. Standard input, output and loopholes apply.
Standard sequence rule... |
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as
|
/_\
|E|
|a|
|r|
|t|
|h|
|_|
/___\
VvV
with the input string written from top to bottom on the fuselage. In this case the input was Earth.... |
Currently at my work we moved to a new building. It's supposed to be state of the art and has automatic lights, automatic roll-down shutters, and is now known as the most eco-friendly building in this town.
However, it doesn't really work all that well.. The roll-down shutters sometimes go down on cloudy days and up wh... |
Write a program that prints the name of its source file. REPL environments are not allowed for this challenge. Your code must work in any file that your language's interpreter will accept. Your answer must also be a full program, not just a function. The source code's file extension must be printed. Leading or trailing... |
Is there any better way to golf this (other than removing newlines/indentation)?
function(a,b,...)
local c=s(a,b)
local d=c
for i,v in ipairs{...} do d=d:push(v) end
return c
end
I'm particularly bothered by the double local usage, but as Lua does not have multiple assignment, and I cannot use function paramet... |
The International Standard Atmosphere (ISA) is a model of the Earth's atmosphere at "reference" conditions. It includes information on pressure, temperature, and density change vs. altitude.
The ISA tabulates these properties at various layers, and an estimation of the value of interest can by found by the following pr... |
As we know, a quine is a program that outputs its own source code. However, it's also possible to write a program that outputs another, different program, that outputs the first program again. For example, the Python 2 program
x = '''x = {}
print 'print '+'"'*3+x.format("'"*3+x+"'"*3)+'"'*3'''
print 'print '+'"'*3+x.fo... |
I have a problem for a cyber club that asks you to print:
ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
Using Brainf**k in 29 bytes or less without using the ',' character.
I have a working code:
++++++++++[>++++++>+++++++++<<-]>-->.<[>-.<-]
However my loop is too long, sending me 16 bytes over the limi... |
In cryptography, PKCS#7 padding is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N.
For example, Hello, World!, which has 13 bytes, is the following in hex:
48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
If we choose to PKCS#7 pad to length 16, then the result is:
48 65 6C... |
This puzzle is derived from CodinGame SamSi's "Heart of the City" puzzle.
Description
You decide to take a walk in an n * n tile city and go to the center tile. All of the buildings are infinitely small, but you have super vision and can see everything close up and far away.
Constraints
n is always odd
You can see any ... |
This challenge is related to Flipping Pancakes.
You may have heard of pancake sorting, where a stack of pancakes is sorted by size by inserting spatula into the stack and flipping all of the pancakes above the spatula, until the pancakes are sorted smallest to largest on the plate. The burnt pancake problem is slightly... |
Given a list of paths, output the correct path.
Example of path:
/\
----+/
|
- and | are horizontal and vertical paths.
/ and \ are 90° turns.
+ is treated as a - or a | depending of the current direction.
Paths may go in any direction and a character may be used in multiple paths.
Input will be like this:
... |
For a positive integer n with the prime factorization n = p1^e1 * p2^e2 * ... pk^ek where p1,...,pk are primes and e1,...,ek are positive integers, we can define two functions:
Ω(n) = e1+e2+...+ek the number of prime divisors (counted with multiplicity) (A001222)
ω(n) = k the number of distinct prime divisors. (A001... |
Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant):
0123456789101112131415161718192021222324252627282930...979899100101102103...
Write a program or function that takes in a nonnegative integer that indexes (0-based) into this infinite strin... |
Implement a simple integer operation scriptable calculator.
Concept
The accumulator starts at 0 and has operations performed on it. At the end of the program output the value of the accumulator.
Operations:
+ adds 1 to the accumulator
- subtracts 1 from the accumulator
* multiplies the accumulator by 2
/ divides the a... |
Disclaimer
While I know there is this particular related question, my question uses two garage doors, a randomizing component, and I'm also basing this on real life events, seeing my son accidentally lowered one of said garage doors whilst I was walking out of the garage last week... Nothing like a blow to the head to ... |
You're given a hexagonal grid of the characters . and #, like this:
. . . . . . . .
. . . . # . . .
. # . . . # . .
. . . # . . . .
. . . . . # . .
. . . . . . . .
Your task is to fill the entire axis-aligned bounding box of the # with further #:
. . . . . . . .
. . # # # # . .
. # # # # # . .
. . # # # # # .... |
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game. If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.
Price refers to the how much people ar... |
Inspired by this CR question (please don't kill me for browsing CR)
Spec
The probabilities of misspelling a word are:
1/3 of the time don't change the output
1/3 of the time remove a random character
1/3 of the time duplicate a random character
The chance for removing/duplicating a given character in the input should... |
In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1.
For example, this (ungolfed) Python 3 program satisfies this behavior:
N = 1
print(N)
with open(__file__, 'r+') as f:
... |
You will be given a list of radii, you must output the area of the smallest rectangle which they will all fit in.
For example, given the list [5,3,1.5] you would output 157.460.
This is the image:
The width is 15.7460 and the height is 10, so the area is 157.460
Rules:
You get the list via stdin or function argument,... |
Write a program or function that takes in a positive integer. You can assume the input is valid and may take it as a string. If the number is any of
123
234
345
456
567
678
789
then output a truthy value. Otherwise, output a falsy value. For example, the inputs
1
2
3
12
122
124
132
321
457
777
890
900
1011
1230
1234
... |
Background:
In finance, the binomial options pricing model (BOPM) is the simplest technique used for option pricing. The mathematics behind the model is relatively easy to understand and (at least in their basic form) it is not difficult to implement. This model was first proposed by Cox, Ross, and Rubinstein in 1979. ... |
Challenge
You must write an encoder (and a separate decoder) which takes a string as input and outputs the string encoded in the style of a strand of DNA.
DNA
DNA is made up of four types of nucleotide:
Adenine (A)
Thymine (T)
Cytosine (C)
Guanine (G)
Adenine and thymine pair up together to make AT or TA. Similarly, ... |
Challenge
Write a program that takes an array of 4 integers (which represents a sequence of numbers generated by a certain algorithm) and returns the next integer that would follow.
We will only be using simple addition, subtraction, multiplication and division algorithms with a constant (i.e non-variable) variation.... |
Challenge description
We've had a few challenges involving the Look-and-say sequence. Quick reminder:
The sequence starts with 1,
Subsequent terms of this sequence are generated by enumerating each group of repeating digits in the previous term,
So the first few terms are:
1 "one"
11 "one one" (we look a... |
It is time to embark on a perilous quest to defeat the British Intelligence. The aim of this challenge is to write the shortest code that will solve a Nonogram.
What is a Nonogram?
The rules are simple.
You have a grid of squares, which must be either filled in black or left blank. Beside each row of the grid are... |
Introduction
A quixel is a quantum pixel. Similar to a classical pixel, it is represented with 3 integer values (Red, Green, Blue). However, quixels are in a super position of these 3 states instead of a combination. This super position only lasts until the quixel is observed at which point it collapses to one of three... |
All credits to Adnan for coming up with this challenge.
My last challenge, before I go on break.
Task
Given positive integer n, if n is odd, repeat / that many times; if n is even, repeat \ that many times.
(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)
Specs
Any... |
Write a program or function that, when given n, will print a spiral n characters long made up of the Latin alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ repeated as needed. This spiral should run through the alphabet only forwards.
Related to Alphabet Spiral, though the spiral runs through the alphabet forwards and backwards, an... |
Given an input string, output that string with all vowels a, e, i, o and u swapped at random between each other.
For example, in the string this is a test, there are 4 vowels: [i, i, a, e]. A valid shuffling of those vowels could be [a, i, e, i] therefore yielding the output thas is e tist.
About shuffling
All shuffles... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.