Code Signal_练习题_growingPlant
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 = 100, downSpeed = 10, and desiredHeight = 910, the output should begrowingPlant(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的更多相关文章
- Code Signal_练习题_digitDegree
Let's define digit degree of some positive integer as the number of times we need to replace this nu ...
- Code Signal_练习题_Knapsack Light
You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the ...
- Code Signal_练习题_arrayMaxConsecutiveSum
Given array of integers, find the maximal possible sum of some of its k consecutive elements. Exampl ...
- Code Signal_练习题_differentSymbolsNaive
Given a string, find the number of different characters in it. Example For s = "cabca", th ...
- Code Signal_练习题_firstDigit
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int&qu ...
- Code Signal_练习题_extractEachKth
Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6 ...
- Code Signal_练习题_stringsRearrangement
Given an array of equal-length strings, check if it is possible to rearrange the strings in such a w ...
- 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) + ...
- Code Signal_练习题_depositProfit
You have deposited a specific amount of money into your bank account. Each year your balance increas ...
随机推荐
- word2vec的原理(一)
最近上了公司的新员工基础培训课,又对NLP重新产生的兴趣.NLP的第一步大家知道的就是不停的写正则,那个以前学的还可以就不看了.接着就是我们在把NLP的词料在传入神经网络之前的一个预处理,最经典的就是 ...
- Akka(0):聊聊对Akka的初步了解和想法
前一段时间一直沉浸在函数式编程模式里,主要目的之一是掌握一套安全可靠的并发程序编程方法(concurrent programming),最终通过开源项目FunDA实现了单机多核CPU上程序的并行运算. ...
- .NET Core 从1.1升级到2.0记录(Cookie中间件踩坑)
.NET Core 2.0 新时代 万众瞩目的.NET Core 2.0终于发布了,原定于9.19的dotnetconf大会的发布时间大大提前了1个月,.NET Core 2.0/.NET Stand ...
- Dubbo实现原理之基于SPI思想实现Dubbo内核
dubbo中SPI接口的定义如下: @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public ...
- pinnet 计算云分区
fdisk /dev/xvdemne mnlEnterEnter 9G-98G-98G-478M-28G-28G-28G mw #设置文件格式mkfs -t ext4 /dev/xvde5mkfs - ...
- 01-Python的基础知识2
- Python变量 - 变量就是重复使用的一个量,或者一个代号. - 变量的命名规则: - 必须以下划线或者字母开头,后面接任意数量下划线.字母.或数字. - 4man , 5for 是不可以的 - ...
- 原子操作--sync/atomic的用法
golang 通过sync/atomic库来支持cpu和操作系统级别的原子操作.但是对要操作类型有如下要求 int32, int64,uint32, uint64,uintptr,unsafe包中的P ...
- Linux CPU实时监控工具
注:ubuntu需要安装sysstat: sudo apt install sysstat [root@testDb ~]# mpstat 1 10 ---显示操作系统内核版本 以及硬件配置 ...
- Django + Uwsgi + Nginx 实现生产环境 项目部署
内容: uwsgi 介绍 uwsgi安装使用 nginx安装配置 django with nginx 如何在生产上部署Django项目? Django项目的部署可以有很多方式,采用nginx+uwsg ...
- 字符串编码C#
给定一个字符串,请你将字符串重新编码,将连续的字符替换成“连续出现的个数+字符”.比如字符串AAAABCCDAA会被编码成4A1B2C1D2A. 输入描述: 每个测试输入包含1个测试用例 每个测试用例 ...