optimize
This commit is contained in:
parent
a612669e19
commit
8d59da0c79
2
sixx.py
2
sixx.py
|
@ -5,7 +5,7 @@ from useful import *
|
|||
ts, ds = [numbers(l) for l in lines(open(0))]
|
||||
|
||||
def wins(t, d):
|
||||
return sum(i*(t-i) > d for i in range(t))
|
||||
return t + 1 - 2 * next(dropwhile(lambda i: i*(t-i) <= d, range(t)))
|
||||
|
||||
print(np.prod([wins(t, d) for (t, d) in zip(ts, ds)]))
|
||||
print(wins(*[int(''.join(str(el) for el in ar)) for ar in (ts, ds)]))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from functools import cache, reduce
|
||||
from itertools import chain, permutations, product, combinations, pairwise, groupby, takewhile
|
||||
from itertools import chain, dropwhile, permutations, product, combinations, pairwise, groupby, takewhile
|
||||
from more_itertools import batched, collapse, sliding_window
|
||||
from collections import defaultdict, deque
|
||||
import re, sys
|
||||
|
|
Loading…
Reference in New Issue