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

learn more… | top users | synonyms

-2
votes
12answers
220 views

Make a search engine

You need to make a program, that when giving a list and a string, searches on the list for items that contains the string. Examples: Input: th [thing, awesome, potato, example] Output: thing ...
29
votes
30answers
5k views

Watson-Crick palindromes

Problem Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true value if the string is a ...
5
votes
1answer
100 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. ...
17
votes
18answers
782 views

Compute the histogram entropy estimation of a string

Write a program or function that estimates the Shannon entropy of a given string. If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability ...
12
votes
11answers
682 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. ...
27
votes
26answers
2k 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 ...
18
votes
2answers
363 views

What's being surrounded

I've always wanted to surround some text with #s, but I have trouble figuring out what I surrounded so in this challenge you'll be writing a program to do just that Examples Input / Outputs are ...
27
votes
14answers
1k views

Levenshtein Distance

While there are many edit distance questions, such as this one, there isn't a simple question to write a program that calculates the Levenshtein distance. Some Exposition The Levenshtein edit ...
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". ...
12
votes
6answers
656 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 ...
5
votes
2answers
206 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 ...
23
votes
9answers
937 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 ...
173
votes
402answers
31k 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 ...
5
votes
3answers
126 views

Taylor Series of a Function with Periodic Derivatives

Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single ...
0
votes
27answers
1k views

Count how many characters are in the program's source

Write a program that counts and prints the number of characters in it's own source code to standard output. The number must be generated from counting the characters. This Ruby solution would not be ...
17
votes
1answer
211 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 ...
11
votes
16answers
732 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 ...
11
votes
20answers
1k views

Convert a Forsyth-Edwards Notation string to ASCII art

In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from ...
24
votes
52answers
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 ...
11
votes
7answers
2k views

Reverse words without changing capitals or punctuation

Create a program with the lowest amount of characters to reverse each word in a string while keeping the order of the words, as well as punctuation and capital letters, in their initial place. By ...
41
votes
33answers
3k 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 ...
31
votes
6answers
1k views

Have you been nice this year?

Introduction Santa has too many names to process, and needs your help! He needs you to write a program or a function, which outputs nice, naughty, very naughty or very very naughty. To determine how ...
-4
votes
26answers
491 views

Convert phrases to reverse style

The Challenge Convert a phrase of two words to reverse style: candy bar -> bar le candy. Specifications There will be one word (only a-zA-Z0-9 + -), a space (), and then another word. For ...
-8
votes
13answers
333 views

Substitution cipher

A substitution cipher is an encoding method where each letter in the alphabet is replaced with a fixed, different one; for example, given the following substitution map: abcdefghijklmnopqrstuvwxyz ...
9
votes
3answers
164 views

How many 14ers did I climb?

In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic ...
6
votes
0answers
183 views

Which switches are on?

Introduction You are sitting with your coworker, having lunch, and bragging to him/her about the latest and supposedly greatest project you've been working on. Getting sick and tired of your constant ...
22
votes
29answers
3k views

Making an acronym

Objective Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must ...
19
votes
19answers
2k views

Javascript left-pad golf

Introduction In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad. The left-pad function consists of 2 default arguments and 1 additional argument, in ...
17
votes
25answers
1k views

Calculate average characters of string

Task Your task is to produce string that contains average characters of string. First character of result would be average character of first character (which is first character) and second character ...
8
votes
5answers
260 views

CamelCase2snake_case()

Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation The input text will be a single suitable identifier in many languages. It ...
28
votes
25answers
1k views

Subsequence Substitution

Most languages come with a built-in to search a string for all occurrences of a given substring and replace those with another. I don't know of any language that generalises this concept to (not ...
72
votes
130answers
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 ...
43
votes
135answers
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 ...
31
votes
7answers
490 views

Can I string all my cords and adapters together?

Suppose one day you are digging through your big box of unused computer cords and adapters (USB to USB mini, VGA to DVI, etc.). There are tangled cords everywhere making quite a mess, and you wonder ...
33
votes
24answers
3k views

Expand a C array

In the C programming language, arrays are defined like this: int foo[] = {4, 8, 15, 16, 23, 42}; //Foo implicitly has a size of 6 The size of the array is inferred from the initializing ...
16
votes
75answers
2k views

Full Width Text

Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: F u l l w i d t h t e x t i s t e x t t h ...
24
votes
1answer
391 views

Reverse Engineer Bracket Rectangles

Every programmer knows that rectangles □ are really fun. To exacerbate this fun, these cute and fuzzy diagrams can be transformed into groups of interwoven brackets. This challenge is the inverse of ...
11
votes
9answers
446 views

“Stair-ify” a string

You must write a program or function that creates a "stair-ified" string. Here is how you "stair-ify" a string: For each character in the string: If the character is an upper or lowercase vowel, ...
17
votes
20answers
1k views

Make a Math Competition Grader

I enjoy participating in math competitions run by Mu Alpha Theta, a mathematics honor society in the United States. At competitions, I take a 30-question multiple choice test. There are five choices ...
17
votes
7answers
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 ...
12
votes
1answer
259 views

Are there brackets in disguise?

Someone's given us a string, but all bracket-like characters have been changed into normal ones, and we don't know which, or even how many there were. All we know is that if L1,L2,L3,...,LN were ...
33
votes
5answers
941 views

Make Bracket Squares

Every programmer knows that brackets []{}()<> are really fun. To exacerbate this fun, groups of interwoven brackets can be transformed into cute and fuzzy diagrams. Let's say that you have a ...
34
votes
18answers
3k views

Are the brackets fully matched?

You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any ...
17
votes
10answers
991 views

Bracket balancing

You will be given a (possibly empty) string containing brackets ([{()}]) and any other characters (A-Z, a-z, 0-9, punctuation). You need to check if it adheres to the following rules: Non-bracket ...
19
votes
11answers
849 views

Make a numeric list converter

Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on? For ...
25
votes
9answers
1k views

De-Parenthesizing a String

Given a properly-parenthesized string as input, output a list of all nonempty substrings within matching parentheses (or outside of all parentheses), with nested parentheses removed. Each substring ...
14
votes
1answer
207 views

Virtual Keyboard Text Input

On modern game consoles and other devices without traditional keyboards, trying to input text is a nightmare. Having to type with a few buttons and a joystick on a virtual keyboard is annoying, and I ...
25
votes
3answers
519 views

¿xu ti te gismytermorna? (Is it a valid gismu?)

(Literally: "Does this follow/realize the gismu-form?") Premise The language Lojban is a constructed language, meaning in part that all of its words have been created rather than allowed to develop ...
22
votes
10answers
2k views

The XOROR sequence

Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. ...
21
votes
13answers
2k views

What ROT is this? - decrypt ROT-n

Here are the letters of the English alphabet in order by frequency: e t a o i n s h r d l c u m w f g y p b v k j x q z That is, e is the most frequently used letter, and z is the least common. ...