Questions tagged [string]
A competition to solve a particular problem through the usage and manipulation of strings.
2,157
questions
28
votes
8
answers
3k
views
What's my type? Well... Probably
There are a lot™ of pokemon. One of the defining characteristics of pokemon is their type, of which every1 pokemon has up to two types, a primary type and an optional secondary type. There are ...
7
votes
8
answers
1k
views
Compile TailwindCSS to CSS
TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from ...
14
votes
10
answers
3k
views
When in {country}, do as the {countrians} do
(or: Output the plural demonym.)
When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, ...
10
votes
12
answers
2k
views
Encrypting Emojis
Problem
You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from ...
12
votes
18
answers
1k
views
Print a meter of numbers to a specified limit
Given a positive integer n, output a number meter formatted like this:
...
19
votes
17
answers
1k
views
Compute the convolution of two strings
While implementing polynomial multiplication in Itr I found the following interesting operation on strings
To compute the convolution of two strings (for instance ...
17
votes
13
answers
1k
views
Efficient censorship
This challenge was originally posted on codidact.
You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in ...
26
votes
17
answers
4k
views
s-n-a-k-e-a-r-o-u-n-d--->
This code-golf challenge is about walking around a string like a snake.
s-n-a-k
.---. e
d <-' a
n-u-o-r
You will be given a string \$ S \$ of length \$ l \$ and ...
13
votes
15
answers
2k
views
Can you perform swaps?
Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check ...
17
votes
23
answers
3k
views
Meta-cat program
Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input.
Note that the input may contain any printable ASCII character or newline ...
9
votes
17
answers
955
views
Continuously Count Consecutive Cases
Background
Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the ...
7
votes
4
answers
272
views
Simulate Keyboard Inputs
Background
You know how in text editors and just text fields in general, there's always that blinking bar where you type? Yeah, simulate typing there.
You'll be given 3 inputs: The current text field, ...
11
votes
11
answers
1k
views
(Robbers) Fast and Golfiest Season 1: The Lord of the Strings
Fast and Golfiest Robbers Thread
Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
17
votes
15
answers
1k
views
(Cops) Fast and Golfiest Season 1: The Lord of the Strings
Fast and Golfiest Cops Thread
Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
13
votes
8
answers
684
views
Generate all linked chains
A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge.
Linking chains
We define a chain to be a string ...
14
votes
15
answers
1k
views
Two Parallel Linked Chains
Background
We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=".
...
10
votes
5
answers
846
views
Translate the keitai input method
The keitai input method is a method for writing Japanese kana on a 12-key phone keypad. Similar to Western keypads, each kana is assigned to a key; when the key is pressed multiple times, it cycles ...
1
vote
0
answers
106
views
Bunny Shakespeare poetry [closed]
Suppose you have a grid of cells that is 6 wide and arbitrarily tall. In each cell is a word. Let the bottom row, which is row #1, be the last 6 words of sample.txt in order. Let the second to last ...
1
vote
0
answers
121
views
making a binary string palindrome using xor operations [closed]
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$...
18
votes
3
answers
2k
views
Render text in a slanted ASCII-art font
Given a text input such as:
THE QUICK
BROWN FOX
JUMPS OVER
THE LAZY
DOG
render the following output:
...
19
votes
24
answers
2k
views
Split a string on unnested commas
Create the shortest program/function/whatever that splits an inputted string along un-nested commas. A comma is considered nested if it is either within parentheses, brackets, or braces.
Input and ...
19
votes
26
answers
2k
views
Find Unique Anagrams
Challenge Description:
An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, "listen" and "silent" are anagrams. In this ...
13
votes
11
answers
2k
views
String Concatenate
You are given a string \$s\$ of characters from a to z. Your task is to count how many unique strings of length \$n\$ you can make by concatenating multiple prefixes of the string \$s\$ together.
...
11
votes
10
answers
2k
views
Parse a CSV file
In this challenge, given a CSV file as a string, you'll return the data contained as a 2d array of strings.
Spec:
The input consists of one or more records, delimited with ...
14
votes
20
answers
2k
views
String Comparison
You are given two strings \$a\$ and \$b\$ consisting of characters from a to z in lowercase. Let \$n\$ be the length of \$a\$. Let \$m\$ be the length of \$b\$. Let \$a'\$ be the string \$a\$ repeated ...
11
votes
7
answers
2k
views
Zahlen auf Deutsch! (Numbers in German)
Your task is to write a program that receives a base 10 number from 0 to 99 and outputs the German name of that number with non-ASCII characters replaced with ASCII equivalents.
German number names
<...
17
votes
10
answers
2k
views
Shortest distinguishable slice
For this challenge, a slice of a string is defined as an upper and lower index that can "cut" a piece of a string. All characters from the string in the range ...
9
votes
5
answers
729
views
On The Subject Of Simon Says
This challenge is from a game, Keep Talking And Nobody Explodes.
This is like one of those toys you played with as a kid where you have to match the
pattern that appears, except this one is a knockoff ...
11
votes
41
answers
2k
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 (...
5
votes
25
answers
496
views
String with the smallest sum of ASCII values
Description
In this challenge, you need to write a function that takes in a list of strings and returns the smallest string based on their ASCII value. You should assume that the input list contains ...
0
votes
5
answers
312
views
Mirror a String in Place
Write a program that takes a string as input and modifies it by reversing the string in its place by mirroring the position. The first position goes to last, second to second last and so it goes on. ...
10
votes
31
answers
2k
views
The number of distinct words in a sentence
Challenge: Find the number of distinct words in a sentence
Your task is to write a program that takes a sentence as input and returns the number of distinct words in it. For this challenge, words are ...
12
votes
15
answers
917
views
Sum of strings (UTF-16 codepoints)
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols
If the resulting sum is greater than ...
13
votes
16
answers
1k
views
Find opposite string
Your function must accept one string and return the opposite
The opposite string is a string where all characters go in reverse order, all letters are replaced with the opposite mirror letter from the ...
13
votes
9
answers
1k
views
Translate to plorcly borglar
plorcly borglar is a "mod" created by jan Misali for the constructed language toki pona that makes words sound funny.
It involves substituting the 14 toki pona letters for funnier versions ...
15
votes
10
answers
2k
views
Human oriented string comparison
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm:
$$
f(x, y)=
\left\{\begin{array}[rr] \\
\mathrm{EQ} & \mathrm{if}\,\...
9
votes
15
answers
2k
views
Sum of numbers of arbitrary length
Your function must accept 2 strings which are correct numbers. It needs to sum them up (without rounding and floating point errors) and return the result (which is also a correct number) without any ...
14
votes
13
answers
2k
views
Salacious Bacon Tripod
In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such ...
10
votes
9
answers
861
views
Parse basic arithmetic into an AST
Introduction
An abstract syntax tree (AST) is a tree of tokens that shows their connection to each other and syntactical meaning. They are commonly used in compilers and static analysis tools, as ...
10
votes
9
answers
794
views
Find the length of the longest substring with all different characters in O(n) time
Let's solve the same task as in this challenge but faster!
Input: a non-empty string containing letters a-z
Output: the length of a longest (contiguous) substring in which all letters are different
...
14
votes
8
answers
1k
views
Change the subject
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the ...
15
votes
20
answers
3k
views
Guess the song title
I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a ...
13
votes
17
answers
2k
views
Remove duplicates from my academic transcript
Consider a list of subject, grade pairs. E.g.
...
16
votes
15
answers
1k
views
Division between two strings
Inverse function of this challenge
To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick ...
8
votes
9
answers
2k
views
Wordle games without repeating letters
Given a word list, find all sets of five words of five letters each, such that the words of each set have 25 distinct letters in total.
This challenge was inspired by this video by Matt Parker.
...
19
votes
16
answers
2k
views
Is it true? Ask Pip!
Title is an homage to this classic challenge
In Pip, the Scalar data type encompasses strings and numbers. A Scalar value is truthy in most cases. It is falsey only if:
It is the empty string ...
15
votes
7
answers
769
views
Parse WebSocket frames
According to MDN, every WebSocket message is sent as one or more frames. Your job is to extract the payload given a (masked) client-to-server text frame. The steps to extract the payload is as follows:...
15
votes
5
answers
430
views
Flip the order of operations
Scientists have made contact with a parallel universe. Just one problem: They write math differently. Help the scientists make a program that can convert normal math expressions to their equivalent in ...
8
votes
32
answers
1k
views
Keep elements in sequence that have a letter repeated at least 3 times
Challenge:
Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like ...
28
votes
45
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 ...