Questions tagged [balanced-string]
In a balanced string certain pairs of characters or substrings always appear with the same amount. Often there are additional restrictions that those pairs also have to be ordered. The most common example is a correctly parenthesized string. See also the [palindrome] and [syntax] tags.
105 questions
14
votes
11
answers
932
views
Counting Rota-Baxter words
A Rota-Baxter word, \$w\$, is a string made of the symbols a, (, and ) such that the ...
23
votes
12
answers
6k
views
How long is this string, really?
In most programming languages, the string Hello, World! can be represented as "Hello, World!". But if you want to ...
14
votes
17
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 ...
19
votes
23
answers
3k
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 ...
10
votes
10
answers
1k
views
Language Word Checker
Develop a program to check if a given word is part of a language defined by the following rules:
The language has a set of rules.
The empty string is considered a valid word in the language.
Two ...
15
votes
20
answers
3k
views
Longest Valid Parentheses
Given a string of parentheses ( and ), find the length of the longest substring that forms a valid pair of parentheses.
Valid ...
16
votes
5
answers
448
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 ...
10
votes
9
answers
554
views
CGCC Rocket Biking
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge.
The intro
One of the most popular events at the annual Cyclist's Grand Competition for ...
23
votes
16
answers
5k
views
Remove redundant parentheses
Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that ...
20
votes
28
answers
3k
views
Rearrange to a palindrome
Given a string, shuffle it so that it becomes a palindrome.
For example, adadbcc can be arranged into dacbcad, or ...
18
votes
26
answers
2k
views
Is it a valid list?
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list.
A list is either:
...
10
votes
6
answers
437
views
Parenthetical Names
Parenthetical names
Your challenge is to build a program that puts parentheses around the 'title' part of names. For example, Sonic the Hedgehog is converted to <...
16
votes
23
answers
2k
views
Pair my brackets
Given a string consisting of ()[]{}, print the paired brackets in the same order as they appear in the string.
Any opening bracket ...
13
votes
9
answers
1k
views
Remove unmatched brackets
Inspired by @AviFS.
Given a string containing brackets, e.g.
[xyz]]abc[[def]hij[
You can parse through it with a stack of brackets. When you find an open bracket, ...
10
votes
6
answers
522
views
The Missing Match
You are given a string of unknown length that contains a varied amount of (, {, [ and their ...