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

learn more… | top users | synonyms

7
votes
20answers
915 views

Count the number of vowels in each word of a string

This is a rather easy challenge. Challenge Input will contain a string (not null or empty) of maximum length 100. Output the number of vowels in each word of the string, seperated by spaces. Rules ...
7
votes
15answers
1k views

Stripping off extra spaces from a string

You are given a string. Output the string with one space per words. Challenge Input will be a string (not null or empty), surrounded with quotes(") sent via the stdin. Remove leading and trailing ...
19
votes
18answers
2k views

Caesar equivalence

Two strings are "Caesar equivalent" if the distance (counting up) between the corresponding characters are the same. Yes, I made this term up. Here's an example: "Abc" and "Cde" are equivalent ...
4
votes
1answer
698 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. ...
-2
votes
5answers
132 views

Return every N-th word of a string

Your goal is to write a program that, given a number N and a string as input, will return a string containing every Nth word of the original string, starting from the first word. Sample ...
31
votes
44answers
3k 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 ...
13
votes
8answers
556 views

Formatting a Lisp-like Syntax

Background (Based on a true, heart-wrenching story) In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made ...
24
votes
35answers
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 ...
11
votes
12answers
2k views

QuickGolf - Barry the messy developer #2

This is a follow-up of QuickGolf - Ignore the noise #1 the only problem being that Barry has made things even worse for us. Lets see what happened Update I've added code to create random ...
13
votes
14answers
2k views

QuickGolf - Ignore the noise #1

Instructions Barry is a not so good backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your ...
15
votes
12answers
731 views

Extract a string from a given string

You are given a string and two characters. You have to print the string between these characters from the string. Input Input will first contain a string (not empty or null). In the next line, there ...
9
votes
16answers
603 views

QuickGolf - Heads or Tails

Instructions Given an unknown input string i with a value of either heads or tails, return 1 for heads or -1 for tails with the shortest code. Sample not golfed code (55b): if(i == "heads"){ ...
13
votes
24answers
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 ...
9
votes
7answers
318 views

Find the longest musical substring

A musical string is any string that can be played on a piano keyboard. For those of us who weren't forced to learn the piano as kids, here is what the keyboard looks like. So the string feed a ...
18
votes
7answers
491 views

Optimize the Scralphabet

Scralphabet A normal bag of Scrabble tiles contains the following letters (? is a blank tile, which can stand for any other letter): ...
21
votes
7answers
1k views

Reassuring parables

Quite a few people here are probably avid XKCD readers. So, I figure I'd challenge you guys to do something that Megan can do easily: make a script that generates thousands of reassuring parables ...
19
votes
7answers
706 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 ...
8
votes
12answers
475 views

Mixing characters in a string

You have to write a function/program that takes input via the stdin/command-line arguments/function arguments, mixes up characters in a string, and then output the final string via the stdout. Input ...
8
votes
7answers
250 views

Detecting anagrams within a Parent String

Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, or an anagram of the query string; appears in the parent string, in a ...
17
votes
14answers
2k views

Determine a string's Scrabble score and validity

Your task is to determine if a given string is of proper length and can be represented with Scrabble tiles and, if so, output the sum of each letter's score. If you don't know how to play Scrabble:, ...
35
votes
24answers
3k views

Fake Marquee Text

In this challenge fake marquee text is text that is shown part by part, in a scrolling-like fashion. Some examples: testing 4 t te tes test esti stin ting ing ng g hello 2 h he el ll lo o ...
7
votes
2answers
176 views

Non-crossing X's and crossing non-X's

You should write a program or function which given a text as input outputs or returns the sum of the following three integers: Number of lowercase x's which are not part of a cross-formation. Number ...
23
votes
10answers
2k views

Where will your buddies sit?

You and some buddies are going bowling. There are a total of N bowlers. However, there are only N-1 chairs to sit in. The solution is simple: whoever's turn it currently is doesn't get a chair. Then ...
12
votes
3answers
891 views

Is that word Feminine or Masculine?

Write a program or function that takes in a single string containing only lowercase a-z, and prints or returns a truthy value if the word is the feminine version of the thing it represents and a falsy ...
19
votes
3answers
1k views

Distinguish between Masculine and Feminine Nouns in French within 100 characters

You are to write a very small program within 100 characters. Your program must distinguish between masculine and feminine french nouns. The output should be un if it is masculine and une if it is ...
14
votes
5answers
512 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 ...
-1
votes
5answers
243 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
1answer
260 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 ...
14
votes
12answers
999 views

Topographic Strings

Here is some example input, so I can explain what the problem is: ((1 2)(3 (4 5) moo)) (i (lik(cherries)e (woohoo))) Think of this line of text as a topographic map of some mountains. Each set of ...
42
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 ...
3
votes
3answers
371 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 ...
11
votes
3answers
222 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 ...
9
votes
3answers
200 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 ...
12
votes
2answers
217 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 ...
1
vote
11answers
507 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 ...
12
votes
8answers
809 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 ...
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 ...
11
votes
4answers
623 views

Reduce html to n characters while keeping the formatting

Almost every language has a built-in function that can split a string at a given position. However, as soon as you have html tags in the string, the built-in function will not work properly. Your ...
2
votes
2answers
270 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
282 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
504 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 ...
41
votes
56answers
4k views

How to randomize letters in a word

According to some controversial story, the odrer of ltteres in a wrod deos not mttaer much for raednig, as lnog as the frist and lsat lteter macth with the orignial wrod. So, for fun, what would be ...
10
votes
6answers
363 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 ...
5
votes
11answers
584 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 ...
12
votes
19answers
3k 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 ...
21
votes
19answers
3k views

How many IP addresses are in a given range?

Inspired by... Networking - How can I work out how many IP addresses there are in a given range? Write a program or function that takes two strings as input, each being an IPv4 address ...
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 ...
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 ...
6
votes
3answers
280 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 ...