32 lines
589 B
Python
32 lines
589 B
Python
from __builtins__ import *
|
|
|
|
|
|
def pow(integer: int, exp: int):
|
|
result = 1
|
|
for _ in range(exp):
|
|
result *= integer
|
|
return result
|
|
|
|
def sum(list: list):
|
|
result = 0
|
|
for item in list:
|
|
result += item
|
|
return result
|
|
|
|
def avg(list: list):
|
|
result = 0
|
|
for item in list:
|
|
result += item
|
|
return result / len(list)
|
|
|
|
|
|
def opposite(direction: Direction) -> Direction:
|
|
return DIRECTIONS_OPPOSITE[direction]
|
|
|
|
def merge_maps(dest: dict, source: dict) -> dict:
|
|
for key in source:
|
|
dest[key] = source[key]
|
|
return dest
|
|
|
|
|
|
DIRECTIONS_OPPOSITE = {North: South, East: West, South: North, West: East} |