Skip to content

Instantly share code, notes, and snippets.

View shiracamus's full-sized avatar

@shiracamus shiracamus

View GitHub Profile
> インタフェースとは後から使うものを先に簡単に作っておいて、それを後でimplementで呼び出して使うものだと自分は認識しました。
API はご存知ですか? Application Programming Interface.
プログラムの仕様。プログラム同士を接続するための仕様。
使う人も作る人もインタフェースに合わせて作る。
クラスが違ってもインタフェースが同じなら接続して使える。
プログラムを作る前にまずインタフェースを定義しましょう。
ハードウェアも同じインタフェース同士なら接続できます。
USB、LAN、RS232C、HDMI、etc.
@shiracamus
shiracamus / fizzbuzz.py
Last active April 13, 2018 00:31
fizzbuzz veriation
print(*map(lambda x:"Fizz"*(x%3<1)+"Buzz"*(x%5<1)or x,range(1,101)))
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def flatten(data, depth=-1):
"""
flatten(data) -> list
flatten(data, depth) -> list
Return flatted data of list or tupple as list.
#!/usr/bin/env python3.6
#-*- coding:utf-8 -*-
import sys
import random
from itertools import product
"""
開発するブラックジャックのルール
・初期カードは52枚。
import random
SIZE = 4
DIGITS = 4
class Game:
def __init__(self, board=None, verbose=True):
self.board = [row[:] for row in board or [[0] * SIZE] * SIZE]
import random
from itertools import count
class Card:
SUITS = "♣♦♥♠"
RANKS = "A23456789TJQK"
def __init__(self, suit, rank=""):
self.suit = suit
class Pipe:
def __init__(self, func, *args, **kwargs):
self.func, self.args, self.kwargs = func, args, kwargs
def __call__(self, *args, **kwargs):
return Pipe(self.func, *self.args, *args, **self.kwargs, **kwargs)
def __or__(self, pipe):
if not isinstance(pipe, Pipe):
//
// 昔懐かし、CBM-3032のようなキャラクタゲームを
// ncurseswで実現。
// Raging robots.
//
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
import tkinter as tk
class Shape:
def __init__(self, x, y, width, height, center=False):
if center:
x -= width // 2
y -= height // 2
self.x1 = x
import tkinter as tk
class Shape:
def __init__(self, x, y, width, height, center=False):
if center:
x -= width // 2
y -= height // 2
self.x1 = x