All Questions

Filter by
Sorted by
Tagged with
15 votes
7 answers
4k views

How many people are awake?

The following data contains the (approximate) population of each UTC timezone in the world (source): ...
enzo's user avatar
  • 1,941
17 votes
19 answers
1k views

Ellipse Lattice Point Counter

Challenge Determine how many integer lattice points there are in an ellipse $$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$ centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, ...
vengy's user avatar
  • 1,603
5 votes
6 answers
453 views

Aircraft registration numbers

Write a program that takes a United States aircraft registration number and returns a 24-bit ICAO hex code corresponding to that registration and vice-versa. An aircraft registration number always ...
Chris's user avatar
  • 2,009
-6 votes
1 answer
167 views

Where to stand to throw circles over sticks

Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2},...
Simd's user avatar
  • 2,760
17 votes
19 answers
2k views

Mousetail's Sequence

I define mousetails's sequence as follows: If the nth element of the sequence is q, then n+1 must appear q times in the sequence The sequence is weakly monotonically increasing (eg. no lower number ...
mousetail's user avatar
  • 12.4k
8 votes
8 answers
1k views

Find the child anagrams of a word

Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present ...
enzo's user avatar
  • 1,941
14 votes
21 answers
2k views

Divmod continuously until the remainder is 1 or 0, then get the remainder

The task is simple, divide, get the quotient and the remainder, and if the remainder isn't 1 or 0, do the same thing (quotient divmod remainder) until the remainder is 1 or 0, then get the remainder. ...
Fmbalbuena's user avatar
  • 3,831
13 votes
10 answers
1k views

How much do you win in the Bingo Golf Flax Lottery?

The challenge, should you accept it, is to determine how much you win in the Bingo Golf Flax Lottery. Based on but not equal to the BingoFlax lottery The input is two lists of numbers (positive non-...
Kjetil S's user avatar
  • 5,857
0 votes
9 answers
547 views

Can you decrypt me? (Robbers)

Can you decrypt me? Robbers Find any combination of \$n\$ working chars to change and what they should change into, where \$n\$ is chosen by the cop. You cannot change less than n chars, only exactly \...
Alan Breadel's user avatar
  • 3,823
1 vote
9 answers
584 views

Can you decrypt me? (Cops)

Can you decrypt me? Cops Cops, post obfuscated code that hides a number \$n\$ (n must not be greater than the program length) inside its code. If \$n\$ chars are changed (no additions or deletions), ...
Alan Breadel's user avatar
  • 3,823
5 votes
6 answers
405 views

Find a fraction with the smallest denominator

Input Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$. Output A fraction with the smallest ...
Simd's user avatar
  • 2,760
18 votes
13 answers
1k views

Validate a CPF number

Every Brazilian citizen has a national identification number associated with them, named CPF. This number has 11 digits (formatted as XXX.XXX.XXX-XX) and it's validated by the following (real) ...
enzo's user avatar
  • 1,941
-6 votes
4 answers
279 views

Print "abracadabra" with 7 different alterations

Abracadabra is a magic word. To make it even more magical, let's make several alterations to how it may be written: Change the casing for any subset of characters; for example: ...
anatolyg's user avatar
  • 13.4k
0 votes
0 answers
139 views

Exact Sum of 1/2 to 1/n [duplicate]

Consider the sequence 1/2, 1/3 + 1/2, 1/4 + 1/3 + 1/2, and so on. In mathematical symbols, this is $$S(n)=\sum_{m=2}^{n+1}\frac{1}{m}$$ where S is the function that makes the sequence. Outputting this ...
Jakav's user avatar
  • 315
3 votes
7 answers
388 views

Heart plus diamond is spade-and-club: table puzzle

I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, ...
HelloWorld's user avatar
24 votes
15 answers
3k views

"Perfect" an array

Given an n non-negative integers, how many numbers must be changed so that each number x appears x times? You cannot add or remove elements, only replace them with other numbers. For example: ...
Alan Breadel's user avatar
  • 3,823
9 votes
12 answers
1k views

Counting Collinear Points

Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two ...
vengy's user avatar
  • 1,603
12 votes
5 answers
992 views

Implement a typeface based on a 3x3 bitmap matrix

Input A single-character string containing an uppercase or a lowercase letter from the English alphabet. Alternatively, you may handle only uppercase or only lowercase letters as input. Output This ...
enzo's user avatar
  • 1,941
8 votes
11 answers
2k views

Shortest path to open a letter lock

This quite literally came to me in a dream. A common combination padlock design has letters on the dials so you can set the combination to a word. Unfortunately, I can't read, but I can count. ...
pacman256's user avatar
  • 3,300
1 vote
1 answer
504 views

Find the optimum circle in an infinite grid

Consider an \$n \times n\$ grid of integers which is part of an infinite grid. The top left coordinate of the \$n \times n\$ grid of integers is \$(0, 0)\$. The task is to find a circle which when ...
Simd's user avatar
  • 2,760
11 votes
20 answers
5k views

Calculate 500 digits of e

Write a program to calculate the first 500 digits of the mathematical constant e, meeting the rules below: It cannot include "e", "math.e" or similar e constants, nor may it call ...
Simd's user avatar
  • 2,760
9 votes
3 answers
464 views

Coin sequence probability

Given two strings containing only 0 and 1, decide the probability that first appears earlier as a consecutive substring in an ...
l4m2's user avatar
  • 22.3k
6 votes
7 answers
696 views

Displaying Inky the ghost from Pac-Man using ANSI escape codes

Challenge Display Inky the ghost from Pac-Man using only ANSI escape codes. Here's a text representation of the image ...
vengy's user avatar
  • 1,603
0 votes
0 answers
76 views

Shortest way to print the first 20 numbers in the fibbonacci sequence with python3 [duplicate]

I was wondering if it was possible to make this code even shorter than it already was. f=lambda x:f(x-1)+f(x-2) if x>1 else 1 [print(f(i))for i in range(20)] ...
Eric Pan's user avatar
-2 votes
2 answers
239 views

Forward foo, reverse bar, but avoid dead code [closed]

So simple: Provide some code that outputs foo and with the reversed source outputs bar. But before you come up with something ...
Philippos's user avatar
  • 2,251
10 votes
6 answers
902 views

Unnecessary Fluff

Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task: Take a list of positive integers and a positive integer \$m\$ as input. ...
Command Master's user avatar
15 votes
2 answers
568 views

Construct this point

Given a constructible point \$(x, y) \in \mathbb R^2\$, output the steps required to construct \$(x, y)\$ Constructing a point Consider the following "construction" of a point \$(\alpha, \...
caird coinheringaahin g's user avatar
23 votes
12 answers
6k views

How long is this string, really?

In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to ...
emanresu A's user avatar
  • 37.1k
8 votes
11 answers
1k views

How many Carlitz compositions are there?

OEIS sequence A003242 comprises the numbers of Carlitz compositions for any given positive integer. This is the number of integer partitions of the integer for which no two adjacent parts are equal. ...
Nick Kennedy's user avatar
18 votes
31 answers
2k views

Is this number tetrahedral?

Happy New Year 2024! 2024 is a tetrahedral number. A tetrahedral number is a number that can be represented in the form \$n(n+1)(n+2)/6\$ for some positive integer \$n\$. Or, equivalently, they are ...
alephalpha's user avatar
  • 47.5k
8 votes
7 answers
792 views

Bloons TD 6 Ordered Upgrade Paths

Background The monkeys need your help again organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options as they appear in your ...
qwr's user avatar
  • 12k
6 votes
13 answers
651 views

Output all the different counts of points

Consider a 10 by 10 grid of points at integer coordinates. Given a coordinate (x, y) of one of the points in the grid and a radius r, some of the points in the grid will fall inside a circle of ...
Simd's user avatar
  • 2,760
7 votes
10 answers
675 views

Official Tetris Piece Ordering

Classic Tetris was often a difficult game to play. One problem was that you could only work with the Tetris piece you were given, so if you had an awkward board, it would sometimes be difficult to ...
vxpr's user avatar
  • 71
19 votes
11 answers
1k views

Name the Dutch ancestor

The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent"...
KeizerHarm's user avatar
  • 1,363
13 votes
12 answers
4k views

The worst spaghetti code

Objective Write a full program that works exactly like the flow chart below. Each output, which is an integer, shall be through stdout, followed by a line feed. ...
Dannyu NDos's user avatar
  • 5,639
19 votes
9 answers
965 views

Output an infinitely proportional sequence

In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that: All positive integers are contained infinitely many times within the sequence. ...
emanresu A's user avatar
  • 37.1k
-4 votes
4 answers
243 views

golf a range with modulus and subtraction

if you have a range of numbers with values missing, eg l=[1,2,9,10,99], you can always use modulus and subtraction to make all the numbers in the list cover a ...
guest4308's user avatar
  • 377
7 votes
12 answers
946 views

Can their first appearance happen together?

Given two non-empty 01 strings, check if there is string containing both given strings, and their first appearance end at same position. Test cases: ...
l4m2's user avatar
  • 22.3k
8 votes
6 answers
625 views

How many points this side of the line

Input An integer n and a pair of distinct integer valued (x, y) coordinates on the boundary of the grid. The coordinates are indexed from 1. For example, n=10 and (1,2), (10, 7). The points will ...
Simd's user avatar
  • 2,760
7 votes
3 answers
186 views

Inscribe a maximal regular polygon into a square image

You want to draw a regular polygon but you have limited space! In this challenge, you should draw a polygon with n sides which is as big as possible for a given square container image. I found ...
anatolyg's user avatar
  • 13.4k
10 votes
6 answers
716 views

Convert from Spoken Binary

This is an exact inverse of the question Convert to Spoken Binary. This introduction is copied from there. Introduction In the video the best way to count, binary is proposed as the best system of ...
Tbw's user avatar
  • 1,129
7 votes
11 answers
762 views

Convert tiers between credit rating system

Related: Sort these bond ratings Credit rating agencies assign ratings to bonds according to the credit-worthiness of the issuer. The rating business is mostly controlled by "Big Three" ...
matteo_c's user avatar
  • 6,162
16 votes
6 answers
1k views

Convert to Spoken Binary

Introduction In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give ...
Tbw's user avatar
  • 1,129
12 votes
10 answers
1k views

Format Datetime in 30-Hour Clock Time

Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time. The 30-hour clock time works as: After 6 a.m., it is same as 24-hour ...
tsh's user avatar
  • 34.3k
4 votes
2 answers
310 views

Maximum pentagon sum

For this problem you are given an \$n \times n\$ matrix of integers. The task is to find a pentagon in the matrix with maximum sum. The pentagon must include part (or all) of the x and y axes as two ...
Simd's user avatar
  • 2,760
8 votes
3 answers
432 views

Stably sort N elements in this restricted "cmov" language

The following problem is taken from the real world — but indubitably code-golf! In this puzzle, the programming language is fixed, and your job is to write the most ...
Quuxplusone's user avatar
21 votes
18 answers
6k views

Am I vaccinated?

Disclaimer: the content of this post is not medical information and should not be used for any medical purpose, as it is deliberately oversimplified for the purpose of the challenge. There are several ...
Someone's user avatar
  • 1,520
16 votes
2 answers
273 views

Translate Japanese hiragana into the flick input method

The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels: あかさ たなは まやら 小わ、 ...
bigyihsuan's user avatar
  • 8,978
18 votes
24 answers
2k views

Test whether a sequence is bitonic

You know what a monotonic sequence is: each element is bigger than its predecessor (monotonically rising) or as its successor (monotonically falling). Bitonic means you have two arms of the sequence, ...
Philippos's user avatar
  • 2,251
2 votes
0 answers
160 views

Golf a PSK31 modulator

Given a string of ASCII text as input, encode it in BPSK31 using Varicode. You may either output an audio file in any common format, or play the audio over the device speakers. You may output at any ...
Someone's user avatar
  • 1,520

15 30 50 per page