码迷,mamicode.com
首页 > 其他好文 > 详细

8kyu Duck Duck Goose

时间:2017-08-08 14:04:07      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:circle   player   layer   head   array   题目   cti   name   one   

题目:

The objective of ‘Duck, duck, goose‘ is to walk in a circle, tapping on each player‘s head until one is finally chosen.

Task: Given an array of Player objects (an array of associative arrays in PHP) and an index (1-based), return the name of the chosen Player.

Example:

duck_duck_goose([a, b, c, d], 1) should return a.name
duck_duck_goose([a, b, c, d], 5) should return a.name
duck_duck_goose([a, b, c, d], 4) should return d.name
// PHP only
duck_duck_goose([$a, $b, $c, $d], 1); // => $a["name"]
duck_duck_goose([$a, $b, $c, $d], 5); // => $a["name"]
duck_duck_goose([$a, $b, $c, $d], 4); // => $d["name"]

答案:

8kyu Duck Duck Goose

标签:circle   player   layer   head   array   题目   cti   name   one   

原文地址:http://www.cnblogs.com/tong24/p/7306274.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!