编程难题?

编程入门 行业动态 更新时间:2024-10-06 16:24:59
本文介绍了编程难题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

类似于Python挑战,有没有人知道任何其他网站 或有编程难题要解决的书籍?我找到了一本名为 黑客拼图的书,但对我来说似乎有点高级 ,我也读过它过分关注加密和 安全问题,确切地说并没有编码问题。但 就像那本书那样很有趣。

Similar to the Python Challenge, does anyone know of any other websites or books that have programming puzzles to solve? I found a book called "Puzzles for Hackers", but it seems like it might be a little advanced for me, and I''ve also read that it focuses too much on encryption and security issues and doesn''t really have coding problems, exactly. But something like that book would be fun to have.

推荐答案

John Salerno写道: John Salerno wrote: 类似于Python挑战,有没有人知道任何其他网站或有编程难题要解决的书籍?我找到了一本名为黑客的谜题的书,但对我来说似乎有点先进,我也读到它过分关注加密和 Similar to the Python Challenge, does anyone know of any other websites or books that have programming puzzles to solve? I found a book called "Puzzles for Hackers", but it seems like it might be a little advanced for me, and I''ve also read that it focuses too much on encryption and security issues and doesn''t really have coding problems, exactly. But something like that book would be fun to have.

就个人而言,我是rec.puzzles的狂热读者。不是因为 我本身就喜欢做愚蠢的谜题,但我从 观点看它们我怎么写一个程序来解决这个问题? 即使简单的单词问题有时也会比这个难题值得花费更多的麻烦,但它教会你如何编写算法来生成排列,组合,分区等可以为其他应用程序提供便利。生成字母 模式是一回事,确定它们是否是英文单词, 可以教你数据库等。 许多拼图纯粹主义者都对这种态度感到愤怒,但我自己这样做是为了b / b 。不是为了他们。

Personally, I am an avid reader of rec.puzzles. Not because I like doing stupid puzzles per se, but I look at them from the viewpoint "how would I write a program to solve this?" Even simple word problems sometimes involves more trouble than the puzzle is worth, but it teaches you how to write algorithms to generate permutations, combinations, partitions, etc. that can be handy for other applications. And it''s one thing to generate letter patterns, determining if they are English words is something else, which can teach you about database and such. Many puzzle purists bristle at this attitude, but I do this for myself, not for them.

me********@aol 写道: me********@aol wrote: 就个人而言,我是rec.puzzles的狂热读者。不是因为我喜欢做愚蠢的谜题本身,但我从的角度看待它们我怎么写一个程序来解决这个问题?即使是简单的单词问题也会涉及到这个谜题值得花费更多的麻烦,但它教会你如何编写算法来生成排列,组合,分区等。 Personally, I am an avid reader of rec.puzzles. Not because I like doing stupid puzzles per se, but I look at them from the viewpoint "how would I write a program to solve this?" Even simple word problems sometimes involves more trouble than the puzzle is worth, but it teaches you how to write algorithms to generate permutations, combinations, partitions, etc.

听起来我很感兴趣。我会检查出来的。

Sounds like what I''m interested in. I''ll check it out!

我自愿写的第一段代码是为了 解决这个难题: 将数字2分配给''a'',3分配给''b''... 27分配给''z''。对每个单词赋予 其字符乘积的值。找到产品最接近百万的英语(或您选择的 语言)单词(或者您选择的 )。 我没有方便的词典。所以我刚打印出最接近一百万的字母 组合并手动玩Jumble。 这是在使用Fortran的PDP-11上,所以你应该没有问题在于用Python做这个。 这个奖项是录像机,当时这是一个大问题,但我并没有这样做> 还有一张绿卡,所以我没有提交我的回答,因为(可能是没有根据的)b / b 毫无根据的恐惧移民当局会给我一些困难时间 表示未经授权的收入。我的回答又回来了 < hack hack type> 999856为其产品。你能做得更好吗? 你可以走得更远。如果你有类似unix的系统,你已经有了一个 的词典,可能是/ usr / share / dict / words。 比较各种解决方法对于性能的这个问题,对于 任意密码,你可以像字典一样传入这个字典,例如 {'''':2,''b'':4 ,''c'':5 ....等 为了让你开始这里的计算,这可能是有趣的 本身。我没有Fortran,但我确定它比 更长! ##### cipher0 = {} for i in range(ord(''a''),ord(''z'')+ 1): cipher0 [chr(i)] = i - ord(''a'')+ 2 来自运营商导入mul def numify(word,cipher = cipher0): return reduce(mul,[密码[c]代表c]) if __name__ ==" __ main __": print numify(" hello") #打印146016 #### mt The first piece of code that I ever voluntarily wrote was intended to solve this puzzle: Assign the number 2 to ''a'', 3 to ''b'' ... 27 to ''z''. To each word assign the value of the product of its characters. Find the English (or language of your choice) word whose product is closest to a million (or number of your choice). I didn''t have a lexicon handy. So I just printed out the letter combinations closest to a million and manually played Jumble with them. This was on a PDP-11 using Fortran, so you should have no problem doing this in Python. The prize was a VCR, which was a big deal in those days, but I didn''t have a Green Card yet, so I didn''t submit my answer, for (probably unfounded) fear the immigration authorities would give me a hard time for unauthorized income. My answer returned <hack hack type> 999856 for its product. Can you do better? You can go further. If you have a unix-like system you already have a lexicon, probably at /usr/share/dict/words . Compare various ways to solve this problem for performance, for arbitrary ciphers, which you can pass in as a dictionary like {''a'':2,''b'':4,''c'':5 .... etc. To get you started here''s the calculation, which may be interesting in itself. I don''t have the Fortran, but I''m sure it was MUCH longer than this! ##### cipher0= {} for i in range(ord(''a''),ord(''z'')+1): cipher0[chr(i)] = i - ord(''a'') + 2 from operator import mul def numify(word,cipher=cipher0): return reduce(mul,[cipher[c] for c in word]) if __name__ == "__main__": print numify("hello") # prints 146016 #### mt

更多推荐

编程难题?

本文发布于:2023-11-29 15:13:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646759.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:难题

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!