Skip to main content

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.

Filter by
Sorted by
Tagged with
14 votes
11 answers
1k views

A Rota-Baxter word, \$w\$, is a string made of the symbols a, (, and ) such that the ...
Wheat Wizard's user avatar
  • 103k
15 votes
17 answers
2k views

Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check ...
Huỳnh Trần Khanh's user avatar
10 votes
10 answers
1k views

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 ...
Huỳnh Trần Khanh's user avatar
16 votes
5 answers
501 views

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 ...
mousetail's user avatar
  • 14.4k
23 votes
16 answers
5k views

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 ...
mousetail's user avatar
  • 14.4k
18 votes
26 answers
2k views

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: ...
emanresu A's user avatar
  • 46.2k
16 votes
23 answers
2k views

Given a string consisting of ()[]{}, print the paired brackets in the same order as they appear in the string. Any opening bracket ...
math scat's user avatar
  • 9,528
10 votes
6 answers
594 views

You are given a string of unknown length that contains a varied amount of (, {, [ and their ...
code's user avatar
  • 541
28 votes
18 answers
2k views

The challenge is simple, find the matching parentheses for every one of the parentheses in a given string input E.g. ()()() -> [1, 0, 3, 2, 5, 4] Always start ...
DialFrost's user avatar
  • 5,189
16 votes
18 answers
1k views

Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 9. Weekends are Bubbler's days off from posting these lol A large stream blocks your path. ...
lyxal's user avatar
  • 35.6k
12 votes
1 answer
850 views

Ungolfed, ugly, horrible proof to help you make progress on this challenge: https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2 A bracket sequence is a string that consists of the ...
Huỳnh Trần Khanh's user avatar
21 votes
31 answers
3k views

Task: Input will consist of some text, with nested [] separating some of it into nested groups: ...
rydwolf's user avatar
  • 19.3k
20 votes
11 answers
4k views

Picolisp has a feature called "super parentheses": Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost ...
Wezl's user avatar
  • 1,496
28 votes
34 answers
3k views

Take the string of brackets ]][][[. When you rotate it to the right once, you get []][][. If you rotate it again, you get ...
rydwolf's user avatar
  • 19.3k
4 votes
5 answers
5k views

Objective Mimic Haskell's reads :: ReadS (). Or in other words, parse nested parentheses. Since the target type is () (the type ...
Dannyu NDos's user avatar
  • 7,371
18 votes
14 answers
3k views

Background Famously, the acronym GNU stands for GNU's Not Unix. 1 It's recursive because, after expanding it once, it still ...
Jonah's user avatar
  • 34.1k
14 votes
17 answers
3k views

Challenge Taken from here and also here An n parentheses sequence consists of n (s and n )s. A valid parentheses sequence is ...
Luis felipe De jesus Munoz's user avatar
6 votes
2 answers
239 views

Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following: $$ a-b-c ...
ბიმო's user avatar
25 votes
25 answers
3k views

You will be given a string s. It is guaranteed that the string has equal and at least one [s and ...
Windmill Cookies's user avatar
15 votes
11 answers
2k views

Task Encode a string that entirely consists of uppercase alphabets (A-Z) using only zeros and ones, using your own favorite scheme. But the rule isn't that simple! ...
Bubbler's user avatar
  • 79.3k
18 votes
9 answers
715 views

Normal brackets ((),[],<> and {}) are nice and ...
Wheat Wizard's user avatar
  • 103k
13 votes
6 answers
414 views

In case you missed Encode Factor Trees, here is the definition of a Factor Tree: The empty string is 1. Concatenation represents multiplication. A number n enclosed in parentheses (or any ...
Nissa's user avatar
  • 3,664
13 votes
7 answers
504 views

I once saw on the xkcd fora a format for expressing numbers in an odd way. In this "factor tree" format: The empty string is 1. Concatenation represents multiplication. A number n enclosed in ...
Nissa's user avatar
  • 3,664
21 votes
14 answers
2k views

A balanced string is a string of parentheses () so that every parenthesis is can be matched with another one. More rigorously they are the strings spanned by this ...
Wheat Wizard's user avatar
  • 103k
13 votes
3 answers
372 views

A quotation is "the repetition of one expression as part of another one". In American English, a quotation is surrounded by double-quotation marks ("), as in the previous sentence. However, this rule ...
musicman523's user avatar
  • 4,802