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.
Will invalidate all solutions, cannot be done at this point
@kgashok
Maybe
str
ors
would make it more clear that the variable is a string.seq
seems to be commonly used to name arrays.That being said, it's perfectly fine to call a string
seq
. I only pointed out the convention because it was assumedseq
was passed by reference.@jistjoalal What variable name would you recommend I change it to?
JavaScript passes strings by value so it's no problem :)
Although it is a tad misleading that the strings name is
seq
Seems like fixed
Fixed
@Voile Very cool way to display that data. I can see why it's not very uniform. The only 'random' thing about it is determining whether one letter is 'greater than' or 'less than' another. So, duly noted that it's not the best solution if you want truly random. But you have to admit, it works for this kata, as HerrWert pointed out.
In my test of "apparent randomness" (for lack of a better term -- not sure if it meets the definition of pseudorandomness), I am running the user's solution 1,000 times and adding up the decimal ASCII value for each letter randomly placed in each position of the cipher. Lower-case letters average an ASCII value of 109.5, so I am looking for a total that's 1,000 * 109.5, give or take a tolerance of 5%, at each position in the cipher.
So the 0.5-Math.random() approach is meeting the criterion for my kata, but possibly doesn't satisfy a stricter definition of randomness.
Nononononono, please don't use
0.5-Math.random()
! There are lots of people encouraging this bad practice due to various reasons (ignorance, laziness, etc), but it's just bad bad bad. For the first part, it doesn't even shuffle uniformly.https://bost.ocks.org/mike/shuffle/compare.html
This is great, because:
Glad you liked it! :D
:)
Better?
Can I improve the description yet?
And then they'll use
Array["len"+"gth"]
.I've considered it. But it's still all too easily circumvented.
Besides,
String.length
is legal.Thanks for the suggestion though!
Loading more items...