You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 line
360B

  1. import sys
  2. from itertools import groupby
  3. A, B = [int(n) for n in sys.stdin.read().split('-')]
  4. strings = [str(n) for n in range(A, B + 1)]
  5. print(sum(list(s) == sorted(s) and any(len(list(vs)) >= 2 for k, vs in groupby(s)) for s in strings)) # noqa
  6. print(sum(list(s) == sorted(s) and any(len(list(vs)) == 2 for k, vs in groupby(s)) for s in strings)) # noqa