Questions tagged [string]
A competition to solve a particular problem through the usage and manipulation of strings.
2,070
questions
24
votes
18
answers
2k
views
Random Move 2x2 Scrambling
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible ...
9
votes
1
answer
171
views
Are We Fast And Furious? [closed]
There are currently nine feature length films in the core Fast & Furious/The Fast and the Furious media franchise, a series of films about bald men scowling and driving cars very fast. The names ...
17
votes
14
answers
971
views
Implement swap encoding
Swap encoding is an encoding method where you iterate through a string, reversing sections of it between pairs of identical characters.
The basic algorithm
For each character in the string:
Check: ...
10
votes
1
answer
275
views
CDGLF: TMN to APL
In this challenge you will remove one of my least favorite features, operator precedence from traditional math notation, to acheive the syntax of one of my favorite languages, APL. The APL subset we ...
26
votes
5
answers
2k
views
I before E, except after C
You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words.
Quoting Wikipedia:
If one is not sure whether a ...
11
votes
3
answers
344
views
Help me count the Omer
During the 49 days between Passover and Pentecost, Jewish liturgy provides four numerical problems that I've here phrased as code golf problems.
Input/Arguments
These four, in any order, and by any ...
25
votes
24
answers
2k
views
Help me get the day of the week correct
Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday).
Your challenge is to display the number of days my estimates are off by.
...
19
votes
17
answers
735
views
Convert superscripts to MathJax
CGCC hasn't always had MathJax. Back in the dark ages, it would have been necessary to write \$x^2\$ as x² (the horror!). In this challenge, you will be given some ...
18
votes
19
answers
3k
views
Did I die or not?
Given a permutation of the alphabet and an intended "word", determine if the word was guessed in a game of Hangman, where the permutation is the list of guesses.
For example, given ...
17
votes
23
answers
1k
views
Reversencode the given string
Given a string, if it is even, break the string into 2 even parts, then reverse the parts to get the "reversencoded" string.
Example:
onomatopoeia -> tamonoaieopo
If the string is not of ...
17
votes
1
answer
535
views
Golfing Expressions
We can write mathematical expressions using the standard math operators (,),+,...
9
votes
3
answers
282
views
Interpret control characters like a terminal
Given a ASCII string containing control characters, compute what it should look like when printed to a terminal. Imagining the behaviour of a cursor, this is how to treat each character in the input:
...
7
votes
5
answers
260
views
Matching homologous groups
Homologous series, any of numerous groups of chemical compounds in each of which the difference between successive members is a simple structural unit.
As an example, Alkane is a homologous group ...
31
votes
23
answers
9k
views
R.E.P.A.I.R. T.H.E. K.E.Y.B.O.A.R.D
Sequel of this AWESOME challenge
You, a genius tech prodigy detective, have successfully disarmed the bomb and want to break into the computer. The police found the password ...
4
votes
3
answers
133
views
Repeating terms of a given sentence [closed]
Program
Write a program to display repeating terms of a given sentence.
Explanation
The program must output the repeating terms of two or more letters from the given input (input is a sentence ...
13
votes
11
answers
1k
views
Variable length Fibonacci word
Challenge
For any two non-empty strings A and B, we define the following sequence :
F(0) = A
F(1) = B
F(n) = F(n-1) + F(n-2)
Where ...
11
votes
5
answers
520
views
Outsmart the boffins at New Scientist (string rotation)
The brainiacs at New Scientist tweeted this morning that "The word STABLE has the neat property that you can cycle the first letter to the end to make a new word: TABLES. And you can do it again ...
23
votes
26
answers
2k
views
Overwrite a string on a tape
Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would ...
19
votes
3
answers
2k
views
Calculate longest Stack Exchange streak
Introduction
This challenge is inspired by the Meta Stack Exchange question The longest consecutive days streak; it turns out that the URL ...
-2
votes
5
answers
188
views
Pretty printing JSON
I want format a JSON string into human-readable form. A string like this:
...
7
votes
5
answers
233
views
(Σ*)² ⟲ Σ* (Round-Trip a String Pair)
We're back! And this time with an objective scoring criteria!
This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a ...
14
votes
2
answers
485
views
What's my TIO uniqueness?
Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering <...
24
votes
27
answers
2k
views
Un-pipe an Elixir expression
Elixir is a programming language with a feature called the pipe operator, |>, similar to the pipe in Bash and other languages. It passes the result of an ...
10
votes
5
answers
509
views
(Σ*)² ⟲ Σ* (aka Round-Trip a String Pair) [closed]
This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :)
Your Task
Define two ...
25
votes
27
answers
1k
views
Decode Polybus Square/Tap Code/Prison Code
The code has a lot of names, but is very simple:
1 2 3 4 5
1 A B C D E
2 F G H I J
3 L M N O P
4 Q R S T U
5 V W X Y Z
A letter is coded by its coordinates, ...
12
votes
15
answers
787
views
Check if B is composed of substrings of A of length n
Given two strings \$ A \$ and \$ B \$ and a positive integer \$ n \$, determine whether \$ B \$ is composed entirely of (possibly overlapping) strict substrings of \$ A \$ of a length of at least \$ ...
27
votes
34
answers
3k
views
Rotate brackets until they're balanced
Take the string of brackets ]][][[. When you rotate it to the right once, you get []][][. If you rotate it again, you get ...
4
votes
6
answers
455
views
I Rot-13 the source code, you Rot-19 the output!
This is alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its ...
20
votes
24
answers
3k
views
I palindrome the source code, you palindrome the input!
This is a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you accept it, is to write a program/function that outputs/returns its input/args. The tricky ...
-5
votes
17
answers
352
views
Inverse Ax+B/Cx+D sized function
Let's assume that
$$
f(x) = \frac{Ax+B}{Cx+D}
$$
Where, \$x\$ is a variable and \$A\$,\$B\$,\$C\$,\$D\$ are constants.
Now we have to find out the inverse function of \$f(x)\$, mathematically \$f^{-1}(...
8
votes
7
answers
289
views
Find the Best Set of Adapters
I'm trying to plug this really old phone into my computer but the phone seems to use a very obscure plug. Luckily I have some adapters. Unfortunately, I can't figure out which of them to use to ...
10
votes
1
answer
304
views
Compile Commentscript
Commentscript is a variant on Javascript that I made up for the purpose of this question. Only commented-out code is evaluated.
Javascript has two types of comments:
...
35
votes
18
answers
3k
views
Find the HTTP status code
Given the name of an HTTP status code, such as OK or Continue, output or return the corresponding number. Your code is limited ...
-13
votes
15
answers
285
views
Reverse source code and double the input
For today's challenge you have to take an input, and if your source code is reversed, then the input should be printed doubled.
Let's say your source code is ABC ...
11
votes
15
answers
2k
views
Alphabet printing challenge
This challenge is related
Challenge
Your task is to write as many programs/snippets as you can, where each one outputs/prints/ returns an alphabet. The first program must output the letter ...
13
votes
10
answers
1k
views
Autogrammatic pairs
For today's task, we have two programs, P and Q, both in the same language. Each of them receives a single-character input.
If P receives character K, P says how many times K appeared in Q. (You can ...
15
votes
6
answers
879
views
Convert Gemtext to HTML
Gemtext is a very simple markup format used by the alternative web protocol Gemini. Write a Gemtext to HTML converter.
From the Wiki:
A line of text is a paragraph, to be wrapped by the client. It is ...
23
votes
10
answers
3k
views
Pangram "Hello, World!"
Your challenge: The code must print "Hello, World!" and nothing else.
Your restrictions: Your program must satisfy these requirements:
The program must be a pangram.
It must use every ...
26
votes
21
answers
2k
views
BalancE the UppercasE
Oh, No!
the sentences are out of balance.
Quick! balance them.
A word is defined as follows:
A sequence of letters [A-Za-z] separated by any non-letter character ([0-9] ~+- etc.)
A word is BaLanCeD ...
0
votes
0
answers
134
views
Is this an anagram of its own source code? [duplicate]
I like anagrams. I like programs that reference their own source code. So this challenge combines them!
Input.
The input to the program could be anything, including letters, numbers, symbols, you name ...
11
votes
1
answer
220
views
Generating minimal regular expression character classes
Background
Character classes are a standard way to indicate a set of characters to match in regular expressions. For example, the class [ab] matches a or b, ...
17
votes
12
answers
2k
views
Make a !!!Batch compiler/translator
!!!Batch is another derivative of the Windows Batch programming language, its wiki is here
Your challenge is to create an compiler/translator that reads a !!!Batch program and returns a Windows Batch ...
3
votes
5
answers
257
views
Write A Book Cipher [closed]
Introduction
Book cipher
A Book cipher is a very unique method of a encipher. Here's how's it done:
You have a book / a document or a article (something full of text, the more pages of text the ...
-9
votes
5
answers
474
views
Print your username by ONLY using the characters in your username [closed]
You have to print out your username, by only using the characters in your username.
Standard loopholes are forbidden
This is not code-golf, so shortest does not win
Don't modify your username please
...
19
votes
13
answers
935
views
Count strictly overlapping substrings
Given two strings a and b, count how many times b occurs as a substring in ...
17
votes
17
answers
3k
views
How likely is this mutation?
In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is.
The two types of substitutions ...
20
votes
12
answers
5k
views
Which Ninjutsu am I casting?
In the MMORPG Final Fantasy XIV, the Ninja class has the ability to use combinations of up to three handsigns (Ten, Chi and Jin) to perform a variety of ninjutsu skills.
The skill you cast depends on ...
38
votes
31
answers
2k
views
Evaluate left-or-right
Originally sandboxed by @xnor
Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), ...
10
votes
8
answers
587
views
Implement bottom (encode)
Challenge
The challenge is to implement the bottom encoding (only encoding, not decoding). There is a wide variety of existing implementations in the bottom-software-foundation org.
Bottom is a text ...
10
votes
15
answers
1k
views
Merge Two Paragraphs with Removing Duplicated Lines
Challenge
The goal of this challenge is to make a function that takes two paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy (but a single copy ...