Code Signal_练习题_Circle of Numbers

Posted yd2018

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Code Signal_练习题_Circle of Numbers相关的知识,希望对你有一定的参考价值。

Consider integer numbers from 0 to n - 1 written down along the circle in such a way that the distance between any two neighboring numbers is equal (note that 0 and n - 1are neighboring, too).

Given n and firstNumber, find the number which is written in the radially opposite position to firstNumber.

Example

For n = 10 and firstNumber = 2, the output should be
circleOfNumbers(n, firstNumber) = 7.

技术分享图片

 

我的解答:

def circleOfNumbers(n, firstNumber):
    return (firstNumber+n/2) % n

 

技术分享图片
我的解法和排名第一的大佬写的一样....哈哈哈
膜拜大佬

 

以上是关于Code Signal_练习题_Circle of Numbers的主要内容,如果未能解决你的问题,请参考以下文章

Code Signal_练习题_arrayChange

Code Signal_练习题_Minesweeper

Code Signal_练习题_stringsRearrangement

Code Signal_练习题_firstDigit

Code Signal_练习题_digitDegree

Code Signal_练习题_matrixElementsSum