This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
def parse_wall(N, wall_lines): | |
grid = [] | |
source = dest = None | |
for r, line in enumerate(wall_lines): | |
row = [] | |
i = 0 | |
while i < len(line): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Twisted Corner Finder - Rubik's Cube (2x2x2) | |
def main(): | |
colors = input().strip().split() | |
if len(colors) != 24: | |
print("Invalid input") | |
return | |
# Each tuple = indices of one corner's 3 stickers | |
corners = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detective_lara(): | |
import math | |
target = input().strip() | |
N = int(input().strip()) | |
pieces = input().strip().split() | |
costs = list(map(int, input().strip().split())) | |
T = len(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
LED = { | |
'0': " _ | ||_|", | |
'1': " | |", | |
'2': " _ _||_ ", | |
'3': " _ _| _|", | |
'4': " |_| |", | |
'5': " _ |_ _|", | |
'6': " _ |_ |_|", | |
'7': " _ | |", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
def in_bounds(x, y, n, m): | |
return 0 <= x < n and 0 <= y < m | |
def get_neighbors(x, y, n, m): | |
dirs = [(1,0), (-1,0), (0,1), (0,-1)] | |
for dx, dy in dirs: | |
nx, ny = x + dx, y + dy | |
if in_bounds(nx, ny, n, m): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nidhi_cubes(): | |
n = int(input().strip()) | |
commands = [] | |
for _ in range(n): | |
a, b, direction = input().strip().split() | |
commands.append((int(a), int(b), direction.lower())) | |