1
\$\begingroup\$

Consider a string like:

a.push(c.push("a",["ad","bd",2,{"ard",duo}]).pop().replace(2,"tg").enc([3,{2,adf},"atr"],5)

Write a program that will verify whether a string is correctly bracketed. A correctly bracketed string can be defined as one in which all brackets are terminated (closed), and the inner brackets are terminated before outer ones. Below are example strings:

Correctly bracketed:

  • a.push(a,{b,[c,d]})

Incorrectly bracketed:

  • a.push(a,{b)}

Your program must be able to deal with the following types of brackets:

  • Curly (flower) brackets {}
  • Square brackets []
  • Parantheses ()

If necessary, the string may contain any of these characters:

  • Alphabets, uppercase and lowercase (A-Z, a-z)
  • Numerics (0-9)
  • Double quotes ("), but not single quotes
  • Arithmetic operators (+, -, *, /)
  • Dots (.)

This is , so the shortest code in terms of bytes wins. The winning answer will be chosen after 7 days from the time of the post.

\$\endgroup\$
2
  • \$\begingroup\$ Related or maybe even a duplicate. \$\endgroup\$
    – nimi
    Commented Dec 8, 2018 at 13:13
  • 2
    \$\begingroup\$ Well written challenge, unfortunate conclusion. \$\endgroup\$
    – Arnauld
    Commented Dec 8, 2018 at 13:33

0

Browse other questions tagged or ask your own question.