Community Puzzle Gravity in Bash passes tests but not validators

I solved the community puzzle gravity in bash.

I use cut and paste (the unix commands cut and paste) and sort. All the tests are passing. But when I submit only the first validator is passing. I have tried different variations of the bash code but everytime only the first validator is passing. I tried on my own system and it handles hundreds of lines and characters without a problem.

Can it be that the gnu/linux/unix system for the test is different than for the validators?

Can someone from the team please take a look?

I can post the code if it is required and/or allowed.

Not sure if it’s related, but beware of the locale with sort. IIRC it’s “LC_ALL=en_US.UTF-8” on CG.

Thank you for reminding me about LC_ALL.

I added LC_ALL=C and had to reverse sort but the result is still the same: all the tests are passing but only the first validator is passing.

I also did uname -a and cut --version. At least for the tests it looks like a fairly recent ubuntu system.

It happens because you use two ways to read the input: “read” and “cat”.

thank you for looking into this.

i understand that a combination of read and cat can mess up the stdin buffer. yet it works fine in the ide tests. it also works fine on my local machines (recent arch linux and ubuntu). only the validators are failing.

i have now tried three combinations: using read and cat, using only read, using only cat. all three pass all tests in the ide. but alle three pass only two tests in the validator. test 1 (example) and test 3 (codingame) pass, test 2 (one fall) and test 4 (snow) fail. regardless of cat or read or both.

can you confirm that the ide tests and validators are done on the same or different systems? maybe with different versions of bash or coreutils or glibc?

ok we had the same issue with someone who used “read” and “stdin” but it seems to be something else actually. So there is a bug. We’ll investigate further. Sorry :confused:

ok we found the issue.

For all validators, we use the same environment. But on the IDE, even for the “play all testcases” button, we do run tests on separate environments. So you just need to clear the columns you’re creating in each test at the beginning of your code.

Voilà!

1 Like

thank you for solving this. it indeed works when i delete the temporary files i create.

do you plan to solve this so that the validators get a clean environment for each test?

Nope, I don’t think so.