[Community Puzzle] Gravity

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Thought I had a solution. Output matches what is expected but still fails.

`package main

import “fmt”
//import “os”

func main() {
var output [10][101] uint8
var width, height int

fmt.Scan(&width, &height)

for i:=0; i<height; i++ {
    for j:=0; j<width; j++ {
        output[i][j] = '.'

for i := 0; i < height; i++ {
    var line string
    for j:=0; j<width; j++   {
        if line[j]=='#'         {
            for k:=height-1; k>=0; k--   {
                if  output[k][j] != '#'     {
                    output[k][j]  = '#'

// fmt.Fprintln(os.Stderr, "Debug messages...")

for i := 0; i < height; i++  {


We’re looking into it. Thank you for pointing that out.

sounds like this problem Suggestion: include unprintable characters in the error messages

1 Like

Your solution prints a lot of “\0” at the end of each line.
Like chrm said, we have an issue with unprintable characters (this will be fixed soon).

I was having the same issue in c#. I can solve the custom test case, but all the others say:
Found: Nothing
Expected: Nothing

I found that my problem was that I had an extra \n at the end of my string I was printing

1 Like

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.


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.