Skip to main content

Questions tagged [string]

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

Filter by
Sorted by
Tagged with
28 votes
78 answers
4k views

String rotation - output string repeatedly moving first character to the end

The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string: ...
26 votes
39 answers
2k views

Segments of a string, doubling in length

Simple task today. Given a string whose length is one less than a whole power of 2, divide it into segments with doubling length. For example for the string ...
30 votes
28 answers
3k views

Compare version numbers

When we publish some software, we assign a version number to it. And users may want to update to the latest version of some software. So, it is the time to find out which version should be newer. ...
15 votes
16 answers
3k views

Palindrome distance

Find what is the distance for a given string to its closest palindrome of the same length. For this task I decided to give the characters further away from the string's center more weight (think of it ...
10 votes
11 answers
3k views

Keyboard Ping Pong

Keyboard Ping Pong (This question was inspired by this post.) Challenge Given a string of letters, determine if the word "ping-pongs" across the keyboard. (Letters alternating between sides ...
53 votes
100 answers
8k views

Is it a pangram?

Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) ...
28 votes
26 answers
3k views

Help Alice fix her text!

When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so q became ...
39 votes
46 answers
3k views

Interleave strings

Inspiration.* I cannot believe we have not had this challenge before: Task Given one or more printable ASCII strings, interleave them by taking one character from each string, cyclically until out ...
28 votes
4 answers
10k 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 ...
42 votes
52 answers
6k views

Every word from babab to zyzyz

Your task is to write a program that will output a readable list of every five letter words with the structure: consonant - vowel - consonant - vowel - consonant The output should be sorted ...
34 votes
53 answers
3k views

Split a list at the second occurrence of the first element

Why should you golf in Haskell? Find out here. In that answer, Zgarb defines a task: Let's define a function f that splits a list at the second occurrence of the ...
51 votes
55 answers
5k views

Split string on first occurrence of each character

Related. Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs. ...
523 votes
986 answers
195k 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 ...
14 votes
20 answers
1k views

Simple CSV/DSV importer

Slightly more than an inverse of this. In: Multi-line DSV data and a single delimiter character. The DSV may be taken as a file, a filename, line-break separated string, list of strings, etc. ...
31 votes
49 answers
3k views

Transpose a page of text

EDIT I modified the wording of the rules to make some things which were implicit more explicit. I also added some emphasis to clear up some points of apparent confusion, and explicitly defined the ...
18 votes
9 answers
4k views

Google Autocomplete Fun

Your task is to create a program which, given an input string, will output the first Google autocomplete result for that search. The format of input/output is up to you. Rules Your program must take ...
30 votes
63 answers
4k views

Is it a pure word?

Introduction A pure word (or perfect word), as defined by me, is a word where the sum of the position in the alphabet of each letter in the word is perfectly divisible by the total length of the word. ...
19 votes
22 answers
1k views

Find characters common among all strings

Find characters common among all strings You are given multiple Strings as an input. Your task is to find the characters that are present in every string, and ...
42 votes
42 answers
4k views

Interlace strings

Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order. Examples ...
12 votes
42 answers
3k views

Counting Letters in a String

Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive. Input: A string consisting of printable ASCII characters (...
22 votes
25 answers
2k views

Generate an arbitrary half of a string

Given a string \$ x \$, we say another string \$ y \$ is half of it, if both of the following properties are true: \$ y \$ is a (not necessarily continuous) subsequence of \$ x \$ - there exists a ...
17 votes
34 answers
2k views

String Zip and Sort

Given a list of strings, output a single string formed by taking a character from each string at each position, sorting them by ASCII ordinal, and appending them in order to the output string. In ...
37 votes
73 answers
6k views

Longest Common Prefix of 2 Strings

Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins. ...
36 votes
51 answers
4k views

Slowly turn a string into another

The Challenge Given two strings/an array of strings, output the first string slowly shrinking and expanding back into the second string. You can assume the strings will always start with the same ...
26 votes
28 answers
2k views

Words that Contain Digits

A digit word is a word where, after possibly removing some letters, you are left with one of the single digits: ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO). For example, BOUNCE ...
37 votes
38 answers
6k views

aaabbabbc⠀⠀⠀⠀⠀⠀

One element of the list aa, ab, ba, bb, c has been removed, and the remainder shuffled and joined with no separator. Find the missing element. For example, if the ...
19 votes
24 answers
3k views

Just another traffic jam!

One lane is closed, the vehicles have to thread their way in according to the zip-lock system: One car from one lane, the next car from the other lane, always taking turns. Input: Two vehicle queues, ...
17 votes
52 answers
4k views

Create a Parrot Program

Given an input, output that input followed by a newline endlessly. Input will be a string consisting only of printable ASCII characters (0x20-0x7E) and newlines (<...
33 votes
42 answers
2k views

Lengthen letter runs

Given a non-empty string of lowercase ASCII letters a-z, output that string with each consecutive “run” of the same letter lengthened by one more copy of that ...
32 votes
49 answers
4k views

Find max sequence length

Assume we have a string, and we want to find the maximum repeated sequence of every letter. For example, given the sample input: "acbaabbbaaaaacc" Output for ...
29 votes
48 answers
2k views

Replace 0s In a String With Their Consecutive Counts

Challenge Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit ...
31 votes
44 answers
4k views

Is my name official?

Introduction As ToonAlfrink says: "Me thinks there aren't enough easy questions on here that beginners can attempt!". So the task is very simple. Given a string, output a truthy or falsy value ...
14 votes
10 answers
1k views

Enumerate all matches of a regex

related For this challenge, we'll be using a simplified dialect of regular expressions, where: A lowercase letter from a to z ...
35 votes
63 answers
5k views

Vowels up, consonants down

Challenge You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower ...
101 votes
62 answers
14k views

Make a "Ceeeeeeee" program

Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, ...
32 votes
54 answers
3k views

Number to String in aaaaa way!

In this challenge, you are going to take a number and turn it into a string, but not in the common way. You will use the aaaaa way! The ...
96 votes
174 answers
24k views

"99 Bottles of Beer"

Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: ...
45 votes
58 answers
6k views

pwaS eht tirsf dna tasl setterl fo hace dorw

Or, "Swap the first and last letters of each word" Your challenge is to, given a string of alphabetical ASCII characters as well as one other character to use as a delimiter (to separate each word), ...
93 votes
251 answers
20k views

"DDoouubbllee ssppeeaakk!!"

Super simple challenge today, or is it? I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way... Double speak is when each and every character in a ...
146 votes
92 answers
24k views

Hello, World! (Every other character)

Write a program that prints "Hello, World!". But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!". If your ...
18 votes
80 answers
2k views

Element of string at specified index

Given a string s and a non-negative number n less than the length of s, output the character ...
29 votes
69 answers
8k views

Is string X a subsequence of string Y?

Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and ...
64 votes
78 answers
5k views

Same length, different string

Challenge Given a non-empty string S of length L consisting entirely of printable ASCII chars, output another string of length L that consists entirely of printable ASCII chars, but is not equal to S....
53 votes
86 answers
5k views

Bernardino identifies unaltered dollar words

Definition A dollar word is a word where when each of its letters is given a cent value, from a = 1 to z = 26, and the letters are summed, the result is 100. Here is an example on CodeReview, and here ...
11 votes
20 answers
3k views

Can the chefs go?

On the TV cooking show Guy's Grocery Games, the chefs cannot begin shopping until Guy Fieri, the show's host, says "Three, two, one, go!" However, the words do not have to be all together. ...
65 votes
66 answers
11k views

One more LUL and I'm out

Challenge description On some channels on a popular streaming site twitch.tv a common message people tend to spam in chats to bait people into spamming "LUL" is ...
20 votes
29 answers
2k views

Break a word into vowels and consonants

Objective Given an string \$n\$, output two strings, namely the string consisting of vowels "a", "e", "i", "o", and "u", and the string consisting of ...
1 vote
2 answers
234 views

Write a function that takes an input string and encodes it using a modified Fibonacci sequence in reverse [closed]

Given an input string, first convert each character to its ASCII value. Generate a reversed Fibonacci sequence of the same length as the input string. Encode each character by adding its ASCII value ...
7 votes
7 answers
583 views

Build the first 6 letters of an Italian codice fiscale (tax identification number)

Given a single string with a person's name and surname, output the first 6 characters of their codice fiscale. Codice fiscale Codice fiscale is a 16-character long alphanumeric string that identifies (...

1
2 3 4 5
45