推荐:数据科学课程和书籍清单以及培训讲座


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 2356|回复: 1
收起左侧

lyft电面一题

[复制链接] |试试Instant~ |关注本帖
kungfucop 发表于 2016-2-24 11:16:26 | 显示全部楼层 |阅读模式

2016(1-3月) 码农类 本科 全职@lyft - 内推 - 技术电面 |Other在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
function to determine whether the driver is allowed to enter driver mode
* drivers are not allowed to drive a total of 12 hours without an 8 hour
break-google 1point3acres
* the function inputs are:. visit 1point3acres.com for more.
- a list of driver shifts as start/end integers, the integer is relative to
lyft launch. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
- the current time since lyft launch as integer

. From 1point 3acres bbsdef can_drive(history, current_time):
    """
    Returns true if the driver has driven less than 12 hours since their
last 8 hour break
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
    history|array - Shifts, e.g. [(0, 12), (13, 19)]
    current_time|int - Current timestamp as hour since Lyft launch, e.g. 50. visit 1point3acres.com for more.

    can_drive = True example
        # 9 hour break, 1 hour shift, 2 hour break, 10 hour shift
        history = [(9, 10), (12, 22)]
        current_time = 24

    can_drive = False example:
        history = [(0, 4), (5, 9), (10, 14), (15, 19), (20, 24)]
        current_time = 24
不会答,大家看看,求解答。

工图新一 发表于 2016-11-20 15:10:16 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
请问一下楼主这个shift区间默认是[0 ~ 24]吗?如果是这样的话就是相当于计算一下所有区间之和是否小于(24 - 8)——为了满足8小时睡眠?
回复 支持 反对

使用道具 举报

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2017-8-17 07:54

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表