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
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
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
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 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 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
#!/usr/bin/python3 | |
import curses | |
import locale | |
from random import randint | |
INSTRUCTION = """\ | |
Maneaters Ver 1.3 | |
Mission : マンイーターを消して生き残れ! | |
O -- Maneater, 段階的に追い詰める敵 |
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
#!/usr/bin/env python3 | |
from enum import IntEnum | |
import random | |
import itertools | |
import sys | |
# 隣のセルへの座標の差分 (x, y), [North, East, South, West] |
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.Scanner; | |
enum Cell { | |
EMPTY("[ ]"), | |
PLAYER1("[O]"), | |
PLAYER2("[X]"); | |
private final String text; | |
private Cell(final String text) { |
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 math | |
import sys | |
import pygame | |
from pygame.locals import * | |
from random import randint | |
import time | |
pygame.init() | |
WIDTH, HEIGHT = 800, 600 | |
screen = pygame.display.set_mode((WIDTH, HEIGHT)) |