Ad
  • Custom User Avatar

    I also found debugging was not easy during main tests. What you can do is, inside the body of each method, print messages that allow you to know first which method is called, and then whatever you're interested in (arguments received by the method, state of the list at the beginning, state of the list after applying the method...). This way you may find out which operation your code is not doing right.

  • Custom User Avatar

    Please use spoiler flag next time.

  • Default User Avatar

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

  • Custom User Avatar

    So I generally agree with the sentiment (especially with geometry/physics katas) but the sum of the first n numbers is such an important formula in the study of algorithms that I think it deserves its place here.

  • Default User Avatar

    Total average is the average of all valid values:

    discard = 2
    array 0 = 800,1200,2100,4100,1300,700 // discard 800,1200 at start and 1300,700 at end
    array 1 = 1000,1500,4500,5000,5800,2000,1500 // discard 1000,1500 at start and 2000,1500 at end
    
    total avg = (2100 + 4100 + 4500 + 5000 + 5800) / 5
    
  • Custom User Avatar

    so true, after this kata i use filter with no math in

  • Custom User Avatar

    Exactly what it says in the description. Random lists are generated, random indexes are called, and random methods are used on the lists. This isn't unusual for a kata. If need be, test it locally. :)

  • Default User Avatar

    I have no idea what is happening in random tests and how to debug them.

  • Custom User Avatar

    Man, this is a much clearer description

  • Default User Avatar

    As I understood it [0, 4] are X coordinates and [0, 0] are corresponding Ys.

  • Default User Avatar

    It's (0,4) not (4,0), order matters.

  • Default User Avatar

    Python

    logistic_map(5,2,[0,4],[0,0])
    #returns
    #[[0,1,2,1,0],
    #[1,2,3,2,1]]
    

    AFAIK Manhattan distance is calculated |x2-x1| + |y2-y1|.

    So at (0,3) with supplys at (0,0) and (4,0) I got:

    |0-0| + |0-3| = 3
    

    and

    |4-0| + |0-3| = 7
    

    But the answer is 1. Did I misunderstand something? TIA.

  • Default User Avatar
      [[64, 63, 3, 4, 5, 6, 58, 57], 
       [56, 55, 11, 12, 13, 14, 50, 49], 
       [17, 18, 46, 45, 44, 43, 23, 24], 
       [25, 26, 38, 37, 36, 35, 31, 32], 
       [33, 34, 30, 29, 28, 27, 39, 40], 
       [41, 42, 22, 21, 20, 19, 47, 48], 
       [16, 15, 51, 52, 53, 54, 10, 9], 
       [8, 7, 59, 60, 61, 62, 2, 1]] 
       
       should equal 
       
       [[64, 2, 3, 61, 60, 6, 7, 57], 
        [9, 55, 54, 12, 13, 51, 50, 16], 
        [17, 47, 46, 20, 21, 43, 42, 24], 
        [40, 26, 27, 37, 36, 30, 31, 33], 
        [32, 34, 35, 29, 28, 38, 39, 25], 
        [41, 23, 22, 44, 45, 19, 18, 48], 
        [49, 15, 14, 52, 53, 11, 10, 56], 
        [8, 58, 59, 5, 4, 62, 63, 1]]
    

    AFAICT that is also a magic square. So why isn't it an acceptable answer?

  • Custom User Avatar

    I can't agree more on that mate!

  • Default User Avatar

    Python,

    Testing for: s=TyTYLX TtEheF xXm MOXruUK bNZU, n=3
    'tyTYLXTtEheFXXMMOXruUKBNZu' should equal 'tytylXTteheFXxMMoxruuKBnzu'
    

    As I understood it:

    TyTYLX  => TyTYLX 
    TtEheF  => TtEheF
    xXm     => XXM
    MOXruUK => MOXruUK
    bNZU    => BNZU
    
    TyTYLXTtEheFXXMMOXruUKBNZU => tyTYLXTtEheFXXMMOXruUKBNZu
    
  • Loading more items...