Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The expand function reverses the matrix in both ways, suppressing the last column, as done in my solution.

  • Custom User Avatar
  • Custom User Avatar

    Thank you for catching that, I have updated the test case.

  • Custom User Avatar

    If you are trying in python, you can always redefine the __getattribute__ method to check which member is being accessed :

    def __getattribute__(*args) :
      print("member %s is being accessed" % (args[1]))
      return object.__getattribute__(*args)
    

    Where object is the argument of the class

  • Custom User Avatar

    In the provided test cases, you use the variable smallTour in the test, whereas I believe it should be medTour.

  • Custom User Avatar

    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.

  • Custom User Avatar

    an example of such a board would be

    board = [
      [1,2,3,4,5,6,7,8,9],
      [2,3,4,5,6,7,8,9,1],
      [3,4,5,6,7,8,9,1,2],
      [4,5,6,7,8,9,1,2,3],
      [5,6,7,8,9,1,2,3,4],
      [6,7,8,9,1,2,3,4,5],
      [7,8,9,1,2,3,4,5,6],
      [8,9,1,2,3,4,5,6,7],
      [9,1,2,3,4,5,6,7,8]
    ]
    
  • Custom User Avatar

    My pleasure

  • Custom User Avatar
  • Custom User Avatar

    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

    • a list of individual elements : the resulting list is the list made of the individual elements as in classical Javascript
    • a range in the form 'start..end' : if end >= start, the list is [start, start+1, start+2, ..., end] otherwise the result is []
    • a single element a followed by a range : let step = start - a
      • if start === end the list is [a,start]
      • if step is positive and end > start then the list is [a, a+step, a+2*step, ...] as long as a+k*step <= end
      • if step is negative and end < start then the list is [a, a+step, a+2*step, ...] as long as a-k*step >= end
      • otherwise the list is []

    I would put the examples after the formal definition, and maybe use

    [2,3,-5,3] // just like in JavaScript : [2,3,-5,3]
    [1..5] // goes forward with step 1 : [1,2,3,4,5]
    [1.3..7] // goes forward with step 2 (3 - 1) : [1,3,5,7]
    [6,5..3] // goes back with step -1 = (5 - 6) : [6,5,4,3]
    [6,4..0] // goes back with step -2 = (4 -6) : [6, 4, 2, 0]
    [5..3] // default step is 1 while the range is decreasing : []
    [10,1..10] // goes back with step -9 for an increasing range : [10]
    [1,1..10] // goes forwaed with step is 0 = ( 1 - 1) : infitite list [1,1,...]. Do not worry about this case in this kata for this, we will deal with it in the third part.
    [1..9,12..15] // invalid since one single range is allowed
    [1,2..20,25] // invalid since a range has to be the final item
    [1,2,3..20] // invalid since at most one inidivual element can be provided before a range
    
  • Custom User Avatar

    No problem. I find it weird now that 1,3..4 gives [1,3] whereas 3,4..0 gives [3]. What is the behaviour of 1,2..2 and 3,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."

  • Custom User Avatar

    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.

  • Custom User Avatar

    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...