instruction stringlengths 34 53.1k |
|---|
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.
Input
The input will always be a string that is a transformat... |
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substring... |
About the Series
This is a guest entry for the Random Golf of the Day series.
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information abo... |
There's quite a lot of work that's been done in the world of chess. For example, there is a standardized file format, .pgn, that describes a chess game, including the list of moves. Additionally, there's another file format .fen, that describes a board position. The challenge today is to convert a list of chess move... |
Last week, we worked to create the shortest 1-D string using the top 10,000 words in the English language. Now, lets try the same challenge in 2D!
What you need to do is to take all of the above words, and put them in a rectangle as small as possible, allowing for overlaps. For example, if your words were ["ape","pen... |
This is the first part of a three part challenge. The next parts will be released on August 13 and 14.
This challenge series was inspired by another challenge series. You can view the original one at Random Golf of the Day #1: Shuffle an Array.
Instructions
Your goal in this code golf is to reverse a URL, but not full... |
Introduction
Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge.
OOOO
O O
O O
O O
OOOO
The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASC... |
Today we'll look at a sequence \$a\$, related to the Collatz function \$f\$:
$$f = \begin{cases}
n/2 & \text{if } n \equiv 0 \text{ (mod }2) \\
3n+1 & \text{if } n \equiv 1 \text{ (mod }2) \\
\end{cases}$$
We call a sequence of the form \$z, f(z), f(f(z)), …\$ a Collatz sequence.
The first number in our sequence, \$a(... |
You are to write a program or function that outputs this exact text:
OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB
May also be lowercase and trailing spaces and newlines are allowed.
Standard loopholes are disallowed
This is code-golf, so smallest byte count wins.
|
Integers are tedious to represent in Brain-Flak. There are 8 operators:
() Evaluates to 1, but does not push anything on any stack
[] Evaluates to an indeterminate value for the purposes of this question
{} Removes the top of the stack and evaluates to it
<> Switches to or back from the alternate st... |
The Challenge
Your challenge is to write a program that evaluates the following function:
f(x, t) = d^x / dt^x (sin t)
That is, the x-th derivative of sin t. In case you aren't familiar with calculus, here is a table of derivatives for the sine function:
...
f(-1, t) = -cos t
f(0, t) = sin t
f(1, t) = cos t
f(2, t)= -s... |
Write a program or function that takes in a nonempty single-line string. The string will either be zero or more spaces followed by one period (a particle), such as . or ., or the string will be a sequence of one or more alternating forward and back slashes (a wave) that could start with either one, such as \ o... |
Your task is to, given an image, compress it to 100000 bytes or less, while following all of the below rules:
No cheating/loopholes.
Your code must not be optimized to work best only on the test set of images, but rather produce a good output in general.
Colours that do not exist in the original input image must also ... |
Introduction
As some of you may know, URLs actually have a list of characters that do special things. For example, the / character separates parts of the URL, and the ?, &, and = characters are used to pass query parameters to the server. In fact, there is a bunch of characters with special functions: $&+,/:;=?@. When ... |
Executive summary: test whether an input sequence of integers is "admissible", meaning that it doesn't cover all residue classes for any modulus.
What is an "admissible" sequence?
Given an integer m ≥ 2, the residue classes modulo m are just the m possible arithmetic progressions of common difference m. For example, wh... |
The challenge: Write a script to print the alphabet, but you can't use any ASCII strings in your program. Unicode escape characters are allowed (if thats what you call them).
External libraries are allowed, as long as a link to the documentation is provided, and an online example if possible.
As this is code-golf, the ... |
In this challenge we'll compute an infinite minimal admissible sequence.
The sequence for this challenge starts with a(1) = 1.
We continue this sequence by finding a(n) as the smallest possible number such that a(n) > a(n-1) and for every prime p, the set {a(i) mod p : 1 ≤ i ≤ n} has at most p-1 elements.
Write a progr... |
Challenge description
A Langford string of order N is defined as follows:
The length of the string is equal to 2*N,
The string contains first N letters of the English alphabet, each letter appearing twice,
For each pair of the same letters, there are M letters between them, where M is that letter's position in the alp... |
Definition
Two integers are coprime if they share no positive common divisors other than 1.
a(1) = 1
a(2) = 2
a(n) is the smallest positive integer which is coprime to the a(n-1) and a(n-2) and has not yet appeared, for integer n >= 3.
Task
Given positive integer n, output/print a(n).
Example
a(11) = 6 because 6 i... |
Introduction
Sharp edges are, frankly, just plain dangerous so, given a PNG as input, blur the image using the method described below and blunt those damned sharp edges.
Method
To get the RGB value of each pixel, use the following three equations:
$$R = \sqrt{\frac{1.5\times\sum^n_{a=1}R^2_a}{n}}$$
$$G = \sqrt{\frac{1.... |
A ballot number, which we'll label B, is the number of ways of arranging the numbers from 1 through B(B+1)/2 into a triangle, such that each row and column is in any increasing order. The first four ballot numbers are:
a(0) = 1
a(1) = 1
a(2) = 1
a(3) = 2
a(3) is 2, which means that there are 2 ways of arranging the nu... |
For this challenge, when given a list of (x,y) points your submission needs to output a polynomial function that goes through all of them.
For example, if your points were [(0,0), (2,5)], you could return y = 2.5*x or y = x + 1/4x^2.
All points passed in will consist only of integers
Two points will never have the sam... |
Disclaimer: Levenshtein coding is completely unrelated to the Levenshtein edit distance metric.
<Insert long story about why Levenshtein codes need to be calculated here.>
The code
Levenshtein coding is a system of assigning binary codes to nonnegative integers that retains some weird property in probability which isn'... |
In arithmetic, an n-smooth number, where n is a given prime number, is mathematically defined as a positive integer that has no prime factors greater than n. For example, 42 is 7-smooth because all its prime factors are less than or equal to 7, but 44 is not 7-smooth because it also has 11 as a prime factor.
Define a p... |
Consider a grammar over the alphabet {0, 1, ?, :} defined by the production rule
s → 0 ┃ 1 ┃ 0 ? s : s ┃ 1 ? s : s
Given a string generated from s, parse it as an expression where ?: is right-associative (for example, a?B?X:Y:c?d:e?f:g means a?(B?X:Y):(c?d:(e?f:g))) and evaluate it with the following semantics:
eval(... |
A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't allowed). Both of these sequences are finite (There are only 83 Right-truncatables, while there are 4260 Left-truncatables)... |
As a programmer or computer scientist one might encounter quite a lot of trees - of course not the woody growing-in-the-wrong-direction kind, but the nice, pure mathematical kind:
*<- root (also a node)
/|\<- edge
* * *<- inner node
| / \
* * *<- leaf (also a node)
|
*
Naturally over time we all have put tog... |
Challenge
Using data from the API here, output the names of the three countries with the most Olympic gold medals at the 2016 Rio Olympic Games (i.e. the first element of the returned list).
For example, at the time of posting (18:23 UTC+1, Monday, 15th August), the USA, the UK and China have the most gold medals, so t... |
What is the shortest way to see if an input is a wordinian using any programming language?
A wordinian is a word that contains words of length 1 to the original word's length. For example,
bin
'I' is a word
'in' is a word
'bin' is a word
Or,
stage
'a' is a word
'ta' is a word (yes it is)
'age' is a word
's... |
OEIS: A167171
A dense number is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two distinct primes. The first 100 dense numbers are:
2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 31, 33, 34,... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.