Skip to main content
168 votes

Count of "a"s and "b"s must be equal. Did you get it computer?

Python 3, 32 bytes eval(input().translate(")("*50)) Try it online! Outputs via exit code: Error for false, no error for True. The string is evaluated as ...
xnor's user avatar
  • 145k
69 votes

N(e(s(t))) a string

Python, 41 39 34 bytes lambda e:"(".join(e)+")"*~-len(e) Ideone it Pretty self explanatory. It puts a parenthesis between every other ...
Wheat Wizard's user avatar
  • 98.8k
67 votes

Write a brain-flak classic interpreter!

Brain-Flak Classic, 1271 1247 1239 bytes ...
Nitrodon's user avatar
  • 10.8k
48 votes

N(e(s(t))) a string

MS-DOS .com file, 30 bytes 0000 fc be 82 00 b4 02 ac 88 c2 cd 21 ac 3c 0d 74 0d 0010 b2 28 50 cd 21 5a e8 f0 ff b2 29 cd 21 c3 The string is passed to the ...
Martin Rosenau's user avatar
40 votes

Are the brackets fully matched?

Brain-Flak, 1101, 1085, 981 bytes ...
DJMcMayhem's user avatar
  • 59.3k
36 votes
Accepted

Count of "a"s and "b"s must be equal. Did you get it computer?

MATL, 5 4 bytes tSP- Prints a non-empty array of 1s if the string belongs to L, and an empty array or an array with 0s (both falsy) otherwise. Thanks to @...
Dennis's user avatar
  • 210k
33 votes

N(e(s(t))) a string

JavaScript (ES6), 40 34 33 bytes Saved 6 bytes, thanks to ETHproductions A recursive function. f=([c,...s])=>s+s?c+`(${f(s)})`:c Try it online!
Arnauld's user avatar
  • 193k
33 votes

Expand compressed brain-flak

Brain-Flak, 952 916 818 bytes ...
Kamil Drakari's user avatar
30 votes

Are the brackets fully matched?

Brain-Flak, 204 196 190 bytes ...
Nitrodon's user avatar
  • 10.8k
30 votes

Can Pac-Man Eat This String?

Retina, 55 38 bytes i`^(([elp])|[^ghos]|(?<-2>.))* $.&$*_< Try it online! (The first line just allows running several test cases at once.) ...
Martin Ender's user avatar
30 votes

Find the First Bracket Match

Brain-Flak, 685, 155, 151, 137 bytes ...
DJMcMayhem's user avatar
  • 59.3k
28 votes

Count of "a"s and "b"s must be equal. Did you get it computer?

Retina, 12 bytes Credits to FryAmTheEggman who found this solution independently. +`a;?b ; ^;$ Prints 1 for valid input and <...
Martin Ender's user avatar
28 votes

N(e(s(t))) a string

Brainfuck, 42 40 bytes >+[-->+[<]>-]>+>>,.,[<+<.>>.,]<<+>[-<.>] Try it online! Ungolfed: ...
Alex Howansky's user avatar
26 votes

Count of "a"s and "b"s must be equal. Did you get it computer?

Haskell, 31 bytes f s=s==[c|c<-"ab",'a'<-s]&&s>"" The list comprehension ...
xnor's user avatar
  • 145k
25 votes

N(e(s(t))) a string

05AB1E, 11 bytes S'(ý¹g<')×J Try it online! Explanation: ...
acrolith's user avatar
  • 3,928
25 votes

(A[l(t[e(r)n]e)s]t) a string!

Python 3, 70 69 65 bytes -1 byte thanks to @Uriel -4 bytes thanks to @xnor f=lambda s,b=0:s and'(['[b]+s[0]+f(s[1:-1],~b)+s[1:][-1:]+')]'[b] Try it online!
ovs's user avatar
  • 59.5k
23 votes

Ungolf my tinylisp code

tinylisp, 1022 bytes ...
emanresu A's user avatar
  • 38.8k
19 votes

N(e(s(t))) a string

Brainfuck, 44 bytes >+++++[-<++++++++>],.,[<.>.>+<,]<+>>[-<<.>>] Reads a byte at a time, puts an open-paren before each ...
user59468's user avatar
  • 271
19 votes

N(e(s(t))) a string

Haskell, 30 bytes f[x]=[x] f(a:b)=a:'(':f b++")" Usage example: f "Nest a string" -> ...
nimi's user avatar
  • 35.9k
18 votes

Count of "a"s and "b"s must be equal. Did you get it computer?

Grime, 12 bytes A=\aA?\b e`A Try it online! Explanation The first line defines a nonterminal A, which matches one letter <...
Zgarb's user avatar
  • 42.7k
18 votes

N(e(s(t))) a string

Jelly, 9 8 bytes -1 byte thanks to @Dennis (use mould, , in place of length, L, and repeat, ...
Jonathan Allan's user avatar
17 votes

Rotate brackets until they're balanced

Husk, 7 5 bytes ṙ¹η◄∫ Try it online! No loops, no recursion, just a straightforward simple operation. Encodes [ as ...
Leo's user avatar
  • 12.7k
17 votes

Remove redundant parentheses

Regex (Perl / PCRE / Boost / Pythonregex), 45 44 45 44 43 bytes s/(\(|^)\K(\((((?2)|[^()])*)\))(?=\)|$)/$3/ Try it online! - ...
Deadcode's user avatar
  • 11.6k
16 votes
Accepted

Can Pac-Man Eat This String?

Jelly, 34 33 bytes Œl“ʋʋ“ṁḍ»ċ€Ð€IF+\‘0ṭi0ð’”_×;”<;ṫ@ Try it online! I think I'm finally starting to understand Jelly. Feels a bit scary.
PurkkaKoodari's user avatar
16 votes

Balance the Brackets

Brain-Flak, 1350 bytes ...
Nitrodon's user avatar
  • 10.8k
15 votes

N(e(s(t))) a string

Retina, 22 17 bytes \1>`. ($& T`(p`)_ Try it online! Alternatively: S_` \`¶ ( T`(p`)_ Explanation I always forget ...
Martin Ender's user avatar
15 votes

AoCG2021 Day 11: Garbageful streams

Retina 0.8.2, 12 bytes !. <.*?> } Try it online! Link includes test cases. Explanation: The first stage deletes !s and ...
Neil's user avatar
  • 172k
14 votes

N(e(s(t))) a string

J, 13 bytes (,'(',,&')')/ J executes from right-to-left so using the insert adverb /, a verb can be used to reduce the ...
miles's user avatar
  • 16.9k
14 votes

N(e(s(t))) a string

><>, 19 18 bytes io8i:&0(.')('o&! o Try it online! Explanation The first line is an input loop which prints everything up to the last character of ...
Martin Ender's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible