本文主要是介绍Google Python挑战赛:不服,就来!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转载来自:量化投资与机器学习
作者:Hanyu、Leon 编译:1+1=6
这是一个来自谷歌的秘密招聘挑战(Google FooBar Invitation) ),如果你收到了谷歌的FooBar邀请,你应该感到高兴。谷歌的许多开发人员都是通过FooBar而被聘用的。
获得Google Foobar邀请也是一件神秘的事情,不是每个人都能接受这个挑战。没有人确切知道 Google Foobar 邀请资格的标准。
当你收到邀请时,它上面写着:
“You’re speaking our language. Up for a challenge?”
接受邀请后,你会看到一个看起来很酷的IDE,你可以在请求后打开右侧的代码编辑器并导航到解决方案文件solution.py。
交互界面模仿了 UNIX Shell:你可以通过命令来请求( request )一个新的 Challenge、 提交( submit )代码、验证( verify )代码正确与否。
一旦你有了一个潜在的解决方案你可以验证它,你可通过测试来看看你的最终解决方案能否被接受。
整个挑战有3个level,level 1有1道题目,level 2有2道,level 3有3道。
level 1和level 2的题目十分简单,每个题目会给24–48个小时的做答时间,考的主要是一些基础的编程概念;
level 3会考一些简单的算法,每个题目会给96个小时的做答时间;
level 4的题目就比较难了,会考一些不常见的算法。
让我们看看今天的这道题目吧(重点标记出来了):
Commander Lambda has had an incredibly successful week: she completed the first test run of her LAMBCHOP doomsday device, she captured six key members of the Bunny Rebellion, and she beat her personal high score in Tetris. To celebrate, she's ordered cake for everyone - even the lowliest of minions! But competition among minions is fierce, and if you don't cut exactly equal slices of cake for everyone, you'll get in big trouble.
The cake is round, and decorated with M&Ms in a circle around the edge. But while the rest of the cake is uniform, the M&Ms are not: there are multiple colors, and every minion must get exactly the same sequence of M&Ms. Commander Lambda hates waste and will not tolerate any leftovers, so you also want to make sure you can serve the entire cake.
To help you best cut the cake, you have turned the sequence of colors of the M&Ms on the cake into a string: each possible letter (between a and z) corresponds to a unique color, and the sequence of M&Ms is given clockwise (the decorations form a circle around the outer edge of the cake).
Write a function called solution(s) that, given a non-empty string less than 200 characters in length describing the sequence of M&Ms, returns the maximum number of equal parts that can be cut from the cake without leaving any leftovers.
相关文章:
这篇关于Google Python挑战赛:不服,就来!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!