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
4answers
163 views

Create a T9 keyboard

This question asks for a T9 dictionary matching functionality which is a very interesting problem. But T9 has another way of typing and that is typing character-by-character. You would NOT need a ...
15
votes
26answers
3k views

yes is 91 lines long

yes, from coreutils, is 91 lines long. Many of them are comments, but that is still WAY too long. Write a program that imitates yes: outputting to stdout an infinite stream of "y\n"'s there must be ...
14
votes
5answers
716 views

Caesar-Cypher-Mania

The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII ...
5
votes
0answers
232 views

Draw Sri Yantra

Challenge: Draw Sri Yantra. How to: There are different ways to draw it. All include many steps. If you think you can draw it without following the linked steps scroll below for the elements you ...
12
votes
9answers
1k views

Find the last Sunday in every month of a given year

F# solutions known inside 140 chars, and this is a Rosetta Code problem. Required result on stdout or in a string variable for input year 2014: 2014-01-26 2014-02-23 2014-03-30 2014-04-27 ...
13
votes
3answers
276 views

Squarefinder – Locating regular tetragons

Imagine a bunch of rectangles drawn in the plane, each rectangle with its vertices at integer coordinates and its sides parallel to the axes: The rectangles partition the plane into a number of ...
41
votes
7answers
2k views

Draw the Warm Welcome Secret Hat

Winter Bash 2014 is on its prime and don't we all love the hats ? Especially the secret hats! So why not draw one of secret hats ? The challenge Your task is to draw the Warm Welcome Hat in ...
-8
votes
19answers
261 views

Produce the word 'codegolf' without using any of its characters in code

You need to produce the word codegolf Rules: None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', etc.) in either case can exist anywhere in the code. Case of the word must be ...
22
votes
2answers
316 views

Implement a PCG

What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator. ...
28
votes
10answers
1k views

Verify a Minesweeper board

Your goal is to check whether a completed Minesweeper board is valid. This means that each number is a correct count of mines in cells adjacent to it, including diagonals. The board does not wrap ...
7
votes
7answers
421 views

Find pairs of numbers with a particular LCM and GCD

I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows: The difference of two natural numbers is 2010 ...
18
votes
9answers
794 views

Sum the time durations

Challenge Write the shortest code that can sum all the time durations that appear in the stdin. The program must only consider the strings that match with one of the following patterns and ignore the ...
11
votes
4answers
591 views

Return the clock emoji closest to the current time when run

I can have a large if/else condition for each 30 minutes but I'm looking for more math and Unicode based solution. Here are clock emojis: 🕐🕑🕒🕓🕔🕕🕖🕗🕘🕙🕚🕛🕜🕝🕞🕟🕠🕡🕢🕣🕤🕥🕦🕧. If you lack ...
5
votes
6answers
444 views

Tic Tac Toe encoder/decoder

James Bond is about to start a new mission and you are his computer scientist friend. As Tic Tac Toe is becoming more and more popular you decide that nothing would be more underhanded than a Tic Tac ...
2
votes
1answer
141 views

Make a working digital clock with ascii numbers [duplicate]

The challenge is make a digital clock that exhibits ascii numbers in a 24-hour format like: _ _ _ _ |_| |_| . |_| |_| |_| |_| . |_| |_| or _ _ _ _| _| . |_| |_ |_ _| . ...
40
votes
19answers
4k views

Significant Whitespace

We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20). For this challenge, you're to write two programs or functions in the same programming language, ...
6
votes
2answers
199 views

Find a point's position on the integral Hilbert curve

The Hilbert curves are a class of space-filling fractal curves where every bend in the path is at a right angle and the curve as a whole fills up a square, with the property that sequences of ...
59
votes
5answers
4k views

Recognise Stack Exchange Sites by Their Icon

After spending a while on Stack Exchange, I can recognise most sites in the Hot Network Questions by their little icon (which is also their favicon), but certainly not all of them. Let's write a ...
6
votes
5answers
554 views

Implement t9-like functionality

Your challenge today is to implement a t9-like functionality. You will implement a function that will only have 2 parameters. You will receive 1 phone number in a string and the content of a text ...
21
votes
2answers
342 views

Partial Ordering of Regex Patterns

For the purpose of this challenge, we say that a regex pattern matches a string if the entire string is matched by the pattern, not just a substring. Given two regex patterns A and B, we say that A ...
11
votes
7answers
1k views

Longest reverse palindromic DNA substring

As you may know, in DNA there are four bases — adenine (A), cytosine (C), guanine (G) and thymine (T). Typically A bonds with T and C bonds with G, forming the "rungs" of the DNA double helix ...
0
votes
3answers
358 views

Use threes to count the threes!

Write a program or function that takes two numbers - x>3 and n>0 - as input, and finds all possible bases b where the digit 3 appears at least n times in (x in base b). Input and output may be ...
6
votes
4answers
323 views

Algorithm - Costliest Possible Route in Grid Puzzle

Objective Find the most expensive path from the top-left of a square grid to the bottom-right such that its total cost is below a given threshold. Scenario You are given a square NxN grid. You are ...
18
votes
4answers
2k views

Convert numbers to binary… but you're allowed to use twos as well

Based on the "binary, but with twos" notation mentioned in this numberphile video, write a function that takes a single number as input and outputs all variations of that number in a "binary" system ...
22
votes
5answers
726 views

Create icy avatar images for the winter season

It's winter, and the time of year has come for it to start getting cold (and for strange colorful headcloths to start appearing... soon). Let's write some code to make avatar pictures and other ...
4
votes
2answers
234 views

Compute the shortest decimal representation of a IEEE 754 double-precision binary floating-point number

Format The format is a 64 bit value x representing a IEEE-754 double-precision binary floating-point number (a.k.a "a double"). x is assumed to represent a real number (not a NaN or Infinity). Goal ...
-2
votes
0answers
35 views

Shortest Java Prime Numbers programme [duplicate]

Your job is to write a Prime Numbers programme, which prints out a certain amount of prime numbers in Java. Rules: You may not look online Have fun! Smallest programme in Java(bytes, determined ...
20
votes
6answers
1k views

Mutual Negative Quines

This was inspired by Print a Negative of your Code and Golf a mutual quine. Consider a rectangle of characters, that meet the following restrictions: Consists solely of printable ASCII characters ...
13
votes
13answers
2k views

Find the Semordnilaps

Semordnilaps (also known as heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes) are words which are also words when ...
21
votes
21answers
2k views

Shortest Minmod Function

The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest ...
8
votes
9answers
1k views

Build a rot32 encryptor

Building a golfed rot13 encryptor is too easy because the letters are all the same order in the ASCII character space. Let's try a rot32 engine instead. Your task is to build a function that takes a ...
9
votes
2answers
351 views

Concatenate Strings with Context

Strings with Context For the purposes of this challenge, a string with context is a triple of strings, called the left context, the data part, and the right context. It represents a substring of a ...
5
votes
4answers
489 views

Decode MD5, Brute Force

The Challenge Create a program that brute-force* decodes the MD5-hashed string, given here: 92a7c9116fa52eb83cf4c2919599c24a which translates to code-golf The Rules You may not use any built-in ...
14
votes
8answers
970 views

RNA to Protein Translation

RNA, like DNA, is a molecule found in cells encoding genetic information. It consists of nucleotides, which are represented by the bases adenine (A), cytosine (C), guanine (G) and uracil (U).* A codon ...
58
votes
11answers
11k views

Print a Negative of your Code

Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6): =\ g \ 7 m+y "g L ~ e> PHq We also require each row ...
5
votes
6answers
303 views

Mobius inversion

Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins. What is Möbius inversion? Given a (finite) ...
13
votes
5answers
905 views

Play Wythoff's Nim perfectly

Your goal is to write a perfect player for the game of Wythoff's Nim. Rules of Wythoff's Nim Wythoff's Nim is a deterministic two-player game played with two piles of identical counters. Players ...
14
votes
14answers
1k views

Look-and-say: Conway revisited

You should all be familiar with the Conway sequence (a.k.a. 'look-and-say'-sequence) by now: 1 11 21 1211 111221 312211 etc You can also start by any arbitrary number as starting ...
-1
votes
0answers
60 views

Circular Quines [duplicate]

A quine is a program that, when run, produces the same output as the program itself. In other words, it is a self-replicating program. We will define a circular quine as follows: given a program A in ...
15
votes
10answers
2k views

Undo the square roots

Your job is to convert decimals back into the sum of the square roots of integers. The result has to have an accuracy of at least 6 significant decimal digits. Input: A number indicating the number ...
31
votes
46answers
6k views

Is a number divisible by each of its digits?

My friend and I were working on a lab in our AP Computer Science class and decided to code golf one one the problems since we still had half the class free after we finished. Here is the question: ...
31
votes
5answers
2k views

Numbers as Circular Graphics

First, study this puzzle to get a feel for what you will be producing. Your challenge is to write a program or function which will output a circular graphic like the ones from the puzzle, given a ...
-1
votes
0answers
96 views

Unholy HTML parsing [duplicate]

Inspired by this classic, Your goal is to write a program that will output this exactly: You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can ...
1
vote
1answer
131 views

Challenge Ulamspiral [duplicate]

The challenge Get familiar with the Ulam spiral: The aim is to print the spiral like in the picture above! Rules Write a function ulam(n) where n is a odd positive integer and describes the size ...
2
votes
2answers
300 views

Shortest Code to Translate a PHP array

NOTE: This question was migrated from http://stackoverflow.com/q/27134588/1442685 PHP QUESTION Almost purely out of curiousity, how can I take an array like this: array( 'fruit' => 'banana', ...
1
vote
0answers
44 views

Solving Des Chiffres Et Des Lettres - The total is right [duplicate]

One of the games of the French TV show Des chiffres et des lettres, called Le compte est bon ('The total is right'), consists of the following : You get a number A between 101 and 999 as well as six ...
12
votes
6answers
596 views

12 Days of Golfmas

Challenge On each of the 12 days of Christmas, output the appropriate verse of "12 days of Christmas", according to the date, otherwise output the chorus of "I Wish It Could Be Christmas Everyday". ...
11
votes
16answers
2k views

Sum of strings without converting

You have to take 2 string inputs and output the sum of these two strings without converting them to int or using any numeric data type. ex. string one = "123"; string two = "456"; string sum = ...
1
vote
0answers
52 views

Automate xmpp requests to ESL website to challenge opponents [closed]

ESL gaming, where you can challenge players to play games. I've provided some steps you can take manually to challenge a player. Note that you have to signup for an account and have to be logged in to ...
4
votes
4answers
511 views

Shortest program to split special array

Background Imagine, you have a big array A, which is mostly zeroes, but contains a short subarray B which has only strictly positive entries. For instance: | A | [0 0 0 ...