### Communities

tag:snake search within a tag
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
created:<1w created < 1 week ago
post_type:xxxx type of post
Sandbox

# Posts tagged code-golf

Code golf is a winning criterion, where users seek to solve the challenge in as few bytes of source code as possible.

This tag doesn't have a detailed wiki yet.

259 posts
50%
+0 −0

posted 8d ago by trichoplax‭  ·  edited 7d ago by trichoplax‭

50%
+0 −0

Output the Nth number in the list of Fibonacci numbers that have no consecutive digits. Input A non-negative integer. Output The Nth number in the list of Fibonacci numbers whose base 10 ...

0 answers  ·  posted 7d ago by trichoplax‭

57%
+2 −1

Goal Print the modular multiplicative inverse with a modulus of 65536 (or a higher exponent of 2) for odd numbers 1-97. Example output Print these values (or an extension of them): 1 43691 52...

0 answers  ·  posted 27d ago by H_H‭  ·  edited 21d ago by trichoplax‭

Question code-golf math
50%
+0 −0

posted 1mo ago by H_H‭  ·  edited 24d ago by trichoplax‭

71%
+3 −0

This is a language specific challenge, for HTML only. Your answer is the content of a self contained HTML file, that when opened in a web browser gives a plain black page. Requirements The HTM...

4 answers  ·  posted 1mo ago by trichoplax‭  ·  last activity 1mo ago by Razetime‭

58%
+5 −3

In this challenge, add 2 integers, but if both the integers are 2, output 5. Shortest code in each language wins! Example ungolfed program in Python 3.x def add(x, y): if x == 2 and y == 2: ...

19 answers  ·  posted 2y ago by General Sebast1an‭  ·  last activity 1mo ago by Olin Lathrop‭

Question code-golf math number
71%
+3 −0

Given a list of non-negative integers the function $f$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So f [1,1,2,2,1,3,3] = [1,2,1,2,3,1...

0 answers  ·  posted 2mo ago by WheatWizard‭  ·  edited 2mo ago by trichoplax‭

66%
+2 −0

Given 3 positive integers, indicate whether they are Borromean coprimes. Definition 3 positive integers are called Borromean coprimes if both of the following are true: Their greatest common d...

2 answers  ·  posted 5mo ago by trichoplax‭  ·  last activity 3mo ago by NikNakk‭

Question code-golf math
60%
+1 −0

Find the shortest representation of an integer in generalised Roman numerals. Since there is more than one way to generalise, only the following definition applies to this challenge. Definition T...

1 answer  ·  posted 5mo ago by trichoplax‭  ·  last activity 3mo ago by NikNakk‭

Question code-golf number
71%
+3 −0

You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few ...

2 answers  ·  posted 4mo ago by WheatWizard‭  ·  last activity 3mo ago by justhalf‭

Question code-golf array
66%
+2 −0

Input is a number, you have to decide if it is part of the mandelbrot set or not, after at least 16 iterations. This is done by applying this formula: $z_n = z_{n-1}^2 + c$ repeatedly. $c$ is the ...

1 answer  ·  posted 6mo ago by H_H‭  ·  last activity 4mo ago by Arpad Horvath‭

Question code-golf
66%
+2 −0

Given a single character, which is a valid Roman numeral, output its value. Values There are 7 valid single character Roman numerals, with the following values: Character Value I...

5 answers  ·  posted 5mo ago by trichoplax‭  ·  last activity 4mo ago by H_H‭

Question code-golf
66%
+2 −0

The Universal Crossword has a set of guidelines for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consis...

1 answer  ·  posted 4mo ago by WheatWizard‭  ·  last activity 4mo ago by Razetime‭

60%
+1 −0

posted 1y ago by trichoplax‭  ·  edited 4mo ago by trichoplax‭

50%
+0 −0

posted 1y ago by trichoplax‭  ·  edited 5mo ago by trichoplax‭

50%
+0 −0

posted 5mo ago by trichoplax‭  ·  edited 5mo ago by trichoplax‭

80%
+6 −0

Inspired by this challenge. If anyone has any suggestions for a song title I could use for the challenge title then please leave a comment. Definition We define f(x) for a given integer as the su...

6 answers  ·  posted 2y ago by Shaggy‭  ·  last activity 5mo ago by RubenVerg‭

Question code-golf sequence
60%
+1 −0

posted 5mo ago by trichoplax‭  ·  edited 5mo ago by trichoplax‭

75%
+4 −0

This is a fixed output challenge. It is similar to a standard Kolmogorov complexity challenge, except you get to choose your own fixed output. Given no input, output 55 fruits. You may choose any 5...

5 answers  ·  posted 1y ago by trichoplax‭  ·  last activity 5mo ago by trichoplax‭

50%
+0 −0

posted 1y ago by trichoplax‭  ·  edited 5mo ago by trichoplax‭

60%
+1 −0

posted 6mo ago by H_H‭  ·  edited 6mo ago by trichoplax‭

66%
+2 −0

Simple challenge: Read a byte, swap bit 7 with 0, 6 with 1, 5 with 2 and 4 with 3 and then output the byte. For example the byte 0b1001'1100 would turn into 0b0011'1001. Rules: Shortest code wi...

6 answers  ·  posted 6mo ago by H_H‭  ·  last activity 6mo ago by lovebuny‭

Question code-golf
84%
+9 −0

Looping counter Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. ...

19 answers  ·  posted 2y ago by celtschk‭  ·  last activity 6mo ago by H_H‭

Question code-golf
75%
+4 −0

Given a chess board with some knights on it, say how many squares are neither attacked by a knight nor containing a knight. Input An 8 by 8 grid where each square is either a knight or empty T...

3 answers  ·  posted 1y ago by trichoplax‭  ·  last activity 6mo ago by Karl Knechtel‭

Question code-golf
50%
+0 −0
Sandbox A word suggester [FINALIZED]

posted 8mo ago by trichoplax‭  ·  edited 6mo ago by trichoplax‭

60%
+1 −0

Suggest a word from a word list, given a string. Motivation Imagine typing a word one letter at a time, and seeing a suggested word after each letter is typed. At first the suggested word is simp...

0 answers  ·  posted 6mo ago by trichoplax‭

Question code-golf string list
57%
+2 −1

Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: 2,8,34,144,610,2584,10946,46368,196418,...

0 answers  ·  posted 6mo ago by WheatWizard‭  ·  edited 6mo ago by WheatWizard‭

80%
+6 −0

Many programming languages have the concept of keywords, special syntax items that are not just identifiers reserved by some library, but words reserved by the language itself. The challenge is to...

6 answers  ·  posted 2y ago by Lundin‭  ·  last activity 7mo ago by H_H‭

Question code-golf
71%
+3 −0

Given a string of printable ASCII characters, convert them all to lowercase, except not just the letters. ASCII characters that are letters have a bit in their binary representation that is 0 for ...

7 answers  ·  posted 1y ago by trichoplax‭  ·  edited 7mo ago by trichoplax‭

86%
+11 −0

Your goal is to reverse an ascii string. Given a (optionally newline or null terminated) input, output your input in reverse order, optionally followed by a newline. Terminate afterward. Function...

32 answers  ·  posted 3y ago by moony‭  ·  last activity 7mo ago by qwr‭

Question code-golf
60%
+1 −0

At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out. When we order the rolls we draw up a layout document which...

0 answers  ·  posted 7mo ago by WheatWizard‭

Question code-golf
71%
+3 −0

Given a sequence of lower case letters, sort them into order of height. Heights The heights of letters are dependent on font, so for this challenge the height order to be used is as defined below...

5 answers  ·  posted 1y ago by trichoplax‭  ·  last activity 7mo ago by Taeir‭

71%
+3 −0

Given a hinged tetromino, give it a unique, consistent label independent of location, rotation, and reflection. Tetrominoes A tetromino is a connected subset of the square tiling, composed of 4 s...

2 answers  ·  posted 8mo ago by trichoplax‭  ·  last activity 7mo ago by RubenVerg‭

66%
+2 −0

Given a number $n \geq 3$ as input output the smallest number $k$ such that the modular residues of $k$ by the first $n$ primes is exactly $\{-1,0,1\}$. That is there is a prime in the first $n$ p...

0 answers  ·  posted 8mo ago by WheatWizard‭  ·  edited 8mo ago by WheatWizard‭

75%
+4 −0

The probability of rolling every number from 1 to 6 with $N$ six-sided dice. Input A positive integer $N$. Your code must work for inputs up to and including 10, but may crash, error, or give ...

4 answers  ·  posted 8mo ago by trichoplax‭  ·  last activity 8mo ago by RubenVerg‭

Question code-golf math dice
66%
+2 −0

You roll $N$ six-sided dice simultaneously. Your score is the highest number rolled. If you play this game many times, what is the expected value (mean) of your score? Input A positive integer ...

2 answers  ·  posted 8mo ago by trichoplax‭  ·  last activity 8mo ago by RubenVerg‭

Question code-golf math dice
60%
+1 −0

posted 8mo ago by trichoplax‭  ·  edited 8mo ago by trichoplax‭

81%
+7 −0

Challenge This is a simple randomness challenge: Given a non-negative integer $n$, and positive integer $m$, simulate rolling and summing the results of $n$ fair dice, each of which have $m$ sides...

10 answers  ·  posted 2y ago by Moshi‭  ·  last activity 8mo ago by RubenVerg‭

Question code-golf random
66%
+2 −0

posted 8mo ago by trichoplax‭  ·  edited 8mo ago by trichoplax‭

66%
+2 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

50%
+0 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

66%
+2 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

60%
+1 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

60%
+1 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

66%
+2 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

60%
+1 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

60%
+1 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

75%
+4 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

60%
+1 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭

71%
+3 −0

posted 2y ago by General Sebast1an‭  ·  edited 8mo ago by trichoplax‭