A competition to solve a particular problem through the usage and manipulation of strings.
12
votes
2answers
327 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 ...
14
votes
1answer
225 views
Find Patterns in Strings
In this challence, your task is to locate substrings with a given structure.
Input
Your input shall be two non-empty alphanumeric strings, a pattern p and a text t.
The idea is that each character ...
40
votes
6answers
9k views
Hodorize a String
Hodor is a slow-minded but endearing character on the show Game of Thrones (he's in the books as well of course). The only word he ever says is 'hodor'.
Surprisingly, despite not having much of a ...
9
votes
3answers
194 views
IMP: Implicit multiplication parser
Jack likes C programming language, but hates to write expressions like V=a*b*h;
to multiply the values.
He would like to write V=abh; instead,
why should compiler moan about abh symbol being ...
11
votes
3answers
216 views
Wrap-Around Subsequences
Introduction
In this challenge, your task is to find generalized subsequences of strings.
The subsequences are not necessarily contiguous, and they can also "wrap around" the string, going past its ...
12
votes
2answers
200 views
ASCII L-system renderer
Background
An L-system (or Lindenmayer system) is a parallel rewriting system that, among other things, can be easily used to model fractals. This question concerns deterministic, context-free ...
12
votes
8answers
790 views
Remove single line and multiline comments from string
Goal
Using the programming language of your choice, write the shortest program to eliminate comments from a string representing a C program.
Input
The string can be...
given as a function ...
2
votes
2answers
267 views
DoIt Java Style [closed]
Given string X, convert it to Java Style string, as defined below:
Strings may only contain numbers and letters(signs are not allowed)
Strings must not start with numbers
Strings must start with ...
9
votes
1answer
278 views
Shortest Substring Index
I'm a lazy but efficient person, as many of you probably are as well. So, whenever I'm doing something I want to do it with minimal effort. Which is why I'm asking you to solve this problem for me.
...
4
votes
7answers
496 views
N-gram histogram
Given a text and a number N, output, in a human readable format, the set of the character N-grams with their respective percentages.
The smallprint
The text can be read from a file, stdin, passed ...
5
votes
11answers
571 views
Decode a Rövarspråket string
This question is the inverse of this one by James Williams.
Rövarspråket
Rövarspråket is a word game played by Swedish children, from the books about Kalle Blomkvist by Astrid Lindgren.
The basic ...
10
votes
6answers
356 views
Implement a Variable Length Hash
My friend and I have this game that we play with words. It is a fun pastime and it involves "canceling out" letters in a word until there is nothing left. I am really tired of him being so much faster ...
12
votes
23answers
2k views
Convert a string to its Rövarspråket equivalent
Rövarspråket
Rövarspråket is a word game played by Swedish children, from the books about Kalle Blomkvist by Astrid Lindgren.
The basic rules are as follows (from Wikipedia):
Every consonant ...
14
votes
8answers
1k views
Discrete Baker's Map
Introduction
The Baker's map is an important dynamical system that exhibits chaotic behavior.
It is a function from the unit square to itself defined intuitively as follows.
Cut the square ...
23
votes
9answers
2k views
Two-way Palindromic Closure Generator
Introduction
A palindromic closure of an input string is the shortest palindrome that can be constructed out of the input string where the final palindrome starts with the input string.
For this ...
3
votes
4answers
274 views
Words of centuries
I'd like to get a list of words that are strongly connected with a particular time epoch, for example, 19th century, 20th century and 21st century. I suspect that nobody used a word like "smartphone" ...
1
vote
11answers
496 views
Palindromic palindrome generator
Create a program, that converts input string to a palindrome starting with the input string. The program itself must be a palindrome.
For example input: neverod, print neveroddoreven. You should ...
16
votes
5answers
574 views
A Basic Pyth-like Syntax Checker
Pyth is a golfing language based on Python. It uses prefix notation, with each command having a different arity (number of arguments it accepts).
Your task is to write a syntax checker for a ...
6
votes
3answers
259 views
Latin Word Judgment
Because I can't concentrate on any task for more than about 5 seconds, I often find myself breaking up words into a sub-strings, each of which is a different length and doesn't contain any repeated ...
21
votes
22answers
2k views
The Characters in the String Go Round and Round
(Inspired by an early draft of PhiNotPi's fractal line challenge.)
You're given a width W > 1, a height H > 1 and string consisting of 2(W+H-2) printable ASCII characters. The task is to print ...
35
votes
5answers
2k views
Adding Numbers with Regex
I want to try a new type of regex golf challenge, which asks you to solve nontrivial computational tasks with nothing but regex substitution. To make this more possible and less of a chore, you will ...
15
votes
9answers
1k views
Keep the unique characters down
It's very simple: Your program or function should generate the following text:
Elizabeth obnoxiously quoted (just too rowdy for my peace): "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG," giving me a ...
37
votes
6answers
2k views
Language Design: 2-D Pattern Matching
This is Fortnightly Challenge #6. Theme: Language Design
There's a chatroom for this challenge. Come and join us if you want to discuss ideas!
And now for something completely different...
This ...
7
votes
1answer
626 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.
...
8
votes
4answers
363 views
Prelude Syntax-Checker
Prelude is an esoteric programming language, which has very few, but unusual, restrictions on what constitutes a valid program. Any block of printable ASCII text ("block" meaning that lines of ...
24
votes
34answers
3k views
Check whether letters of word are in alphabetical order
Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and ...
20
votes
2answers
346 views
Golf Down the PPCG Usernames
A comment I made in chat and the ensuing conversation inspired me to make this challenge.
Am I the only one referred to by initials around here? We are all about golfing things down. We can have ...
19
votes
6answers
1k views
A Mnemonic for Remembering 23940
The major system is a mnemonic device for converting numbers into words so they can be memorized more easily.
It is based on how words sound phonetically, but to keep things simple for the challenge ...
-2
votes
4answers
133 views
Extract URI parts without using libraries [closed]
Given a URI like:
postgres://username:password@hostname:PORT/dbname
Extract it all into an array data-structure, like so:
['postgres', 'username', 'password', 'hostname', 'PORT', 'dbname']
More ...
3
votes
3answers
354 views
Generate unique non-sequential string of length n without memory of previously generated strings
Scenario:
Imagine a situation where you wish to share a unique alphanumeric code. Perhaps it is a one-time-use coupon code you hand write on business cards, or some other scenario where it is ...
17
votes
35answers
3k views
Convert C header names to C++ header names
In the C standard library, header names end with a .h suffix:
stdio.h
In C++, those header names are available in an alternative form, with a c prefix instead:
cstdio
Write a function that ...
16
votes
8answers
1k views
Convert human readable time interval to date components
Challenge
Write the shortest program that converts a human readable time interval to date components of the form:
{±YEARS|±MONTHS|±DAYS|±HOURS|±MINUTES|±SECONDS}
Sample cases
Each test case is ...
8
votes
9answers
613 views
Find Privileged Substrings
Privileged Strings
The set of privileged strings is defined recursively as follows.
All strings of length 0 or 1 are privileged.
A string s of length at least 2 is privileged, if there exists a ...
6
votes
2answers
186 views
String Equivalence: Counting Substrings
Background
Two strings s and t are called k-Abelian equivalent (shortened to k-equivalent in the following) for a positive integer k if the following conditions hold:
The length-k-1 prefixes of s ...
0
votes
0answers
75 views
Find the longest recurring substring [duplicate]
Given a string of no more than 255 characters, find a function that returns the longest recurring substring.
An example would be:
aabbacadeauaaabba
where the longest recurring sub-string is ...
-3
votes
5answers
214 views
How many contiguous “strings” can you find in a set of strings?
Consider the set of 16-character strings containing only the 95 printable ASCII characters. There are 9516 ≈ 4.4×1031 such strings.
Imagine these strings are put into a list and sorted ...
14
votes
15answers
2k views
Fill In the Blanks
Input
A nonnegative integer n, and a nonempty string s containing only alphanumeric characters and underscores _.
The first character of s is not _.
The underscores of s are interpreted as blank ...
16
votes
7answers
1k views
Typing with scrambled keys
Your friend isn't too good with computers so as a practical joke someone scrambled the letters (a-z) on his keyboard. When he sit down and tried to type his name looking at the keyboard he realized ...
10
votes
11answers
612 views
Binary encryption
This is based on xkcd #153.
Make a program or named function which takes 2 parameters, each of which is a string or a list or array of bytes or characters. The second parameter will only contain ...
23
votes
16answers
3k views
Shortest Unique Substrings
Input
An alphanumeric string s.
Output
The shortest string that occurs exactly once as a (contiguous) substring in s.
Overlapping occurrences are counted as distinct.
If there are several ...
5
votes
3answers
370 views
Code Golf: Gibberish Echo
This is my first code golf challenge, as such I am not entirely certain if it is suitable as a Code Golf challenge, but it's all a learning experience.
The challenge is that in as few characters as ...
-2
votes
2answers
171 views
Find Anagrams in the Dictionary [closed]
This a code challenge. The winner will be the person to provide the most efficient implementation of the solution in terms of algorithmic complexity.
Using the dictionary found in '/usr/share/dict' ...
11
votes
22answers
1k views
String to Binary
This is a code golf challenge. Just like the title says, write a program to covert a string of ascii characters into binary.
For example:
"Hello World!"
should turn into
1001000 1100101 1101100 ...
14
votes
17answers
2k views
Find the substring with the most 1's in a sequence
Introduction
I want to find the substring with the most 1's in a sequence of 0's and 1's.
Input
Your program has two inputs, the sequence and the substring length.
The sequence is any number of ...
6
votes
3answers
395 views
Retrograde morse (d)e(n)coder
This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar ...
2
votes
1answer
115 views
String generator based on a wildcard [duplicate]
Your task, if you accept it, is to make a string generator that generates strings based on a wildcard.
You can make a function or a full program that receives 1 argument and sends to the standard ...
12
votes
4answers
581 views
Write a Magic Spellchecker
The game Waving Hands is somewhere between a pen-and-paper Magic: the Gathering and a very elaborate Rock Paper Scissors. Each turn you write down one of eight gestures for each hand:
wiggled ...
35
votes
9answers
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 ...
18
votes
9answers
1k views
Caesar-Cypher-Mania
The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII ...
45
votes
20answers
5k views
Significant Whitespace
We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20).
For this challenge, you're to write two programs or functions in the same programming language, ...