📣 Back to School开学季 - VIP通行证5折优惠!蓝莓、Offer多多同步优惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

特斯拉 电面 OA

全局:

2017(7-9月) 码农类General 硕士 全职@ - 网上海投 - 技术电面  | | Fail | 在职跳槽

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

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

x
最近投了特斯拉,有两个组联系,一个是做power的simulator,一个是QA的
power的只做了OA,给了三个小时的时间,要求完成一个client/server message的程序,里面用到了C++的jason API
因为他们现在C++的系统还没搭建起来,就直接把题目发给我了。最近比较忙拖了好久才做。
按照要求写好了,
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
我的简历,发现不match,也就算了。

有需要的同志可以私信我,我可以吧oa发给你。
以上就这些,有问题请留言。

各位加油 加油 加油 加油  

攒人品 。。。


评分

参与人数 1大米 +3 收起 理由
bready + 3 很有用的信息!

查看全部评分


上一篇:阅后即焚家面筋
下一篇:zenefits 电面
🔗
edyyy 2017-7-13 14:37:20 | 只看该作者
全局:
谢谢楼主 发我一份行吗
回复

使用道具 举报

🔗
 楼主| 洋葱头 2017-7-23 07:10:56 | 只看该作者
全局:
edyyy 发表于 2017-7-13 14:37
谢谢楼主 发我一份行吗

不好意思 刚看到
我还是把我的答案发到帖子里吧
回复

使用道具 举报

🔗
 楼主| 洋葱头 2017-7-23 07:11:39 | 只看该作者
全局:
  1. #!/usr/bin/python
  2. """
  3. Module to test function "_is_point_in_poly".
  4. """

  5. from unittest import TestCase


  6. class TestIsPointInPoly(TestCase):
  7.     """
  8.     Unit tests for function "_is_point_in_poly".
  9.     """
  10.     def _is_point_in_poly(self, x, y, poly):
  11.         """
  12.         This is the function we want to test.
  13.         """
  14.         n = len(poly)
  15.         inside = False

  16.         p1x, p1y = poly[0]
  17.         for i in range(n+1):
  18.             p2x, p2y = poly[i % n]
  19.             if y > min(p1y, p2y):
  20.                 if y <= max(p1y, p2y):
  21.                     if x <= max(p1x, p2x):
  22.                         if p1y != p2y:
  23.                             xints = (y-p1y)*(p2x-p1x)/(p2y-p1y)+p1x
  24.                         if p1x == p2x or x <= xints:
  25.                             inside = not inside
  26.             p1x, p1y = p2x, p2y

  27.         return inside

  28.     def test_when_poly_is_none(self):
  29.         """
  30.         When poly is None, any point should be
  31.         judged as not inside the polygon.
  32.         """
  33.         x = 0
  34.         y = 0
  35.         poly = None

  36.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  37.     def test_when_poly_is_a_point_and_different_from_the_input_point(self):
  38.         """
  39.         When poly is a point (not a real polygon),
  40.         a different point should be judged as not inside the polygon.
  41.         """
  42.         x = 0
  43.         y = 0
  44.         poly = [(1, 1)]

  45.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  46.     def test_when_poly_is_a_point_and_as_same_as_the_input_point(self):
  47.         """
  48.         When poly is a point (not a real polygon),
  49.         the same point should be judged as not inside the polygon.
  50.         """
  51.         x = 1
  52.         y = 1
  53.         poly = [(1, 1)]

  54.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  55.     def test_when_poly_is_a_line_and_the_input_point_is_not_on_the_line(self):
  56.         """
  57.         When poly is a line (not a real polygon),
  58.         a point on the line should be judged as not inside the polygon.
  59.         """
  60.         x = 1
  61.         y = 2
  62.         poly = [(1, 1), (1, 3)]

  63.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  64.     def test_input_point_on_poly_vertex(self):
  65.         """
  66.         When the input point is on the polygon's vertex,
  67.         the point should be judged as not inside the polygon.
  68.         """
  69.         x = 2
  70.         y = 4
  71.         poly = [(2, 4), (6, 4), (6, 2), (2, 2)]

  72.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  73.     def test_input_point_on_poly_edge(self):
  74.         """
  75.         When the input point is on the polygon's edge,
  76.         the point should be judged as not inside the polygon.
  77.         """
  78.         x = 4
  79.         y = 4
  80.         poly = [(2, 4), (6, 4), (6, 2), (2, 2)]

  81.         self.assertEqual(True, self._is_point_in_poly(x, y, poly))

  82.     def test_input_point_inside_poly(self):
  83.         """
  84.         When the input point is really inside the polygon,
  85.         the point should be judged as inside the polygon.
  86.         """
  87.         x = 3
  88.         y = 3
  89.         poly = [(2, 4), (6, 4), (6, 2), (2, 2)]

  90.         self.assertEqual(True, self._is_point_in_poly(x, y, poly))

  91.     def test_input_point_outside_poly(self):
  92.         """
  93.         When the input point is really outside the polygon,
  94.         the point should be judged as outside the polygon.
  95.         """
  96.         x = 7
  97.         y = 7
  98.         poly = [(2, 4), (6, 4), (6, 2), (2, 2)]

  99.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))

  100.     def test_input_point_outside_concave_polygon(self):
  101.         """
  102.         When the polygon is a concave polygon, and the input point
  103.         is outside the polygon, but inside the concave part.
  104.         the point should be judged as outside the polygon.
  105.         """
  106.         x = 4
  107.         y = 5
  108.         poly = [(2, 2), (2, 6), (3, 6), (3, 4), (5, 4), (5, 6), (6, 6), (6, 2)]

  109.         self.assertEqual(False, self._is_point_in_poly(x, y, poly))
复制代码


仅供参考
回复

使用道具 举报

🔗
edyyy 2017-7-23 11:36:32 | 只看该作者
全局:

多谢楼主啊,好人好运
回复

使用道具 举报

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

本版积分规则

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