回复: 2
跳转到指定楼层
上一主题 下一主题
收起左侧

doordash oop设计

全局:

2022(4-6月) 码农类General 硕士 全职@doordash - Other - 技术电面  | 😃 Positive 😐 Average | Fail | 在职跳槽

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

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

评分

参与人数 2大米 +9 收起 理由
drool + 1 赞一个
匿名用户-2L1P2 + 8

查看全部评分


上一篇:香蕉 OA
下一篇:阿特拉斯安 negative 电面+VO
地里匿名用户
🔗
匿名用户-ZN76Y  2022-6-24 08:57:30
doordash开始考OOP了?
回复

使用道具 举报

🔗
 楼主| Chasedream.df 2023-1-8 10:10:02 | 只看该作者
全局:
chatgpt
  1. class Island:
  2.     def __init__(self, name: str, flight_paths: List[Island], bridges: List[Island]):
  3.         self.name = name
  4.         self.flight_paths = flight_paths
  5.         self.bridges = bridges

  6. class Vehicle:
  7.     def __init__(self, name: str, max_speed: int, can_use_flight_paths: bool, can_use_bridges: bool):
  8.         self.name = name
  9.         self.max_speed = max_speed
  10.         self.can_use_flight_paths = can_use_flight_paths
  11.         self.can_use_bridges = can_use_bridges

  12. class Competitor:
  13.     def __init__(self, name: str, current_island: Island, vehicle: Vehicle):
  14.         self.name = name
  15.         self.current_island = current_island
  16.         self.vehicle = vehicle
  17.    
  18.     def move(self, destination: Island):
  19.         if destination in self.current_island.flight_paths and self.vehicle.can_use_flight_paths:
  20.             self.current_island = destination
  21.             return True
  22.         elif destination in self.current_island.bridges and self.vehicle.can_use_bridges:
  23.             self.current_island = destination
  24.             return True
  25.         return False

  26. class Race:
  27.     def __init__(self, start: Island, end: Island, competitors: List[Competitor]):
  28.         self.start = start
  29.         self.end = end
  30.         self.competitors = competitors
  31.    
  32.     def start_race(self):
  33.         while True:
  34.             for competitor in self.competitors:
  35.                 if competitor.current_island == self.end:
  36.                     return competitor.name
  37.                 move_success = competitor.move(self.end)
  38.                 if move_success:
  39.                     break
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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