| Conditions | 8 |
| Total Lines | 19 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import heapq |
||
| 20 | def checkio(price, denominations): |
||
| 21 | conn = defaultdict(dict) |
||
| 22 | open_number = set([price]) |
||
| 23 | closed_number = set([]) |
||
| 24 | while open_number: |
||
| 25 | current = open_number.pop() |
||
| 26 | closed_number.add(current) |
||
| 27 | for i in denominations: |
||
| 28 | if current - i >= 0: |
||
| 29 | conn[current][current - i] = 1 |
||
| 30 | if current - i == 0: |
||
| 31 | conn[0][current] = 1 |
||
| 32 | if current - i not in closed_number: |
||
| 33 | open_number.add(current - i) |
||
| 34 | if conn and 0 in conn: |
||
| 35 | steps, numbers = shortestPath(conn, price, 0) |
||
| 36 | else: |
||
| 37 | return None |
||
| 38 | return steps |
||
| 39 | |||
| 47 |