CGX Formatter puzzle discussion

Hello all,
strangely enough, my (Javascript) code passes all test cases and all validation tests but one: “Block without spaces not containing a value”.
This is strange, because you’d presume from the title that this means having an empty “()” block, which is covered by the test cases named “Empty block” (alone) and “Full example” (inside another block), that my code passes.

Any idea what this validation test actually is ? I cannot decently stay with 95% success :smile:

2 Likes

Hello !

I have the same probleme :
-> I can’t pass one test: ‘Simple key/value with spaces’.

all the other test passed…
all the exemple in the forum passed (no problem with space or tab)

Hi all !
Like some people in this thread, I was blocked at post-submission tests, namely :

Valeur booléenne avec espaces blancs (Boolean value with spaces)
    Simple clé/valeur avec espaces blancs (Simple key/value with spaces)
    Bloc avec espaces blancs contenant une valeur (Block with spaces containing a value)

Until I discovered this :
Non-string values (true, false, null) can have white spaces inside, and these white spaces should be removed.
For example :
tr ue
should be replaced by
true

Maybe it could work for others too :wink:

5 Likes

I’ve got the same problem here, I don’t know if you found a solution for that problem since you posted the post. I assume it is a test case like ‘()’ as well, but I’m not sure.

I’m kinda sad about it ^^

1 Like

So, for those looking for a solution, test your code with a string like ‘( )’.
If it doesn’t show :
(
)

then your code isn’t ok.

I’m now at 100%, and happy

6 Likes

hi, my code also doesn’t work for “simple key/value with spaces”… it works in all other cases… can u give some examples with expected output…please help

1 Like

there is no need to create some tree / map structure to save parsed keys and values, and that’s a pity
this task can be solved much easier when treating ()=; symbols like formatting characters for output
and the case / switch operator i wrote to solve this puzzle is even easier than one for depressed robot

I solved this one with a finite-state machine.
Dirty solution but it worked.

My solution is a multiple-pass one but does not encounter timeout (I used Java). I removed all space types of characters including new line characters but excluding those in a string in the first pass. I then process the formats.

Wow, thanks a lot. The test says “Block without spaces not containing a value”, but there is a space between the parentheses. It is kind of confusing, but still thanks a lot :smiley:

2 Likes

Reading the discussion helped me to resolve this case Block with spaces containing a value But I’m still stuck with Block without spaces not containing a value. I don’t really understand the difference with the Full example testcase.

I tested several posibility without space and no value like:
http://pastebin.com/J0LtGCPs

"'plop'=(();())"
"'plop'=(();)"
"'plop'=(())"
"()"

I don’t see other cases, I must be missing something, but i don’t know what.

2 Likes

Hello.
I have coded an algo to solve the Indentation CGX puzzle. All tests are Ok but when i submit my code, there are still some errors

  • Simple chiffre
  • Bloc contenant une suite de clés / valeurs
  • CGX Contenant toutes les règles d’indentations

Do you have some tips about the reasons that make my algo failed on it ?
thx

Ok i found out my problem : solved @ 100% now
i forgot to remove the indentation when encountering true,false or null after a = character

i debugged my code with the following input :
(‘un’=1;‘deux’=‘TWO TWO’;‘trois’=null;‘quatre’=true;‘cinq’=false;‘centvingtdeux’=122)

Hope it helps.
Good luck

3 Likes

Hello,
Have any idea what I can miss for both:

  • Empty string of characters with spaces
  • Simple key/value with spaces
1 Like

Hi,

I reviewed all the previous answers but none seemed to address this point specifically.
I can’t pass the test:
“Simple string of characters which must not be modified”.

I tried everything:

  • Tabs and Whitespaces before the string of characters. I remove them preemptively.
  • Preserve Tabs, Whitespaces and even NewLines in a string of characters. I preserve them, checked everycase I could imagine. I even tried it on KeyValues instead of PrimaryValues only.
  • Tabs and WhiteSpaces after the string of characters. I remove them preemptively.

Can someone, exemplify or explain what is this test??

Thanks in advance for the time reviewing this post. :smiley:

2 Likes

Have you kept the string delimiters?

Hi, my code is also failing on that single test : “simple key/value with spaces”.
But I am confused with the fact spaces/tabs should be removed from key-values containing them, since the specs state that the content of character strings should not be altered.
if anybody can give pointers on this… thanks a lot, help much appreciated (-:

Test1[simple]:
“1
‘abc’”
Answer:
“‘abc’”
Test2[space+tab]:
“1
‘a b c’”
Answer:
“‘a b c’”
Test3[paragraph]:
“2
‘a b
c’”
Answer:
“‘a b
c’”
Test4[Assignment]:
"5

‘a’=‘a bc’

"
Answer:
“‘a’=‘a bc’”
Test5[assignment in which variable has paragraphs]:
"7

’ _
a ! .
b
cd’ = ’ :
a b c’"
Answer:
“’ _
a ! .
b
cd’ = ’ :
a b c’”

I tried many variations on these tests and they seem fine. Does anyone know what I am missing in these tests??

I pass all tests by simple if-else statement. Is there a better way to do it in python3?

I pass everything but
Boolean value with spaces
Empty string of characters with spaces
I have no idea whts wrong.
I’ve tested everything I found in this forum. All was good.
If someone can give me an example for these two so i can see
whats going on, that would be very nice.
Greetz

Edit:
Problem solved. Forgot ‘\n’ …