Skip to content

Instantly share code, notes, and snippets.

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):
# 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 = [
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)
import itertools
LED = {
'0': " _ | ||_|",
'1': " | |",
'2': " _ _||_ ",
'3': " _ _| _|",
'4': " |_| |",
'5': " _ |_ _|",
'6': " _ |_ |_|",
'7': " _ | |",
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):
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()))