A competition to solve a particular problem through the usage and manipulation of strings.

learn more… | top users | synonyms

29
votes
17answers
2k views

Print the nth prime that contains n

This question will be a twist on finding the nth prime number. Challenge You must write a program that will take one input n, and output the nth prime number whose decimal representation contains ...
5
votes
2answers
265 views

QWERTY Quine Creation

Challenge Create a quine, that instead of outputting it's source, output's it's source QWERTY-sorted. What is QWERTY sorting? QWERTY sorting is sorting code by the QWERTY keyboard. Anything higher ...
46
votes
142answers
8k views

Simple cat program

One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after ...
15
votes
6answers
716 views

Real-time string matching

Task The task is to golf a real-time exact string matching algorithm of your choice. Input Two lines of text supplied on standard input, separated by a new line. The first line contains the ...
18
votes
2answers
316 views

Virtual Keyboard Text Input

On modern game consoles and other devices without traditional keyboards, trying to input text is a nightmare. Having to type with a few buttons and a joystick on a virtual keyboard is annoying, and I ...
25
votes
53answers
4k views

Reverse stdin and place on stdout

Requirements: Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.) Output the ...
8
votes
1answer
167 views

Double run-length encoding

Everyone knows what run-length encoding is. It has been the subject of many code-golf challenges already. We'll be looking at a certain variation. Example Normal: ...
15
votes
32answers
1k views

Toggle a string

The challenge involve simply toggling a string within another string. Explanation If the toggle string is a substring of the main string, remove all instances of the toggle string from the main ...
50
votes
94answers
9k views

“99 Bottles of Beer”

Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles ...
3
votes
2answers
121 views

Chaining Words Together

Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words ...
175
votes
409answers
34k views

“Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
29
votes
26answers
2k views

Manage Trash So

It's become somewhat of a tradition in PPCG that some users temporarily change their names by an anagram (a new name formed by reordering the letters of the old). Sometimes it gets difficult to find ...
21
votes
15answers
2k views

Golf a string twister

How strings are twisted The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It works like ...
7
votes
3answers
132 views

The confused twister

The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source ...
30
votes
20answers
1k views

Locate and rotate

The task This is a simple challenge. Your input is a single non-empty string, containing only digits 0123456789 and hashes #. It will contain exactly one run of digits, which encodes a nonnegative ...
10
votes
1answer
176 views

RegEx-golf: match all contents in a string

Your task is to write a RegEx that matches everything inside strings. A string is defined as everything surrounded by (but not including) two unescaped ". A " can be escaped by \, which can also be ...
17
votes
7answers
849 views

Normal and visual string reversion

Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual ...
51
votes
10answers
2k views

Reverse indentation

I've heard that your code can run faster if you indent it in reverse, so that the compiler can process it like a tree design pattern from the very top of the "branches" down. This helps because ...
22
votes
30answers
4k views

What is the most frequent word?

What is the most frequent word? Given a sentence, your program must make it's way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed ...
14
votes
10answers
473 views

Shortest Pangrammatic Window

A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of ...
2
votes
1answer
187 views

Find the last three words of each paragraph if they are shorter than 20 characters in total

Based on my SO question, but more specifically: Find a RegEx such that, given a text where paragraphs end with an empty line (or $ at the very end), match the up to twenty last characters of a ...
23
votes
21answers
2k views

Golf Text into DNA

Text to DNA golf Challenge Convert input into a DNA output. Algorithm Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102]) String the ASCII codes ...
35
votes
13answers
5k views

Universal Spooky Meme Translator

Introduction Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, ...
25
votes
42answers
3k views

Is it a pangram?

Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) ...
20
votes
15answers
1k views

Caesar Shifting

A Caesar shift is probably something we're all familiar with. (You might be even doing it as a homework task. If so, please don't copy these answers, your teacher almost certainly doesn't want ...
27
votes
27answers
3k views

Exploded substrings

Introduction Let's observe the string abc. The substrings that can be made from this are: a, ab, abc, b, bc, c We now need to align them under the initial string, like this: abc a b c ab bc ...
13
votes
6answers
661 views

Split a Shakespeare Script

Mr. William Shakespeare wrote plays. A lot of plays. In this tarball containing every single one of his works, each one of his plays is one long file. It needs to be split into Scenes for a stage ...
1
vote
28answers
1k views

Count how many characters are in the program's source

Write a program that counts and prints the number of characters in it's own source code to standard output. The number must be generated from counting the characters. This Ruby solution would not be ...
24
votes
49answers
3k views

Longest Common Prefix of 2 Strings

Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins. Test Case 1: "global" , "glossary" ...
8
votes
2answers
137 views

Find the Words on the Grid!

Write a program or function that extracts a word from a wordsearch using its start and end coordinates. The Input Your program or function should accept three parameters: the start coordinate, the ...
11
votes
5answers
288 views

Print the AdamN tile

Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 ...
4
votes
74answers
9k views

Shortest code to print ':)' random times [duplicate]

You have to create a code which prints :) a random number of times from 1 to 255 inclusive. Your output may not contain any whitespace. Your score : The count in bytes EDIT : Also show 3 ...
10
votes
1answer
224 views

How many squares are there?

This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this: ┌─┬───┬─┐ ├─┼─┬─┼─┤ ├─┼─┴─┼─┤ ├─┼─┬─┼─┤ └─┴─┴─┴─┘ The ...
-20
votes
15answers
280 views

Reverse a 1-dimensional array

Note: This challenge is not the same. Challenge Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should ...
-1
votes
1answer
94 views

Needs more jQuery! [closed]

Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet ...
10
votes
5answers
327 views

Implement the dog bash utility

dog is a command-line utility that takes in an arbitrary number of arguments, the first of which is the text to be written and the others are arbitrarily many files. The dog utility will split the ...
6
votes
1answer
284 views

Create a CleverBot

CleverBot is a conversational AI that works fundamentally by repeating responses from real humans it has heard previously. It starts off pretty dumb, but once the database becomes (a lot) larger it ...
7
votes
20answers
674 views

Briefest code to find vowels and print consonants

Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: ...
19
votes
11answers
1k views

All possible ways to interleave two strings

I recently saw this question on stackoverflow. It's a great question, but there's one fatal problem with the question. They are asking for the best way to do it. E.g, easiest to read, most idiomatic, ...
40
votes
26answers
4k 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 ...
14
votes
36answers
1k views

Detect rotated strings

Read two strings from stdin. Output Yes if one string is a rotated version of the other. Otherwise output No Testcases Input CodeGolf GolfCode Output Yes Input stackexchange changestackex ...
11
votes
21answers
1k views

Convert a Forsyth-Edwards Notation string to ASCII art

In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from ...
-5
votes
4answers
431 views

Print “Hello World” without its characters [closed]

Mission is write a program that prints "Hello World!". Simple? Text must be human readable and should not be "|-| € |_ |_ 0 // 0 |? |_ |) \./" or something like that Program should not contain: ...
17
votes
15answers
2k views

Counting in bijective base 62

The task is to generate all the strings from 'a' to '999' including upper case characters like so: 'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ... '8', '9', 'aa', 'ab', 'ac' ...
16
votes
0answers
2k views

Longest common substring

This challenge is about writing code to solve the following problem. Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties. ...
-4
votes
26answers
518 views

Convert phrases to reverse style

The Challenge Convert a phrase of two words to reverse style: candy bar -> bar le candy. Specifications There will be one word (only a-zA-Z0-9 + -), a space (), and then another word. For ...
28
votes
25answers
1k views

Subsequence Substitution

Most languages come with a built-in to search a string for all occurrences of a given substring and replace those with another. I don't know of any language that generalises this concept to (not ...
42
votes
36answers
4k views

Swap the Alphabet

In this challenge, you will be "reversing" the alphabet or swapping a-z with z-a Because this transformation makes the output look like some foreign language, your code will need to be as short as ...
74
votes
136answers
12k views

1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
24
votes
17answers
2k views

Is it a prefix code?

In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other. For example, ...