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的更多相关文章

  1. Code Signal_练习题_isLucky

    Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if t ...

  2. Code Signal_练习题_digitDegree

    Let's define digit degree of some positive integer as the number of times we need to replace this nu ...

  3. Code Signal_练习题_Knapsack Light

    You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...

  4. Code Signal_练习题_growingPlant

    Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed ...

  5. Code Signal_练习题_arrayMaxConsecutiveSum

    Given array of integers, find the maximal possible sum of some of its k consecutive elements. Exampl ...

  6. Code Signal_练习题_differentSymbolsNaive

    Given a string, find the number of different characters in it. Example For s = "cabca", th ...

  7. Code Signal_练习题_firstDigit

    Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...

  8. Code Signal_练习题_extractEachKth

    Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6 ...

  9. Code Signal_练习题_stringsRearrangement

    Given an array of equal-length strings, check if it is possible to rearrange the strings in such a w ...

随机推荐

  1. Linux学习系列之一:在centos 7.5上安装nginx 以及简单配置

    说到Linux我们都知道那是相当相当得重要得啊,在计算机这个行业,开发运维都是离不开它得.我作为一个准毕业生,智商可能不太够,只能自己笨鸟先飞,自己操作起来咯.俗话说的好,好记性不如难笔头嘛.而且ng ...

  2. odoo开发笔记-日期时间相关操作

    日期格式化字符串:DATE_FORMAT = "%Y-%m-%d" 日期时间格式字符串:DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" ...

  3. 解决ubuntu安装系统默认没有创建root用户

    安装ubuntu操作系统的时候,默认没有设置root账户的步骤!!! 这样在操作系统安装完成之后,就没有root用户, 一般,当前的普通用户,如果需要执行一些命令的时候,只要在命令前边加上sudo就行 ...

  4. C#:VS2010 由于缺少调试目标"xx.exe",Visual Studio无法开始调试,请生成项目并重试,或者相应地设置OutputPath和AssemblyName属性,使其指向目标程序集的正确位置

    解决办法:重置VS2010的环境配置 原文地址:曾是土木人 转载请注明出处:http://www.cnblogs.com/hongfei/p/3813369.html

  5. js中编写velocity逻辑

    <script type="text/javascript"> $(function(){ #foreach( $var in $entity.showConfigs ...

  6. Java - replace a character at a specific index in a string?

    String are immutable in Java. You can't change them. You need to create a new string with the charac ...

  7. 全网最详细的再次或多次格式化导致namenode的ClusterID和datanode的ClusterID之间不一致的问题解决办法(图文详解)

    不多说,直接上干货! java.io.IOException: Incompatible clusterIDs in /opt/modules/hadoop-2.6.0/data/tmp/dfs/da ...

  8. Yum安装Zabbix4.2.0

    目录 1. 下载所需的存储库 2. 安装zabbix 3. 安装mysql 4. 配置数据库 5. 基本配置 6. zabbix配置文件 7. 进入web安装zabbix 1. 下载所需的存储库 # ...

  9. 比特币算法——SHA256算法介绍

    SHA256是安全散列算法SHA(Secure Hash Algorithm)系列算法之一,其摘要长度为256bits,即32个字节,故称SHA256.SHA系列算法是美国国家安全局 (NSA) 设计 ...

  10. postgresql的启停和创建

    一.启停方法 两种方法 1.直接运行postgres进程启动: 2.使用pg_ctl命令启动 postgres -D /home/osdba/pgdata  & 二.停止数据库的三种模式 sm ...