#!/usr/bin/env python # coding: utf-8 # Some common used functions to avoid to rewrite them. # In[ ]: def read_file(file): s = "" try: with open(file) as f: s = f.read() except FileNotFoundError: from urllib.request import urlopen with urlopen("https://xojoc.pw/challenges/aoc/" + file) as response: s = response.read().decode() return s def open_file(file): s = "" try: return open(file) except FileNotFoundError: from urllib.request import urlopen return urlopen("https://xojoc.pw/challenges/aoc/" + file)