Ad
  • Custom User Avatar

    Disagree this is an issue. Booleans are their own distinct primitive in JS, they are strictly not a "special case of number". There is no reason the validation logic for this kata should be any more complicated than "is it a number?"

  • Custom User Avatar

    Good question! I've added a note to source timestamps from time.time() to the description and also added the import to the initial solution.

    The original intention was that any source of timestamps would work, but this is better to avoid ambiguity.

  • Custom User Avatar

    @HananAbSh did you test this solution to find that out, or are you just assuming so?

  • Custom User Avatar

    Kata forked and updated to address all open issues

    https://www.codewars.com/kumite/6899181990a07832ede399a2?sel=6899181990a07832ede399a2

    Patch notes:

    • Description amended to note that decorated functions must handle input args
    • Tests extended to ensure positional and keyword args are handled appropriately
    • Random tests added for timing
    • Error messages added to test cases
  • Custom User Avatar
    1. Don't post solution code in the discourse without a spoiler tag. It appears on the front page.
    2. The code you posted doesn't work at all. Plus it looks nasty.
  • Custom User Avatar

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

  • Custom User Avatar

    A good start! Things to fix:

    1. Assertions should be grouped under @test.it('') blocks for the random tests
    2. Random tests should not sample from digits. It's unnecessary and could create function names which are syntax errors.
    3. for i in range(r-1) => for i in range(1, r) or else you generate tests with underscores at the end - or change the logic.

    Nitpicks:

    1. The random module has ways to take randomly from iterables already; use for example choice(chars) over 'somechars'[random_index]
    2. It would probably be better to just define a get_random_test_case(min_length, max_length) method rather than repeating the same logic twice in the small/large "true random" tests.
    3. Prefer descriptive variable names

    Suggestion snippet:

    from random import randint, choice
    
    ALPHABET = "qwertyuiopasdfghjklzxcvbnm"
    
    def get_random_test_case(min_length, max_length):
        test_case = ''
        length = randint(min_length, max_length)
        for i in range(length):
            should_flip = randint(0, 6) == 6
            if i != 0 and i != length - 1 and test_case[-1] != '_' and should_flip:
                test_case += '_'
            else:
                test_case += choice(ALPHABET)
        return test_case
        
    @test.describe("Random tests")
    def random_tests():
      ...
      @test.it('Tests with real words'):
      def word_concat_tests():
        ...
      @test.it('Tests with random strings'):
      def whatever():
        ...
      # So on and so forth
    
  • Custom User Avatar

    Please state which language you're working in when raising issues.

    Your Prolog solution is buggy, so I'm closing this īssue as it's not a problem with the kata itself.

    To fix your solution, consider what would happen if I called solution(-1, R)

  • Custom User Avatar

    TypeScript: random test generator was failing to correctly order inputs as per this issue:

    Fork with fix here

  • Custom User Avatar

    It's helpful to note what language you're working in when raising issues.

    Confirming this is an issue in TypeScript, however. The random test generator is sorting inputs lexicographically rather than numerically. Will post a fix.

  • Custom User Avatar

    Dang programmers, making math all complicated

  • Custom User Avatar

    0 * -1 does, in fact, equal -0 in almost every language's floating point math.

  • Custom User Avatar

    Python list slicing works like this:

    list[start:stop:step]

    Where start is the first index to visit, stop is the index before which we will stop, and step is how far to move at each step of the process.

    When start isn't specified it defaults to 0, and when stop isn't specified it means we take the entire list after start. When step isn't specified it also defaults to 1.

    Putting this all together, list[::-1] means "take the entire list, stepping backwards" - or, in simpler terms, reverse it!

  • Custom User Avatar
  • Custom User Avatar

    Fork approved by someone, closing issue.

  • Loading more items...