ANEO Sponsored Puzzle discussion

i was able to only past the first 4 tests, this trick saved me from getting stuck all day, thaaaank youuuuuuuu

Hey, I can not seem to get it to work. I went with the bruteforce approach (probably not the best way to do it). So it works for the first four test cases and for some other ones but not for all? I tried a few things but it did not help. I would appreciate it if someone could look at my code and help me out. Thanks!

import sys

import math

# Auto-generated code below aims at helping you parse

# the standard input according to the problem statement.

speed = int(input())

light_count = int(input())

all_lights = []

for i in range(light_count):

    distance, duration = [int(j) for j in input().split()]

    # get current total distance

    try:

        current_total_distance = all_lights[0][2]

    except IndexError:

        current_total_distance = 0

    # last light is always the first element

    all_lights.insert(0, (distance, duration, current_total_distance + distance))

# start with last one

# speed is an integer => bruteforce because there is a set amount of speeds

# iterate through all possible speeds

for s in range(speed, 0, -1):

    possible = True

    # iterate through all lights

    for l in all_lights:

        # check if light is red and stop the inner loop if it is

        # calculates seconds per meter -> multiplies by distance to light -> divides by duration -> checks if it is an even number

        if math.floor(((1 / (s / 3.6)) * l[2]) / l[1]) % 2 != 0:

            possible = False

            break

    

    if possible:

        print(s)

        break

In view of the sentence in the puzzle statement:

– An integer distance representing the distance of the traffic light from the starting point (in meters).

what does the following expression try to calculate?

1 Like

Oh wow… I overread that and thought it was the distance between the lights. Thank you!

1 Like

It worked now. Thanks!

1 Like

Thanks for the puzzle. I tried to solve it with python and im a little bit confused. Since in my understandig “The village traffic light 2” should fail at speed 36 km/h

This is because we pass the traffic light exactly in 20s and the duration (green/red) is 10s. So if I’m not wrong first 10s Green 10+1 seconds = Red … 20s=Red!

Any help appreciated!

See this :wink:

Thanks that did the trick! :wink: 100% Pass Yipee

1 Like

I am somewhat concerned about the company sponsoring this puzzle, it is a great puzzle however the information they provide about themselves leaves much to be desired. For example, the link they provide (join.aneo.fr) does not lead to their domain, it leads to a Spanish website with a numerical URL. Aside from that I was unable to locate much, or really any, information about them from the web. Should I send them my resume/personal information?

1 Like

thanks for reporting this, we’ll look into it. I don’t know if they’re still hiring from CG

Hello!

I’m Maje.

I completted all test in IDE, but i cant pass 2º validating test and I dont know why.

Can you help me?

Hi Maje, have you tried to read the previous posts to see whether those may give you any hints?

Hi.

I read a lot of previous post, but i can`t locate the error.

Hi.

I had same problem, it’s because the real answer is like 59.9999… and php shows 60, but if you takes the integer, this is 59.

for solve it, i have this(intAnswer is te integrer calculated by php):
if(answer - intAnswer > 0.999){answer = intAnswer+1} else{answer = intAnswer}

1 Like

No need to use floating points nor worry about precision, integer math is enough. Think about what causes inaccuracy and set up your expression(s) to minimize it to a point where it is no longer significant for the task at hand.

1 Like

Hi !
I finish the puzzle but at the end i can’t add the elements list in " OPPORTUNITÉS D’APPRENTISSAGE" to my profil competence.
Is that normal ?

I was able to check “loops”. Could you add some details on how you can’t add it?

We’re in contact with Aneo. The proper link to see their job opportunities is this one: Carrières - Aneo
However, we’ll soon remove the puzzle from the library of puzzles.

Thank you for your help :slight_smile:
May I ask why you are removing the puzzle?

We’ve ended our contract with Aneo on this puzzle.