Most probably no one thought of using Z for big numbers at the time (I definitely did not, because I did not even knew that Z exists), and this challenge already uses finite integers in many languages. Besides, maybe solving it for n up to 66 might be good eneough and would not differ much form solving it for arbitrary n? Or maybe you think it would be a good exercise to get familiar with Z?
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 represent 5, 0 and 15.
But it should not match "111", "10000" nor "1" as they represent 7, 16 and 1.
Reading back this fork, I realise that the pretty-printing leaks the expected number of elements. I don't know whether that's a good idea.
Yeah I'll have some trouble remembering what I was thinking three years ago, so I don't remember why I did it that way.
There are indeed two possibilities:
I went with the first one for some reason; someone could change the translation to the second if it seems like a good idea.
Most probably no one thought of using
Z
for big numbers at the time (I definitely did not, because I did not even knew thatZ
exists), and this challenge already uses finite integers in many languages. Besides, maybe solving it forn
up to 66 might be good eneough and would not differ much form solving it for arbitraryn
? Or maybe you think it would be a good exercise to get familiar withZ
?Why not just
Z
?(Yes I know this is ancient)
This comment is hidden because it contains spoiler information about the solution
Woops the formatting is botched, my bad
I only saw your reply when I posted mine and the page refreshed. At least you got a second confirmation.
Is 44 your answer or the expected answer ? Because 39 seems correct to me.
13 + 21 + 5 = 39
In
assert_eq!(...)
, when the two values compare unequal, the macro needs to print them and does so with the Debug trait.You can take a look at the signature of
assert_failed
in core::panicking.Approved some time ago
Approved
Approved
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
This comment is hidden because it contains spoiler information about the solution
Loading more items...