Ad
  • Custom User Avatar

    I thought |n| means the absolute value of n, but fine

  • Custom User Avatar

    Marking as resolved if no further issues

  • Custom User Avatar

    |n| means the length of n as a binary string is less than or equal to 10^5. This doesnt guarentee that it can be expressee as an integer in Python

  • Custom User Avatar

    It only works both ways by chance that second case. You need to take into account every possible way of removing pairs. The expected value is the one which is alphabetically the smallest (left to right). "czab" < "zacb". But remember, the remaining characters still need to maintain their original order. Characters cannot "jump" over other ones.

  • Custom User Avatar
  • Custom User Avatar

    This is just the end of the "small" random tests, "medium" and "large" are obviously larger:

    Random Tests
    Small
    
    [...]
    
    Log
    n='1000001001011110001011000000' (=136700608), k=3
    'Too big!' should equal 438933664
    
    Log
    n='1100001110000111111010001111111' (=1640232063), k=15
    'Too big!' should equal 321509065
    
    Log
    n='10111001001111110000011111000010010100' (=198906605716), k=12
    'Too big!' should equal 628816705
    
    Log
    n='100001000011000100001101110' (=69306478), k=9
    'Too big!' should equal 803835291
    
    Log
    n='101011110011110110000100011000011111' (=47040710175), k=26
    'Too big!' should equal 33423597
    
    Log
    n='101110001111000011011100100001001100' (=49644685388), k=13
    'Too big!' should equal 752500598
    
    Log
    n='100101000010100101110100001000010001000000' (=2545402545216), k=7
    'Too big!' should equal 46506382
    
    Log
    n='1001001110011110110101101111000100110000111001011' (=324620840493515), k=16
    'Too big!' should equal 747391858
    

    Under "large", it's even worse:

    ValueError: Exceeds the limit (4300) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit
    
  • Custom User Avatar

    kthxbye

  • Custom User Avatar

    I may have not completely understood the instructions, but why would solve("czaccb") give "czab" instead of "zacb"?
    I naively thought that you should use a rolling algorithm to remove each duplicate beginning on the left side :

    czaccb -> _za_cb -> zacb
    

    edit : this algorithm works with the second example

    geeegfffgdadd -> _eee_fffgdadd -> eeefffgdadd -> __efffgdadd -> efffgdadd -> e__fgdadd -> efgdadd -> efg_a_d -> efgad
    

    What am I getting wrong?

  • Custom User Avatar

    Is it fine now? The first thing $1 \leq |n| \leq 10^5$ looks to be right.

  • Custom User Avatar
  • Custom User Avatar

    issues:

    • description says 1 ≤ ∣n∣ ≤ 10 which is wrong
    • example in description says n = 11 but "Note that n will be represented as a binary string"
  • Custom User Avatar
    "aa"   --> ""
    "aaa"  --> "a"
    "aaaa" --> ""
    "aabb" --> ""
    etc?
    
  • Custom User Avatar

    I was able to improve my speed considerably. I was creating sets of the same list over and over again.

  • Custom User Avatar

    Oops, done.

  • Custom User Avatar

    Did you forget to update tests? The description states that n <= 10**18 but large binary strings are tested. I prefer binary strings: The kata is much more challenging with them. So I suggest to revert the description back to the original description.

  • Loading more items...