[Community Puzzle] No More Pythons, Please!

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @VictoriousTriceraton,validated by @BleedingWithin and @Westicles.
If you have any issues, feel free to ping them.

1 Like

Sure of the ā€œReal Madnessā€ Validator ? I have no ā€œhard-codeā€ and pass all other tests and other validatorsā€¦
Fun Puzzle :slight_smile:

The second character from the head cannot be ā€˜oā€™. In other words snake is always of length 3 or more. Without this condition Validator 5th fails, even if 5th Test passes.

Also check that your code moves from o to | only if itā€™s over/under and from o to - only if itā€™s on its right/left.

Right. And how can a snake have another head right after its head? The snake has only 1 head :slight_smile:
And based on the rules at the end of the problems of the statement - the minimum possible size can be 3.

3 Likes

Sure, I start with ā€œoā€ and my code check only ā€œ-ā€ or ā€œ|ā€ next.

And I check independantly vertical and horizontal cases. After ā€œoā€ is ā€œ-ā€ only if "o"row == "-"row

My solution counts the size of each snake while removing them from the drawing. On that test, I get a blank field with dots ā€œ.ā€ at the end. So yes, sure =)

2 Likes

Mine stocks snakesā€™s history in an array and check if the cell Iā€™m on is an other snakeā€¦
Maybe I should use yours to see if itā€™s make a differenceā€¦

There can also be a problem with the size of the execution stack if you do it recursively but there are longer snakes in other validators so it would fail in other validators too.

1 Like

Yes =) That is why this problem donā€™t have tag ā€œrecursionā€. But someone use sys.setrecursionlimit(6400) (in python3) to get 100% with Recursive Algorithm =)

6400 - because 80x80 - max possible size of grid.

1 Like

Where is said in statement that snake cannot be of size 2? For example ā€˜o>ā€™

In previous post, i meant second character from the tail cannot be ā€˜oā€™ (if somene starts with tail), Sorry.

1 Like

In tests and validators you wonā€™t see:
"o>"
"<o"

"^
 o"

or

"o
 v"

If your solution deal with such 2-length snakes it will be aslo 100% in puzzle. You get wrong - because you count, for example "o<" as snakeā€¦ but this can be a fish, not a snake :wink:

1 Like

This is why i didnā€™t make such snakes in test cases. You can tell visually that a lot of the combinations wouldnā€™t be valid.

  1. Snake head next to a tail that points at the head. This canā€™t be a snake of size 2 because the tail points in the wrong direction, so itā€™s either two separate snakes, or a snake facing its own tail.
    Example: ā€œo<ā€ is not a valid snake, but ā€œ<-o<-oā€ is two valid snakes.

  2. Snake head next to a tail that points sideways. This canā€™t be a snake of size 2, because a turn in the snake requires a ā€œ*ā€ character. Similarly to the first case itā€™s could either be two distinct snakes, or a snake touching its tail.
    Example: ā€œovā€ is not a valid snake but the following is two valid snakes

"...o"
"...|"
"<-ov"
  1. Snake head next to a tail that points away from the head. This is a valid snake of size 2, but I avoided putting those in the test cases to make the solutions easier to implement.
    Example: ā€œo>ā€ is valid
1 Like

For those who canā€™t pass the 5th validator, your solution is probably not fast enough. The last validator has over 400 snakes, and their sizes vary from 3 to [the answer to the problem :-)]

1 Like

I donā€™t think so, according to the statement.

1 Like

It doesnā€™t matter if you count such cases as a two-character snake or not. in tests you will not encounter such a situation, and therefore you will not get an error during validation.

1 Like

Yes, and we are both right. :beers:

1 Like

That was a size problem.
My code was checking if a cell had been seen in an other snake to eliminate it. I though win timeā€¦
But I wasnā€™t :slight_smile:

1 Like

Hey everyone!
I have some trouble with the ā€œReal Madnessā€ validator, I guess my code isnā€™t fast enough
is ā€œoā€”<ā€ a snake ?
and ā€œo----^ā€