Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Price-fraction/Python/price-fraction-1.py
Normal file
5
Task/Price-fraction/Python/price-fraction-1.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
>>> import bisect
|
||||
>>> _cin = [.06, .11, .16, .21, .26, .31, .36, .41, .46, .51, .56, .61, .66, .71, .76, .81, .86, .91, .96, 1.01]
|
||||
>>> _cout = [.10, .18, .26, .32, .38, .44, .50, .54, .58, .62, .66, .70, .74, .78, .82, .86, .90, .94, .98, 1.00]
|
||||
>>> def pricerounder(pricein):
|
||||
return _cout[ bisect.bisect_right(_cin, pricein) ]
|
||||
5
Task/Price-fraction/Python/price-fraction-2.py
Normal file
5
Task/Price-fraction/Python/price-fraction-2.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
>>> import bisect
|
||||
>>> _cin = [ 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101]
|
||||
>>> _cout = [10, 18, 26, 32, 38, 44, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100]
|
||||
>>> def centsrounder(centsin):
|
||||
return _cout[ bisect.bisect_right(_cin, centsin) ]
|
||||
20
Task/Price-fraction/Python/price-fraction-3.py
Normal file
20
Task/Price-fraction/Python/price-fraction-3.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
def bisect_right(a, x, lo=0, hi=None):
|
||||
"""Return the index where to insert item x in list a, assuming a is sorted.
|
||||
|
||||
The return value i is such that all e in a[:i] have e <= x, and all e in
|
||||
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
|
||||
insert just after the rightmost x already there.
|
||||
|
||||
Optional args lo (default 0) and hi (default len(a)) bound the
|
||||
slice of a to be searched.
|
||||
"""
|
||||
|
||||
if lo < 0:
|
||||
raise ValueError('lo must be non-negative')
|
||||
if hi is None:
|
||||
hi = len(a)
|
||||
while lo < hi:
|
||||
mid = (lo+hi)//2
|
||||
if x < a[mid]: hi = mid
|
||||
else: lo = mid+1
|
||||
return lo
|
||||
Loading…
Add table
Add a link
Reference in a new issue