[Community Puzzle] Level of nested parentheses

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @TheMagicShop,validated by @timbersson,@Lisa-Has-Ideas and @UncleV.
If you have any issues, feel free to ping them.

Hello,

I pass all the tests, but I fail at validator 4.

As the tests do not contain a sample with empty brackets (), I checked my solution works in this case.

Please, do you have any other idea for check I should do to pass validator 4 ?

Only test case with empty parenthesis, try this: (test())

Edit: I am blind, you literally said you tested it already…
Only test case with unclosed ", perhaps you check them? : (test ’ " ())

Hello, I double-checked validator 4. It is a lisp expression. It is correct from a parenthesis point of view, very similar to example 4, but - fun fact - there is a syntax error: a double-quote that is never closed. Could this make your program fail? Try to make a custom test by copying test 4 but removing the double-quote after “factorial” and see if you program work.

Actually you should ignore any character that is not a parathesis…

I have the same issue (at least I think I have the same issue): the validator 4 is the only one that fail. I have the following outputs for the 2 examples you suggest:

(test ’ " ())
^         ^^^
|         |||
|         22|
1-----------1
(defun fact (n) "factorial (if (<= n 1) 1 (* n (fact (- n 1)))))
^           ^ ^            ^   ^      ^   ^    ^     ^     ^^^^^
|           | |            |   |      |   |    |     |     |||||
|           2-2            |   3------3   |    |     5-----5||||
|                          |              |    4------------4|||
|                          |              3------------------3||
|                          2----------------------------------2|
1--------------------------------------------------------------1

I feel like the answer are correct. What did I miss?

1 Like

Seems correct to me.

An other idea would be: only test case starting with a space:

 (fun ( " ()))

Or only text case with a closing parenthesis directly followed by an opening parenthesis. Try: (a+b)(c+(d+c))

I tried both. and others. here are the results (looks fine for me):

 (fun ( " ()))
 ^    ^   ^^^^
 |    |   ||||
 |    |   33||
 |    2-----2|
 1-----------1
(a+b)(c+(d+c))((c+d)+c)(a+b)(a+b) (a+b)
^   ^^  ^   ^^^^   ^  ^^   ^^   ^ ^   ^
|   ||  |   ||||   |  ||   ||   | |   |
1---1|  2---2||2---2  |1---11---1 1---1
     1-------11-------1

What did I miss?

I am sorry we could not find the issue.
Try this one:

(a b (c &d (e '())) "f (g (h i) j (k (l m) (n (o p) q))))

(a b (c &d (e '())) "f (g (h i) j (k (l m) (n (o p) q))))
^    ^     ^   ^^^^    ^  ^   ^   ^  ^   ^ ^  ^   ^  ^^^^
|    |     |   ||||    |  |   |   |  |   | |  |   |  ||||
|    |     |   44||    |  3---3   |  4---4 |  5---5  ||||
|    |     3-----3|    |          |        4---------4|||
|    2------------2    |          3-------------------3||
|                      2-------------------------------2|
|                                                       |
|                                                       |
1-------------------------------------------------------1

It also seems good for me

Nop. The outer 1 is one character too long (or too high if you prefer).

This is the expected output:

(a b (c &d (e '())) "f (g (h i) j (k (l m) (n (o p) q))))
^    ^     ^   ^^^^    ^  ^   ^   ^  ^   ^ ^  ^   ^  ^^^^
|    |     |   ||||    |  |   |   |  |   | |  |   |  ||||
|    |     |   44||    |  3---3   |  4---4 |  5---5  ||||
|    |     3-----3|    |          |        4---------4|||
|    2------------2    |          3-------------------3||
|                      2-------------------------------2|
1-------------------------------------------------------1
1 Like

Nice catch! I didn’t saw it. thanks

I am curious to know why this bug did not appear on the examples. Can you explain?