Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
12,031
questions
86
votes
222
answers
23k
views
The Letter A without A
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 ...
19
votes
31
answers
2k
views
Is it a tower permutation?
A tower is made out of layers, each one being one unit shorter than the one below it. Every layer is completely on top of the previous layer. For example, here is a tower along with it's height map:
<...
16
votes
26
answers
5k
views
FizzFizzFizzBuzz!
Given a positive integer n, output the "FizzFizzFizzBuzz" sequence for that number: print the decimal representations of the numbers 1 through ...
8
votes
4
answers
8k
views
Convert CP437 to UTF-8
The goal is to read bytes from input encoded in Code Page 437 and output the same characters encoded as UTF-8. That is, bytes should be translated into Unicode codepoints per this table (a particular ...
198
votes
418
answers
77k
views
1, 2, Fizz, 4, Buzz
Introduction
In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
27
votes
21
answers
5k
views
Generalized FizzBuzz
Task
FizzBuzz, but instead of 3 and 5, you'll take the numbers and corresponding strings as input.
You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, ...
12
votes
1
answer
314
views
Plot the ground path of a satellite
If you model a satellite as a free point orbiting a body, you can pretty easily see it has 6 degrees of freedom: three for the X, Y, and Z position, and three for the X, Y, and Z velocity. However, ...
23
votes
4
answers
1k
views
Stroke Count of a Chinese Numeral
Task
Given an integer \$n\in[0,10^{12})\$ in any convenient format, return the number of strokes needed to write that character in simplified Chinese.
Background
Chinese numerals are expressed in base ...
13
votes
15
answers
880
views
Reorder for smallest largest prefix sum
Given a multiset of integers, order them such that the largest absolute prefix sum $$\max_i \left| \sum_{k<i} a_k \right|$$ is smallest. Output any solution if multiple exist.
You can assume input ...
26
votes
42
answers
3k
views
Sum of a range of a sum of a range of a sum of a range of a sum of a range of a sum of
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,...
18
votes
11
answers
1k
views
Is this a word?
Toki pona is a minimalist constructed language, and thus it has minimalist phonotactics (rules describing what sounds make valid words).
Toki Pona has 8 consonant sounds ...
57
votes
154
answers
8k
views
The vanilla factorial challenge
Task
Given a non-negative integer \$n\$, evaluate the factorial \$n!\$.
The factorial is defined as follows:
$$
n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases}
$$
Rules
All default I/...
3
votes
18
answers
305
views
Check if two lists are permutations of each other [duplicate]
Challenge
Given two lists of equal length, find if one of them is a permutation of the other. Output truthy or falsy values, or 1 or 0.
Test case Examples
...
4
votes
39
answers
22k
views
Find the temperature closest to 0
In this exercise, you have to analyze records of temperature to find the closest to zero.
Write a program that prints the temperature closest to 0 among input data.
Input
N, the number of ...
56
votes
37
answers
7k
views
Encode the date in Christmas Eve format
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
...