I am working on a challenge which is to be given a list of information, let’s say some flight data
[AB123, 12 december 2024, 11:00, 12:00, NewYork]
[AC122, 12 december 2024, 15:00, 02:00, Syndney]
[AD523, 13 december 2024, 18:00, 20:00, Tokyo]
The question is to calculate the number of flights that run on a same day and recursively return it in a format of:
date: 12 december 2024, No.of flights: 2, flight no.:AB123, AC122
date: 13 december 2024, No.of flights: 1, flight no. AD523
All the flight data are stored in a data
object and can be extracted as flightNo., date, dep_time
etc, and you don’t need to consider if a flight goes overnight, we only need to consider the flight that departs from today (so only need to measure the date
here). I have some initial thoughts but can’t really solve the problem, can anyone help me here?
Adding my draft thoughts here:
No.flights = 0
for data.flightNo, data.date in data:
for d in dates:
if d == date:
No.flights++
return No.flights, flightNo
I can manage how to count the No.flights but don’t know how to really record the flightNo in this case.
13