求职某网站笔试被刷,求指导,求正确答案! - V2EX
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 4835 次点击
    这是一个创建于 4637 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我是今年的应届毕业生,求职某个工程师文化挺浓的公司,给了两个笔试题如下:

    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     Solana     5787 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 03:00 PVG 11:00 LAX 19:00 JFK 22:00
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86