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.
You are right that the tests aren't fully exhaustive. I specifically tried to ensure that that kind of literal edge cases wouldn't come up because it would be too hard to specify exactly what should happen in the instructions, especially given floating point precision issues.
This comment is hidden because it contains spoiler information about the solution
The expand function reverses the matrix in both ways, suppressing the last column, as done in my solution.
Great one !
Thank you for catching that, I have updated the test case.
If you are trying in python, you can always redefine the
__getattribute__
method to check which member is being accessed :Where
object
is the argument of the classIn the provided test cases, you use the variable smallTour in the test, whereas I believe it should be medTour.
I can't submit right now, but it seems like now you check that the state falls back to regular in test 15, then you suppose in test 16 that eating a ghost increases points by 10, but the state is now regular, so it occurs to me that this test is wrong since the value should be 0 when you ask for 10, then in test 17 you eat an other ghost, suppose that a life is lost, but a life is already lost in the previous test, therefore you suppose 2 when its 1. I also mention that since I can't submit working code, I can neither see spoiler content nor actual test cases.
an example of such a board would be
My pleasure
Fixed. Thanks!
Since the ranges in both 1,2..2 and 3,2..2 contain 2, the specification I described is wrong about increasing and decreasing sequences. It should say that a sequence is constant if start === end, increasing if start < end and decreasing otherwise. It should also be added somewhere that a constant sequence has one single element, which is its start. In the text, I used the word descriptor, while you use generator in the kata description. Finally, given your example, I also realize from your examples that if a range is provided, only one single individual element is allowed. I would therefore reformulate my previous description as
A valid generator can be either
'start..end'
: ifend >= start
, the list is[start, start+1, start+2, ..., end]
otherwise the result is[]
a
followed by a range : letstep = start - a
start === end
the list is[a,start]
step
is positive andend > start
then the list is[a, a+step, a+2*step, ...]
as long asa+k*step <= end
step
is negative andend < start
then the list is[a, a+step, a+2*step, ...]
as long asa-k*step >= end
[]
I would put the examples after the formal definition, and maybe use
No problem. I find it weird now that
1,3..4
gives[1,3]
whereas3,4..0
gives[3]
. What is the behaviour of1,2..2
and3,2..2
then ?I believe you should define formal specifications for the descriptor, something like "a valid descriptor is made of a (possibly empty) list of individual numeric elements, plus a single optional final range with format 'start..end', where start and end are numbers. A range is increasing if end ≥ start, decreasing otherwise. The provided individual elements provide the first elements of the output list. The range elements are appended to these, and are defined using a step. The step is defined as start-a, where a is the last individual element provided. In case no individual element is provided, the step is 1. An increasing (resp. decreasing) range with a negative (resp. positive) step is empty. Otherwise the elements of the range are defined as
start + k * step
, with k starting at 0 and increasing one by one as long as the result is in between start and end."In your description, in the code example, you use the key 'definition', which is 'generator' in part (i) of the kata, and in the tests you run.
What about ['1,2..6,8..11,10..0'] ? and ['1,1..10'] ? My current solution infinitely loops on the last one.
Loading more items...