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.
Short and sweet, but not best practices. I think this is a cute and clever solution for a simple string, but not efficient if the input was 100s or 1000s of characters long. I'd prefer a solution that returned false as soon as a lowercase character was found. In this case this solution is O(n) yet always the worst case, meaning that it always has to reach the last item (ALL characters must be uppercased) before it can determine the boolean value. This is more of a JS like solution than an Elixir solution. Elixir has better "tools" for working with strings.
This is very clever!!!
No, it is not the precision. You need to do the integer division - so, not n / x, but div (n, x).
I'm not entirely sure, but it must be more expensive to concatenate with the longer string on the end. Even the one that passes takes about 6 seconds. The docs mention that there are often performance costs associated with working with strings and that it may be adventageous to work directly with binaries. Let me know if you're able to optomize it (I may take a crack at it later). Maybe a line could be added to the description warning of the high cost of String operations in Elixir.
To generate 1_000_000 numbers
I tried with
Integer.to_string(:rand.uniform(2) - 1) <> acc
, and it timed out. Do you know why the order matters?Need to pass the test... it was the precision causing the problem.
This comment is hidden because it contains spoiler information about the solution
Like this solution!
Cool. Thanks... I was wondering how cold this be done in a nicer way.
|> (&(&1 -- ids)).()
can be replaced as
|> Kernel.--(ids)
Looks better this way :)