Compare commits
2 Commits
ae55249b47
...
799f2283c7
| Author | SHA1 | Date | |
|---|---|---|---|
| 799f2283c7 | |||
| b58f0998db |
17
epigdanceoff.py
Normal file
17
epigdanceoff.py
Normal file
@@ -0,0 +1,17 @@
|
||||
n, m = map(int, input().split())
|
||||
|
||||
lines = []
|
||||
for _ in range(n):
|
||||
lines.append(input())
|
||||
|
||||
t = 1
|
||||
for col in range(m):
|
||||
new_frame = True
|
||||
for row in lines:
|
||||
if row[col] != "_":
|
||||
new_frame = False
|
||||
break
|
||||
if new_frame:
|
||||
t += 1
|
||||
|
||||
print(t)
|
||||
56
glitchbot.py
Normal file
56
glitchbot.py
Normal file
@@ -0,0 +1,56 @@
|
||||
NORTH = 0
|
||||
EAST = 1
|
||||
SOUTH = 2
|
||||
WEST = 3
|
||||
|
||||
LEFT = 0
|
||||
RIGHT = 1
|
||||
FORWARD = 2
|
||||
|
||||
|
||||
def run_program(program: list) -> tuple:
|
||||
x, y = 0, 0
|
||||
facing = NORTH
|
||||
|
||||
for instruction in program:
|
||||
if instruction == LEFT:
|
||||
facing = (facing - 1) % 4
|
||||
|
||||
elif instruction == RIGHT:
|
||||
facing = (facing + 1) % 4
|
||||
|
||||
elif instruction == FORWARD:
|
||||
if facing == NORTH:
|
||||
y += 1
|
||||
elif facing == SOUTH:
|
||||
y -= 1
|
||||
elif facing == EAST:
|
||||
x += 1
|
||||
elif facing == WEST:
|
||||
x -= 1
|
||||
|
||||
return x, y
|
||||
|
||||
|
||||
x, y = map(int, input().split())
|
||||
instruction_count = int(input())
|
||||
|
||||
program = []
|
||||
for _ in range(instruction_count):
|
||||
instruction = input()
|
||||
if instruction == "Left":
|
||||
program.append(LEFT)
|
||||
elif instruction == "Right":
|
||||
program.append(RIGHT)
|
||||
elif instruction == "Forward":
|
||||
program.append(FORWARD)
|
||||
|
||||
for i in range(len(program)):
|
||||
for _ in range(3):
|
||||
program[i] = (program[i] + 1) % 3
|
||||
result = run_program(program)
|
||||
if result == (x, y):
|
||||
print(
|
||||
f"{i+1} {'Left' if program[i] == LEFT else 'Right' if program[i] == RIGHT else 'Forward'}"
|
||||
)
|
||||
exit()
|
||||
Reference in New Issue
Block a user