注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
一家小众的 quant,叫 Beacon Platform,三道题三个小时,基本上一个多小时可以做完。就是 codility的test部分很麻烦,要求自己想例子测试,还强调了说demo能跑过不代表hidden test能跑过。。。那你好歹告诉我我有几个跑不过也行啊?或者像hackerrank那样随便提交也行。只允许提交一次,然后就不能再提交了。略有些麻烦。祝大家都能拿到想要的offer!!
第一题比较简单,就是说骰子如果是面对面的就加两次,如果不是就加一次,如果相等就不加了。
There are a number of dice, and the input array contains the number on the dice's face up. Dice is 6 faced. Calculate the total number of minimum rotations of dice, to make all faces the same. 1 will require only one rotation to have 2, 3, 4 and 5 face up, but would require minimum two rotations to make it the face 6, as 6 is the opposite side of 1. The opposite side of 2 is 5 and 3 is 4.
I have come up with a solution, but I believe there should be a better solution.
For example:
A = {1,1,6}, Answer = 2. Rotate 6 two times to get 1.
A = {1,2,3}, Answer = 2. Rotate 1 and 2 and make them 3.
A = {1,6,2,3}, Answer = 3. Rotate 1, 6 and 3 to maksame. 1 will require only one rotation to have 2, 3, 4 and 5 face up, but would require minimum two rotations to make it the face 6, as 6 is the opposite side of 1. The opposite side of 2 is 5 and 3 is 4.
I have come up with a solution, but I believe there should be a better solution.
For example:
A = {1,1,6}, Answer = 2. Rotate 6 two times to get 1.
A = {1,2,3}, Answer = 2. Rotate 1 and 2 and make them 3.
A = {1,6,2,3}, Answer = 3. Rotate 1, 6 and 3 to make them all 2.
|