Ad
  • Custom User Avatar

    Oh dear... has been quite a few years since I wrote this. Trying to remember what I was thinking...

    normally:

    When a train arrives at a station it stops there for a period of time determined by the length of the train!

    So the NOTES part is intended to say this "stoppage-time" rule does not apply when the "start position" by chance happens to be at a station. In that rare case, on the next/first move you will immediately depart the station. So is the description really misleading? At the very beginning the "next move" and the "first move" is the same thing.

    I saw something in the discourse that someone changed and I reverted 6yrs ago. But I can't see the history to see the actual changes to the wording.

  • Custom User Avatar

    As always with @dinglemouse, it is a fantastic Kata, but I found an issue and may have some suggestions :

    1. Issue :

    If the start position happens to be at a station then the train leaves at the next move

    Someone _changed_ (as I read in the comments!) your description six years ago, and now this is **misleading**  since the train leaves the station right from the beginning.
    
    1. Suggestions :
    • There could more "small" tests to start with, maybe even some edge cases. The one present in the description is quite challenging!
    • It would be nice to have (when trains crash), a visualisation of the track. For example, for the one found in the description, it could be :
                                    /------------\                    
    /-------------\                /             |                    
    |             |               /              S                    
    |             |              /               |                    
    |        /----+--------------+------\        |                    
    \       /     |              |      |        |                    
     \      |     \              |      |        |                    
     |      |      \-------------+------+------Bbbbbbb                
     |      |                    |      |        a   b                
     \------+--------------------+------/        a   b                
            |                    |              a    b                
            \------S-------------+-------------/     b                
                                 |                   |                
    /-------------\              |                   |                
    |             |              |             /-----+----\           
    |             |              |             |     |     \          
    \-------------+--------------+-----S-------+-----/      \         
                  |              |             |             \        
                  |              |             |             |        
                  |              \-------------+-------------/        
                  |                            |                      
                  \----------------------------/   
    
  • Custom User Avatar

    You don't seem to realize I have put a lot of efforts to help you refine your kata...

    You just have to make those changes to make it more "good looking" and maybe approved.

    Note : For a kata to be approved nowadays, it needs to reach some standards of quality...

  • Custom User Avatar

    I made that suggestion because after following the 3Blue1Brown video, I conjectured a false formula that passes all your fixed but not the random ones...

    So I think this could help other warriors go deep into reasonning before just using the 'obvious' (but not easily generalizable) formula found in the video !

  • Custom User Avatar

    Since the problem is more difficult than the one presented in this video, I suggest to add the following tests :

        @test.it("Special Tests")
        def _():
            test.assert_equals(subset_sum(48745, 48745), 253593)
            test.assert_equals(subset_sum(15825, 15), 702143)
            test.assert_equals(subset_sum(83960, 40), 323446)
    
  • Custom User Avatar

    Task

    Given an array of integers arr of length n, count how many index pairs (i, j) with 0 <= i < j < n satisfy the condition :

    j - i = arr[i] + arr[j]

    Return the total number of such valid pairs.

    Samples

    • Input : arr = [3, 1, 4, 1, 5, 9, 2, 6, 5]
    • Output : 3
      since :
    i = 0 and j = 8 => j - i = 8 = a[0] + a[8] = 8
    i = 1 and j = 3 => j - i = 2 = a[1] + a[3] = 2
    i = 3 and j = 6 => j - i = 3 = a[3] + a[6] = 3
    
    • Input : arr = [1, 2, 1, 2, 1, 2]
    • Output : 6
      since :
    i = 0 and j = 2 => j - i = 2 = a[0] + a[2] = 2
    i = 0 and j = 3 => j - i = 3 = a[0] + a[3] = 3
    i = 1 and j = 4 => j - i = 3 = a[1] + a[4] = 3
    i = 1 and j = 5 => j - i = 4 = a[1] + a[5] = 4
    i = 2 and j = 4 => j - i = 2 = a[2] + a[4] = 2
    i = 2 and j = 5 => j - i = 3 = a[2] + a[5] = 3
    

    Notes :

    • Expected complexity is O(n) where n is the length of arr.
    • Test structure :
      • 20 small tests (length < 300)
      • 10 medium tests (length < 1500)
      • 20 larges tests (length = 100000)
  • Custom User Avatar

    First of all, love the Yoshi drawing. Now, what tests exactly do you want in the description? I already have the sizes in the description, do you want the number of tests?

    Pretty much all I could say about the random tests are in the final tests and you can just hit submit with an empty solution to see all information.

  • Custom User Avatar

    Precise nature of the very challenging tests should be in the description

                                  
                   ████ ███        
                  ██▒▒▒█▒▒▒█       
                 ██▒        █      
             ██████  ██ ██  █      
            ██████   ██ ██  █      
            ██▒▒▒█          ███    
            ██▒▒▒▒▒▒   ▒  ██████   
           ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███ 
          ██▒▒▒▒     ▒▒▒▒▒▒▒▒▒▒▒▒█ 
          ██▒▒▒       ▒▒▒▒▒▒▒█▒█▒██
           ██▒▒       ▒▒▒▒▒▒▒▒▒▒▒▒█
            ██▒▒     █▒▒▒▒▒▒▒▒▒▒▒▒█
            ███▒▒   ██▒▒▒▒▒▒▒▒▒▒▒▒█
             ███▒▒   █▒▒▒▒▒▒▒▒▒▒▒█ 
            ██▀█▒▒    █▒▒▒▒▒▒▒▒██  
          ██▀██▒▒▒    █████████    
        ██▀███▒▒▒▒    █▒▒██        
    █████████▒▒▒▒▒█   ██  ██       
    █▒▒▒▒▒▒█▒▒▒▒▒█    ████▒▒█      
    █▒▒▒▒▒▒█▒▒▒▒▒▒█   ███▒▒▒█      
    █▒▒▒▒▒▒█▒▒▒▒▒█    █▒▒▒▒▒█      
    ██▒▒▒▒▒█▒▒▒▒▒▒█   █▒▒▒███      
     ██▒▒▒▒███████   ██████        
      ██▒▒▒▒▒██     ██             
       ██▒▒▒██     ██              
        █████     ███              
        █████▄   █████▄            
      ▄█▓▓▓▓▓█▄ █▓▓▓▓▓█▄           
      █▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓█          
      █▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓█          
      ▀████████▀▀███████
    
  • Custom User Avatar

    Thanks

  • Custom User Avatar
  • Custom User Avatar

    description was updated

  • Custom User Avatar
  • Custom User Avatar

    subset_sum(8, 4), 67) => 64

    subset_sum(14, 2), 8256) => 8192

    subset_sum(24, 8), 97141) => 97134

    subset_sum(46, 2), 626605) => 432337

    subset_sum(48, 4), 867746) => 864674

    subset_sum(68, 4), 342516) => 244212

  • Custom User Avatar

    Small typo:

    Find the sum of all integers less than n that have exactly k ones in their binary represetations.

  • Custom User Avatar

    Thanks!

    1. I have fixed the missing suits for the example

    2. This is mentioned in the problem description. I have added the fixed tests for this example (there was one actually - that tested full deck of cards in two different orders, but I added some better examples to the flop section.

  • Loading more items...