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

learn more… | top users | synonyms

5
votes
4answers
241 views

Semi-decide Post's Correspondence Problem

The Post's Correspondence Problem (PCP) gives you a list of pairs of strings, P_1 ... P_n. Your task is to find a k, and some sequence of k indices such that fst(P_i1) ... fst(P_ik) = snd(P_i1) ... ...
42
votes
44answers
5k views

Count of “a”s and “b”s must be equal. Did you get it computer?

In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated: mainly because this ...
17
votes
10answers
1k views

What exactly was your question?

Introduction When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text: Ens colligi timenda etc priorem judicem. De quascunque ii at ...
41
votes
23answers
4k views

Polar Bear, Polar Bear, what do you hear?

The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts. My son was quickly bored by ...
23
votes
22answers
2k views

Which ghosts are missing?

In this challenge, given a list of ghosts from Pac-Man, you must output which ghosts are missing. You must do it in as few bytes as you can Input Input will consist of a string or list, which will ...
14
votes
20answers
779 views

Select the word around the given index in a given string

In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected. (This feature has more complicated properties, but they will not be required to be ...
20
votes
24answers
3k views

#Hashtag_or_not

In this code golf, You will verify Hashtags! #What_your_code_should_do Input a string. output truthy value if it is a valid hashtag, and falsy value if not. We define a string as a valid Hashtag if....
14
votes
8answers
809 views

Find numbers within the Copeland–Erdős constant

Background The Copeland–Erdős constant is the concatenation of "0." with the base 10 representations of the prime numbers in order. Its value is 0.23571113171923293137414... See also OEIS A033308. ...
8
votes
7answers
309 views

Write a program to display directory treehouse

Given a directory (such as C:/), given from stdin or read from a file, produce a directory tree, with each file/folder indented based on its depth. Example If I have a C:/ drive which only contains ...
26
votes
15answers
1k views

Remove duplicated & switched case

Goal The goal of this challenge is: given a string as input, remove duplicate pairs of letters, if the second item in the pair is of opposite capitalization. (i.e. uppercase becomes lowercase and ...
21
votes
7answers
838 views

I programming puzzles, il code golf

Background The Italian definite article (corresponding to English the) has seven different forms: l', il, lo, gli, i, la, le. Which one to use depends on three variables: Gender: masculine / ...
17
votes
13answers
446 views

Directory calculation

For this challenge, you will be given an absolute path, and a "new" path (which can be absolute or relative), and you need to return the final path. For example, if your current directory was /var/...
21
votes
21answers
1k views

Post-determined Array Sorting

Input: An array containing three integers: 0, 1 and 2 in any order (i.e. [2, 0, 1]) And a string of length >= 2 only containing alphabetic letters (both lower- and uppercase) and digits (i.e. a1B2c3)...
9
votes
3answers
365 views

Find the paths!

You must write a program or function. The input is a 'map' of numbers. You can choose to take the map as either a string with new line characters (\n) or a 2D array of strings. All maps are 5 ...
15
votes
26answers
1k views

Convert n strings of m length to m strings of n length

Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition: Every new string should contains the letters at the same index of ...
21
votes
18answers
2k views

Unzip some numbers

Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --: -- -- -- -- -- -- -- -- -- -- The program/...
3
votes
3answers
339 views

Do not repeat yourself

Inspired by this challenge Given a number m, output a program that prints out the string Do not repeat yourself. Now for the challenging part: Each program the original code prints out has to have ...
2
votes
5answers
210 views

Golf a Sentence

Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English! Your task is to write a program or function that takes a string as input, and then ...
8
votes
2answers
129 views

Directory Structure Graphical Treefication

Convert a classical directory structure like this: config.yml drafts begin-with-the-crazy-ideas.textile on-simplicity-in-technology.markdown includes footer.html header.html Into ...
25
votes
32answers
2k views

Duplicate & switch case

The goal is, having taken a string as input, duplicate each latin letter and "toggle" its case (i.e. uppercase becomes lowercase and vice-versa). Example inputs & outputs: Input Output bad ...
8
votes
14answers
383 views

Truncate consecutive character runs to n length

The challenge Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The ...
14
votes
2answers
237 views

Normal sentences

Write a program or function which, given an input string and a standard deviation σ, outputs that string along the normal distribution curve with mean 0 and standard deviation σ. Normal distribution ...
14
votes
24answers
2k views

Generate a Stack Exchange Favicon

Do you recognize the PPCG logo? it looks like this, when you do an ascii art of it. +---+ |PCG| +---+ v Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to ...
33
votes
16answers
3k views

Determine the “Luck” of a string

Given a string, return that string's "luck". A string's luck, as I completely just made up for the purpose of this challenge, is an integer, determined as so: The base luck for a string is 1. For ...
22
votes
31answers
3k views

Reverse a string while maintaining the capitalization in the same places

The goal here is to simply reverse a string, with one twist: Keep the capitalization in the same places. Example Input 1: Hello, Midnightas Example Output 1: SathginDim ,olleh Example Input 2: .Q ...
21
votes
12answers
4k views

Was it Really Canada Day?

July 1st is Canada day (yay Canada)! Or is it? It seems that the Wikipedia page for this day has a lot of Canada related content, but is there another day which is more Canadian? Your task is to ...
23
votes
1answer
406 views

Domain Name Appraisal

Domain name trading is big business. One of the most useful tools for domain name trading is an automatic appraisal tool, so that you can easily estimate how much a given domain is worth. ...
11
votes
2answers
316 views

Compute the runs of a string

Consider the following definitions taken from The number of runs in a string by W. Rytter. Note that word, string and substring are all roughly synonyms. A run in a string is a nonextendable (...
28
votes
13answers
3k views

Where should I put my mirror?

This is a mirror: |. I just found out that you can stick a mirror in the middle of a string if the string can be mirrored on itself! For example, the string abccba. If you cut it in half the two ...
8
votes
3answers
258 views

Parse and Process the Key-Language Input

Let's parse and process Key-Language! Given the input of a sequence of keyboard keypresses and/or special keys, write a program, function, etc. that outputs the product when all the actions are ...
11
votes
26answers
1k views

What's the second non-repeating character?

Based on this question from Code Review Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD, output F. Input A single ...
44
votes
18answers
9k views

Can Pac-Man Eat This String?

In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string. Your task is to create a function that feeds ...
-1
votes
1answer
197 views

Write a AZERTY to QWERTY converter [duplicate]

Your task is to create a program will transform each letter of a text typed on a AZERTY keyboard to the equivalent on a QWERTY keyboard, using the same keystrokes. Example: Hello; Zorld1 => Hello, ...
29
votes
9answers
2k 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
730 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 , ...
31
votes
44answers
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 ...
-6
votes
7answers
227 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?...
37
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 ...
26
votes
42answers
4k 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 ...
2
votes
9answers
539 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 ...
22
votes
24answers
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
60 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 ...
15
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 ...
14
votes
4answers
342 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
706 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
931 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
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
158 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 ...