Lepsi stahovani informaci o pocasi

This commit is contained in:
Michal Kváček
2024-09-30 06:43:11 +02:00
parent 186dbd0720
commit ca3f6ef07c
14 changed files with 198 additions and 96 deletions
+7
View File
@@ -12,3 +12,10 @@ def chunks(items: list | dict, n: int) -> typing.Generator:
it = iter(items)
for i in range(0, len(items), n):
yield {k: items[k] for k in islice(it, n)}
def evenly_spaced_elements(lst: list, count: int) -> list:
if count > len(lst):
return lst
interval = (len(lst) - 1) / (count - 1) if count > 1 else 0
return [lst[int(round(i * interval))] for i in range(count)]