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.
The point of this kata is not to write a function
boolean isDiv5(String s)
, but to create a regular expression that will match all strings that represent in binary a number divisible by five and only these strings.For example, this regular expression should match
"101"
,"0"
and"1111"
because they represent5
,0
and15
.But it should not match
"111"
,"10000"
nor"1"
as they represent7
,16
and1
.You mad genius
You are doing WAY too much work generating all the permutations. Let's take the example in the description :
The whole list of permutations of "abc" is
["abc", "acb", "bac", "bca", "cab", "cba"]
, and the answer is"bac"
.Do you really need to know that
"abc"
comes before"acb"
to determine the middle permutation ? No you don't.Do you even need to generate them ? Once again, no you don't. After all,
'a'
is the very first letter in order, so there's not much chance for it to be the middle permutation's first letter.It's really quite simple, actually : look at the fork.
Edit : similar solution (except that I used 128 instead of 1000)
Without leading zeros. k is 2 for d=3.
You may find the range patterns useful ;-)
By rethinking how to approach this problem.
Do you actually need to count from 1 to a million to know that there are indeed a million integers from one to a million? You could, sure, but I really hope you didn't answer yes.
Now think about the intervals
[0, 10]
and[5, 15]
: they can be reduced to[0, 15]
, but why ?This comment is hidden because it contains spoiler information about the solution
Not under normal circumstances. But unsafe operations exist.
Comment unsuccessfully ignored.
Please review and approve, thanks !
Two full turns clockwise and then continue clockwise until you reach the next number.
Not closing the issue because I too think the steps should be made clearer.
Was susceptible to input mutation.
Was susceptible to input mutation.
Was susceptible to input mutation
Loading more items...