mirror of
https://github.com/thib8956/advent-of-code.git
synced 2026-11-27 00:46:34 +00:00
fix lint
This commit is contained in:
1 parent
0232b9326d
commit
5c3fb89870
50 files changed
+97
-117
No files matched your search
@@ -1,8 +1,7 @@
|
||||
#! /usr/bin/env python3
|
||||
from collections import defaultdict
|
||||
from enum import Enum
|
||||
import logging
|
||||
import os
|
||||
from enum import Enum
|
||||
|
||||
loglevel = (os.getenv("LOGLEVEL") or "WARN").upper()
|
||||
logging.basicConfig(format="%(levelname)s:%(message)s", level=loglevel)
|
||||
@@ -38,7 +37,7 @@ class Instruction:
|
||||
self.memory = memory
|
||||
self.opcode = memory[ip]
|
||||
# A B C D E
|
||||
# 0 1 1 0 3
|
||||
# 0 1 1 0 3
|
||||
# A B C modes, DE opcode
|
||||
self.operation = Operation(self.opcode % 100)
|
||||
self.modes = [Mode(get_nth_digit(n, self.opcode)) for n in range(2, 5)]
|
||||
@@ -140,13 +139,13 @@ class Instruction:
|
||||
match self.modes[offset - 1]:
|
||||
case Mode.POSITION: return value
|
||||
case Mode.RELATIVE: return value + self.base
|
||||
case _: raise ValueError(f"{self.modes[i]}")
|
||||
case _: raise ValueError(f"{self.modes[offset - 1]}")
|
||||
|
||||
def _get_parameters(self):
|
||||
first = self._get_value(1)
|
||||
second = self._get_value(2)
|
||||
return first, second
|
||||
|
||||
|
||||
def _write(self, address, value):
|
||||
while address >= len(self.memory):
|
||||
self.memory += [0] * len(self.memory)
|
||||
@@ -191,4 +190,3 @@ def interpret_intcode(program, stdin=[]):
|
||||
interpreter = Interpreter(program, stdin)
|
||||
interpreter.interpret(break_on_output=False)
|
||||
return interpreter
|
||||
|
||||
Reference in new issue
Block a user