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 java.util.*; | |
import java.util.stream.*; | |
import java.awt.*; | |
import java.awt.Point; | |
import java.awt.event.*; | |
import javax.swing.*; | |
interface Disk { | |
public void paint(Graphics g, Point p, int size); | |
public String toString(); |
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 Zodiac: | |
def __init__(self, name, last_day, best_partner): | |
self.name = name | |
self.last_day = last_day | |
self.best_partner = best_partner | |
def __str__(self): | |
return self.name |
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 os | |
import sys | |
import subprocess | |
import tempfile | |
def autopep8(code): | |
with tempfile.NamedTemporaryFile('w', delete=False) as f: | |
f.write(code) | |
code_file_name = f.name |
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 Formula: | |
def __init__(self, text): | |
self.text = text.replace(" ", "") | |
self.pos = 0 | |
def __bool__(self): | |
return self.pos < len(self.text) | |
def fetch(self): |
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 queue import Queue | |
def solve(): | |
width, height = map(int, input().split()) | |
world = [[*map(int, input().split()), 0] for _ in range(height)] + [[0] * width] | |
iland = 0 | |
q = Queue() | |
for y in range(height): | |
for x in range(width): | |
if world[y][x]: |
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 n_queen(n): | |
count = 0 | |
for board in put_queens(board=[None]*n): | |
for queen in board: | |
print(''.join('.Q'[x == queen] for x in range(n))) | |
print() | |
count += 1 | |
print(count, 'ways') | |
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): |
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 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
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 |