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.
Sorry, I couldn't think of better names at the time. 😅
Why is everyone on Codewars allergic to naming variables? What's
f
? What'sff
? What doesx
mean? It's so annoying!Lol, I tried my best to have the shortest answer possible and I almost went with this solution...
These are completely different algorithms that just both happened to involve elevators.
Oh. Okay. I was testing it in
irb
but I guess I did a poor job then :')Looking at
~/.irb_history
, I did use two dots... even though I was specifically wondering about the difference between the two. Sigh.Aight. Send it.
Thank you!
It's not inclusive.
I added the other cases.
There are also some extra edge case tests in JS which are probably worth adding:
Oh sweet. Still reading.
set operations on array? weird language. had to go try it to see if it actually did the right thing x)
one tiny bug:
rand(0...10)
that's inclusive, so that's 11 outcomes where in python it's 10. I don't actually care and will approve that, would be nice if it's the same though.same with 0...5 of course
You're right, and thanks for the feedback. I made them distinct and followed the logic of Python snippet you provided. Check it out!
Hi! I will not dig into discourse to figure out why you're making this, but, the current ruby implementation is obviously wrong so it's presumably about that if I was to look.
So, I'm glad to see this already here.
However. Still wrong. This implementation doesn't guarantee that A B C D are distinct since you pick four random values for them.
One way to go about it is to put all candidates in an array and swap the chosen element with the end and then pop off the end. Another way to do it is to re-try the roll if it rolls an already chosen value - this is typically better when the pool is large and the desired amount of values is small, such as here.
Could you make that update? I'm quite keen to press the approve button after that even if I don't know ruby and will do a poor job of looking it over -- since the current one is entirely broken.
The python version has some additional code related to edge cases that uhm I have no clue if that's good or bad really, but seeing as python is the original language and has the most solve, I would copy exactly what it says there.
this is how it reads there:
This comment is hidden because it contains spoiler information about the solution
Wow...how far I have to go still.
Description isn't too bad, just think about you inputs and outputs and you should be fine to solve.
I think you're seeing errors from different tests. The UI unfortunately doesn't make this very clear. One thing you can try to do is use something like
console.log(a, b, margin)
in your function to see what exactly is being tested.if I return 0 the margin case gives me this: "expected +0 to equal -1"
if I return -1 the margin case gives me this: "expected -1 to equal +0"
if I try to set margin as 0 itself it still gives me: "expected +0 to equal -1"
Am I missing something?
Loading more items...