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.
This comment is hidden because it contains spoiler information about the solution
Surely most of us already know, but the description should probably note that: in C and some other languages, the input ranges are
0 <= (x) <= 2^64-1
(which is smaller than 1.9 * 10^19) rather than10^32
.(C translation)
Description says,
I picked 32 for a buffer size, and eventually found out that
youhavechosentotranslatethiskata
in sample tests is 32 (not including'\0'
) because it was truncated bysnprintf(buf, 32, ...)
. Okay, whatever. I increased it just enough, and later failed on random tests withgmsecfbdaesyiafxelikivvqauafiwrokjunr
being 37.With C translation, when I first edited & retried to see if I could remove my single-digit early-bailout check, right away, I got
n = 0
in a random test. I still returned0
but it failed expecting2^32-1
or similar. I tried another handful of times and it didn't reappear, but now I can see the reference solution, and I think it needed to not be able to return-1U
.So I solved the problem more or less exactly as it was described in the linked video, instead of searching for the simplest equivalent. Now I feel silly.
First, English uses
amount
for the sort of quantities for which you would use real (floating point) numbers. For traditionally countable things, or units of continuously variable things, use the wordnumber
. (Examples: an amount of water, a number of bottles of water, an amount of rain, a number of centimeters of rain, a number of raindrops, etc.) As an aside, the same distinction applies to how much vs. how many, with many corresponding to a number.Second, "the number of times you've already seen it" starts at zero. because "have already" implies the exclusion of this time. OK, you specifically force the first time to get a
1
, but the second time it appears, I have already seen it just once, and yet you expect a2
. It's possibly confusing. From the examples, it becomes obvious, but then also it appears that the distinction between the first occurrence and every following occurrence is unnecessary. The line becomes consistent and agrees with the examples if you only change it to:and/or something such as
then the examples make clear it means 1-indexed and not 0-indexed.
is not a question.
for some raisin, I thought it should be from M to M+N and not from 1 to N. that was dumb...
leeks
(C translation)
I had a bad approach to accepting the sign which completely passed the full tests but correctly fails after I added this to sample tests:
There is of course already one like it:
but my original way of permitting the
+
handled that one "accidentally correctly" by noting that there was a digit before it without bothering about its position in the string. After fixing my solution I hacked it back into a fork, which shouldn't have passed.It reads, "remove those two digits from the string", but then the spaces are both assumed and relevant, part of the string which never really got "smaller" (shorter). If it means "replace those two digits with spaces", and "return the minimum possible number of remaining ones and zeroes" then it should say that. Also that apparently was a question in the past, but now it's a direct instruction, and it still has a question mark.
past or present denominators, or defaults
That line, paraphrased / decoded / whatever:
(l+r)/(m+s)
is each new fraction (next iteration), before substitution and simplification. Letl/m
represent whatever the fraction was, just before you most recently parsed anL
choice. Letr/s
represent whatever the fraction was, just before you most recently parsed anR
choice.This is how values of
l, r, m, s
are obtained most often. Butl = 1, r = 0, m = 0, s = 1
are defaults, used when there is no previously parsed L or R (or neither, as shown in the way that the initial1/1
, corresponding to the empty string, is formed entirely out of them).HTH
wat.
It seems to be. Thanks!
Loading more items...