Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I made this Kata for Ruby, somebody has translated to Python, so I'm guessing that's where the formatting issue has come in.
I should remove my Kata, that I wrote in Ruby, to be used for practicing Ruby, that SOMEBODY ELSE translated to Python, because you find it 'offensive' in the language I DID NOT write it in?
You need to return a function from the method
getSequence
, which calculates the 'nth term' for any given value of n.So getSequence([1,2,3,4,5])(10) is equal to calling yourNewSequence(10), which should then calculate f(10) for the sequence [1,2,3,4,5].
Sorry if this isn't very clear!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
The random number is generated for each test, you don't need to refer to it, you just need to write the "getNumber" method to return it.
Hi, apologies this seems to be an error on my part in the tests! Should be corrected now.
That's a good question - I have no idea to be honest! 3 would of been plenty.
I guess people may have used a simpler method to check if the sequence was non-linear with only 3 numbers from the sequence though?
How is that really the same as this?
Other than the inclusion of a sequence...
You are correct! Thank you for pointing this out, I have fixed the issue. I don't know how I managed to get it wrong in Ruby but not in Javascript... doh!
You should return the number once you have calculated it, that is all :).
The second part (returning a function/lambda version) is now published :).
http://www.codewars.com/kata/calculate-the-function-f-x-for-a-simple-linear-sequence-medium
I'm glad you enjoyed it! :)
I have amended the description as per your recommendation to include the various formats for the purpose of clarity.
I have also added some tests which are
f(x) = m
!As for the final suggestion that is actually part of my plan for this series of Kata's!
This was the easy version, for the next I am going to require an actual function (or lambda / block) to be returned which you can then pass in 'x' as an argument and return a value. I'm also hoping to do something similar with more complex sequences, i.e. quadratic.
I don't believe you can create a range using a ',' by default. (To the best of my knowledge). That was a mistake on my behalf in the description.
You can use '..' to include the max value or '...' for up to but not including the max value. E.g.
I'm pretty sure chaining methods is not a problem in Ruby! I'm sure you'll see quite a lot of one line solutions to data sorting problems similar to this, there's no need to overcomplicate it.
Loading more items...