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

5
votes
0answers
67 views

ASCII Art of the Day #3 - Chinese Shrines

In today's episode of AAOD, we are going to construct a Chinese Shrine of varying heights. Consider the following examples for height (N) 1 to 6 N = 1: . | . ]#[ . ...
12
votes
4answers
312 views

Sum in each dimension

You are given a multi-dimensional array of integers. Each dimension has a fixed size (so that it would be always rectangular if it is 2D). Your program should calculate the sums in each dimension and ...
-2
votes
4answers
105 views

Return every N-th word of a string

Your goal is to write a program that, given a number N and a string as input, will return a string containing every Nth word of the original string, starting from the first word. Sample ...
10
votes
1answer
129 views

Find the Fenceposts

Background An atomic bomb has exploded near the fencepost factory! Since fenceposts are essential for the survival of our civilization, we must rescue as many as possible. We are sending ...
12
votes
8answers
504 views

Formatting a Lisp-like Syntax

Background (Based on a true, heart-wrenching story) In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made ...
10
votes
1answer
130 views

Scale up a Diamond Tiling

Any regular hexagon can be tiled with diamonds, for instance like so: ______ /_/_/\_\ /_/\_\/\_\ /\_\/_/\/_/\ \/_/\_\/_/\/ \_\/_/\_\/ \_\_\/_/ We'll consider the above a tiling of size 1 ...
7
votes
19answers
860 views

Count the number of vowels in each word of a string

This is a rather easy challenge. Challenge Input will contain a string (not null or empty) of maximum length 100. Output the number of vowels in each word of the string, seperated by spaces. Rules ...
18
votes
18answers
2k views

Caesar equivalence

Two strings are "Caesar equivalent" if the distance (counting up) between the corresponding characters are the same. Yes, I made this term up. Here's an example: "Abc" and "Cde" are equivalent ...
24
votes
4answers
1k views

ASCII Art of the Day #2 - Flow Snakes

I came across this really nice snow-flake like ASCII fractal by Michael Naylor [citation needed but not found]. Just like a fractal, it grows exponentially in size with each order/iteration. Below are ...
7
votes
13answers
972 views

Stripping off extra spaces from a string

You are given a string. Output the string with one space per words. Challenge Input will be a string (not null or empty), surrounded with quotes(") sent via the stdin. Remove leading and trailing ...
30
votes
10answers
3k views

ASCII Art of the Day #1 - Double Knot

Write a full program or a function that takes a positive integer N as input via STDIN/command line/ARGV or function arguments and prints an ASCII double knot corresponding to the N to STDOUT. The ...
34
votes
20answers
2k views

Check if words are isomorphs

Two words are isomorphs if they have the same pattern of letter repetitions. For example, both ESTATE and DUELED have pattern abcdca ESTATE DUELED abcdca because letters 1 and 6 are the same, ...
5
votes
0answers
145 views

HappyCube Puzzle Solver

This challenge is inspired by a puzzle I played, consisting of foam pieces like these: which have to be assembled into 3D cubes, like these: The puzzle pieces can be viewed as grids of 5 * 5 ...
6
votes
2answers
213 views

Remove the mininum sum seam from an array

The seam carving algorithm, or a more complex version of it, is used for content-aware image resizing in various graphics programs and libraries. Let's golf it! Your input will be a rectangular two ...
8
votes
0answers
110 views

Given a table, place in the chairs

Challenge You will be given a table as input, drawn with ASCII | and _. Your task is to set the chairs around it. Example Input: ____ | | | | | | | | |____| Output: _^_^_ < ...
11
votes
12answers
2k views

QuickGolf - Barry the messy developer #2

This is a follow-up of QuickGolf - Ignore the noise #1 the only problem being that Barry has made things even worse for us. Lets see what happened Update I've added code to create random ...
15
votes
2answers
376 views

Selectively murder positive integers

Introduction Arithmetic Gaol is a special facility that incarcerates positive integers. However, recently, the positive integers have been trying to escape. Therefore the wardens have decided to, um, ...
11
votes
0answers
113 views

Schedule a 4-way stop

A bunch of cars are lined up at a 4-way stop sign waiting to proceed. Everyone is confused about who gets to go next, who is going which way, etc. Clearly suboptimal. Your job is to schedule the ...
9
votes
7answers
314 views

Find the longest musical substring

A musical string is any string that can be played on a piano keyboard. For those of us who weren't forced to learn the piano as kids, here is what the keyboard looks like. So the string feed a ...
-1
votes
0answers
14 views

Help with shortening this Haskell combinations snipped [migrated]

I was happy with my shell script that needed to generate alphanumeric combinations of length N (in this case, 3) for i in {a..z}{a..z}{a..z}; do ... Now I became less happy when I needed ...
4
votes
4answers
217 views

Most concise way to fold tree structures

Background (F#) Let there be trees: type Tree<'T> = Node of 'T * Tree<'T> list Now lets fold them nicely with a function called... foldTree f:('a -> 'b -> 'c) -> g:('c -> ...
-2
votes
1answer
60 views

Generate a Pallette for an Image [duplicate]

This is a successor to my previous Code Golf challenge, which may be found here. This time, you are trying to determine what the contents of colors.txt should be. Your task is to take from the input ...
9
votes
2answers
235 views

Finding Poly Nemo!

Oh no! Nemo, our small clown fish is lost in this ASCII ocean and his dad Marlin is trying to find him. Your task is to get Marlin to Nemo safely. But beware, we have a feeding frenzy Bruce on the ...
13
votes
14answers
2k views

QuickGolf - Ignore the noise #1

Instructions Barry is a not so good backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your ...
15
votes
12answers
731 views

Extract a string from a given string

You are given a string and two characters. You have to print the string between these characters from the string. Input Input will first contain a string (not empty or null). In the next line, there ...
19
votes
15answers
2k views

Generalised Array Riffle

A simple golf to start the week! You're given three arrays: the base array B, the value array V and the index array I. You should produce another array where the values from V are inserted into B at ...
8
votes
1answer
283 views

ASCII art square affine fractals

Write the smallest program you can to create affine fractals. You may use any method you feel like that generates the same results as the rules below. You don't have to use any ideas from the ...
15
votes
6answers
212 views

Given an input, move it along the keyboard by N characters

The Challenge: Given any input that can be typed on a keyboard, move the text along by N chars. Here is the QWERTY keyboard to be used. You can ignore the modifier keys (Shift, Caps, Enter, Delete ...
18
votes
6answers
1k views

Thorough though Thoreau threw, Troll throws through tough troughs

To each of these nine confusingly similar words, assign a number 1-9 in any way you like: though through thorough Thoreau throw threw trough tough troll Write a program that takes in a string. If ...
32
votes
12answers
3k views

Me Want Honeycomb

Write the shortest program that prints this ASCII art section of a hexagonal tiling or honeycomb: __ __/ \__ __/ \__/ \__ / \__/ \__/ \ \__/ \__/ \__/ / \__/ \__/ \ \__/ \__/ ...
5
votes
4answers
286 views

Approximate a given image using only colors from a given list

The Specs Your program must read the image from one file and write the results to another file, the name of at least the first of which should be taken from the input You may accept and return any ...
9
votes
1answer
77 views

Determine whether rational coordinates are in the right Sierpinski triangle

The Sierpinski triangle is a set of points on the plane which is constructed by starting with a single triangle and repeatedly splitting all triangles into four congruent triangles and removing the ...
8
votes
12answers
475 views

Mixing characters in a string

You have to write a function/program that takes input via the stdin/command-line arguments/function arguments, mixes up characters in a string, and then output the final string via the stdout. Input ...
6
votes
0answers
63 views

Normalise my decision map

Write a function or program that processes a block of text and returns the new text. Smallest valid program wins. Each line in the block of text will have the following format: 12:34,56 The first ...
4
votes
1answer
160 views

Plus one sheep minus one sheep

Once upon a time long long ago...when there was no money or stocks yet, people were trading sheep. Even before (but close to) the invention of abacus, the great-grandfather of Warren Buffet decided it ...
9
votes
16answers
601 views

QuickGolf - Heads or Tails

Instructions Given an unknown input string i with a value of either heads or tails, return 1 for heads or -1 for tails with the shortest code. Sample not golfed code (55b): if(i == "heads"){ ...
9
votes
1answer
144 views

We're Spiralling out of control, Doctor!

The Doctor, in trying to escape from the Dalek forces has decided to send them in a spin by traveling in various pockets of space in a spiral motion. Depending on the nature of the available ...
8
votes
7answers
249 views

Detecting anagrams within a Parent String

Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, or an anagram of the query string; appears in the parent string, in a ...
21
votes
17answers
2k views

XOR multiplication

You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (^) as binary addition without carrying 101 5 ^ ...
9
votes
3answers
176 views

Order and Chaos and Codegolf

Order and Chaos is a variant of Tic-Tac-Toe played on a 6x6 board. What makes the game unique, however, is that both players can place either an X or an O! Each turn (starting with Order), a player ...
9
votes
1answer
102 views

Simplest Tiling of the Floor

You should write a program or function which receives a string describing the floor as input and outputs or returns the area of the simplest meta-tiling which could create the given pattern of the ...
1
vote
0answers
30 views

Find keyboard-friendly words [duplicate]

Inspired by Generate Keyboard Friendly Numbers. The most common keyboard layout for typing English is QWERTY, which is laid out like this: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M ...
14
votes
19answers
1k views

Reverse sentences

The goal of this challenge is to receive an input and output that input but with sentence order reversed. Example Input: Hello friend. What are you doing? I bet it is something I want to do too! ...
9
votes
0answers
158 views

Connecting Gaps with Tetris Pieces

You should write a program or function which given a list of tetris blocks as input outputs or returns the biggest gap between two points in the same height level which the pieces can connect. The 7 ...
15
votes
10answers
655 views

Undirect a Graph

Introduction In this challenge, you are given a directed graph with self-loops, and your task is to convert it to an undirected graph without self-loops. Input Your input is a directed graph with ...
35
votes
24answers
3k views

Fake Marquee Text

In this challenge fake marquee text is text that is shown part by part, in a scrolling-like fashion. Some examples: testing 4 t te tes test esti stin ting ing ng g hello 2 h he el ll lo o ...
10
votes
9answers
716 views

Calculating distances mod N

You have been collecting data from a Advanced Collecting Device Controller™ for a long time. You check the logs, and to your horror you discover that something has gone terribly wrong: the data ...
7
votes
1answer
249 views

What date is that again?

On my website, users enter their date of birth in the style xx.xx.xx - three two-digit numbers separated by dots. Unfortunately, I forgot to tell the users exactly which format to use. All I know is ...
1
vote
4answers
383 views

Convert Brainfuck to a Non-Golfing Language

Input: Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-].. Output: A program in one of the below languages that produces the same output as the ...
13
votes
4answers
386 views

Order 40 sticks

We have 40 sticks of same widths but different heights. How many arrangements are there possible to put them next to each other so that when we look from right we see 10 sticks and when we look from ...