Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
12,337 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
6
votes
5
answers
64
views
Peg solitaire starting position
Write a program/function to output a peg solitaire board in its starting position:
●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる ●くろまる ●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる ○しろまる ●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる ●くろまる ●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる
●くろまる ●くろまる ●くろまる
...
13
votes
17
answers
444
views
Find the first relabeling
I had this problem come up for me recently and I thought it would make a fun code-golf.
You will receive as input a list of positive integers. e.g.
...
8
votes
6
answers
651
views
How does the NSDT program end?
Challenge:
NSDT is like a calculus model invented by me that contains only 4 commands and grouping. Your task is to check in which way the program ends. The program is read from left to right. There ...
3
votes
4
answers
672
views
Emoji-art sunburst
Write a program or function to output an N x N sunburst image made of red, orange and yellow emoji icons.
For N=40, it should look roughly like this:
...
16
votes
9
answers
1k
views
Output the colour code of a given resistance
Should be relatively easy to do, given an input of a resistance (in ohms) and a tolerance (%), output the colour codes for a 4 band resistor, left to right. Input will always be a valid ohm value and %...
12
votes
2
answers
200
views
Autocomplete a word at the cursor position
You will be given a block of text and a cursor position at the end of a possibly incomplete word.
You must output a suggestion for what this word (let's call it w) ...
Ted's user avatar
- 2,055
12
votes
15
answers
1k
views
Sum of Neighbours in a 2D Grid
This is the 2D version of Sum of neighbours: Given a 2D grid of integers, output a grid of the same size where each cell contains the sum of the values of its orthogonal and diagonal neighbors (up to ...
12
votes
8
answers
1k
views
Exit a pinball board
You will be given a pinball board with a ball on it. Determine where the ball will exit the board. The ball will fall straight down, unless obstructed by a left or right bumper, in which case it will ...
-4
votes
3
answers
265
views
Render a polygon...in ASCII [closed]
Given the anti-clockwise points of a properly formed, non-self-intersecting, not-necessarily-convex polygon, render it as a filled ASCII art polygon.
Input
A series of at least 3 (x,y) pairs ...
0
votes
0
answers
179
views
Code Golfing in Bash
I'm pretty new to code golfing, but I recently came across a guy on Kattis that consistently has exactly 5 character Bash solutions for some problems. For example, here is a leaderboard showing his 5 ...
12
votes
15
answers
2k
views
Unroll the loop!
A loop is a rectangle of text like this:
hgf
ile
jkd
abc
To unroll it, you start at the bottom left, and proceed to the right, spiralling anti-clockwise in towards ...
21
votes
10
answers
2k
views
"e" ejects the letters. Re-enter them
Overview
I have a sample of 10 quotes. You will receive as input to your program one of these quotes, however all the vowels (aeiou) will be replaced with the ...
17
votes
6
answers
796
views
Decompose a palindromic polynomial
A palindromic polynomial is a polynomial whose list of coefficients is a palindrome. For example, the polynomial \$p(x) = x^4 + 2x^3 + 3x^2 + 2x + 1\$ is palindromic because its coefficients are \$[1, ...
2
votes
4
answers
541
views
Program Generator: Print a Paragraph
Objective
Your challenge is to write a program that, given a paragraph from a book, will output another program that prints out that paragraph. (See my example program in an answer)
Scoring
The link ...
19
votes
24
answers
2k
views
Add Y to X to get a palindrome
Given X>0, return the smallest Y>=0 such that X+Y is a palindrome. Code golf.
Tests:
5 => 0
14 => 8
200 => 2
819 => 9
1100 => 11
1122 => 99