instruction stringlengths 34 53.1k |
|---|
Yup, you read the title right. play the sound of pi.
More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file.
Basically, each digit turns to a note on the C Major scale (basically the normal scale). so 1 turns to Middle C, 2 turns to D4, 3 turns to ... |
Count the number of contiguous blocks within a given 3D input.
Input
The input will consist of one or more rectangles of characters separated by blank lines. Each rectangle represents a cross section of the 3D space. The characters used will be 0, representing empty space, and 1 representing a solid block.
Example
0000... |
Inspired by this default for IO.
The Task
Write a program that, given an input integer x between 0 and 255, crashes with exit code x.
Restrictions
You may not call anything which is intended directly for exit code output (System.exit(x), returning from main, etc.). Instead, your program must cause an error or crash wh... |
Challenge
Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result.
The required shuffling can be described using the following algorithm:
Label each character in the input with a 1 based index.
Write character number 1 as o... |
The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It contains nearly 280000 sequences of mathematical interest.
Examples of sequences:
positive integers (A000027)
prime numbers (A000040)
Fibonacci numbers (A000045)
Your task is to write a program or function that displ... |
Often I need a simple Hello World! program to show some basic concepts of a programming language on my travels. As I usually travel only with light luggage I can't to carry a Hello World! program for each language. So a program that generates Hello World! programs in as many languages as possible would be a great help.... |
EDIT
It appears that there has been some confusion following my typo in the original post which used a lowercase o to define the plane and then an uppercase later. Unfortunately this bug did not get picked up in the Sandbox. Since many members have written answers with both and since the typo was my fault I will allow ... |
Given a directed graph, output the longest cycle.
Rules
Any reasonable input format is allowed (e.g. list of edges, connectivity matrix).
The labels are not important, so you may impose any restrictions on the labels that you need and/or desire, so long as they do not contain additional information not given in the in... |
Task:
Your challenge is, given previous submissions and itself as input, output the language that they're written in, in the following format:
Say the first program is in Ruby. It must output 1, because Ruby is the 1st language used in this challenge. An example program is:
a=gets
puts 1
When given itself as input, it... |
Challenge description
On some channels on a popular streaming site twitch.tv a common message people tend to spam in chats to bait people into spamming "LUL" is
One more LUL and I'm out
LUL is a popular emote used to express that something funny happened on stream.
Soon dank memes showed their potential and a parody o... |
You should write a program or function which receives no input and outputs a stream of digits.
The stream should contain at least once every positive integer number which does not contain the digit sequence 42. E.g. The string 1231 contains the integers 1 12 123 1231 2 23 231 3 31 (and 1 again)
The stream should not c... |
Disarium Dilemma
A Disarium is defined as a number whose:
sum of its digits powered with their respective position is equal to the original number
Your Task:
You have a strange obsession with numbers classified as being a disarium. The need to follow the ways of disarium is so great in you that you refuse to read a... |
Task
There is a set of numbers x, such that x^2 divides 7^x-1.
Your task is to find these numbers. Given an input of n, the code will print the nth number that follows this rule.
Examples 1-index
In Out
3 3
9 24
31 1140
The relevant sequence can be found here.
Rules
Shortest answer will be the winner*
Standa... |
Sandbox post here.
Create a function or program that "Springifies" a string.
Input will be a String in Stdin, or closest alternative
Input will only contain printable ASCII and/or spaces
Output will be to Stdout, or closest alternative
A trailing newlines and spaces are acceptable
How to springify a String
Format th... |
Question :
You will be given the starting and ending integers of a sequence and should return the number of integers within it which do not contain the digit 5. The start and end numbers should be included!
Examples:
1,9 → 1,2,3,4,6,7,8,9 → Result 8
4,17 → 4,6,7,8,9,10,11,12,13,14,16,17 → Result 12
50,60 → 60 → Result... |
Background
Incident is a fairly unusual programming language, in that its list of tokens is not predetermined, but rather inferred from the input. As such, tokenising an Incident program can be fairly difficult, especially if you want to do so efficiently. This task is about doing that yourself.
The task
Your program w... |
Challenge Description
You have to show a simulation of rain in terminal.
In the example given below its adding 100 raindrops at random (use the default random function which your language offers) coordinates, waiting for 0.2 seconds and then redrawing again until the given time expires. Any character can be used for r... |
Given a non-negative integer \$n ,\$ output the \$n^{\text{th}}\$ Euler number (OEIS A122045).
All odd-indexed Euler numbers are \$0 .\$ The even-indexed Euler numbers can be computed with the following formula (\$i \equiv \sqrt{-1}\$ refers to the imaginary unit):
$$
E_{2n}
= i
\sum_{k=1}^{2n+1}{
\sum_{j=0}^{k}{
... |
There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table.
Challenge
Your task is to write a program or function which takes no input, and outputs this exact text:
!
"#
$%
... |
Backstory
Disclaimer: May contain made up information about kangaroos.
Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry.
In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is... |
Brun's constant is the value to which the sum of the reciprocals of twin prime pairs (1/p and 1/(p+2) where p and p+2 are both prime) converges. It is approximately 1.902160583104.
Given a positive integer N, approximate Brun's constant by summing the reciprocals of the twin prime pairs where both primes in the pair ar... |
Now, we all know most languages have very simple ways to "self-modify" code.
However, what if you were to actually modify the code and edit parts of it...on disk?
Your goal is to make code that prints a number, then edits its own file to replace the number with the next one in the Fibonacci sequence like so:
$ ./progr... |
Write a program that terminates without an error.
If any single byte is substituted by any other byte the program should output
CORRUPTED
Do not read your source code from a file
Your program should not produce any other output
This is code-golf so the shortest answer in bytes wins.
Edit: removed "NOT CORRUPTED" req... |
(Challenge taken from a multiplayer game (clash of code) at codingame.com)
The challenge
Find the n-th term of the following sequence: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4... or, to make it more obvious, {1}, {1,2}, {1,2,3}, {1,2,3,4}...
The sequence is made up from concatenated ranges from 1 to x, starting from 1, all the way... |
Write a program or function that takes two inputs:
A text message
The dictionary of English language, as it appears in this Github file (containing about 60000 words)
and outputs the number of spelling errors in the message (see below for definition and test cases).
You can receive the dictionary as a parameter to yo... |
Your task is to create a program that will display the following text, wait for the user to press a key (it is okay to ignore keys like ctrl, alt, caps lock, etc., as long as keys like letters, numbers, symbols, and enter are not ignored), and then terminate the program:
Press any key to continue...
Trailing newlines... |
Everybody has heard of the phrase "be there or be square". So I thought it was time for a challenge about it.
Input
You will take a full absolute directory address as text as input via STDIN or equivalent.
Output
If the directory address exists and is valid, your program will move itself to that folder on your computer... |
Related
Goats are great. Everybody loves goats.
And they also, for some reason, are an excellent complex ascii art for many languages to have built-ins for. Because of this, I personally feel a catalogue to document just how easily a language can print goats is greatly needed.
The Challenge
Given an integer input via a... |
Introduction
There is a small village with nothing but a few houses and empty fields.
The local bureaucrats want to divide the village into lots so that each lot contains exactly one house, and the borders of the lots form a nice straight-line grid.
Your task is to determine whether this is possible.
The task
Your inpu... |
Challenge Summary
In summary, the challenge is to provide the glider synthesis for a Game of Life configuration, which is your input.
What does this mean?
Well, firstly, let me explain a few terms.
By Game of Life, I mean Conway's Game of Life. If you don't know what this is, you can read the Wikipedia article at htt... |
Introduction
There is a tax collector that has some trouble managing the taxes of his kingdom: the historical records have burnt down in a great fire.
He wants to find out how many possible pasts there could be in terms of where the current money was inherited from. Luckily, his kingdom is very simple.
The kingdom can ... |
The problem: Write a function which, given a cycle length n and a number of cycles m, where 'm' is within [2, n-2], generates m random cycles, each of length n, and all of which are derangements of each other. Then n=7, for example, m could be 2, 3, 4, or 5. All possible sets of m cycles of length n that fit the criter... |
Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1.
Here's the catch: your program itself has to sum to a prime number. Convert every character (including spaces) to its Unicode/... |
This is a Hello World challenge! Those plain ones! Yeah....
However, it's different this time.
Because here, you can't use C or C++ or Stuck or ArnoldC or whatever you want. You can only choose raw x86 opcodes from this list, or any other x86 opcode lists.
It is also assuming you have no Protected Mode or any other thi... |
Challenge:
In the programming language of your choice, shut down the machine that your code was executed on.
Rules
No shutting down by resource exhaustion (e.g.: forkbomb to force shutdown)
You are allowed to write code that only works in a specific environment/OS, if you wish.
Standard loopholes are forbidden
This ... |
Guide the Alphabet
Given an array of directions, where the directions are defined as follows:
NW N NE
W . E
SW S SE
Or as indexes (you may use these indices for directions instead of the strings above):
0 1 2
3 . 4
5 6 7
You may choose either format, supporting both is not required by the challenge. Generate ... |
Task
You will be given a positive integer and you must output a "self-complementary graph" with that many nodes. If you don't know what a self-complementary graph is the wikipedia article wont help you much so below are two explanations, a technical and a non-technical one.
Non-Technical
A graph is a set of nodes that... |
As George Orwell wrote in 1984:
War is peaceFreedom is slaveryIgnorance is strength
Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart.
Specifically:
[input] -> [output]
war -> peace
peace -> war
freedom -> slavery
slavery -> freedom
ignorance -> stre... |
Challenge:
Write a code that, when executed will output the source code of a second program that can be executed in another language. The second program should output the source code of a third program that can be executed in a third language and so on. The last program should output PPCG with an optional single traili... |
Challenge:
In the programming language of your choice, take no input and output your programming language's name.
Fair enough, right?
Restrictions:
You can't use any character that is included in your programming language's name in your code. E.g., if I use Batch, I must not use the chars 'B' 'a' t' 'c' 'h' in my code... |
What is a home prime?
For an example, take HP(4). First, find the prime factors. The prime factors of 4 (in numerical order from least to greatest, always) are 2, 2. Take those factors as a literal number. 2, 2 becomes 22. This process of factoring continues until you reach a prime number.
number prime factors
4 ... |
Golomb rulers are sets of non-negative integers such that no two pairs of integers in the set are the same distance apart.
For example, [0, 1, 4, 6] is a Golomb ruler because all distances between two integers in this set are unique:
0, 1 -> distance 1
0, 4 -> distance 4
0, 6 -> distance 6
1, 4 -> distance 3
1, 6 -> di... |
Introduction
Long story short: a few days ago I accidentally started knitting a sock and the pretty logical structure of the plain stitches lead me to the idea: Why don't we just ASCII-knit a sock?
Input
The input is an even integer N in the range [2,30].
Output
The output is a sock, obviously.
Structure
Because we wil... |
One of the lesser known programming paradigms which seems rather fitting for code golfing is Overlapping Oriented Programming (OOP) *. When writing partly identical code, many bytes can be saved by simply overlapping the identical parts and remembering in some way where the two original code lines start. Your task is t... |
Introduction
Some of you may have heard of Hilbert's Grand Hotel. The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a room number less than their value and if a guest is added to a lower room, all guests in hig... |
Write a program that produces an output such that:
At least three distinct characters appear.
The number of occurrences of each character is a multiple of 3.
For example, A TEA AT TEE is a valid output since each of the 4 distinct characters, A, E, T and (space), occurs 3 times.
Of course, a challenge about the numbe... |
Create a program or function to unjumble a 9x9x9 cube of digits by rotating individual 3x3 cubes within it.
This is similar to (but, I suspect, a bit harder than) my Flippin' Squares question.
Input
Input will be a 9x9x9 cube. I'm not going to be as strict over the input as I was last time, 3d arrays are allowed, array... |
Write the shortest possible code which converts tabs to spaces in the input. Tab size should be supplied as a parameter or be hardcoded in the code in a single place.
Spaces on output should point to the right column, e.g. (\t represents a tab character):
a\tb
aa\tb
aaa\tb
aaaa\tb
should become (for tab size 4):
a b... |
Your very own "for" instruction
Assuming you have the following input : a, b, c, d
Input can be in one-line using any format "a/b/c/d" or "a,b,c,d" etc..
You can also have 4 inputs.
You must code the following behaviour (pseudo-code here) :
var i = <a>
while (i <b> <c>)
print i
i = i + <d>
print "\n"
Here ... |
A boring version of yourself
Have you ever dreamed of a boring version of you which types the text you just typed ?
No ? Because that's exactly what I'm challenging you to do !
The program needs to check how many time it took for the user to input a text at program launch and then retype the text again using the same p... |
Brachylog is a language that's beginning to rise in prominence in code-golfing recently (and just received a major update with a terser syntax). Like Prolog, it has the advantage that it can often solve a problem (typically via brute force) merely from a sufficiently accurate description of what a problem looks like, a... |
tinylisp is, in its essence, a very stripped-down version of Lisp, as the name suggests. It was made by @DLosc for an "interpret this language" challenge, which can be found here. It features a small amount of builtins, which can be used to create practically anything.
There is a repository for the "official" tinylisp ... |
Inspired by Sygmei's question, I'm interested in finding out what languages can "do this properly".
Your task is to write a "for loop" function / macro / instruction. The arguments should be:
an initializer
a test
an increment
a body
All of these are "pieces of code" and should be able to access variables in the con... |
Your task is simple: write a program (or function) that takes no input and outputs (or returns) its source code. The catch is that when the program is wrapped in "quotes" (Unicode character 34), it should again output its (now quoted) source code.
Standard rules for quines apply. This is code-golf, so the shortest prog... |
The beautiful pattern drawer
Good morning PPCG !
The other day, when I was trying to help someone on Stack Overflow, a part of his problem gave me an idea for this challenge.
First of all, check the following shape :
Where all black numbers are the index of the points in the shape and all dark-blue numbers are the ind... |
Preface
In the well known carol, The Twelve Days of Christmas, the narrator is presented with several gifts each day. The song is cumulative - in each verse, a new gift is added, with a quantity one higher than the gift before it. One Partridge, Two Turtle Doves, Three French Hens, and so on.
At any given verse, N, we ... |
The Pi function is an extension of the factorial over the reals (or even complex numbers). For integers n, Π(n) = n!, but to get a definition over the reals we define it using an integral:
In this challenge we will invert the Π function.
Given a real number z ≥ 1, find positive x such that Π(x) = z. Your answer must b... |
Goal:
Create a program to find the smallest file in the current folder.
File size may be measured in bytes or characters.
If multiple files have the same size, you can either choose one or display all of them.
You can assume there will be at least one file in the folder, and no files will have a size of 0.
Assume t... |
Your task is to create a program that performs a bubble sort on a given array until it is sorted.
Algorithm
In order to qualify as a bubble sort, the program must operate as follows:
Each pass goes through the array, looks at every two adjacent elements in turn, and potentially swaps them.
Each pass goes through the ... |
Implement a simple digital Stopwatch,
which will display the time elapsed in seconds and minutes, as described below.
Important
Please read both Display and Controls sections !
Display
Time elapsed, should be displayed in the MM:SS format,
by replacing the previously displayed time string "in-place"
(clearing the who... |
A haiku is a poem with three lines, with a 5/7/5 syllable count, respectively.
A haiku-w is poem with three lines, with a 5/7/5 word count, respectively.
Challenge
Write a program that will return true if the input is a haiku-w, and false if not.
A valid haiku-w input must consist of 3 lines, separated by a newline.
L... |
Intro:
You accidentally corrupted the flow of time with a device you made for fun, that turned out to be a time machine. As a result, you got pushed to the far future. You realized that computing, processing power, and computers in general have been evolved by a huge amount, an infinite amount to be precise. So you g... |
Mike Bufardeci (Pyth) - 175 bytes
Leo (Retina) - 175 bytes
devRicher (Lua) - 182 bytes
Peter Taylor (CJam) - Waiting for clarification
Lyth (C++11) - Waiting for clarification
Edit: Several changes made, should not affect any already submitted answers.
Edit #2: Very few people are taking advantage of the 1024 b... |
Sometimes lexicographical sorting of strings may cut it, but when browsing the filesystem, you really need better sorting criteria than just ASCII indices all the time.
For this challenge, given a list of strings representing filenames and folders in a directory, do a filesystem sort, explained below:
Split every stri... |
A bronze plaque in the pedestal of the Statue of Liberty displays the poem "The New Colossus" by Emma Lazarus, part of which reads:
Give me your tired, your poor,
Your huddled masses yearning to breathe free,
The wretched refuse of your teeming shore.
Send these, the homeless, tempest-tost to me,
I lift my lam... |
The Challenge
In this challenge, you are supposed to write a program or function that takes in a String, which will contain the simplified Markdown-like Markup, and outputs the corresponding HTML Markup.
The Input
You can take input in whatever way you wish to. The type of the input should be String.
The Output
You c... |
You are providing tech support to the Bruce Dickenson as he produces a Blue Öyster Cult recording session. When he asks for more cowbell, you can give it to him.
Your task
Write a program or function that takes a string (or equivalent in your language) as input, and outputs a related string containing one more cowbell.... |
Write a program or function that given an integer radius r returns the number of unit squares the circle with radius r centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares.
Here's an illustration for r = 5:
Illu... |
Many of you may have interacted with people from Russia on the internet at some point, and a subset of you may have noticed the slightly odd method they have of expressing themselves.
e.g. удали игру нуб)))
where the ))) are added for emphasis on the previous statement, I have been working on a theory that the ratio of... |
Given an input string S, return truthy if all the letters in S are Lexically Ordered: their ASCII values need to be in either ascending or descending order. Return falsy in other cases.
Input
Input will be in the same case (all upper- or all lowercase). Your submission should be able to handle both.
Input will consist... |
This is a fairly simple challenge. Given a lower-case word, you must "interpolate" between letters. Here's some examples to hopefully clarify this:
Input: test
Output: tsrqponmlkjihefghijklmnopqrst
Between letters you must add, in alphabetical order, the letters between those two letters. So if you have ad, you must ou... |
Goal:
Write a complete program or function which takes a formula in propositional logic (henceforth referred to as a logical expression or expression) and outputs that formula in conjunctive normal form. There are two constants, ⊤ and ⊥ representing true and false, a unary operator ¬ representing negation, and binary o... |
CodeGolf Challenge
PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe detects that you are from the year 2000. Because of this, and a few stereotypes, you are assumed stupid compared to today's ... |
Pyramid Scheme is a language being developed by @ConorO'Brien. In Pyramid Scheme, the code that you write looks like this:
^ ^
/ \ /3\
/ \ ---
/ + \
^-------^
/9\ /3\
/123\ ---
-----
Now, that code has two obvious qualities: It's difficult to parse, and it's difficult... |
A graphic sequence is a sequence of positive integers each denoting the number of edges for a node in a simple graph. For example the sequence 2 1 1 denotes a graph with 3 nodes one with 2 edges and 2 with one connection.
Not all sequences are graphic sequences. For example 2 1 is not a graphic sequence because there ... |
Definition
The Alternating Power Fibonacci Sequence is formed as follows.
Start with the empty sequence and set n to 1.
Compute fn, the nth non-negative Fibonacci number, with repetitions.
0 is the first, 1 is the second and the third, 2 is the fourth. All others are obtained by summing the two previous numbers in the... |
Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given 2 cards (your hand) and 0, 3, 4 or 5 cards (the dealt cards), you must decide what the best possible hand you can get will be. If a... |
Challenge:
Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below.
Note: Checking if the input is actually a positive non-zero integer is not necessary
Sequence:
Every number in this sequence (apart from the first, which is the input) shall be com... |
The Challenge
For this challenge, you are supposed to determine if a given number is in the Cantor set. So first, let's define the Cantor set.
First, start with the numbers between 0 and 1. Any numbers outside this range are not in the Cantor set. Now, let's divide the numbers into three equal parts: [0,1/3], [1/3,2/3]... |
Background
You work for the police force as a programmer.
A villain has planted a bomb in the city, luckily the police force has captured both him and the bomb. The bomb is really complicated to disarm, however it has a password input to disarm it.
The villain, being cocky, has told you that there was no way you'd find... |
An easy way to understand the unit n-dimensional hypercube is to consider the region of space in n dimensions that you can get if every coordinate component lies in [0, 1]. So for one dimension it's the line segment from 0 to 1, for two dimensions it's the square with corners (0, 0) and (1, 1), etc.
Write a program or ... |
We are all familiar with the Fibonacci sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
However, instead of, f(n) = f(n-1) + f(n-2) we'll be taking digital sum of the previous 2 entries.
The sequence should still start with 0, 1, after that the differences are rapid... |
This challenge is inspired by xkcd:
Challenge:
You'll simulate the copying a large file (1 Gigabyte). The transfer rate will vary between 10 kB/second to 100 MB/second.
Your task is to output the time remaining of the file transfer. The output should look like:
Time remaining: 03:12 (meaning it's 3 minutes and 12 s... |
At the opening scene of the Dark Knight rises, there is a rather awkward dialogue between a CIA agent and the villain Bane.
CIA agent: “If I pull that [mask] off, will you die?”
Bane: “It would be extremely painful…”
CIA agent: “You’re a big guy.”
Bane: “…for you.”
It’s unsure if Bane intends to say “painful for you”... |
OEIS has a variation (A111439) on Golomb's sequence. As in Golomb's sequence, A(n) describes how often n appears in the sequence. But in addition, no two consecutive numbers may be identical. While building up the sequence, A(n) is always chosen as the smallest positive integer that doesn't violate these two properties... |
One of the interesting aspects of gravity is that, as far as I'm aware, you can't just have stuff floating in midair.
However, it seems not everyone at the Association of Random Castle Builders is aware of this fact, leading to castles such as this one:
#
#
# # # #... |
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.
Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha... |
TAS Golf
In the style of a tool-assisted speedrun with a code-golf twist, the goal of this challenge is to complete World 1-1 of the original Super Mario Bros game for the NES in your chosen programming language in as few bytes as possible, using only the in-game controller inputs in the format I'll describe below. Yo... |
Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value).
Rules
Your program must take an array as input containing... |
Write a program that keeps track of the number of consecutive days it has been run.
The day resets at midnight (the local time of the computer on which the program is run).
If there is a day that the program is not run, the counter is reset to zero.
Every time the program is run, the counter should go up by one day ... |
A symmetric polynomial is a polynomial which is unchanged under permutation of its variables.
In other words, a polynomial f(x,y) is symmetric if and only if f(x,y) = f(y,x); a polynomial g(x,y,z) is symmetric iff g(x,y,z) = g(x,z,y) = g(y,x,z) = etc.
For example, x^2+2xy+y^2, xy and x^3+x^2y+xy^2+y^3 are symmetric pol... |
You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value.
Rules and clarifications:
The integers will be non-negative
Optional input and output format
The output must be accurate up to at least 2 decimal poins (if it's non-integ... |
Goal
This is a simple challenge. Your goal is to unscramble a string by swapping each letter with the next letter of the same case, while leaving non-letter characters unchanged.
Step by step explanation
The first character is a E. We look for the next letter in upper case: it's a C. We swap these characters, which l... |
Scrolling through social media, one might encounter something like this:
We can see that, following PEMDAS order of operations, the answer is clearly 11 9.
For the sake of this challenge, PEMDAS means that multiplication will occur before division, so a/b*c = a/(b*c), not (a/b)*c. The same goes for addition and subtr... |
Simple Mancala Game
Create a mancala game using as few bytes as possible.
The game
Mancala is a family of games where a player has a control over a set amount of pots filled with stones/seeds. The particular version which you should implement has a board with 14 pots, of which two are designated as scoring pots. At the... |
Write a program that creates a two-state checkbox that people can interact with using a mouse.
Specifically, your program should achieve all of the following:
Have a 8×8 pixel (or larger if desired) region of the screen that is the clickable area of the checkbox. Henceforth this region is simply called the checkbox.
... |
Your task is to write a program or function which:
When run for the first time, outputs its source code.
On subsequent executions, it should output what it output previously, but with one random character change (defined below). It does not have to be a uniformly random change, but every possible change should have a ... |
Create a function (preferably) or a program that takes an ordered collection and outputs the smallest possible palindrome that starts with the input.
For example:
>>> completePalindrome( [1, 2, 3] )
[1, 2, 3, 2, 1]
>>> completePalindrome( [1, 2, 3, 4, 5, 4, 3, 2] )
[1, 2, 3, 4, 5, 4, 3, 2, 1]
>>> completePalindrome( ... |
In mathematics an exclamation mark ! often means factorial and it comes after the argument.
In programming an exclamation mark ! often means negation and it comes before the argument.
For this challenge we'll only apply these operations to zero and one.
Factorial
0! = 1
1! = 1
Negation
!0 = 1
!1 = 0
Take a string of ... |
You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value.
Rules and clarifications:
The integers will be non-negative
Optional input and output format
The output must be accurate up to at least 2 decimal poins (if it's non-integ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.