# Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

11,957 questions
Filter by
Sorted by
Tagged with
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-...
• 5,887
409 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 ...
• 2,896
2k 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) ...
• 2,083
286 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: ...
• 13.5k
1 vote
144 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 ...
• 335
411 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, ...
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: ...
• 4,163
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 ...
• 2,163
1k 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 ...
• 2,083
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. ...
• 3,750
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 ...
• 2,896
473 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 ...
• 23.8k
725 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 ...
• 2,163
85 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)] ...
920 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. ...
• 10.5k