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

learn more… | top users | synonyms

40
votes
22answers
1k views

Generate Wordenticons

Identicons are visual depictions of hash values, often made from symmetrical arrangements of geometric shapes. Your default Stack Exchange avatar is an identicon. This challenge is about creating ...
14
votes
20answers
1k views

Separate alphabets and numbers

A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. ...
30
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 ...
3
votes
2answers
130 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 ...
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 ...
10
votes
1answer
179 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 ...
2
votes
1answer
192 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 ...
17
votes
7answers
862 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 ...
14
votes
10answers
477 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 ...
10
votes
1answer
230 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 ...
11
votes
5answers
293 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 ...
-1
votes
1answer
95 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 ...
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, ...
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 ...
8
votes
1answer
168 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: ...
0
votes
0answers
56 views

Drawing the Number ASCIIuare [duplicate]

You have to write a function/program that will draw an ASCII art of a square made with numbers. Challenge This program will take one input n as a positive integer and draw a hollow square using this ...
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' ...
7
votes
20answers
677 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: ...
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 ...
-20
votes
15answers
283 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
vote
1answer
80 views

Scale up an image! [duplicate]

Your task is to write a program/function to scale up an image (list of strings) by a factor of n. Specs You will receive two inputs: an image, and a positive integer. The image will only contain ...
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, ...
0
votes
1answer
108 views

Random word-sentence-story generator

This question got me nostalgic: Build a word generator! In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to ...
5
votes
1answer
137 views

Will it ​float?

The challenge Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. ...
12
votes
13answers
747 views

Shortest Unique Substring

Given (on STDIN, as command line arguments, or as function arguments) two distinct non-empty strings, find and return the shortest substring of the first string which is not a substring of the second. ...
12
votes
6answers
672 views

How compatible are my strings?

Introduction Consider two strings A and B of the same length L, and an integer K ≥ 0. For the purposes of this challenge, we say that the strings are K-compatible, if there exists a string C of ...
6
votes
1answer
307 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 ...
17
votes
1answer
224 views

Symme-Try This Triangle Trial

A string whose length is a positive triangular number (1, 3, 6, 10, 15...) can be arranged into an "equilateral text triangle" by adding some spaces and newlines (and keeping it in the same reading ...
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 ...
16
votes
23answers
2k views

Generate a parity bit

A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". ...
17
votes
18answers
802 views

Compute the histogram entropy estimation of a string

Write a program or function that estimates the Shannon entropy of a given string. If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability ...
5
votes
3answers
135 views

Taylor Series of a Function with Periodic Derivatives

Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single ...
30
votes
30answers
5k views

Watson-Crick palindromes

Problem Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true value if the string is a ...
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 ...
6
votes
0answers
211 views

Which switches are on?

Introduction You are sitting with your coworker, having lunch, and bragging to him/her about the latest and supposedly greatest project you've been working on. Getting sick and tired of your constant ...
10
votes
3answers
178 views

How many 14ers did I climb?

In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic ...
8
votes
5answers
261 views

CamelCase2snake_case()

Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation The input text will be a single suitable identifier in many languages. It ...
-9
votes
13answers
372 views

Substitution cipher

A substitution cipher is an encoding method where each letter in the alphabet is replaced with a fixed, different one; for example, given the following substitution map: abcdefghijklmnopqrstuvwxyz ...
33
votes
24answers
3k views

Expand a C array

In the C programming language, arrays are defined like this: int foo[] = {4, 8, 15, 16, 23, 42}; //Foo implicitly has a size of 6 The size of the array is inferred from the initializing ...
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 ...
23
votes
6answers
2k views

Concatenating Primes

Challenge: You are given a string containing only digits. Your task is to output the minimum number of primes which must be concatenated to form the string. If this is impossible, output 0. Test ...
-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 ...
18
votes
2answers
328 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 ...
18
votes
2answers
374 views

What's being surrounded

I've always wanted to surround some text with #s, but I have trouble figuring out what I surrounded so in this challenge you'll be writing a program to do just that Examples Input / Outputs are ...
11
votes
9answers
448 views

“Stair-ify” a string

You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string: For each character in the string: If the character is an upper or lowercase vowel, ...
9
votes
8answers
500 views

Split string into n pieces (or pieces of length n)

The Challenge In this challenge you have to do two different (but related) tasks depending of the order of the input. Your program will recieve a string s and an integer n as input and will split s ...
14
votes
6answers
294 views

Insert semi-sorted into unsorted array

Welcome to your first day at PPCG Inc. As our newest junior assistant document sorter, you are responsible for making sure all documents we sent down to you are archived in alphabetical order. It's so ...
7
votes
2answers
193 views

Is the path correct?

Is the path correct ? Given a string, your program must determine whether or not Alice can reach Bob, following the signs on the map. You must return a truthy or falsy value. The input string will ...
42
votes
10answers
4k views

De-Snakify a String

A regular string looks like this: Hello,IAmAStringSnake! And a string snake looks something like this: Hel l rin o,IAmASt g S !ekan Your Task String snakes ...
25
votes
21answers
2k views

Find the first word starting with each letter

Given a string, find the first word starting with each letter (case insensitive). Sample Using Ferulas flourish in gorgeous gardens. as input: "Ferulas flourish in gorgeous gardens." ^^^^^^^ ...