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
11
votes
29answers
5k views

Count All Possible Unique Combinations of Letters in a Word

You are given a string, which will contain ordinary a-z characters. (You can assume this will always be the case in any test, and assume that all letters will be lowercase as well). You must ...
21
votes
6answers
974 views

Subtract the Folded Matrix

Challenge: Given an NxN matrix where \$N\geq2\$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values. The eight folding options are: left-to-right; right-to-...
33
votes
8answers
6k views

Cut the gold chain

A traveler needs to stay for n days in a hotel outside town. He is out of cash and his credit card is expired. But he has a gold chain with n links. The rule in this hotel is that residents should ...
12
votes
7answers
382 views

Print the total length of all “quoted” characters

Rules In this challenge, I'm going to redefine the definition of "quotes" a bit. Quotation marks (AKA quotes) are any identical characters used in pairs in various writing systems to set off direct ...
11
votes
3answers
2k views

Print 'A' 1000 times with BrainFuck

What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ? My approach is: set 'A' to p[0] set 255 to p[1] to display 255 'A', 3 times set 235 to p[1] to display 235 'A' This ...
8
votes
2answers
187 views

Reroute the Path

Given a grid of directions and a start and end position, determine the minimum number of substitutions in the direction grid that needs to be made to complete the path between the two points. The grid ...
29
votes
4answers
2k views

Print the new site header

The new site header has some bits of source code from various questions as the background. Here are the first 3 lines: ...
21
votes
8answers
1k views

Fill the maze with a wall-following Snake until it gets stuck

Make a snake fill any maze (until it gets stuck). The snake The snake starts at a given starting point, pointing EAST. It moves by always having a wall or a part of its body immediately to the LEFT ...
17
votes
31answers
3k views

First occurrence in the Sixers sequence

The Sixers sequence is a name that can be given to sequence A087409. I learned about this sequence in a Numberphile video, and it can be constructed as follows: First, take the multiples of 6, ...
-3
votes
1answer
132 views

Pandemic Outbreak Calculator [closed]

In the board game Pandemic, an outbreak occurs when a city contains more than 3 disease cubes. When the outbreak occurs, any disease cubes in the city in excess of 3 are removed, and each city ...
-2
votes
14answers
440 views

FizzBuzz but time-based

Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print ...
-7
votes
10answers
211 views

The year counter is here [closed]

Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program ...
8
votes
1answer
269 views

Partition and Restructure

Given two contiguous shapes of the same area, determine the optimal way to divide the first shape into a minimum number of contiguous segments such that they can be rearranged to form the second shape....
3
votes
15answers
577 views

The anti-narcissist

The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this. Create a program that, ...
49
votes
29answers
10k views

Print the phrase “And she said, 'But that's his.'” using only the alphabet

Print the phrase And she said, 'But that's his.' using only the following characters: ...
57
votes
11answers
8k views

New Site Design!

Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design! (It's November now) So, to celebrate, let's make a program that ...
12
votes
2answers
396 views

Who can escape the Nonary Game?

The Nonary Game is a fictional game played in the video game trilogy of the same name. Your goal is to find how many players (at best) can escape a given game, in as few bytes of code as possible. ...
41
votes
29answers
5k views

Nth term of Van Eck Sequence

Output the Nth term of the Van Eck Sequence. Van Eck Sequence is defined as: Starts with 0. If the last term is the first occurrence of that term the next term is 0. If the last term has occurred ...
0
votes
2answers
196 views

Alphabet without the alphabet [duplicate]

You are tasked with displaying the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and only that, except for trailing newlines if they're unavoidable. You must not output any homoglyphic characters like Cyrillic ...
55
votes
10answers
5k views

Parsing text written the millitext font

Reading the text of the millitext font There is a font here that fits each character into a single, 1x5 pixel block. It does this (assuming you're using an LCD screen) by using the RGB channels of ...
45
votes
45answers
13k views

Print “N NE E SE S SW W NW”

This seems almost trivial, but since after some effort I was not able to beat the literal solution in J, I thought it might make a decent challenge (though, to be clear, this is not a J-specific ...
17
votes
17answers
4k views

That's not my X, its Y is too Z

This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter. In each book a mouse (illustrated, but not part ...
3
votes
3answers
163 views

Find longest consecutive characters in 2D array

Challenge Given a 2D array, find the length and direction of all the longest consecutive characters. If there are ties, output every possible winning combination in any order, (winners can overlap ...
23
votes
24answers
2k views

Make Gimbap cutter

Gimbap(김밥) is Korean food, somewhat looks like sushi roll. Here is Korean emoticon represent Gimbap : @)))))))))) Your quest is make ASCII Gimbap cutter. Rule ...
13
votes
38answers
4k views

ASCII Meme Arrow Generator

Specifications Given a number n, output an ASCII "meme arrow" (greater-than symbol, >) of size ...
0
votes
1answer
155 views

Find 77 7-letter Magic Words [closed]

A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example: ...
6
votes
1answer
190 views

Insert commas into numbers [closed]

Write a program that reads a string, and inserts commas to divide large numbers in groups of 3. i.e. 10000 => 10,000. It should 'fix' incorrectly formatted numbers as described below. It must work ...
2
votes
1answer
115 views

Shortest Gomoku (5 in a row) implementation [closed]

I suspect Gomoku may be one of the simplest games to implement in code. https://en.wikipedia.org/wiki/Gomoku The game is this: players BLACK and WHITE take turns putting down black and white stones. ...
92
votes
12answers
8k views

Proving that a Russian cryptographic standard is too structured

The aim of this challenge is to find an impossibly short implementation of the following function p, in the langage of your choosing. Here is C code implementing it ...
1
vote
1answer
190 views

Implement the EnScript CHS command [closed]

JonoCode9374 had almost completely implemented my language EnScript except for the CHS command. I was impatient of waiting for them to implement this command, so I chose to put this question here. ...
3
votes
1answer
209 views

Multiplication in the Steenrod Algebra

Here's yet another Steenrod algebra question. Summary of the algorithm: I have a procedure that replaces a list of positive integers with a list of lists of positive integers. You need to repeatedly ...
23
votes
17answers
3k views

Who won a Game of Bar Dice?

Challenge Bar Dice is a simple game played in a Bar with Dice (hence the name). You roll 5 six-sided dice and attempt to make the best hand. Scoring is based on amassing the largest number of ...
1
vote
3answers
271 views

Manhattan Directions Code Golf

This code golf challenge is to show directions through numbers. When the user enters a number, then that means a direction change as follows: ...
16
votes
11answers
1k views

Generate basis elements of the Steenrod algebra

The Steenrod algebra is an important algebra that comes up in algebraic topology. The Steenrod algebra is generated by operators called "Steenrod squares," one exists for each positive integer i. ...
11
votes
6answers
855 views

Group Integers by Originality

Introduction: I collect twisty puzzles. Most twisty puzzles are produced and sold by Chinese companies. Most well-known companies ask permission from puzzle designers to produce their designs and ...
21
votes
21answers
2k views

Overlapping String-Blocks

Challenge: Given a list of multi-line strings, overlap them (in the top-left) and output the result. Example: Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"] ...
24
votes
9answers
2k views

Generate a Graeco-Latin square

disclaimer: I'm not aware of any non-bruteforce solutions A Graeco-Latin square is, for two sets of same length \$n\$, a \$n \times n\$ arrangement of cells, each containing a unique (across the ...
29
votes
20answers
3k views

Implement Homestuck's Catenative Doomsday Dice Cascader

Challenge I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short ...
14
votes
31answers
1k views

Incremental Ranges!

Your task is to, given two positive integers, \$x\$ and \$n\$, return the first \$x\$ numbers in the incremental ranges sequence. The incremental range sequence first generates a range from one to \$...
20
votes
22answers
2k views

Rotated Position of Integers

Challenge: Input: A sorted list of positive integers. Output: The amount of integers which are still at the exact same index, after rotating the digits in each integer its index amount of times ...
31
votes
9answers
3k views

The qvolume of an integer

It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any ...
8
votes
4answers
609 views

Leading and Suffering Numbers

Introduction: In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij", as we ...
7
votes
5answers
2k views

Using the smallest number of bytes of code, write a program that produces this image

Context: Gynvael Coldwind, a famous security researcher, published a contest in his blog post (that is now complete). The goal was similar to the one described here, but with certain restrictions ...
3
votes
5answers
189 views

Is there are exactly one partition, given length of partition and maximum number?

It is Restricted Integer Partitions, but with maximum number. Question Three positive integers are given. First number is number to divide, second number is length of partition, and third number is ...
-2
votes
11answers
207 views

Convert alphanumeric (base-36) sentences into hexadecimal (base-16) sentences

I use "sentence" here loosely to mean "any sequence of words separated by spaces" and "words" to mean "sequences of alphanumeric (hexatrigesimal) characters unseparated by spaces". Conversion is from ...
14
votes
4answers
370 views

Convert between Korean two-set keyboard and qwerty keyboard

Introduction It is somewhat like DVORAK Keyboard layout , but MUCH harder. Let's talk about the Korean keyboard first. As you can see in Wikipedia, there is a Kor/Eng key to change between Korean ...
-3
votes
10answers
374 views

Point out a string character [closed]

Introduction In many programming languages, within syntax exceptions, it is often pointed out to the programmer exactly which character or line is the culprit. This challenge will be a bit of a ...
30
votes
32answers
3k views

Construct a word ladder

Given a list of at least two words (made only of lowercase letters), construct and display an ASCII ladder of the words by alternating the direction of writing first to the right, then to the left, ...
34
votes
18answers
2k views

Count rotary dial pulses in a phone number (including letters)

In your grandparents' day, dialing a phone number was done with a rotary dial like this: To dial each digit, put your finger in the corresponding hole, pull it over to the finger stop, and release it....
-4
votes
2answers
171 views

Random Cake Bake

Warning: This is a bit lengthy I have decided to build my own random function I call it "Random Cake" This function should get an integer value between 0 and 99999 Ingredients ...