ANEO Sponsored Puzzle discussion

I am pleased that I could contribute to this

I second that!

I cleaned, formatted, commented, explained my code (with jokes and cats) but no sharing :frowning:

Better to stick with non sponsored puzzles, I guess.

Why can’t i see the other answers to this puzzle? I wanted to see an analitic solution to this. Also, i am learning c++ just now so i would like to see how others approach this,.

+100. By any chance, have you encountered an analitic solution to this?

I can only think of try and error. Also, my solution is inneficient.

As they mentioned above, this puzzle can be solved without any floating point calculation. I’ll pm you with further details.

I see this is quite an old puzzle, so no harm in providing solutions now. I tried to do this intelligently and analytically - I kept getting stuck on the last one at 88.848 km/h as did others. I gave in and went for the brute force approach, and got 100% straight away:

[Admin edit]: don't post solutions

And here is my analytical solution (70% pass, but actually more accurate though much slower):

[Admin edit]: don't post solutions

On German highways there is also no speed limit…

1 Like

I was idiot not convering km/hr to m/s. it takes hours of efforts. I will never repeat it again

I think the same. There is no solution, just try and error.

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?