The Bridge - Episode 2 - Puzzle discussion

In the results replay under settings you can turn on debug mode. This will let you see exactly where on the bridge your bikes are each turn. Even though the replay doesn’t have console output, you should be able to get a good idea what your bikes are doing if you step through turn by turn.

Excluded one redundant command helped me. Try to analyse only 5 of them.

Weird test cases going on here.

Had an inf loop on a 12 test, but submitted code to save it, nonetheless got a 100% in results.

okay that makes sense, because the possible moves tree will explode after 8 moves (6^8=1679616) - so i figured optimization somewhere (in your case, limiting tree height) was definitely required to apply dfs/backtracking as the skill tags suggest

Hi,
I’m using Python and I got a timeout in about 0.2ms which is much lower than the 150ms from the statements. Is it normal?

Not sure how you calculated the time? I ran the following code and no timeout was observed:

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

m = int(input())  # the amount of motorbikes to control
v = int(input())  # the minimum amount of motorbikes that must survive
l0 = input()  # L0 to L3 are lanes of the road. A dot character . represents a safe space, a zero 0 represents a hole in the road.
l1 = input()
l2 = input()
l3 = input()

from time import perf_counter
# game loop
while True:
    s = int(input())  # the motorbikes' speed
    for i in range(m):
        # x: x coordinate of the motorbike
        # y: y coordinate of the motorbike
        # a: indicates whether the motorbike is activated "1" or detroyed "0"
        x, y, a = [int(j) for j in input().split()]

    # Write an action using print
    # To debug: print("Debug messages...", file=sys.stderr, flush=True)

    # A single line containing one of 6 keywords: SPEED, SLOW, JUMP, WAIT, UP, DOWN.
    start_time = perf_counter()
    while perf_counter() - start_time < 150 * 0.001:
        pass
    print("SPEED")
1 Like

Hi,
Thanks for the answer. I’m using perf_counter_ns().
I found another error so I’ll fix it first and then see if I still have the issue.

For some reason, the achievement (Biker) for completing level 8 with no sacrifice does not unlock, despite getting 100%, and having all the bikes survive on level 8. Not important for me, but it does appear to be a bug with the puzzle in that regard.

Sometimes there’s a lag in the update of achievements. And sometimes resubmitting the solution triggers an achievement. If you want, you may also share the link to the replay of the validator here.

Very strange. When actually reviewing the validator when submitting, it does sacrifice the bike, but when I do it manually before submitting, it manages to keep all four.
Review on submission: Coding Games and Programming Challenges to Code Better
Playing the test case before submission: Coding Games and Programming Challenges to Code Better

This consistently happens on all my attempts.

Turn on debug mode; you’ll see they’re different cases :wink:

Ah, I see. My algorithm does not account for failure to receive commands. This should be its own test case, but since it is not explicitly stated in the problem formulation, and more of an extra challenge I guess it’s fine. It could be stated in the title of the validator, though, but I see the title is already very long so maybe not ideal.