Ad
  • Custom User Avatar

    I just did a version guessing using the most common patterns. It has most of the failures as the other solutions but with comments explicitly pointing out the issues.

    You should be able to click 'View Solution' under my post to see it. If not then this link should work: https://www.codewars.com/kata/reviews/553a8bb91e0399d6f70001b9/groups/5ff1ed99f0bb620001b79f96

  • Custom User Avatar

    I suggest that the url secure.ftp.g.cn be added to the test suite.

    g is the domain name. secure and ftp are two subdomains and the TLD is cn.

    The url is fictitious but g.cn is a real website while multiple sub-domains are a possibility.

  • Custom User Avatar

    Fair point. I deleted the comment without reading to start from a clean slate, before trying to find the schema names.

  • Custom User Avatar

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

  • Custom User Avatar

    There's two bugs with the random tests when using Python. Here's the code I used to get around the bugs.

      item_count = ...
      
      # the test script seems to have several bugs in it..... !?
      # Bug A - when the index is invalid and negative return page_size
      if page_index < 0:
          return self.page_size
          
      # Bug B - when page requested is last page, return 0 if page is full
      if page_index+1 == len(self.pages) and item_count == self.page_size:
         return 0
         
      return item_count
    

    Here's also a fix for the test script:

      item_count = b-a
      page_number = x
      max_page_index = int(ceil(item_count / float(pagelength))) - 1
    
      if page_number >= 0 and page_number < max_page_index:
          solution = pagelength
      elif page_number == max_page_index:
          solution = (item_count % pagelength) or pagelength
      else:
          solution = -1