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, state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

0
votes
0answers
57 views

Find unique, sorted, dot+alphanumeric strings in a file not beginning with a digit/dot, not ending in dot

Given the Ruby script: #!/usr/bin/env ruby NUMS=(0..9).to_a.map{|i|i.to_s} CHARS=(NUMS + ('A'..'Z').to_a + ('a'..'z').to_a + ['.']).join current_memb = nil membs = [] exit 0 if ARGV.size == 0 ...
4
votes
0answers
93 views

Write a Shift Interpreter

Introduction Shift is an esoteric functional programming language I made a couple of years ago, but published today. It is stack-based, but also has automatic currying like Haskell. Specification ...
4
votes
14answers
466 views

Minimum base to count to a string

The Challenge Input: alphanumeric string. You can assume that the string will only contain the characters [0-9A-Z]. This can come from a parameter, command line, or STDIN. Digits are always before ...
23
votes
13answers
1k views

Draw a Random ASCII Art Quilt

For this challenge, an ASCII art quilt will be a block of text 24 characters wide and 18 lines tall, containing the characters =-<>/\ in a quilt-like pattern that is horizontally and vertically ...
10
votes
1answer
329 views

Two-zero-one-five puzzle

Background This puzzle is a variation on the four fours puzzle (itself the topic of a past question). Like that puzzle, the aim is to find mathematical expressions for different whole numbers, using ...
31
votes
3answers
6k views

Hodorize a String

Hodor is a slow-minded but endearing character on the show Game of Thrones (he's in the books as well of course). The only word he ever says is 'hodor'. Surprisingly, despite not having much of a ...
7
votes
0answers
157 views

Meta quine checker

This challenge, if you accept it, is to write three functions or programs A, B, and C: A is a quine that outputs all of A,B and C (which is also the whole content of the code in your submission). B ...
1
vote
1answer
71 views

Write two single line functions to encode and decode base64 [duplicate]

Write two functions of one line each that can encode and decode base64. Use any language you want, but if the language can naturally be converted to a single line (e.g. javascript) then any block of ...
5
votes
1answer
125 views

The Gray area of n-ary codes

Write a program or function that takes a base n and a number x, and returns or outputs the n-ary Gray code of x. Rules n is an integer in the range 2 <= n <= 16. x is an integer in the range ...
17
votes
3answers
313 views

Reaching one's lucky numbers in reputation

A new code-golfer, Joe, just registered to the site. He has 1 reputation but determined to reach all his lucky numbers in reputation exactly. Joe believes in higher powers which will help him to ...
9
votes
2answers
180 views

Tips for golfing in The Shakespeare Programming Language

What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
16
votes
11answers
2k views

Output a Face on a Numbered Cube

Assign the numbers 0 through 7 to the 8 vertices of a cube in any way you want. Exactly one number must be assigned to each vertex. For example, your vertices might be assigned like this: ...
19
votes
1answer
297 views

Optimal Games of Tic Tac Torus

This challenge is about the game Tic Tac Toe, but it's played on a torus. How to play To create the necessary game board, you start out with a regular Tic Tac Toe game board. First fold it into a ...
3
votes
0answers
85 views

Solving a Jigsaw Puzzle!

I've just bought a new jigsaw puzzle but, as a programmer, I'm too lazy to do it by myself. So I've devised a way to encode the pieces, and now I need a way to solve the puzzle itself. Challenge A ...
22
votes
2answers
329 views

Connecting letters

You should write a program or function which receives a block of chars represented as a string and outputs or returns a similar string in which the letters adjacent in the alphabet are connected. A ...
14
votes
17answers
3k views

Calculating (3 + sqrt(5))^n exactly

Today your goal is to find integers a and b given non-negative integer n such that: You should write a program or a function that takes parameter n and outputs a and b in a format of your choice. ...
9
votes
3answers
183 views

IMP: Implicit multiplication parser

Jack likes C programming language, but hates to write expressions like V=a*b*h; to multiply the values. He would like to write V=abh; instead, why should compiler moan about abh symbol being ...
9
votes
3answers
204 views

Wrap-Around Subsequences

Introduction In this challenge, your task is to find generalized subsequences of strings. The subsequences are not necessarily contiguous, and they can also "wrap around" the string, going past its ...
0
votes
0answers
117 views

Generate net puzzles

An acyclical grid is a mapping of an acyclical graph (that is, a tree) where each node has no more than four edges onto a toroidal rectangular grid such that each cell of the grid is occupied by a ...
-1
votes
0answers
58 views

write the shortest code to print a diamond shape [duplicate]

write the shortest code in c++(other languages are also welcome) using only standard library, which will: ask for a value, which will be the size of the diamond shape. print the diamond shape, ...
17
votes
1answer
335 views

Programming Tetris Blocks (Literally)

In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments: The have the names I, J, L, O, S, T, ...
10
votes
10answers
525 views

Cops and Robbers

Everyone always wants to implement Conway's Game of Life. That's boring! Let's do cops and robbers instead! You'll have two teams: the cops and the robbers. Each team has 5 members with 50 health ...
18
votes
9answers
2k views

Generate a pair of integers from a non-negative one

You should write a program or function which takes a non-negative integer N as input and outputs or returns two integers (negative, zero or positive) X and Y. Integers are meant in the mathematical ...
12
votes
2answers
182 views

ASCII L-system renderer

Background An L-system (or Lindenmayer system) is a parallel rewriting system that, among other things, can be easily used to model fractals. This question concerns deterministic, context-free ...
7
votes
3answers
253 views

Nameless to Brainf**k converter

This is inspired by the Brainf*** to tinyBF converter challenge. Brainf**k (which will be henceforth referred to as BF) is a well-known estoric programming language, so I won't go over it too much ...
8
votes
1answer
217 views

Slime Molds Can Count!

Background Slime molds are awesome. If you place them on a surface with food sources, they will spread their tendrils to find the food, after which they form a network of connections between the ...
60
votes
21answers
5k views

Interpreting Fish (no, not that Fish)

Consider these five ASCII art sea creatures: Standard fish: ><> or <>< Speedy fish: >><> or <><< Sturdy fish: ><>> or <<>< Stretchy ...
5
votes
5answers
297 views

Brainf*** to tinyBF converter

You don't need to know these languages to participate. Every necessary info is in this question. You should write a program or function which given a brainfuck (BF) code as input outputs its tinyBF ...
16
votes
15answers
977 views

Generate MathJax for the Golden Ratio Continued Fraction

In anticipation of MathJax being temporarily disabled, the rendered MathJax in this question has been replaced with images. You are still welcome to post answers but you'll have to view the rendered ...
13
votes
6answers
354 views

Out-of-Control Rounding Errors

Background You have recently been hired by a small accounting firm. The world of accounting is somewhat foreign to you, so you're not sure whether you are following all the professional guidelines. ...
29
votes
3answers
2k views

ASCII Doodling: Laser in a Box

Sometimes when I'm doodling, I draw a rectangle, start with a diagonal from one of the corners, and then just trace out a line by "reflecting" it whenever I hit a side of the rectangle. I continue ...
15
votes
1answer
371 views

Prepare to… die?

Background One source of ennui in tabletop role-playing games is dealing with rolls involving many dice. Casting a Disintegration spell may be instantaneous, but rolling and adding together 40 dice ...
9
votes
4answers
317 views

The Sound of Words

People have written many things allowing one thing to be visualized as another. Now I propose being able to translate letters to music! Its your job to write a program that takes a text file and ...
26
votes
11answers
2k views

Official Ruby Inspector

Here is a simple ASCII art ruby: ___ /\_/\ /_/ \_\ \ \_/ / \/_\/ As a jeweler for the ASCII Gemstone Corporation, your job is inspect the newly acquired rubies and leave a note about any ...
-2
votes
1answer
96 views

Compare array of decimal sum of Integers and exact fractional part

Develop a program which takes two arrays of decimal numbers, and compare the sum of whole numbers only and the decimal part. If the sums of the whole numbers are the same, and the decimal parts of ...
7
votes
4answers
388 views

The Partition Problem - Sorting Stacks of Boxes

Just last night I was reading a book which had a chapter on the Partition Problem; the Partition Problem is basically about splitting a set of numbers into two smaller sets of equal size. To ...
8
votes
5answers
308 views

Decide existence of total orderings

In this task, we consider arrays of positive integers such as this: 3 18 321 17 4 4 51 1 293 17 The input comprises a pair of such arrays both of arbitrary, possibly distinct, positive length. ...
-1
votes
4answers
86 views

Detect the main order based on sub-lists [closed]

The question is simple but the answer maybe not! suppose that you have the following lists that all of them are ordered (not consecutive): x = ['one', 'two', 'four'] y = ['two', 'three', 'five'] z ...
14
votes
6answers
645 views

Overlapping circle

You should write a program or function that given an N by N equally spaced square grid and a solid inscribed circle outputs or returns the number of grid squares which are overlapped partially or ...
4
votes
2answers
164 views

Tips for golfing in whitespace

What general tips do you have for golfing in Whitespace? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Whitespace (e.g. "remove ...
11
votes
4answers
514 views

Is the word typeable with keys adjacent to each other?

Before reading this I suggest reading this little puzzle: http://puzzling.stackexchange.com/questions/11408/longest-word-with-adjacent-letters-on-a-keyboard I want you to make a program that takes ...
14
votes
2answers
377 views

Programs to build a rat maze

You have been hired as a research assistant, and asked to create a small program that will build rat mazes. The rat box is always 62x22 and has an entrance (a) and exit (A) for the rat, like this ...
8
votes
4answers
227 views

Row, Column, Diagonal, Block

Write a square block of code that is N characters wide and N characters tall, for some positive integer N. For instance, your N may be 5 and the block look like this: ThisI sMy5B y5Cod eBloc kOkay ...
14
votes
5answers
428 views

Unwise bit operations

I like to golf in dc, but I'm sometimes frustrated because dc doesn't have bitwise operations. Challenge Provide four named functions which implement the equivalent of the c bitwise operations ...
7
votes
1answer
326 views

Code Golf - Write the shortest game of alak

Alak was invented by the mathematician A. K. Dewdney, and described in his 1984 book Planiverse. The rules of Alak are simple: Alak is a two-player game played on a one-dimensional board with ...
3
votes
0answers
106 views

Simulate a Game of Quagmire

Background Many moons ago, in a galaxy much like our own, a young BrainSteel attempted to invent a board game. He believed that he, too, could find an amazingly simple set of rules that would ...
18
votes
19answers
1k views

Find the next 1-sparse binary number

A positive integer N is K-sparse if there are at least K 0s between any two consecutive 1s in its binary representation. So, the number 1010101 is 1-sparse whereas 101101 is not. Your task is to ...
12
votes
2answers
270 views

Find a mirror configuration to match laser destinations

UPDATED SCORING: As this challenge is more difficult than I anticipated, I have adjusted the scoring. A program that can solve a single mirror input is a valid answer. More sophisticated programs get ...
-3
votes
1answer
166 views

Write an evil April Fools file scanner

This is inspired by my python-ideas "new module loader" prank. Your task is to write a cat-like program that does the following: Read the file on disk labeled files. Assume it exists. No error ...
4
votes
2answers
211 views

Remove boxes under preservation of shape

This challenge is specific to languages of the APL family. Although it might be solvable in other languages, please do not expect this to be easy as it depends on some specific concepts of this ...