[Community Puzzle] ASCII Snakes - Puzzle discussion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @ajaiy,validated by @DeanTheMachine and @Edjy.
If you have any issues, feel free to ping them.

I have a problem. All testcases are green, but when I submit my code I get only 75%. One validator “Snaaaaaaaaake” isn’t working, but I have no idea what I have wrong in my code. Could you write this validator here? @ajaiy, @DeanTheMachine, @Edjy

Check that your code deals with starting from a horizontal direction “L” or “R”.

Info

I’ve not done this puzzle but it seems that the first result would be as follows:
L:

--+
--+

R:

+--
+--
1 Like

Good point, I added it, but it is still failing :frowning:
I tested it locally and everything is working. Probably I missed some case, but I don’t have idea what can be wrong.

Try this custom case:

Input:

RRDDRRURRRDRRDLLDLLLULDDLLDRRRRURRRRDRRRRD

Output:

+-------+
+-----+ |
      | |   +----------+
      | |   | +------+ |
      | +---+ |      | +-----+
      +-------+      +-----+ |
         +----+      +-----+ |
         | ++ |      | +-----+
         | || +------+ |
         | |+----------+
   +-----+ |   +-------------+
   | +-----+   | +---------+ |
   | +---------+ |         | +-----------+
   +-------------+         +-----------+ |
                                       | |
                                       +-+
1 Like

I tried it, I think output is correct.

My output:

+------+
+----+ |
     | |   +----------+
     | |   | +------+ |
     | +---+ |      | +-----+
     +-------+      +-----+ |
        +----+      +-----+ |
        | ++ |      | +-----+
        | || +------+ |
        | |+----------+
  +-----+ |   +-------------+
  | +-----+   | +---------+ |
  | +---------+ |         | +-----------+
  +-------------+         +-----------+ |
                                      | |
                                      +-+

Maybe I did something wrong with start size of buffer? Or I get timeout?

I created 500x500 grid at the begining and start from the middle.

No, your output isn’t the same as mine. Count the “-” carefully.

1 Like

I did position.x += 2; instead of position.x += 3.

Thank you so much @5DN1L and also @Harry.B! It’s working now.

1 Like