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 sys | |
import random | |
def show_maze(maze): | |
print() | |
for row in maze: | |
print(' ', *row, sep='') | |
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 ipaddress import IPv4Address, IPv4Network, AddressValueError | |
def read_lines(filename): | |
try: | |
with open(filename) as f: | |
return f.read().splitlines() | |
except IOError: | |
print(f"Error: {filename}が開けない") | |
exit() |
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 random | |
class Card: | |
RANKS = "A23456789TJQK" | |
def __init__(self, rank): | |
self.rank = rank if rank != "T" else "10" | |
self.number = Card.RANKS.index(rank) + 1 |
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 pprint import pprint | |
def sign(i): | |
return (+1, -1)[i & 1] | |
def cof(matrix, y, x): | |
return [[value for c, value in enumerate(row) if x != c] | |
for r, row in enumerate(matrix) if y != r] | |
def det(matrix): |
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 tkinter as tk | |
import random | |
HANDS = ROCK, SCISSORS, PAPER = "グー", "チョキ", "パー" | |
WIN, LOSE, DRAW = "勝ち", "負け", "引き分け" | |
class Player: | |
STRONGER_THAN = {ROCK: PAPER, SCISSORS: ROCK, PAPER: SCISSORS} |
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 time | |
class Hanoi: | |
def __init__(self, n): | |
self.n = n | |
self.tower = list(range(1, n+1))[::-1], [], [] | |
def solve(self): | |
yield from self.move(self.n, 0, 1, 2) |
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 tkinter as tk | |
import math | |
class Board: | |
def __init__(self, divide, top=90): | |
self.divide = divide | |
self.top = top | |
self.offset = top - 360 // divide // 2 |
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
class Board: | |
def __init__(self, size, space=None): | |
self.cells = [[space] * size for i in range(size)] | |
self.space = space | |
def __iter__(self): | |
return (tuple(row) for row in self.cells) | |
def __getitem__(self, pos): |
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
N, M = map(int, input().split()) | |
a = {int(input()) for i in range(M)} | |
n, m = 1, 0 | |
for i in range(1, N + 1): | |
n, m = (i not in a) * (n + m) % 1000000007, n | |
print(n) |
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
class Bottle: | |
def __init__(self, capacity, water): | |
self.capacity = capacity | |
self.water = water | |
def __repr__(self): | |
return repr(self.water) | |
def __eq__(self, water): |