Skip to content

Instantly share code, notes, and snippets.

@shamir92
Created April 2, 2020 07:27
Show Gist options
  • Save shamir92/ac81fd0e020a4fa9cc1b3bbd8c59aca8 to your computer and use it in GitHub Desktop.
Save shamir92/ac81fd0e020a4fa9cc1b3bbd8c59aca8 to your computer and use it in GitHub Desktop.
Junior Engineer Code Test
initialState = {
'byTripId': {},
'byStartDate': {}
}
GET_v1_trips = {
"summary": {
"top_rpm": 4218,
"avg_speed": 28.154825026511137
},
"trips": [
{
"trip_id": 17094,
"duration": 1956,
"distance": 16,
"start_time": "2017-07-04T07:50:36+0000",
"end_time": "2017-07-04T08:23:12+0000"
},
{
"trip_id": 17095,
"duration": 891,
"distance": 4,
"start_time": "2017-07-04T08:30:45+0000",
"end_time": "2017-07-04T08:45:36+0000"
},
{
"trip_id": 17096,
"duration": 1956,
"distance": 16,
"start_time": "2017-07-06T07:50:36+0000",
"end_time": "2017-07-06T08:23:12+0000"
},
{
"trip_id": 17097,
"duration": 891,
"distance": 4,
"start_time": "2017-07-07T08:30:45+0000",
"end_time": "2017-07-07T08:45:36+0000"
}
]
}
// start code from here
// end here
// # Write a function that takes in initialState and GET_v1_trips and returns newState
// # # correct answer for newState
// # newState = {
// # 'byTripId': {
// # 17094: {
// # "trip_id": 17094,
// # "duration": 1956,
// # "distance": 16,
// # "start_time": "2017-07-04T07:50:36+0000"
// # "end_time": "2017-07-04T08:23:12+0000",
// #
// },
// # 17095: { ...}
// #
// },
// # 'byStartDate': {
// # "2017-07-04": [
// # {
// # "trip_id": 17094,
// # "duration": 1956,
// # "distance": 16,
// # "start_time": "2017-07-04T07:50:36+0000",
// # "end_time": "2017-07-04T08:23:12+0000"
// #
// },
// # { ...}
// #]
// #
// }
// #
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment