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

learn more… | top users | synonyms

23
votes
9answers
1k views

Professor Schwartzman's Acme Canine Decoder 2000

Introduction We -- especially the geeks among us, who tend to be fans -- all remember this old Far Side cartoon: Clearly, Professor Schwartzman could have brushed up on his programming skills just ...
13
votes
11answers
2k views

I only pay with dollars

As the title -- although discretely -- hints, I only pay with dollars. The challenge Write a function/program that takes a string as input, which is a monetary value preceded by a symbol. ex) £4.99....
7
votes
20answers
704 views

Character Counting System [duplicate]

GOAL : To Implement a character counting program This is how this counting system works : input of the program is a set of printable ASCII characters . the program counts each type of character , ...
29
votes
43answers
4k views

Write a program to elasticize strings

Nice verb there, in the title. Write a program that given an input string, will "elasticize" this string and output the result. Elasticizing a string is done as follows: The first character is shown ...
-7
votes
7answers
205 views

Convert the first letter of each word to uppercase, and the rest to lowercase [closed]

Description Your task is to take a string as input, and convert the first letter of each word to uppercase, and the rest to lowercase. Test Cases Input => Output ISN'T THIS A REALLY COOL TEST CASE?...
-1
votes
0answers
47 views

Hexdump generator [duplicate]

Some answers to our challenges include unprintable characters, i.e. characters in the range of U+0000 to U+001F and U+0080 to U+00FF. PPCG filters out those characters, except U+0009, U+000A, and U+...
35
votes
25answers
2k views

Reverse the consonants

The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples ...
24
votes
39answers
3k views

Lithp Tranthlator

My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed. So the task is to make a ...
1
vote
9answers
500 views

The teacher is always wrong, flip his answer

Your dumb teacher is always wrong, so flip his answer. Change these responses True -> False Yes -> No 0 -> 1 Yeah -> Nope and vice versa. Keeping punctuation and the first letter's ...
20
votes
20answers
2k views

Write a program that reverses the name of its source file

In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering ...
0
votes
0answers
58 views

Abacabadabacaba [duplicate]

I recently stumbled on the fractal word abacabadabacaba..., which is a 67 million letter word according to a pattern. The full word is actually the 26th word in a series as follows: A aBa abaCaba ...
14
votes
12answers
2k views

Geobitsian Language

Geobitsian language is a new perversion of English where a word is broken into segments that each must start with a different letter. Then every time one of those starting letters appears in another ...
9
votes
2answers
260 views

Determine the winner of a game of War

The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked ...
15
votes
11answers
699 views

Oneliner to merge lines with same first field

This is my first codegolf question, so I apologize in advance if it's not appropriate, and I welcome any feedback. I have a file with this format: a | rest of first line b | rest of second line b | ...
20
votes
16answers
922 views

Case Permutation

Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...
18
votes
28answers
3k views

24 and 12 Hour Times

Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: 00:00 12:00am 01:00 1:00am 02:00 2:00am 03:00 3:00am 04:00 4:00am 05:00 5:00am 06:00 6:...
11
votes
7answers
1k views

Let's build a Staircase

We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't ...
10
votes
1answer
155 views

Compute the RFC 2550 timestamp

RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and ...
48
votes
24answers
2k 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
24answers
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. Rules:...
31
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
140 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
33answers
2k 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
187 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
210 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
874 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
489 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 ...
11
votes
1answer
243 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
301 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
100 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 ...
37
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, ...
23
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
177 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
17answers
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
694 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: a:...
24
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
16answers
327 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
81 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
2answers
200 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
140 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
752 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
329 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
225 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 ...
30
votes
29answers
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". ...