-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergio M
committed
Dec 15, 2020
1 parent
d84b7f9
commit 1d7c1c2
Showing
6 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1000677 | ||
29,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,661,x,x,x,x,x,x,x,x,x,x,x,x,13,17,x,x,x,x,x,x,x,x,23,x,x,x,x,x,x,x,521,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,x,x,19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
input_filename = __file__.split(".")[0] + ".input" | ||
with open(input_filename) as f: | ||
raw = f.read().strip().split("\n") | ||
|
||
reach_bustop_at = int(raw[0]) | ||
in_service_bus_routes = [int(x) for x in raw[1].split(",") if x != "x"] | ||
|
||
earliest = {} | ||
for bus in in_service_bus_routes: | ||
x = 0 | ||
while x < reach_bustop_at: | ||
x += bus | ||
earliest[bus] = x | ||
|
||
earliest_buses = sorted(earliest.items(), key=lambda x: x[1]) | ||
print(earliest_buses) | ||
|
||
waiting_time = earliest_buses[0][1] - reach_bustop_at | ||
print(waiting_time) | ||
print(earliest_buses[0][0] * waiting_time) |
Oops, something went wrong.