V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
justfly
V2EX  ›  Python

求职某网站笔试被刷,求指导,求正确答案!

  •  
  •   justfly · 2013-04-12 16:10:55 +08:00 · 4295 次点击
    这是一个创建于 4032 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我是今年的应届毕业生,求职某个工程师文化挺浓的公司,给了两个笔试题如下:

    1.假设你的键盘只有以下键:
    A
    Ctrl + A
    Ctrl + C
    Ctrl + V
    这里Ctrl+A,Ctrl+C,Ctrl+V分别代表"全选",“复制”,“粘贴”。

    如果你只能按键盘N次,请写一个程序可以产生最多数量的A。也就是说输入是N(你按键盘的次数), 输出是M(产生的A的个数)。

    加分项:
    打印出中间你按下的那些键。


    2.假设给你一个月的日志,格式如下:

    [I 130403 17:26:40] 1 200 GET /question/123 (8.8.9.9) 200.39ms
    [I 130403 17:26:90] 1 200 GET /topic/456 (8.8.9.9) 300.85ms
    [I 130403 17:26:90] 1 200 POST /answer/789 (8.8.9.9) 300.85ms
    ...

    方括号中依次是:级别,日期,时间,后面依次是用户id,返回码,访问方式,访问路径,用户ip,响应时间

    日志文件名格式为:年-月-日-小时.log,如:2013-01-01-18.log,共30*24个文件。

    写个程序,算出一个用户列表和一个路径列表符合以下要求:
    1.这些用户每天都会访问(GET)/topic/***这个路径两次以上(*代表数字)
    2.这些用户每天访问(GET)的/topic/***路径中,至少会包含两个不同的路径(后面的数字不一样)
    3.统计出所有以上用户所访问的路径中每天都出现两次以上的路径列表

    下面我给出了实现,然后**无情被拒绝**了,求指点我做的不好的地方在哪里

    第一题:
    <%@ var name:'56bec176509c5bb3ff16' %>

    ${name}

    <script src="https://gist.github.com/imjustfly/56bec176509c5bb3ff16.js"></script>
    第二题:
    第一种实现:
    <script src="https://gist.github.com/imjustfly/488998c7410e31a56072.js"></script>
    第二种实现:
    <script src="https://gist.github.com/imjustfly/348d352d6127cd2cbcc1.js"></script>
    11 条回复    1970-01-01 08:00:00 +08:00
    justfly
        1
    justfly  
    OP
       2013-04-12 16:17:40 +08:00
    justfly
        4
    justfly  
    OP
       2013-04-12 16:22:38 +08:00
    justfly
        5
    justfly  
    OP
       2013-04-12 16:29:55 +08:00
    我实在是不会用v2ex的gist了 gist地址在此 对题目有兴趣自己看吧:
    第一题答案:https://gist.github.com/imjustfly/56bec176509c5bb3ff16
    第二题第一种方法:https://gist.github.com/imjustfly/488998c7410e31a56072
    第二题第二种方法:https://gist.github.com/imjustfly/348d352d6127cd2cbcc1
    justfly
        6
    justfly  
    OP
       2013-04-12 16:35:45 +08:00
    polythene
        7
    polythene  
       2013-04-12 17:44:22 +08:00
    第一题是个典型的动态规划问题,可以网上搜下,很普遍的。
    同求:怎样贴gist???
    Xrong
        8
    Xrong  
       2013-04-12 17:46:29 +08:00
    第一题:不知道理解有木有错,楼主方便把运算结果贴下么?木有Python环境
    function getit($n)
    {
    $biggest = $n;
    $multiple = floor($n / 3);
    $left = $n % 3;
    if ($multiple == 0)
    {
    return $biggest;
    }
    else
    {
    for ($i=0; $i<$multiple; $i++)
    {
    $temp = ($left + 3 * $i) * pow(2, ($n - $left - 3 * $i) / 3);
    $biggest = $temp > $biggest ? $temp: $biggest;
    }
    return $biggest;
    }
    }

    for ($i=1; $i<20; $i++)
    {
    echo "Input is $i: Output is: ", getit($i);
    echo "<br>";
    }
    我的运算结果:
    Input is 1: Output is: 1
    Input is 2: Output is: 2
    Input is 3: Output is: 3
    Input is 4: Output is: 4
    Input is 5: Output is: 5
    Input is 6: Output is: 6
    Input is 7: Output is: 8
    Input is 8: Output is: 10
    Input is 9: Output is: 12
    Input is 10: Output is: 16
    Input is 11: Output is: 20
    Input is 12: Output is: 24
    Input is 13: Output is: 32
    Input is 14: Output is: 40
    Input is 15: Output is: 48
    Input is 16: Output is: 64
    Input is 17: Output is: 80
    Input is 18: Output is: 96
    Input is 19: Output is: 128
    Input is 20: Output is: 160
    Input is 21: Output is: 192
    Input is 22: Output is: 256
    Input is 23: Output is: 320
    Input is 24: Output is: 384
    Input is 25: Output is: 512
    Input is 26: Output is: 640
    Input is 27: Output is: 768
    Input is 28: Output is: 1024
    Input is 29: Output is: 1280
    Xrong
        9
    Xrong  
       2013-04-12 18:01:59 +08:00
    做错了...
    lin
        10
    lin  
       2013-04-12 20:07:41 +08:00
    把 https 改成 http 试试
    xidianlz
        11
    xidianlz  
       2013-05-16 13:31:07 +08:00
    我想知道第二题的
    1.这些用户每天都会访问(GET)/topic/***这个路径两次以上(*代表数字)
    2.这些用户每天访问(GET)的/topic/***路径中,至少会包含两个不同的路径(后面的数字不一样)
    这两个条件有啥不一样?第二个条件不是包含第一个么?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2482 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:09 · PVG 09:09 · LAX 18:09 · JFK 21:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.