Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed meters due to the lack of sun heat. Initially, plant is 0 meters tall. We plant the seed at the beginning of a day. We want to know when the height of the plant will reach a certain level.

Example

For upSpeed = 100downSpeed = 10, and desiredHeight = 910, the output should be
growingPlant(upSpeed, downSpeed, desiredHeight) = 10.

我的解答:

import math
def growingPlant(upSpeed, downSpeed, desiredHeight):
if upSpeed > desiredHeight:
return 1
return math.ceil((desiredHeight - upSpeed) / (upSpeed - downSpeed)) + 1
一样滴

膜拜大佬

Code Signal_练习题_growingPlant的更多相关文章

  1. Code Signal_练习题_digitDegree

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

  2. Code Signal_练习题_Knapsack Light

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

  3. Code Signal_练习题_arrayMaxConsecutiveSum

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

  4. Code Signal_练习题_differentSymbolsNaive

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

  5. Code Signal_练习题_firstDigit

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

  6. Code Signal_练习题_extractEachKth

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

  7. Code Signal_练习题_stringsRearrangement

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

  8. Code Signal_练习题_absoluteValuesSumMinimization

    Given a sorted array of integers a, find an integer x from a such that the value of abs(a[0] - x) + ...

  9. Code Signal_练习题_depositProfit

    You have deposited a specific amount of money into your bank account. Each year your balance increas ...

随机推荐

  1. cpu 亲和性 affinity

    http://www.ibm.com/developerworks/cn/linux/l-affinity.html

  2. odoo按钮图标 icon

    https://www.slideshare.net/TaiebKristou/odoo-icon-smart-buttons http://www.iconfont.cn/collections/d ...

  3. K-means算法的原理、优缺点及改进(转)

    文章内容转载自:http://blog.csdn.net/sinat_35512245/article/details/55051306                                ...

  4. Spring中内置的一些工具类

    学习Java的人,或者开发很多项目,都需要使用到Spring 这个框架,这个框架对于java程序员来说.学好spring 就不怕找不到工作.我们时常会写一些工具类,但是有些时候 我们不清楚,我们些的工 ...

  5. List集合中的对象按照某个字段去重实现

    package com.liying.banana.user; import java.util.ArrayList; import java.util.Comparator; import java ...

  6. map的容量的获取

    在go语言中,有两个内建函数分别是len(),cap(),前者用于获取容器的具体内容个数,后者用于获取容器分配的容量大小,但是这个cap对象是不能获取到map具体分配的容量大小的.有没有办法获取到呢, ...

  7. windows10 设置软件开机启动

    在 C:\Users\your_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup 在这个目录下,新建你想开机启动的软 ...

  8. php的explode()和implode()方法

    php 中,字符串与数组互转       拆分字符串 到数组 explode()    - -(其他语言中的 split) 将数组连接成字符串 implode() <?php $test = ' ...

  9. BackgroundWorker简单实用(简便的异步操作)

    微软提供了一个快捷使用多线程的帮助类BackgroundWorker,能够快速创建一个新的线程,并能报告进度,暂停,以及在线程完成后处理别的任务. 1.BackgroundWorker类介绍 1.1. ...

  10. php里input数组的应用

    一般我们使用input传递表单数据时,可以使用<input name="xxx[]" value="1"><input name=" ...