7 kyu
Simple Fun #74: Growing Plant
2,768 of 12,307myjinxin2015
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Elm random tests do not seem to match the
2 ≤ downSpeed < upSpeed
constraint:Given (9,448,3)
This comment has been hidden.
I've just submitted my solution in C++, it works fine, double check your code and read this
This comment has been hidden.
This comment has been hidden.
Yes, thanks a lot bro, just got it right before ur message ))
love well written katas where i can intuitively understand what's the problem to solve, thank you
Python update with correct parameter names and new test framework: https://www.codewars.com/kumite/64a01b04dddc252308dfa565?sel=64a01b04dddc252308dfa565
Kata needs to be changed to explicitly define the condtions to "reach desired height". There are assumptions that the plant has to equal the height exactly and not being greater than or equal to the height. Users should not have to sift through test cases to clarify.
Update to Scala 3
.
C# tests generate warnings!
tests/Fixture.cs(106,15): warning CS0219: The variable 'passed' is assigned but its value is never used
fixed
COBOL translation (author is inactive).
Approved
Hi, fun kata! Just sayin', glad I don't live near any plants growing 100m/day. Yowza!
This comment has been hidden.
This comment has been hidden.
Not an issue. You're not returning anything.
Please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
HI I am creating function which starts with CREATE FUNCTION growing_plants(up_speed INT, down_speed INT, desired_height INT) RETURNS INTEGER LANGUAGE plpgsql AS $$ DECLARE r INTEGER; And I got that mistake: unterminated dollar-quoted string at or near "$$ What's wrong with this $$?
The Kata in JS is fine but you should think carefuly about the moment to apply the changes.
{expression,"kata : growing_plant ( 10 , 9 , 4 )"}, {expected,1}, {value,4}]
why expected value is 1, if every day we have growing (10-9) and height must be 4? Or maybe I didn't understand something
if the desired height is 4, and the plant grows by 10 everyday, then the plant would reach the desired height on the first day, therefore expected 1.
That's the whole point of the problem ;-)
Also saying that variable passed is made but never assigned so I can't solve either way. I can't access that variable.
I passed the kata with no problem in C#. Read this and give useful information about the problem, state the language, post your code with markdown formatting and marking your post as having spoiler content.
It keeps saying it expects the plant in one day while my answer is 4, but the solution is 4.
A problem with your code is not a kata issue. There are already more than 400 solutions in C#.
What I mean is that for the plant to get to the height of 4, it would take 4 days, because it basicaly only grows an inch a day.
If it is that test, you can see it reaches 4 inches mark the first day when going up.
thanks
Elm random tests do not match the 2 ≤ downSpeed < upSpeed constraint:
Yes, they do. Read the setup carefully.
This comment has been hidden.
This comment has been hidden.
The highest Python version here is 3.6
this kata works fine on pycharm but not here whats the problem? im using recursion
my final answer for every new test case is incrimented by 1 each time
I trained this kata on Go, but is's confusing me.
First of all we need to understand actual value of
upSpeed
anddownSpeed
variables.It seems to me sometimes it's counting as (assumption 1)
daySpeed
andnightSpeed
, and somitemes like (assumption 2)speed
andnightlySpeedDecrease
.It's funny, when I try to resolve this kata with assumption 1, then I getting some passed tests, and some failed, and the similar situation for assumption 2. So what is actually right? Please fix it.
the Go version seems alright with almost 200 completions and no complaints
The expected answers are wrong? I tweaked my query to match the expected.
always state the language you are using if you want help
Most likely he's talking about SQL, see issue below. It should be fixed now.
i passed the basictest but randomtest fail,did the randomtest using log? logarithm?
always state the language you are using if you want help
Oh sorry, im using java language
4th sample test expected result in SQL is wrong, see post below for details. And in the final tests there are more tests expecting wrong results, it seems related to the expected results are using integer division.
fixed
No, it's not fixed.
Have you clicked Reset to get the new version?
Ah, sorry, there was some minor issue in my browser. Resetting multiple times solved the issue.
This comment has been hidden.
I agree with you, and don't understand the id 4 result
For the test case: Test.assert_equals(growing_plant(10,9,4),1)
I am getting 4 days instead of 1 day.
After day 1 --> 10 10 - 9 = 1 After night 1 --> 1 1 + 10 = 11 After day 2 --> 11 11 - 9 = 2 After night 2 --> 2 2 + 10 = 12 After day 3 --> 12 12 - 9 = 3 After night 3 --> 3 3 + 10 = 13 After day 4 --> 13 13 - 9 = 4 After night 4 --> 4
Am I thinking too little on this?
You reach 4 the first day while going up from 0 to 10.
Ah understood, thanks!
The question's meaning is that when your plant's height is bigger or equals to the desiredHeight,so your program should return 1,since 10 is bigger than 4.
Elixir: too much code in the initial solution.
fixed
Clojure, CoffeeScript, Dart, Elixir, Elm, Factor, Forth, Go, Groovy, Julia, Lua, Nim, PHP, Racket, Reason, Scala, SQL, Swift, and TypeScript translations.
SQL sample tests:
fixed
C/C++, NASM, & Java translations available.
upSpeed and downSpeed are not speeds, they're distances, maybe upDistance and downDistance would be a better naming?
Kotlin Translation Please, review and approve.
Approved. Cheers ;-)
R translation. Please, review and approve.
Approved. Cheers ;-)
Haskell random tests do not match the
2 ≤ downSpeed < upSpeed
constraint:Fixed.
Haskell : https://www.codewars.com/kumite/5bb97f34945bd5be0a00000e?sel=5bb97f34945bd5be0a00000e
;-)
@cliffstamp: Please have a look at issue above. Thanks, suic
Fixed.
Is 1 the output when the parameters are exceeded?
This comment has been hidden.
I've modifed the descrption like this:
For
upSpeed = 100, downSpeed = 10 and desiredHeight = 910
, the output should be10
.For
upSpeed = 10, downSpeed = 9 and desiredHeight = 4
, the output should be1
.Because the plant reach to the desired height at day 1(10 meters).
If desiredHeight is 0, the result must be 0 but it says 1. It is already 0 meters, there is no need to pass a day to reach it.
0
is not a valid input, because the description wrote:A positive integer representing the threshold.
Please tell me which language you meet 0 in the testcase? thanks ;-)Removed basic testcase (5,2,0) from python, ruby,crystal translations.
It was python and yes that testcase was exactly the problem :) thanks
I get time outs even in the example tests. Anyone else having the same problem? Solved.. infinite loop :)
Python, Ruby and Crystal translations submitted; and, on a side note, I really enjoyed this one as a quick exercise in the lunch break: thanks :)
Approved, all. Thanks.
And for some reason someone downvoted me for this, ok :D
Totally stole your Ruby solution for the Haskell translation.
Be my guest, any time, mate :)