instruction stringlengths 34 53.1k |
|---|
Objective
Given an integer \$n\$ interpreted as two's complement binary, output two integers, namely the integer consisting of \$n\$'s bits at places of \$2^0, 2^2, 2^4, \cdots\$, and the integer consisting of \$n\$'s bits at places of \$2^1, 2^3, 2^5, \cdots\$.
Note that the input may be negative. Since \$n\$ is inter... |
The game is played on a 1x8 board with the following setup:
KNR..rnk
White's pieces are on the left, while black's pieces are on the right.
The king (K) can move 1 space in any direction.
The knight (N) can jump 2 spaces in any direction, regardless of bordering pieces.
The rook (R) can move any number of spaces in an... |
For the purpose of this challenge, arguments are things you pass to a function at the call site, while parameters are what the function uses in its implementation. Or, more succinctly: arguments = external, parameters = internal.
While there are several modern languages that have support for argument labels for func... |
Given a non-empty string containing only printable ASCII (codepoints 0x20 to 0x7E), write the shortest program or function that map the key to its value. Inside the string the key will always have a value and vice-versa.
How the key is made:
Start with an opening parenthesis (
Contains letters and/or numbers [a-zA-Z0-... |
The Rockstar programming language has "poetic number literals", allowing you to assign nonnegative, finite (at least one Rockstar interpreter supports infinity) numbers to variables without typing a single digit: just type words with length equal to each digit, modulo 10. For example,
This is a challenge
sets the vari... |
Rectangle covers
Suppose you have a matrix of bits, for example the following.
1 1 0 0 0 1 1 0
1 1 1 1 0 1 1 1
0 1 1 1 0 1 1 1
1 1 0 1 1 1 1 0
1 1 0 1 1 1 0 1
We would like to find a rectangle cover for this matrix.
It is a set of rectangular subsets of the matrix that don't contain any 0s, but together contain all th... |
Given a positive integer input N, output the two non-negative numbers, a and b, where a < b, with the lowest possible mean value that will result in the number N being part of the recurring relation sequence:
f(0) = a
f(1) = b
f(n) = f(n-2)+f(n-1)
In case there are more than one solution where the mean of a and b are ... |
In this challenge, your task is to take an anion and a cation, and output the chemical formula of the compound.
Input rules
Take in 2 strings (in any order) representing the anion and cation, e.g. F, NH_4, or Al.
To take in the charge of each ion, you can either have it as part of the string separated by a caret (e.g... |
Given an n-dimensional array filled with numbers, output which p-dimensional array has the largest sum.
Input
An n-dimensional array of numbers, or your language's equivalent. You can assume this is a rectangular array, or not.
n, the number of dimensions in the array. (doesn't need to be called n)
p, the number of di... |
Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data.
Example
Given the number 7831, we first convert it to binary (removing any leading zeroes):
1111010010111
We then find the consecutive group of 8 bits which, when removed,... |
Alternate Title: Tally Your Prison Sentence on the Wall
Given a number n, output tallies grouped into the traditional 5-per-group and 50 per row.
Examples
1
|
|
|
|
4
||||
||||
||||
||||
5
|||/
||/|
|/||
/|||
6
|||/ |
||/| |
|/|| |
/||| |
50
|||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/ |||/
||/| ||/| ||/| ||/| ||/... |
Background
The Thousand Character Classic is a chinese poem written around the 4th Century CE in China, and memorized by large populations since then. The name comes from not only its length, but its number of characters: each character occurs only once in the text. It is commonly used to teach children chinese charact... |
Given a list of unique strings that are anagrams of each other, output an anagram of those words that is different from each word in the list.
The strings will be alphanumeric, and there is guaranteed to be a valid anagram.
The program or function can, but doesn't have to be non-deterministic, meaning given the same in... |
Introduction
Every rational number between 0 and 1 can be represented as an eventually periodic sequence of bits.
For example, the binary representation of 11/40 is
0.010 0011 0011 0011 ...
where the 0011 part repeats indefinitely.
One way of finding this representation is the following.
Start with r = 11/40, then rep... |
Given a string, return whether the string is a substring of the program's source code.
Standard quine rules apply, meaning you cannot read your own source code. The length of the input is guaranteed to be less than or equal to the length of the program. You may return any two distinct values, not necessarily truthy and... |
Bobby's booby-trapped safe requires an n-digit code to unlock it. Alex has a probe which can test combinations without typing them onto the safe. The probe responds Fail if no individual digit is the same as that in its corresponding position in Bobby's code. Otherwise it responds Close, including when all digits are c... |
Input
The input is a single positive integer n
Output
The output isn with its most significant bit set to 0.
Test Cases
1 -> 0
2 -> 0
10 -> 2
16 -> 0
100 -> 36
267 -> 11
350 -> 94
500 -> 244
For example: 350 in binary is 101011110. Setting its most significant bit (i.e. the leftmost 1 bit) to 0 turns it into 001011110... |
Minecraft inventory management is hard. You have 17 diamonds, but you need 7 to craft an enchantment table, a pickaxe, and a sword. Do you pick them up and right click 7 times? Or do you right click once and right click twice and take the 7 left? It's so confusing!
for those of you who are now confused, don't worry, I'... |
Task
Given a letter (A, B, C), and a number (0-10), output the size of the matching standard paper size (Series A and B) or the matching standard envelope size (C series) in millimetres in the format aaaa x bbbb where aaaa and bbbb are the width and height measurements in millimetres as per ISO216 (Series A & B) or ISO... |
Mathematical Background
Let A be an N by N matrix of real numbers, b a vector of N real numbers and x a vector N unknown real numbers. A matrix equation is Ax = b.
Jacobi's method is as follows: decompose A = D + R, where D is the matrix of diagonals, and R is the remaining entries.
if you make an initial guess solutio... |
An EAN-8 barcode includes 7 digits of information and an 8th checksum digit.
The checksum is calculated by multiplying the digits by 3 and 1 alternately, adding the results, and subtracting from the next multiple of 10.
For example, given the digits 2103498:
Digit: 2 1 0 3 4 9 8
Multiplier: 3 1 ... |
BCD difference
Given an integer n, convert it to BCD (binary-coded decimal) by replacing each decimal digit with its 4-digit binary representation
234 -> 0 0 1 0 0 0 1 1 0 1 0 0
Then rotate the list of binary digits in order to find the largest and smallest numbers, representable by this list without other rearrange... |
It is well known that a person on a grid under the influence of alcohol has an equal chance of going in any available directions. However, this common-sense statement does not hold in the realm of very small drunkards, whose behavior is very much as if they take every available path at once, and the possible paths they... |
Background
In C, there is a function to help parse command-line arguments: getopt.
Getopt takes the argument count (argc), the argument list (argv), and a string representing the options the program should take (optstring).
The option string (optstring) is a series of option characters each followed by one colon (for a... |
Write a program that reviews posts for the Close Votes queue on Stack Overflow.
Since it's near-impossible to write a bot that can accurately review posts in the actual queue, we're instead going to use a grossly oversimplified version of the queue and its rules.
Your program should take in the body of a question as a ... |
Goal
Morse code is often represented as sound. Given a stream of bits that represent whether sound is on or off, translate the stream into letters and numbers and spaces.
Specifics
The bit stream is analysed based on the length of repeating ON/OFF bits.
1 ON bit is a dot
3 ON bits are a dash
1 OFF bit delimits dot... |
Task
Take input string separated by space.
Sort the words alphabetically.
Print them out vertically in 3 columns separated by space(s).
Challenge
All three column's heights should be as evenly weighted as possible.
All three column's should be left aligned.
This is code-golf, so shortest code wins!
Example
If the i... |
There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be:
# Level one header
## Level two header
### Level three header
Note the space after the hash marks. Also, note that trailing hash marks are not included.
Challenge:
Take a (possib... |
A bipartite graph is a graph whose vertices can be divided into two disjoint set, such that no edge connects two vertices in the same set. A graph is bipartite if and only if it is 2-colorable.
Challenge
Your task is to, given the adjacency matrix of an undirected simple graph, determine whether it is a bipartite grap... |
Make me an icecream cone please
We have a ton of great ice cream places here in New England. Most of them are closed for the winter now, so...
.-@@-.
(======)
(--------)
(==========)
(__________)
\/\/\/\/\/
\/\/\/\/
\/\/\/
\/\/
\/
GOAL
Output the above icecream cone exactly. (or return it from ... |
A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and 233494.0 are whole, while 1.1 and 0.001 and 233494.999 are not.
Input
A floating-point number in the default base/encoding of your language.
For example, the default integer representation for Binary Lambda Calculus would be Churc... |
According to TIO there are two types of programming languages:
Practical (seen in many corporate environments as a development standard).
Recreational (if seen in a corporate environment, you're probably fired).
Your Task
Mix together one language from each of these realms to achieve the simple goal of calculating th... |
Task:
Given an integer number in decimal number system, reduce it to a single decimal digit as follows:
Convert the number to a list of decimal digits.
Find the largest digit, D
Remove D from the list. If there is more than one occurrence of D, choose the first from the left (at the most significant position), all oth... |
Introduction
I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it provides regex enthusiasts with a bit of fun golfing time.
Challenge
The challenge is to match what I've very loosely dubbed a... |
Consider a triangle where the Nth row (1-indexed) is the array of the first N positive integer powers of N. Here are the first few rows:
N | Triangle
1 | 1
2 | 2 4
3 | 3 9 27
4 | 4 16 64 256
5 | 5 25 125 625 3125
...
Now if we concatenate those powers into a single sequence, we get OEIS A075363:
1, 2, 4, 3, 9, 27, 4... |
Alternate name: ChessMoveQ
Given a list of up to 32 elements, each consisting of 4 elements, and a second list with 4 elements, determine whether the move detailed in the second input is a valid chess move.
The first list indicates the position of all 32 pieces on the board. Each element will follow the structure <colo... |
Task
Given a representation of a line, output the number of quadrants that that line passes through.
Valid Representations of a Line
You can represent a line as
Three signed integers A, B, and C which share no common factor and where A and B are not both zero, representing the line Ax + By = C,
Four signed integers X1... |
A deck of cards is the Cartesian product of S suits and R ranks.
Many, though not all, card games use S=4 and R∊{6,8,13}.
A hand of H cards is dealt from the deck.
Its distribution, a.k.a. "hand pattern", is an array that describes
how many cards you got from each suit, ignoring suit order (so, it's like a multi-set).
... |
An ordinary N-digit combination lock consists of N rotating discs. Each disc has digits 0-9 inscribed in order, and you need to turn them to the correct password to open it. Obviously, if you don't know the password, you will need to try at most 10N times before unlocking it. That's not interesting.
So let's consider ... |
Introduction
Kerning means adjusting the spacing between the letters of a text.
As an example, consider the word Top written with the following three glyphs:
##### ..... .....
..#.. ..... .....
..#.. ..##. .###.
..#.. .#..# .#..#
..#.. .#..# .#..#
..#.. ..##. .###.
..... ..... .#...
..... ..... .#...
We could just fil... |
Task
Given a string of English names of digits “collapsed” together, like this:
zeronineoneoneeighttwoseventhreesixfourtwofive
Split the string back into digits:
zero nine one one eight two seven three six four two five
Rules
The input is always a string. It always consists of one or more lowercase English digit nam... |
I honestly don't know what the point of this sort of calculation would be, but it should make fun golfing. Shortest code wins.
Input (in no particular order)
An array of integers, a (All elements will be integers less than the length of the array.)
An index therein, i
An iteration count, n
Processing
Store a number ... |
Introduction
Street talk can be really difficult to understand, in particular to programmers, who aren't known to be very streetwise.
It is your job to create an interpreter to help us all survive in the urban environment.
Challenge
Given an English sentence as input, create a program or a function that determines whet... |
As an exercise, I've created a simple solution for this challenge, in x86 Assembly Language. I'm running this with FASM on Windows. Here's my source code:
format PE console
entry start
include 'WIN32A.inc'
section '.text' code executable
start:
push char ; Start at 'A'
call [printf] ; ... |
Historical Background
The shield wall is a tactical war formation that dates back to at least 2500 BC. It consisted of warriors overlapping their shields with those of their companions to form a 'wall'. The appeal of the tactic comes from the fact that even the most unskilled warrior could fight in a wall as long as th... |
I got inspired by this: Print every character your program doesn't have
But with the exception that the letters have to be between ASCII 32 to 126. We started fooling around with it at the office with PHP and this is the best we could come up with:
<? while($i++<95)if(!strstr(file(__FILE__)[0],$a=chr($i+31)))echo$a;
Is... |
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer.
A number's digitangular counterpart is calculated in the following way:
Split a number into an array of its digit... |
Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence.
The task
Consider an arithmetic sequence: a list of positive integers in which the difference between any two successive elements is the same.
2 5 8 11 14 17
Now suppose one or more integers... |
Tomorrow, November 23rd, is Thanksgiving Day in the United States. To prepare, you need to cook up some ASCII turkeys. However, since you're late in planning, you need a program (or function) to help you with how many birds you need to prepare.
.---. _
.' './ )
/ _ _/ /\
=(_____) (__/_/==
======... |
Your challenge is to compute the Lambert W function. \$W(x)\$ is defined to be the real value(s) \$y\$ such that
$$y = W(x) \text{ if } x = ye^y$$
where \$e = 2.718281828...\$ is Euler's number.
Sometimes, \$y\$ may not be real.
Examples
W(-1) = non-real
W(-0.1) = -0.11183, -3.57715
W(1) = 0.56714
W(2) = 0.85261
Here'... |
Definition
If you take the sequence of positive integer squares, and concatenate them into a string of digits (i.e. 149162536496481100...), an "early bird" square is one that can be found in this string ahead of its natural position.
For example, 72 (the number 49), can be found at an offset of 2 in the string, althoug... |
Some of you may be familiar with the BigNum Bakeoff, which ended up quite interestingly. The goal can more or less be summarized as writing a C program who's output would be the largest, under some constraints and theoretical conditions e.g. a computer that could run the program.
In the same spirit, I'm posing a simila... |
A Sumac sequence starts with two integers: t1 and t2.
The next term, t3, = t1 - t2
More generally, tn = tn-2 - tn-1
The sequence ends when tn < 0.
Your challenge: Write a program or function that prints the length of a Sumac sequence, starting with t1 and t2.
t1 and t2 are integers within your language's range.
Standa... |
My kids have an alphabet mat to play with, something like this:
After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according to their background colors. So, if the letters represent the background color, I got a mat like this:
AABBCDDDE
ABBCCCDEE... |
We have a square 10x10 meter garden outside our house. We want to plant grass and make a terrace. We have decided how to divide the garden, but we haven't decided the ratio between amount of grass vs terrace.
We need help visualizing it, and ASCII-art is clearly the best way to do so.
Challenge:
Take an integer in the... |
Your pyramid
The pyramid I want you to build is made entirely of cubes. It has 24 layers, and the Nth layer from the top contains N2 cubes arranged in an N by N square. The pyramid looks like this:
To build the pyramid, you will need a supply of cubes. You are given 4900 cubes arranged in a 70 by 70 square that looks ... |
One of my favorite definitions of the prime numbers goes as follows:
2 is the smallest prime.
Numbers larger than 2 are prime if they are not divisible by a smaller prime.
However this definition seems arbitrary, why 2? Why not some other number?
Well lets try some other numbers will define n-prime such that
n is t... |
The Challenge
There are N cities aligned in a straight line. The i-th city is located A[i] kilometers to the right of the origin. No two cities will be in the same place.
You are going to build an electrical grid with some power plants. Power plants must be built inside a city. However, you are only allowed to build K ... |
Introduction
You have gotten a job as the minister of finance in your made-up country in your back yard. You have decided to make your own bank in your country for you and your less trustworthy friends. Since you don't trust your friends, you have decided to write a program to validate all transactions to stop your fri... |
Given one line that consists of only letters, process as following:
You maintain a string that's empty at the beginning.
If the next input character is in the string, remove it from the string.
If the next input character isn't in the string, append it to the string.
Output the final state of the string.
You can saf... |
As most of you probably know, (byte-addressable) hardware memories can be divided into two categories - little-endian and big-endian. In little-endian memories the bytes are numbered starting with 0 at the little (least significant) end and in big-endian ones the other way round.
Fun fact: These terms are based on Jon... |
⢣⠃⢎⠆⣇⡇⡯⡂⠈⡏⢰⢵⢐⡭⢸⠪⡀⢸⢐⡭⠀⢹⠁⢎⠆⢸⣱⢸⡃⢎⠰⡱⢸⣱⢸⡃⠈⡏⢸⡃⡱⡁⢹⠁⢸⡀⡇⡗⢅⢸⡃⠈⡏⢸⢼⢸⢐⡭⠀
⣇⢸⡃⢹⠁⢹⠁⣟⢸⢕⢐⡭⠀⡮⡆⡯⡂⣟⠀⡯⠰⡱⢸⣸⢸⢕⠀⣏⡆⢎⠆⢹⠁⣪⠅⢸⢼⢸⠰⣩⢸⢼⠀⡮⡆⡗⢼⢸⣱⠀⢎⠆⡯⠀⢇⠇⡮⡆⡯⡂⡇⡮⡆⣟⡆⣇⢸⡃⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀
⢎⠆⡗⢼⢸⡃⢸⡃⡗⠔⡇⡯⠂⢹⠁⢣⠃⠸⡸⢸⡃⡯⡂⢹⠁⡇⢎⢰⢵⢸⡀⢸⡀⡇⡗⢼⢸⡃⢐⡭⢸⡃⡯⠂⡮⡆⡯⡂⡮⡆⢹⠁⣟⢐⡭⠀⢎⢸⢼⢰⢵⢸⢕⢰⢵⠰⡁⢹⠁⣟⢸⢕⢐⡭⠀
⡮⡆⢐⡭⢸⠕⢰⢵⠰⡁⣟⠀⡇⣪⠅⢈⣝⢸⡃⡯⡂⢎⠆⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀
⣪⠅⢎⠆⢸⠈⡏⠀⣇⠰⡱⠰⡱⢸⠪⡀⣪⠅⢸⡀⡇⡗⢅⢸⡃⠸⡰⡸⠰⡱⢸⢕⢸⣱⢐⡭⠀⡮⡆⡯⡂⣟⠀⣪⠅⣟⢸⠕⢰⢵⢸⢕⢰⢵⠈⡏⢸⡃⣏⡆⢸⣳⠘⡜⠀... |
A standard ruler of length n has distance marks at positions 0, 1, ..., n (in whichever units). A sparse ruler has a subset of those marks. A ruler can measure the distance k if it has marks at positions p and q with p−q=k.
The challenge
Given a positive integer n, output the minimum number of marks required in a spars... |
To normalize a vector is to scale it to a length of 1 (a unit vector), whilst keeping the direction consistent.
For example, if we wanted to normalize a vector with 3 components, u, we would first find its length:
|u| = sqrt(ux2 + uy2 + uz2)
...and then scale each component by this value to get a length 1 vector.
û ... |
The gravitational binding energy of a planet is the amount of energy required to separate every tiny piece of it so that no piece will orbit or collide with another piece. For a uniform sphere, Wikipedia gives this formula:
$$E = \frac{3GM^2}{5R}$$
Where G is the gravitational constant (6.672e-11 m3•kg-1•s-2), M is mas... |
Given a square matrix, output the matrix's eigenvalues. Each eigenvalue should be repeated a number of times equal to its algebraic multiplicity.
The eigenvalues of a matrix A are scalar values λ such that, for some column vector v, A*v = λ*v. They are also the solutions to the characteristic polynomial of A: det(A - λ... |
There are several questions regarding this game, even a king-of-the-hill contest here. But I think all those challenges and contests need a way to automatically determine the winner of a game. So:
Challenge
Given two inputs in the range ["rock", "paper", "scissors", "lizard", "spock"] representing the selections for pl... |
It's all in the title...
Take as input a positive integer n>=12 and... do what the title says.
Yes, this is on OEIS A187924.
Some test cases
12 -> 912
13 -> 11713
14 -> 6314
15 -> 915
16 -> 3616
17 -> 15317
18 -> 918
19 -> 17119
20 -> 9920
40 -> 1999840
100-> 99999999999100
This is code-golf. Short... |
Forget BIDMAS! Write a program that takes an equation and an operator precedence order, and prints the result.
Example input format:
1.2+3.4*5.6/7.8-9.0 */+-
Rules & guidelines:
The only operators that are defined are addition (+), subtraction (-), multiplication (*), and division (/). No parentheses, no exponentiati... |
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to ... |
Objective
Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size.
Details
You will be passed a matrix (as a string) as input of random dimensions such as this.
bbbbbbbbbb
bbbbbdbbbb
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb
Your job is to find the letter that doesn't... |
Let's define fn(k) as the sum of the first k terms of the natural numbers [1, ∞) where each number is repeated n times.
k | 0 1 2 3 4 5 6 7 8 9
--------+-------------------------------------------------
f_1(k) | 0 1 3 6 10 15 21 28 36 45
deltas | +1 +2 +3 ... |
Another sequence, another challenge.*
Definition
A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted.
For example, 11 is trivially in this sequence (it's the first number, incid... |
Introduction
As you all know, German has umlauts. They're these things: ¨
However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue.
Challenge
Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions).
You have t... |
This is a QWERTY keyboard.
Q W E R T Y U I O P
A S D F G H J K L
Z X C V B N M
We can "spiral out" on this keyboard, starting from G. The spiral will start at G, go to H, then to Y, then to T, then F, then V, then B, then N, then J, then U, then R, then D, then C,... etc. Your challenge is to, given a number 1 ≤ N ... |
The Challenge
Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it.
Related.
Permissions in UNIX system
In UNIX, every file has three classes of permissions (user, group and others... |
Description
While support is getting better and better for people to write in various scripts around the world using unicode, and now you can even write in emojis as well, unfortunately most fonts[citation needed] are still missing Latin characters based on the double acute accent, which is required to write properly i... |
The Task
Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized.
Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should b... |
Background
The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case brought before the Supreme Court. Gerrymandering, especially when related to race, is ruled illegal and results in the r... |
Introduction
Mathematicians often work with number sets. These are groups of numbers that share common properties. These are number sets are, in order from most specific to most broad:
Natural numbers (symbol N): These are the counting numbers: 1, 2, 3, ...
Integers (symbol Z): These are all the numbers with... |
It's that time of year when many of us get our advent calendars! If you are unfamiliar with an advent calendar, these are special calendars used to count down advent in anticipation of Christmas. In my experience the doors are placed randomly, and part of the fun as a child was working out where tomorrow's door was! O... |
The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows:
if year is divisible by 400, LEAP YEAR
else if year is divisible by 100, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
... |
You left your computer for too long, and it went to sleep. Wake it up again by printing the following coffee maker.
________._________
| | \ - /
| || | \ - /
| || |___\___/
| || | X
| | ___
| | / - \
|______| / - \
| ____ | /_______\
||7:30||__________
||____| |
|______... |
Look at the following string. Notice a pattern?
ABEFNOPEFGH
DC G Q I
M H R J
LKJI S K
D T L
C U M
BAZYXWV N
E O
D P
C Q
BAZYXWVUTSR
As some might have noticed, it's basically a spiral of the alphabet, where the distances between rows / columns are gradually increasing b... |
The challenge
Given two integers as input (x and y), output x as a string with as many leading zeroes necessary for it to be y characters long without the sign.
Rules
If x has more than y digits, output x as string without modification.
Output as integer is not accepted, even if there are no leading zeroes.
When x is ... |
Next >>
Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find
Challenge
Santa has had a history of elves stealing presents from his vault in the past, so this year he designed a lock that is very hard to crack, and it seems to have kept the elves out this year. Unfortunately, he has l... |
4-state barcodes
Many postal services (Royal Mail UK, Canada Post, US Mail, etc) use a 4-state barcode to encode information about their mail. Rendered in ASCII, it may look something like this:
| | | | | | | | | |
| | | | | | | | | | | | | | | | |
| | | | | | | |
A 4-state barcode is a row ... |
You probably know the rhetorical question of whether a glass is half full or half empty. I'm getting a little tired of the phrase, so I decided that it's time to eliminate this confusion about glass fullness or emptiness programmatically.
Your task is to write a program that takes an ASCII art representation of an ugly... |
Given you have an infinite sequence of numbers defined as follows:
1: 1 = 1
2: 1 + 2 = 3
3: 1 + 3 = 4
4: 1 + 2 + 4 = 7
5: 1 + 5 = 6
6: 1 + 2 + 3 + 6 = 12
7: 1 + 7 = 8
...
The sequence is the sum of the divisors of n, including 1 and n.
Given a positive integer x as input, calculate the lowest number n which will produ... |
Inspired by this comment.
Input
The number of seconds on the timer.
Output
Here's our basic microwave:
_____________________________________________________________
| | ___________ |
| | | [display] | |
| ____________________... |
I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code:
f=->a{b,c,d=a;b ?a==b ?~-a:a==a-[c-c]?[[b,c,f[d]],~-c,b]:b:$n}
h=[],$n=?~.ord,[]
h=f[h]until h==p($n+=$n)-$n
Ungolfed:
f=->{b,c,d=a
if b
if a==b # a is not an array
return a-1
elsif a... |
<< Prev Next >>
Challenge
Now that Santa has finally figured out how to get into his present vault, he realises that somehow the elves got in there before him and stole some of his presents! They haven't figured out how to leave the vault yet though, so Santa has to try and catch them all. Santa and the elves both have... |
Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list:
2 × 8388608
4 × 41943... |
Introduction
Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4].
I like having balance in my life, so I'm happy to see it has as many odd elements as even elements.
What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in:
[-1,2,2,1,2,7,1,4]
0 mod 3:
1 ... |
Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following:
7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯
6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯
5♯ - B C♯ D♯ E F♯ G♯ A♯ B
4♯ - E F♯ G♯ A B C♯ D♯ E
3♯ - A B C♯ D E F♯ G♯ A
2♯ - D E F♯ G A B C♯ D
1♯ - G A B C D ... |
<< Prev Next >>
Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to figure out the expenses for how much to pay them.
Challenge
Given some information for the presents, determine the cost of manufactu... |
Introduction
As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment.
Challenge
Create a program or a function that produces the flag of Finland (the grey border is there for presentation purposes only):
Flag specif... |
<< Prev Next >>
Santa was able to remanufacture all of the presents that the elves stole overnight! Now he has to send them to the assembly line for packaging. He usually has a camera to supervise the assembly line both to make sure the elves are doing a good job and because assembly line pictures look nice on advertis... |
Related: Iterated phi(n) function.
Your challenge is to compute the iterated phi function:
f(n) = number of iterations of φ for n to reach 1.
Where φ is Euler's totient function.
Related OEIS.
Here's the graph of it:
Rules:
Your goal is to output f(n) from n=2 to n=100.
This is code-golf, so shortest code wins.
Here... |
A traditional Western die is a cube, on which the integers 1 to 6 are marked on the faces. Pairs that add to 7 are placed on opposite faces.
As it is cube, we can only see between 1 and 3 faces (inclusive)1 at any given time. Opposite faces can never be seen at the same time.
Your task is to write a program or function... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.