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

learn more… | top users | synonyms

10
votes
9answers
1k 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....
48
votes
151answers
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 ...
29
votes
28answers
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 ...
48
votes
7answers
2k views

Make the Stretchy Snakes Kiss

A stretchy snake looks something like this: <||=|||:)~ Each separate sequence of vertical bars (|) in a stretchy snake, known as a stretchy portion, is individually extendable to twice its width,...
7
votes
20answers
695 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 , ...
10
votes
36answers
4k views

Display number of occurrences for every character in an input string

The code should take a string as input from keyboard: The definition of insanity is quoting the same phrase again and again and not expect despair. The output should be like this(not sorted in any ...
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:...
28
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 ...
15
votes
11answers
698 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 | ...
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' ...
183
votes
421answers
37k 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 ...
13
votes
6answers
942 views

Capture on the Pawn Chessboard

You should write a program or function which receives a string representing a chessboard with only pawns as input and outputs or returns whether any capture is possible on the board. Input is in a ...
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 "...
10
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 ...
34
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 ...
33
votes
48answers
4k views

Capitalize first letter of each word of input

This is a relatively quick one, but I'm sure you'll like it. Codegolf a program that will take input in the form of a sentence and then provide the output with the first letter capitalized in each ...
-7
votes
7answers
201 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?...
80
votes
127answers
22k views

Sing Happy Birthday to your favourite programming language

Your favourite programming language has just had a birthday. Be nice and sing it the Happy Birthday song. Of course you should accomplish this by writing a program in that language. The program takes ...
-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+...
1
vote
9answers
497 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 ...
16
votes
37answers
2k views

Shortest program to split a string at non-digits without RegExps

EDIT: If you're using Lisp, I have given some guidelines at the bottom in counting bytes. Objective: Make the shortest function that splits a string at non-digits and returns an array consisting of ...
12
votes
4answers
581 views

Golf String's format() inverse

Invert the Format method. The Format method of the String class (or equivallent, such as sprintf) is available in most languages. It basically takes a "Format" string which may contain placeholders ...
29
votes
7answers
6k views

Build a twisted “Hello world!”

Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!. How strings are twisted The twisting algorithm is very simple. Each ...
26
votes
24answers
2k views

Counting and spelling up

Write a program that takes as its input a string that outputs a string with the following properties. If a character in the string is an uppercase letter (ASCII 41-5A), then the character is ...
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:...
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 ...
25
votes
26answers
6k views

Outputting ordinal numbers (1st, 2nd, 3rd)

I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number. Samples: 1st 2nd 3rd 4th ...
9
votes
8answers
536 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 ...
27
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 ...
18
votes
6answers
625 views

Parse RNA into codons

Introduction RNA is the less famous cousin of DNA. Its main purpose is to control the production of proteins in cells through a process called translation. In this challenge, your task is to ...
0
votes
2answers
199 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 ...
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 ...
17
votes
8answers
2k views

Who's gonna win the football game?

The American football championship, Super Bowl 50, is happening today at 11:30pm UTC (and you can watch it live online). This challenge was made to celebrate it. In an American football game, two ...
26
votes
24answers
1k views

Generate the Abacaba sequence

This challenge is about printing the abacaba sequence of a specific depth. Here is a diagram of the first 5 sequences (a(N) is the abacaba sequence of depth N, upper/lowercase is just to show the ...
0
votes
0answers
57 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 ...
51
votes
96answers
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 ...
21
votes
28answers
2k views

Reverse the truth

Write a program or function that: takes in a string from stdio or arguments replaces all occurrences of true with false and false with true reverses it, but does not reverse true and false returns ...
43
votes
36answers
4k views

Stretch the word

The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional. The same word must be output in a modified version: For each character, double it the second ...
2
votes
12answers
1k views

How's your string theory?

Back to the basics! You're in you comp sci class again, except wiser and golfier. You have the tools, you have the power… but do you have the skill? Probably. Crash Course for the non-Computer ...
18
votes
16answers
1k views

Remove more than n consecutive vowels from input string

I don't like strings with more than three vowels in a row. Can you write a program that removes all the vowels I don't want from words? You may write a program or function, taking input via STDIN (or ...
26
votes
9answers
1k views

“You must construct additional pylons!”

Introduction In the strategy game Starcraft 2, there are three "races" to choose from: Terran, Zerg, and Protoss. In this challenge we will be focusing on the Protoss and the iconic phrase "You must ...
9
votes
2answers
258 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 ...
74
votes
139answers
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 ...
8
votes
7answers
618 views

Read a crossword

Inspired by this question about packing into this format. Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were. ...
20
votes
16answers
919 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; ...
-20
votes
16answers
324 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 ...
55
votes
25answers
11k views

Why was 6 afraid of 7?

Why was 6 afraid of 7? Because 7 8 9! Given a string apply the following transformations: If there is a 6 next to a 7 remove the 6 (6 is afraid of 7) If the sequence "789" appears remove the 8 and ...