I am trying to figure out the route that a car takes in a fictional manhattan.
I have defined the starting position, being(1,2)
(in a 2 dimensional grid).
manhattan=[[1, 2, 3, 4, 5],[6, 7, 8, 9, 10],[11, 12, 13, 14, 15],[16, 17, 18, 19, 20]]car_in_manhattan=8
car_unmerged = ([(index, row.index(car_in_manhattan)) for index, row in enumerate(manhattan) if car_in_manhattan in row])
car=list(itertools.chain(*car_unmerged))
i am doing this because I do not want a list in a list
route1=car
The first position in the route is where the car starts. I start a for loop that looks at which person is closest to my car. This person needs to be picked up, this location should be appended to the list for the route.
printing this result gives:
[1, 2, (.,.), (.,.), (.,.), (.,.), (.,.)]
the dots in the brackets are correctly filled, I have intentionally left them 'blank' here.
the problem is that I do not know how this starting position for the car, (1,2) can also be between brackets, just like all the other locations. This has to do with tuples, if I am correct?
Thanks in advance!