-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.py
61 lines (50 loc) · 1.59 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import collections
from collections import defaultdict
import enum
import functools
import itertools
import math
import msvcrt
import operator
import os.path
import re
import sys
#import numpy as np
def get_input(filename=None):
if not filename:
filename = os.path.splitext(os.path.basename(__file__))[0] + '.txt'
with open(filename) as fp:
input = fp.read().rstrip('\n')
#return list(map(int, input.split(',')))
return input.split('\n')
def part1(input):
return None
def part2(input):
return None
if __name__ == '__main__':
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-c', '--clip', '--copy', action='store_true',
help='Copy answer to clipboard')
parser.add_argument('-p', '--part', type=int, choices=(1, 2),
help='Which part to run (default: both)')
parser.add_argument('-1', '--part1', action='store_const', dest='part',
const=1, help='Part 1 only')
parser.add_argument('-2', '--part2', action='store_const', dest='part',
const=2, help='Part 2 only')
parser.add_argument('input', nargs='?', metavar='input.txt')
args = parser.parse_args()
if args.clip:
import pyperclip
input = get_input(args.input)
if not args.part or args.part == 1:
answer1 = part1(input)
print(answer1)
if args.clip and answer1 is not None:
pyperclip.copy(str(answer1))
if not args.part or args.part == 2:
answer2 = part2(input)
print(answer2)
if args.clip and answer2 is not None:
pyperclip.copy(str(answer2))