CGX Formatter puzzle discussion

I’m sure everything is right :sweat_smile:.
I would like a tip on the cases 3 and 5 on check.

Help me, please

You mean testcases 3 and 5 or validators 3 and 5 ?
Testcases 3 and 5 are visible if you click on the upper right corner of the testcase area.
You can see the inputs and the expected output.

If you get 100% on testcases but fail on validators 3 and 5, then it will be harder to debug cause validators are not known for official puzzles like this.
So unless an admin gives you insights about those validators, you’ll have to debug it by yourself.
Maybe read the full thread cause it can be interesting, re-read the statement carefully, try all edgecases you can think of with custom testcases (if you set expert mode you can add your own testcases).

1 Like

What does \9 mean on the expected outputs?
Sorry, it actually appeared in my code’s outputs, not the expected outputs. But why did that show up?
Edit 2:
Wait, it also appeared on the expected outputs.

It means horizontal tab, aka “\t”.

For anyone confused about the simple key/value with spaces test #6, my problem was that there was spaces in between the key and the ‘=’.

That was it, thank you @Firefly !
I was getting the 95% because one validator was failing.

Previously I was managing only the spaces around ‘=’. Watch out on this point! :slight_smile:

Can someone please give me an example of Empty string of characters with spaces validator, as it is the only one my code is not passing?
My code works with empty strings (''), deals with spaces inside and/or around strings, with strings consisting in spaces (' ') or when the input is only spaces.

Hello, I also get 95% and can’t pass the ‘Block with spaces containing a value’. Did you already found a sample test case to validate this?


There can be spaces in the original CGX content almost everywhere : before and after parenthesis, semicolons, and equal signs.
Everywhere a space can be, you can also encounter TABULATION (’\t’) ! I had a hard time figuring this, as you can pass all the test cases without handling tabulations, but not final tests.
There are certainly many ways to solve this puzzle, so my solution is only an exemple. I never studied parsers or lexers, so my approche is probably quite “naive”, and lacks efficiency. But it gives a cool example of inheritance / polymorphism, very important concepts of OOP.

[no full code please]

[no ad please]

[no full code please]

Hope this code will help you.

Hi everyone,

I can’t pass the validator #6 (simple key/value with spaces), and I can’t really figure out why.

I have already read the posts mentionning this issue, but I still don’t really understand.

The examples are using this input :
["(‘key’=‘value’)"], which gives with my code the right result:

With my code, all this variant with spaces and tabs gives the same answer :["\t \t (‘key’ \t \t = \t \t ‘value’)"]

So I don’t really get which space can be misleading in the validator #6

Does anyone have a clue? :slight_smile:


i have the same problem (#6) and I think it’s something like
(key=my key;)
without quotes but I am not sure

@V.Antoine @fireproof75
Re: validator #6 (simple key/value with spaces)
Do these comments help?

1 Like

@5DN1L thanks a lot for your answer!

I already had to look to those comments, but unfortunately it doesn’t seem to be the same issue:

With input ["(\n’key’= t\nr u\ne\n)"], (example from comment #1), I obtain:
which seems to be the right answer.

So I’m really confused…

So I finally got 100% thanks to @5DN1L !

The case that made me realize my mistake is the following:
((tr ue)
alse) ; (0))

Once I fixed this issue, the validator #6 was ok :slight_smile:


Validator Empty string of characters with spaces (number 5) seems to have 3 lines. The line number 2 should have 2 spaces, then 2 quotes. Two other lines (line number 1 and line number 3) sould have between 1 and 3 spaces.

same here. any news one year later ?

For those getting 95% only failing the test Block with spaces containing a value, it is needed to ignore whitespaces and tab characters as well.
So for example for this block:

(tr u e)

The expected result is:


while for this other block:


The expected result is:


I hope this helps


I think I have tested all the additional tests on this topic but I still can’t pass 2 validators:

  • validator #7 - Simple key/value with block
  • validator #14 - Block containing a string of characters without spaces

Do you have an idea of a test that would allow me to debug these validators?

Not sure if relevant/useful, but have you tried all the cases listed in the statement? A few of them are not included in the test cases.