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 really enjoyed this one! Although my own solution ultimately didn't work and I resorted to comparing existing algorithms and implementations, I learned a lot.
I definitely agree with other commenters - these kinds of problems often seems to be about finding the right algorithm.
That's a cool solution!
I assume it has been generated somehow. How does it work? :D
Thanks for the quick reply! :)
This comment is hidden because it contains spoiler information about the solution
I might have found a solution, see my issue above!
This could be related to
@MikeHathaway
's comment below, but my case is a little bit different. I don't get the"u r using restricted stuff"
error message but i do have500
/501
tests passing.After looking closer at the failing test, I realised that the issue is with the tests themselves:
This is the second sample test
The third basic test for the attempt-suite fails as well.
Negative numbers aren't prime. The expected results of these tests should therefore be
false
.In addition to that, the instructions has an invalid example with a negative number as well. It's a good idea to test with negative numbers - but only if the test cases have correct assertions.
Could you show your code for reference? :)
Interesting approach! Not the shortest but still quite clean :)
This repetition is a good example of when it's recommended to use an abstraction to separate the logic (your
if
s andelse
s) from the data of a similar format (the roman numerals and the values they represent).Since the data is in a clear
key: value
format, an object{}
would be great.Good luck, and happy coding! :)
Only thanks to the random tests, I found an edge case related to an "off by one" error in my solution (See
range(m, n)
which initially didn´t use an inclusive upper bound). I initially passed with an incomplete solution but once I tested again it didn't pass.How about adding an additional basic test case similar to the following?
Could you give some example code? :)
From https://mdn.io/call:
Function.prototype.call()
returnsYou can basically use array methods on strings and vice versa.
For example, an array can be "split" into pieces just like a regular string:
This is basically the same as running:
Where the array is treated as the
this
value:And this is the
argument
: