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.
Thanks, fixed.
It can be easily done without exceeding BigInt size. I don't think randomising the length increases the complexity in any way - it's still just one check.
I have added an explicit max length of input data(64 bits) to simplify things. Sadly, I don't see any way to easily get the max value of
BigInt
so this will have to do.JS: it doesn't make much sense to have a single fixed test where calculations may exceed the maximum BigInt size. Easy to hardcode (see my solution). Either make random tests generate such occurences, but that would make the kata significatively harder compared with other languages, or just remove it.
Javascript:
export
in initial code makes the program crash.Thanks for the comment, I've updated the tests.
I've left
full length
andpartial length
as they were. 'partial length' means some bits may be trimmed from most significant bit's side, 'full length' means no bits trimmed.Decimal offsets are more readable than hexadecimal ones.
[Python]
In python "full length" and "partial length" don't make sense, "offet with sign bit set" is simply
4026531840
(without sign bit).Tests import
solution
but useextract_bit
. Use eitherimport solution
/solution.extract_bits
orfrom solution import extract_bits
/extract_bits
.No random tests.
This comment is hidden because it contains spoiler information about the solution
I solved this kata, but can anyone tell me what theorems from mathematics or algorithms will help to solve this problem more efficiently?
++
Helper method makes debugging much nicer. Great kata!
Thanks, I've updated the description.
👍
New tasks are only put into the queue when they arrive. You cannot predict the future, so this cannot be done before their arrival time.
At
t = 0
: The queue is[]
, runningtask0
At
t = 2
:task1
arrives, the queue is[task1]
At
t = 3
: window finishes buttask0
is not done yet, puttask0
at the end;task1
is now executed, the queue is[task0]
At
t = 4
:task2
arrives, the queue is[task0, task2]
At
t = 6
: window finishes buttask1
is not done yet, puttask1
at the end;task0
is now executed, the queue is[task2, task1]
...
I would like an explanation/clarification for the DifferentStartTimes test:
After doing task 0 and task 1, it is now startTime + 6 seconds.
However, after running their timeslots, tasks 0 and 1 are at the end of the job list. So task 2 is next on deck.
Since task 2's arrival time is startTime + 4 seconds, which is less than the current time after the first two timeslots, why can't we run it instead of running task 0 again?
Loading more items...