instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
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... | stackexchange_codegolf |
(I've tagged the question "C" for the time being, but if you're aware of another language that supports unions, you can also use that.)
Your task is to build the four standard mathematical operators + - * / for the following struct:
union intfloat{
double f;
uint8_t h[8];
uint16_t i[4];
uint32_t j[2];
... | stackexchange_codegolf |
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively.
Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu:
[e]gg | [s]ausage | [b]acon | [S]pam
-------+-----------+--------... | stackexchange_codegolf |
Given two string inputs of "Rock", "Paper", or "Scissors", determine the outcome of the RPS round. Output 1 if the first player wins, -1 if the second player wins, or 0 for a tie.
Rock Rock -> 0
Rock Paper -> -1
Rock Scissors -> 1
Paper Rock -> 1
Paper Paper -> 0
Paper Scissors -> -1
Scissors Rock -> -1
Scissors Paper ... | stackexchange_codegolf |
Your task today is to write a program or function that takes an array of integers, and counts the number of times, reading it left to right, that the value changes. This is easier to show with an example: [1 1 1 2 2 5 5 5 5 17 3] => [1 1 1 **2** 2 **5** 5 5 5 **17** **3**] => 4
Test case:
Input | Output
[] ... | stackexchange_codegolf |
Given a rectangular text as a word search puzzle and a search string, determine if the text contains the search string. The search string may appear:
horizontally, vertically or diagonally
forwards or backwards
You may write a function or a program and take two strings as input via function argument, ARGV or STDIN. T... | stackexchange_codegolf |
Challenge
Given two question IDs, try to figure out how similar they are by looking at the answers.
Details
You will be given two question IDs for codegolf.stackexchange.com; you may assume that there exist questions for both IDs that are not deleted, but are not necessarily open. You must run through all of the answer... | stackexchange_codegolf |
It's 2050, and people have decided to write numbers in a new way. They want less to memorize, and number to be able to be written quicker.
For every place value(ones, tens, hundreds, etc.) the number is written with the number in that place, a hyphen, and the place value name. "zero" and it's place value does not need ... | stackexchange_codegolf |
Maximillian is the chief commander of the Great Greek Army and he is leading his forces into a crucial war with Spain.
If all the enemy soldiers stand in a straight line incrementally marked starting from position 1, and a particular soldier at position \$i\$ dies, the soldiers at position \$2i\$ and \$2i+1\$ die as we... | stackexchange_codegolf |
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.).
Input can be any combination of upper or lower case alphabetic cha... | stackexchange_codegolf |
Introduction
A sequence of numbers is passed in as the input. The program has to generate the lowest degree polynomial possible. This was my first programming project in college and it would be interesting to see how much smaller the solution could have been.
Challenge
The input is a list of integers separated by a com... | stackexchange_codegolf |
In 2D Mario, Bullet Bill cannons are two units tall. The Bullet Bill is fired out of the upper unit and travels in a straight line (parallel to the x axis).
Mario is two units tall when standing up and one unit tall when ducking. His jump height is three units. It takes him 0.5 seconds to reach the full height and 0.5 ... | stackexchange_codegolf |
When playing Rock-Paper-Scissors-Lizard-Spock, your robot reflexes let you see your opponent's throw before they make it. You just need to choose a throw that beats theirs, in as few bytes as possible of course.
There's always two winning throws, and either one will work.
Input -> Possible outputs
----------------... | stackexchange_codegolf |
Many people consider RPS to be a game of chance. If both players play unpredictably, the best strategy is to play randomly. However, let's introduce a bit of predictability to it.
Each bot will have a chance to tell the other bot what it's going to play simultaneously. Then there is a pause in which each bot will know... | stackexchange_codegolf |
I recently learned from a comment by MathOverflow user pregunton that it is possible to enumerate all rational numbers using iterated maps of the form \$f(x) = x+1\$ or \$\displaystyle g(x) = -\frac 1x\$, starting from \$0\$.
For example, $$0 \overset{f}{\mapsto} 1 \overset{f}{\mapsto} 2 \overset{g}{\mapsto} -\frac12 \... | stackexchange_codegolf |
Inputs
A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (integer larger than zero).
Outputs
A single number, or again, a numerical string.
Problem
The idea is to reduce the list of nu... | stackexchange_codegolf |
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is,
they both have the same shape, or one has the same shape ... | stackexchange_codegolf |
Inspired by this OEIS entry.
Background
A saturated domino covering is a placement of dominoes over an area such that
the dominoes are completely inside the area,
the dominoes entirely cover the given area,
the dominoes may overlap, and
removal of any domino reveals an uncovered cell (thus failing to satisfy condition... | stackexchange_codegolf |
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that:
the numbers are separated by single space,
if a number is divisible by 3, it should be in parentheses,
if a number is divisible by 4, it should be in square brackets,
if a number is divisible by both 3 and 4, it s... | stackexchange_codegolf |
Challenge
Given a list of keys and values, and a target n, return all sets of keys where the sum of their values equals or exceeds n.
Input
Input will be like this:
[["Part 1", 20], ["Part 2", 15], ["Part 3", 14.75], ["Part 4", 3]], 30
Input consists of a list with keys (which can be any kind of string) and values (wh... | stackexchange_codegolf |
Your task is to take \$n \ge 2\$ points in 3D space, represented as 3 floating point values, and output the Euclidean distance between the two closest points. For example
$$A = (0, 0, 0) \\ B = (1, 1, 1) \\ C = (4, 0, 2)$$
would output \$\sqrt3 = 1.7320508075688772...\$, the distance between \$A\$ and \$B\$.
The Euclid... | stackexchange_codegolf |
The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII characters. These are the 95 characters from code points 0x20 to 0x7E. For a given offset d, we map the code point C to
(C ... | stackexchange_codegolf |
Given an initial \$n\$-tuple \$t_0=(t_{0,1},...,t_{0,n})\$, we can obtain its corresponding Ducci sequence \$\{t_0, t_1, ...\}\$ by the recurrence \$\displaystyle t_{i+1}=\left(\left|t_{i,1}-t_{i,2}\right|,\left|t_{i,2}-t_{i,3}\right|,...\left|t_{i,n}-t_{i,1}\right|\right)\$.
That is, to obtain the next term of the seq... | stackexchange_codegolf |
"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the 012345 respectively with ()[]{}†, so every 0 becomes (, every 1 becomes ), etc.
You don't have to use ()[]{} per se. As long as you spec... | stackexchange_codegolf |
Write a program that groups a string into parentheses cluster. Each cluster should be balanced.
Examples :
split("((())d)") ➞ ["((()))"]
split("(h(e(l)l)o)(w(o)r)l(d)(w)h(a(t)(s)u)p") ➞ ["((()))", "(())", "()", "()", "(()())"]
split("((())())(()(()()))") ➞ ["((())())", "(()(()()))"]
Input may contain letters other t... | stackexchange_codegolf |
Recently, I created a binary word search that got me working with grids. It was fun, so I wanted to create some more similar content. Meet Pythagoras' Golfing grid:
Each of d, e, f, g, h, i, j, k and T represent a numeric value.
Now consider an orthogonal triangle along the lower diagonal of this grid (so the vertical... | stackexchange_codegolf |
So you want to create a haiku, but you're not sure if it follows the syllable rules for a haiku.
I couldn't be bothered to write a proper blurb like I usually do, so you'll have to make do with this. Let's get stuck right in.
Finding a haiku out in the wild
For the purposes of this challenge, we will be checking if the... | stackexchange_codegolf |
Giving a challenge involving a Star Trek reference just after May the 4th may be frowned upon, but here goes.
You, Luke, Anakin, Palpatine, Yoda and Han Solo are involved in an insane tournament of Rock, Paper, Scissor, Lizard, Spock.
The catch here is that you are only allowed to use a fixed order of moves. If your or... | stackexchange_codegolf |
Given a sequence of integers or to be more specific a permutation of 0..N
transform this sequence as following:
output[x] = reverse(input[input[x]])
repeat
For example: [2,1,0] becomes [0,1,2] and reversed is [2,1,0]. [0,2,1] becomes [0,1,2] and reversed [2,1,0].
Example 1
In: 0 1 2
S#1: 2 1 0
S#2: 2 1 0
Output:... | stackexchange_codegolf |
The new site header has some bits of source code from various questions as the background. Here are the first 3 lines:
--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. Hello, World! IT'S SHOWTIME TALK TO THE HAND "Hello, World!" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a4... | stackexchange_codegolf |
A zigzag scan is a method of encoding 2D information in one dimension:
Write a function or program that, given a one-dimensional string of printable ASCII characters, will reverse the zigzag scan to arrange its characters into a square.
For example, given the input string ABeIfCDgJmnKhLop, your program should return:
... | stackexchange_codegolf |
The setting
"Well I actually wrote the sql library they, the maintainers actually.."
"Right, but do you have any experience working with django?"
" ...no I don't use frameworks"
After the phone interview is over, you feel like you really need a coffee. While the brew is heating, you check your messages on BusinessBook.... | stackexchange_codegolf |
Challenge description
A Smith number is a composite number whose sum of digits is equal to the sum of sums of digits of its prime factors. Given an integer N, determine if it's a Smith number or not.
The first few Smith numbers are 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438 (seque... | stackexchange_codegolf |
Balanced binary search trees are essential to guarantee O(log n) lookups (or similar operations). In a dynamic environment where a lot of keys are randomly inserted and/or deleted, trees might degenerate to linked lists which are horrible for lookups. Thus there are various kinds of self-balancing binary trees that cou... | stackexchange_codegolf |
Given an input of a pair of nonnegative integers describing a
leaper in chess,
output a diagram of the squares to which the leaper can move.
From Wikipedia's description:
An (m,n)-leaper is a piece that moves by a fixed type of vector between its
start square and its arrival square. One of the coordinates of the vec... | stackexchange_codegolf |
Given positive integer n and e, knowing that e<n and that n is the product of two different odd primes(but the primes are not directly given to you), find such a positive integer d smaller than n that, for each integer m, (me)d ≡ m (mod n).
Your program should handle n up to 24096 in 1TB space, but not necessary reaso... | stackexchange_codegolf |
This is the cops' thread, the robbers' thread is here
A polyglot is a program, that without modification, can run in multiple languages.
Allowed languages
Any language that was made before the challenge and isn't made for the purpose of the challenge, it is allowed, though discouraged, to use languages that are easy t... | stackexchange_codegolf |
Warning: Contains minor Deltarune Chapter 1 Spoilers
Within the Forest section of the first chapter of Deltarune, there are a few puzzles that consist of entering playing-card suits in a certain order to move to the next section. Below is an example of such a puzzle:
The way to solve the puzzle is to do any of the ... | stackexchange_codegolf |
AKA: Generate Clickbait From an Array.
Given an array of integers, generate some cringe-worthy clickbait based on its arrangement and length:
If it's 20 elements or less, you can make a Top X List. Parameters: length of the array.
Prime numbers are celebrities, so anytime two of them are next to each other it'll pass ... | stackexchange_codegolf |
This is alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/args. But again, The tricky part is that if I rot-13 your source code, the output must be returned rot-19.
Your co... | stackexchange_codegolf |
In honor of recent news of Google developing a keyboard for iPhone...
Your input (for simplicity, all input is case sensitive):
Location of standard dictionary file. File format is 1 valid word per line; in alphabetical order. Example file:
apple
banana
citrus
domino
durian
orange
tuna
zabc
Location of personal dicti... | stackexchange_codegolf |
For the purpose of this challenge, a smaller-base palindrome (SBP) is a number which is palindromic in a base between 1 and itself (exclusive), and is not a repdigit in the same base. For example, 5 is a SBP because it is a palindrome in base 2 (101). The first few SBPs are 5,9,10,16,17,20,21,23,25,26,27,28,29,33...
... | stackexchange_codegolf |
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter.
In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin... | stackexchange_codegolf |
This javascript code:
for(x=1;x<6;x++)for(y=1;y<6;y++)console.log((y==1?'\n':'')+x+'*'+y+'='+x*y);
prints the following:
1*1=1
1*2=2
1*3=3
1*4=4
1*5=5
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
3*1=3
3*2=6
3*3=9
3*4=12
3*5=15
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
2 questions:
Is there a smaller ... | stackexchange_codegolf |
Create a function which takes a polynomial equation, a value for x and returns the result of the operation.
Example: given 4x^2+2x-5 and x=3 output 37. This is the result of 4(3)^2+2(3)-5
Assume all polynomials are valid
Polynomial format will always be coefficient(variable)^exponent => 4x^2 except :
When exponent ... | stackexchange_codegolf |
Challenge
Hi, given a string as input, remove any salutations found at the start of the string.
The program which performs the most correct substitutions in under 50 bytes wins.
Salutations
Hey, a salutation is defined as one of the following words:
hi
hey
hello
dear
greetings
hai
guys
hii
howdy
hiya
hay
heya
hola
hih... | stackexchange_codegolf |
Given a positive integer n, compute the nth Wilson number W(n) where
and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n.
This is code-golf so create the shortest code for a function or program t... | stackexchange_codegolf |
Given an input of two integers n and m, output an ASCII ladder of length
n and size m.
This is an ASCII ladder of length 3 and size 3:
o---o
| |
| |
| |
+---+
| |
| |
| |
+---+
| |
| |
| |
o---o
This is an ASCII ladder of length 5 and size 1:
o-o
| |
+-+
| |
+-+
| |
+-+
| |
+-+
| |
o-o
This is an AS... | stackexchange_codegolf |
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 ... | stackexchange_codegolf |
Given a set of letters, output all strings made of those letters. (This is Kleene star of the set.) For example, for {'a','b'}, the strings are:
'', 'a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', 'aab', ...
Input: A non-empty collection of distinct letters a..z. These may be characters or single-character strings.
Output: A... | stackexchange_codegolf |
Quinary is like binary, except that 1 is represented by the text of the program, and 0 is represented as the backwards text of the program.
The Fibonacci Sequence is the well known sequence
F(0) = 0, F(1) = 1, F(n) = F(n - 1) + F(n - 2)
Write a program that takes some input n and outputs the nth fibonacci number in qui... | stackexchange_codegolf |
Given a single integer x where 0 <= x <= 91 output a stack of bottles of beer with that many bottles (and shelves) missing. For simplicity sake I'll only show the first 6 bottles and what it would be for each of the first inputs.
Here's the stack of bottles, each number is the bottle you should remove for that input (1... | stackexchange_codegolf |
So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further.
Your challenge
There is a naming system for polygons above a few sides, so arbitrarily large polygons have a name.
Your task is to write a program or ... | stackexchange_codegolf |
You are to create a program that creates exact clones of itself infinitely until stopped. Whatever is in the original program must be in the clones. In other words, the clones and original program are the same in every way except for that the clones don't have to be in the same type of file as the source code (they can... | stackexchange_codegolf |
For the purpose of this challenge a rectangular piece of ASCII art is Mondrian if it looks the same upside down.
What does "looks the same" mean?
A feature is any orthogonally connected region of at last 5 characters. A Mondrian feature is any feature that appears in the same picture upside down. (This includes the pos... | stackexchange_codegolf |
When I saw this title in the Hot Network Questions I thought it was going to be a PPCG challenge. I was a little disappointed when it was on Mathematica.
So now it is on PPCG:
Challenge
Given an input string, output the ROT13, flipped value. The input will contain characters from the following alphabet: [abcdefghijklmn... | stackexchange_codegolf |
A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example:
⠎ ⠝ ⠥ ⠛ ⠛ ⠇ ⠽ snuggly
⠏ ⠕ ⠇ ⠽ ⠛ ⠕ ⠝ polygon
⠝ ⠥ ⠛ ⠛ ⠑ ⠞ ⠽ nuggety
⠽ ⠕ ⠛ ⠓ ⠥ ⠗ ⠞ yoghurt
are all magic words.
Objective:
Craft a program to identify 77 such mag... | stackexchange_codegolf |
Goal: This goal to take a string and output how many contributions should be made on which days in order to display a message.
Specification
Input
Support letters plus space (i.e. [A-Za-z ] )
Space is a blank 3X7
The letters are defined in this 5x7 DOT Matrix font provided below
The size of each letter is the minim... | stackexchange_codegolf |
Introduction
Let's draw some regular hexagons formed by hexagonal tiles, marking the vertices of the tiles with dots. Then we will count the number of dots.
size 1: 6 dots
. .
. .
. .
size 2: 24 dots
. .
. . . .
. . . .
. . . .
. . . .
. . . .
. .
size 3: 54 dots
. .
. . . .
... | stackexchange_codegolf |
Inspired by ecofont.
Given a string containing # and , output it more eco-friendly by cutting out circles, while keeping it "recognizable" (defined later, in the Circles section). # represents black, and represents white. This program is supposed to do something like this:
Input:
####################
#################... | stackexchange_codegolf |
Write a program that accesses Project Gutenberg's KJV Bible, either from a file called pg10.txt in the working directory or in any other way that is typical for the language, takes a Bible verse reference as input, and prints the corresponding verse, with no newlines except optionally one at the end, as output.
The sta... | stackexchange_codegolf |
Given a number N, output the sign of N:
If N is positive, output 1
If N is negative, output -1
If N is 0, output 0
N will be an integer within the representable range of integers in your chosen language.
The Catalogue
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list o... | stackexchange_codegolf |
Write a program that prints "Hello, world!" without using any kinds of literals.
Don't use string literals, numeric literals, byte literals, char literals, etc. Default values are allowed in languages that have them.
Printing data from external files/websites/arguments is not encouraged.
edit: probably don't use Bool... | stackexchange_codegolf |
You are going to be planting pumpkins soon, and you are preparing your supplies. Pumpkins come in all sorts of sizes and have their sizes written on the seed bag. A pumpkin that is size n will grow to be n units wide. However pumpkins need their space.
If a pumpkin is stuck between two other pumpkins with not enou... | stackexchange_codegolf |
I recently got a new Sudoku app that produces really hard Sudoku's, which can't be solved using the standard strategies. So I had to learn a few new ones. One of these strategies is the Y-Wing Strategy. It is ranked under "Tough Strategies", but it is actually not that hard.
Example
For this strategy only 4 cells are ... | stackexchange_codegolf |
Today is Halloween and it's time to carve some pumpkins!
&
((^.^))
Given an input integer, string, list of integers, etc., output the corresponding pumpkin. The input will always be of the form Stem, Eyes, Mouth, Width. For example, 2331 would be a valid input.
The pumpkin takes the form:
S
((EME))
where S is t... | stackexchange_codegolf |
quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2.
Given a list of numbers, k1, k2, ... ,km, output the residue of the multinomial coefficient:
reduced mod 2. The following algorith... | stackexchange_codegolf |
Input: A string
Output: The rarity of the string, as described below.
To find the rarity of a string, follow the steps below.
Start with 0.
Subtract 3 for each E, A, T, or O in the string.
Subtract 2 for each I, N, S, or H in the string.
Subtract 1 for each R, D, L, or C in the string.
Add 1 for each W, F, G, or Y in ... | stackexchange_codegolf |
Challenge:
I have thousands of songs in my music collection, and luckily for me, my favorite player has a search function. I also have a great memory—I can remember the title of every song in my collection. However, I'm very lazy and don't like to type—each extra keystroke is a chore!
What is the shortest string I mus... | stackexchange_codegolf |
SF(n) is a function which computes the smallest prime factor for a given number n.
We'll call T(N) the sum of every SF(n) with 2 <= n <= N.
T(1) = 0 (the sum is over 0 summands)
T(2) = 2 (2 is the first prime)
T(3) = 5 = 2 + 3
T(4) = 7 = 2 + 3 + 2
T(5) = 12 = 2 + 3 + 2 + 5
...
T(10000) = 5786451
The winner will be the ... | stackexchange_codegolf |
Write a script that outputs A to stdout infinitely.
There should be no newlines or separators between the characters.
Standard loopholes apply.
This is code-golf. The shortest solution in each language wins.
| stackexchange_codegolf |
Amazingly, this is the easier of the three card tricks I know off the top of my head...
The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the compiler won't be memorizing the choice and saying "Voila, this is your card!" The code will basically manipulate a stack of ... | stackexchange_codegolf |
Given an integer n as input write a program to output the numbers of digit in it.
Input
12346
456
Output
5
3
Constraint
n<=10^9
| stackexchange_codegolf |
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested.
For example, with the list [[1, 2], [3, [4, 5]]] the depth of the 2 is 2, as it is nested within two lists: The base list, and the list [1, 2]. The depth of the 4 is 3 as it is nested within three li... | stackexchange_codegolf |
Qat is a tool that lets you search for words matching a given pattern, often used by crossword and other word puzzle writers and solvers.
In this challenge, you will have to implement a specific part of Qat, namely a subset of the "equation solver".
Equations
The output of a Qat query depends on the dictionary you use ... | stackexchange_codegolf |
Challenge
Given two question IDs, try to figure out how similar they are by looking at the answers.
Details
You will be given two question IDs for codegolf.stackexchange.com; you may assume that there exist questions for both IDs that are not deleted, but are not necessarily open. You must run through all of the answer... | stackexchange_codegolf |
I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea:
Write a program that takes 2 inputs, a string and integer:
the message to encode or decode
how far to shift
You can input in a function call, and output in any legal way
twist:
it must work with any printable... | stackexchange_codegolf |
Input:
A list of integers (which will never contain a zero)
Output:
A list of the same size with counts based on the following:
If the current item is negative: Look at all items before this item, and count how many times the digits occurred in those other numbers
If the current item is positive instead: Look at all i... | stackexchange_codegolf |
The task is simple, given an integer n of how many lines the next n lines is and, a multi-line input, output the resulting 90 degree tilted grid in a clockwise formation.
E.g.
Input:
2
c d
o e
Output:
o c
e d
I/O format:
Input will have spaces in between them
Input always contains alphabetical characters except the ... | stackexchange_codegolf |
Input
A single positive integer \$ 10 \geq n \geq 2\$
Output
A list of strings, each of length \$2n\$, satisfying the following properties.
Each string will contain each of the first \$n\$ lowercase letters of the alphabet exactly twice.
No letter can occur twice consecutively. That is abbcac is not allowed.
No two st... | stackexchange_codegolf |
The problem
You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months.
Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay.
Fortunatelly, you are not required to write everyt... | stackexchange_codegolf |
If you like this, consider participating in:
The Official Dyalog APL 2016 Year Game
The monthly Dyalog APL 2017 Code Golf Challenge
Make 12 snippets/expressions, in the same language, that result in the numbers 0 through 10, and 42 respectively, but without writing any literal numeric, string, or character data.
Bui... | stackexchange_codegolf |
Input: A valid 6 HEX digit color code wihout a # prefix
Valid:
000000
FF00FF
ABC123
Your job is to find to which one of these:
Red: FF0000
Green: 00FF00
Blue: 0000FF
White: FFFFFF
Black: 000000
the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v... | stackexchange_codegolf |
Your task is to create a program that will, given an input image, create an output image of the same size, where all pixels are ordered by hex value.
Your program may:
Sort the pixels from left to right and then down or first sort down in columns and then right. In any case, the top left pixel is the smallest, and the... | stackexchange_codegolf |
Introduction:
Inspired by both Perfect License Plates and How many points does my license plate give?
Just like in the challenges above, me and my little brother had a game of our own with license plates as kids. We tried to create (random/funny) sentences with the (numbers and) letters of the license plates.
For examp... | stackexchange_codegolf |
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... | stackexchange_codegolf |
Original: https://james-iry.blogspot.co.at/2009/05/brief-incomplete-and-mostly-wrong.html
Alain Colmerauer designed the logic programming language Prolog. His goal was to create a programming language that is as intelligent as a two-year-old child. In order to prove that he had succeeded in his goal, he presented a P... | stackexchange_codegolf |
Background Information: What is a Fenwick Tree?
With a normal array, it costs \$O(1)\$ to access and modify an element, but \$O(n)\$ to sum \$n\$ elements. Working with a prefix sum array (an array where the \$i\$th value represents the sum of the first \$i\$ values in the underlying data), access and summation are \$O... | stackexchange_codegolf |
Alright, my second attempt at a code golf, let's see how this goes.
Pretend you have a 3x3 grid of digits, from 0 to 8:
0 | 1 | 2
---+---+---
3 | 4 | 5
---+---+---
6 | 7 | 8
Return the neighbors the input has as indexes of the array.
Rules:
It's code golf, so shortest answer wins.
The pretend array's index can sta... | stackexchange_codegolf |
Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol X for the painting, + for the matting, and # for the framing. The symbols must be space-separated. Trailing whitespace is alright, as long as the o... | stackexchange_codegolf |
Definition
Given some string return an integer whose digits are the number ocurrences of a-z (case insensitive, in alphabetical order) in that string. Any character with 0 instances is skipped. Characters with 10 or more instances will define 2 or more digits of the returned integer. For example, aaaaaaaaaaaaaaaaaaaaaa... | stackexchange_codegolf |
This is my attempt to pair code-shuffleboard with code-golf.
You need to write a full program or function that sums all codepoints of the input string. If there is no input, you can output any number, including 0.
Rules
The input will always be in printable ASCII.
The sum of the codepoints of your source must be exact... | stackexchange_codegolf |
Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming.
What general tips do you have for golfing in Pip? I'm looking for approaches and tricks that are commonly useful for code golf and are specific to Pip (e.g. "remove comments" is not an answer... | stackexchange_codegolf |
Given a PPCG User ID, output that user's current username.
Examples
Input -> Output
61563 -> MD XF
2 -> Geoff Dalgas
12012 -> Dennis
foo ->
-3 ->
Rules
Input/output can be taken via any allowed means.
The output must be the full username with proper capitalization and spacing, nothing more and nothing less... | stackexchange_codegolf |
Challenge :
Check if the given number forms a number staircase or not
Input :
A integer (greater than 0 and not decimal). NOTE : You can take input as string , array of digits.
Output :
a truthy / falsy value depending on whether the number forms a staircase or not
Number staircase :
A number staircase is an integer... | stackexchange_codegolf |
Given an ASCII representation of a piece of string, determine its length.
Input
An multi-line ASCII rendering of a piece of string, which runs from top to bottom, with one 'node' (corner) on each line of input. The delimiter may be assumed to be CR, LF, CRLF, or LFCR. Input may be accepted from STDIN, Command Line Argu... | stackexchange_codegolf |
The event scheduler is a recurrent theme in event-driven architectures: something triggers an event that needs to be checked in the future one or more times. I has particular use in trading where you want to correlate one market event with price movements in the future at several time deltas (1ms, 100ms, 1s, 1 min, etc... | stackexchange_codegolf |
This challenge is similar to my previous one, but has a twist that makes it significantly more difficult.
There are n people on a 2D plane. Using distances between them we're going to find their positions. You may make four assumptions:
There are at least 3 people.
The first person is at position (0, 0).
The second pe... | stackexchange_codegolf |
Write a program that precisely clones GNU cat version 8.32, which is
installed on my computer.
In any case, if called with the same arguments, same stdin, and same files,
your program's output to both stdout and stderr must by byte-for-byte identical
to that of GNU cat, and the exit code must be the same. This applies ... | stackexchange_codegolf |
This is an answer-chaining challenge in which each answer builds on the previous answer. I recommend sorting the thread by "oldest" in order to be sure about the order in which the posts are made.
Note: This has become quite a long-lasting challenge, and posting new answers is fairly difficult. As such, there's now a ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.