Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, please state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

Filter by
Sorted by
Tagged with
18
votes
1answer
284 views

Complete the grid-filling meander

A grid-filling meander is a closed path that visits every cell of a square \$N \times N\$ grid at least once, never crossing any edge between adjacent cells more than once and never crossing itself. ...
4
votes
2answers
225 views

Regex golf and ccTLDs, hooray!

Write a regex that only matches valid country code top level domains (ccTLDs). Your regex must match both the domains with the dot and without the dot (it must match tv and .tv). Any domain that is ...
-3
votes
10answers
427 views

Decode an URL string

Challenge I think everyone of us heard of URL encoding mechanism - it's basically everywhere. Given an URLEncoded string on stdin, decode it, and output the decoded form to stdout. The encoding is ...
7
votes
2answers
361 views

Formula One Strategist

Introduction Formula One is a complex sport and as with complex sports, strategy is very important.Some teams will manage better strategy than others and those teams will often win the races. After ...
52
votes
115answers
10k views

“DDoouubbllee ssppeeaakk!!”

Super simple challenge today, or is it? I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way... Double speak is when each and every character in a ...
28
votes
4answers
2k views

Move arrows along a contour

Sandboxed Given a set of closed non-overlapping 2d contours (separated by at least one space even on diagonals) with arrows oriented consistently in the same clockwise or counter-clockwise direction (...
-4
votes
4answers
232 views

Shortest way to get a TypeError

It's simple, simply write the shortest code to raise a TypeError. In Python you can do: raise TypeError However it should be ...
11
votes
5answers
777 views

Does this addition pyramid puzzle have a unique solution?

Given an addition pyramid \$P\$, determine whether it can be solved. An addition pyramid consists of layers, each having one number less than the one below it. Layer \$i\$ is symbolized as \$P_i\$. \$...
11
votes
6answers
474 views

Virus vs Antidotes code golf [closed]

There is a rectangular 2D array containing viruses denoted by 'v', antidote1 denoted by 'a', and antidote2 denoted by 'b' (there are no values other than 'v', 'a' and 'b'). Antidote1 can kill ...
17
votes
12answers
2k views

Composing fill in the blanks

Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of ...
29
votes
16answers
6k views

To find islands of 1 and 0 in matrix

Given a two dimensional matrix of 0 and 1s. Find the number of island for 1s and 0s where neighbours are only in the horizontal and vertical. ...
5
votes
19answers
500 views

Get delta of days by current hour and added delta of days

Inputs: current hour: from 0 to 23 (inclusive) delta of hours: [current hour] + ...
23
votes
22answers
2k views

Invert Some Switches on a Switchboard

Inspired by this challenge. Goal: Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes. A switchboard is made up of some number of switches (...
22
votes
43answers
4k views

Character Frequency in a String [duplicate]

Given a string of printable ASCII, output the frequency of each character in that string. The Challenge Input is given as a string of printable ASCII characters (decimal ...
27
votes
28answers
4k views

Inverse Colombian Function

Let's define a sequence: The n digit summing sequence (n-DSS) is a sequence that starts with n. If the last number was k, then the next number is k + digit-sum(k). Here are the first few n-DSS: ...
2
votes
0answers
207 views

What are some of the most character-efficient programming languages? [closed]

Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character? I was thinking of APL and J but ...
32
votes
23answers
4k views

Brute-force the switchboard

The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, ...
6
votes
7answers
503 views

Battle of the Jimmys

/o\ Jimmy has been receiving a lot of attention on this site recently and it has caused Jimmy to get a little stressed. The bodybuilder Jimmys ...
4
votes
2answers
162 views

How many pages have issues? [duplicate]

At work I've been acting as quality control on our public documents, to make sure that they are WCAG 2.0 compliant. Given the length of some of these documents there tend to be issues, and so I record ...
0
votes
0answers
69 views

Print everything which a regular expression matches [duplicate]

Modern regular expressions (regexes) have many features (\d, {n,m}, \1, etc.), but to define ...
22
votes
17answers
2k views

Inscriptio Labyrinthica

In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this). The first letter is found in the very middle, and from there one reads by ...
11
votes
1answer
238 views

Draw Recamán's sequence with ASCII

Recamán's sequence (A005132) is a mathematical sequence, defined as such: $$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\ A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not ...
66
votes
12answers
11k views

Operation Unz̖̬̜̺̬a͇͖̯͔͉l̟̭g͕̝̼͇͓̪͍o̬̝͍̹̻

I'm sure you're all familiar with Z̃͗̇̚͟Ḁ̬̹̈̊̂̏̚L̜̼͊ͣ̈́̿̚G̱̮ͩ̃͑̆ͤ̂̚Õ̷͇͉̺̜̲ͩ́ͪͬͦ͐ ̪̀ͤͨ͛̍̈͢ĝ̭͇̻̊ͮ̾͂e̬̤͔̩̋ͮ̊̈ͭ̓̃n͖͎̘̭̯̳͎͒͂̏̃̾ͯe͕̖̋ͧ͑ͪ̑r̛ͩa̴͕̥̺̺̫̾ͭ͂ͥ̄ͧ͆t͍̻̘̆o͓̥ͤͫ̃̈̂r̹̤͇̰̻̯̐ͮ̈́ͦ͂͞. If not, you can play ...
2
votes
0answers
213 views

Another version of “The Bridge and Torch Problem”

The idea for this code golf puzzle is from link: The Bridge and Torch Problem The inspiration for this code golf puzzle is the Bridge and Torch problem, in which d people at the start of a bridge ...
9
votes
17answers
1k views

Alphanumeric Line and Curve Counting

Given an input string, write a program that outputs the total number of lines and curves it has. The Challenge Take input from STDIN, or any other input method. ...
9
votes
16answers
1k views

MQTT subscription topic match

Background MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: ...
24
votes
21answers
5k views

A scene of Jimmy diversity

As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a ...
19
votes
6answers
2k views

Using two linked programs, output ordinal numbers up to n

...Ordinal numbers (or ordinal numerals) are words representing position or rank in a sequential order. From Wikipedia. Your task is, using 2 separate programs (of which can be made from 2 different ...
38
votes
13answers
6k views

Too many spies!

You are fighting an extensive network of enemy spies. You know that each spy has at least one (sometimes multiple) fake identities they like to use. You'd really like to know how many spies you're ...
21
votes
5answers
447 views

How long's left?

How long's left? Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the ...
5
votes
4answers
414 views

Find X,Y,Z coordinates from index

Introduction I began studying the Collatz Conjecture And noticed these patterns; 0,1,2,2,3,3...A055086, and 0,1,2,0,3,1...A082375, in the numbers that go to 1 in one odd step, 5,10,20,21,40,42......
-6
votes
3answers
296 views

Find the hardest OEIS sequence to golf!

Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully ...
28
votes
10answers
1k views

There's an echo in my array… echo in my array… my array

Help! I seem to have an annoying echo in some of my arrays, and I'd like to get rid of it. When this occurs, the original array repeats itself somewhere in the middle causing the values to be added ...
21
votes
17answers
3k views

Matchmaker, Matchmaker, make me a match

(we won't be finding a Find or catching a tryCatch, though) This is part two of a multi-part series of implementing some ...
11
votes
5answers
367 views

Reverse your code, reverse the OEIS

The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of ...
11
votes
8answers
626 views

Jimmy needs a new pair of shoes!

Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on! Your job is to take a string containing multiple Jimmys and give them ...
4
votes
3answers
173 views

Tips for golfing in Grass

What general tips do you have for golfing in Grass? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Grass (e.g. "remove no-op ...
23
votes
14answers
3k views

Do you know your 'KVZ's?

Concept In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune? Rules Swapping Let's just assume the ...
2
votes
0answers
65 views

Mutation chain generator [duplicate]

Given a start word and a target word, print the "mutation chain" that starts at the start word and ends at the target word. You may assume both words are lowercase and only have alphabetic characters....
9
votes
28answers
1k views

String to Bit Transition

Task Given an input string of one or more ASCII characters which codepoints are between 0 and 128 (exclusive), do the following: Convert each character into its 7-bit ASCII code (if the ASCII code ...
14
votes
9answers
967 views

Fivenum and a little bit

(a paradox, a paradox, a most ingenious paradox) This is the first part of a multipart series inspired by different R functions. The Task Given a dataset \$D\$ of positive integers, I need you to ...
59
votes
93answers
10k views

Print the last, middle and first character of your code

The challenge is simple: Print the last, middle, and first character of your program's source code, in that order. The middle character is defined as follows, assuming a source length of ...
1
vote
14answers
190 views

Reverse Cat Programme [duplicate]

Simple problem, create a programme that takes one input, and the outputs that input in reverse. Some test cases are [input -> output]: ...
11
votes
24answers
3k views

Shortest hex dumping program

Challenge Write a console program to display every byte of a file in hexadecimal (0-9  ...
-4
votes
4answers
103 views

One square root function for unsigned numbers [closed]

One square root function for unsigned numbers Write the function sqrti(x) that from one not negative integer number x, it returns the integer square root of that number truncate to the 0 digit, so ...
25
votes
55answers
6k views

Integer Lists of Noah

Introduction: I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The ...
-1
votes
3answers
217 views

Find all a, b, c, d, e, such that a + b + c + d + e = 1000 with no more than 3 loops [closed]

The rule is: a, b, c, d, e is an integer from 0 to 1000, no relation between ...
10
votes
55answers
6k views

Swapping “Good” and “Bad”

Challenge Description: Write a program that asks the user for input. The user will enter Good or Bad. You do not have to ...
2
votes
3answers
114 views

Sum of multiples of powers of ten of an integer [duplicate]

Write a function to produce, for a non-negative integer, a string containing a sum of terms according to the following: ...
17
votes
23answers
7k views

Can Jimmy hang on his rope?

Yet another Jimmy challenge by his original father. See these other lovely challenges. As you all know, recently we've been seeing challenges related to Jimmy on platforms. Now, Jimmy is an acrobat ...