Skip to content

Instantly share code, notes, and snippets.

@typosone
typosone / test_fizzbuzz.py
Last active August 29, 2015 14:25
fizzbuzz の簡単なユニットテストする
import sys
from io import StringIO
import unittest
import fizzbuzz
pattern10 = """1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n"""
pattern100 = """1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz
11\nfizz\n13\n14\nfizz buzz\n16\n17\nfizz\n19\nbuzz
fizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizz buzz
31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz
41\nfizz\n43\n44\nfizz buzz\n46\n47\nfizz\n49\nbuzz
@typosone
typosone / test_student_code.py
Last active August 29, 2015 14:25
学籍番号チェック関数のテストケース
import unittest
import student_code
class StudentCodeTest(unittest.TestCase):
exists_student_codes = [
's15001', 's15002', 's15003', 's15004', 's15005',
's15006', 's15007', 's15008', 's15009', 's15010',
's15011', 's15012', 's15013', 's15014',
'n15001', 'n15002', 'n15003', 'n15004', 'n15005',
@typosone
typosone / breakout.py
Created July 29, 2015 01:51
Breakout
from tkinter import *
import random
import time
class Ball:
def __init__(self, canvas, paddle, speed, color):
self.canvas = canvas
self.paddle = paddle
self.speed = speed
self.id = canvas.create_oval(10, 10, 25, 25, fill=color)
import turtle
def triangle(pen, size):
"""penを使用して一辺の長さsizeの正三角形を描きます"""
for a in range(3):
pen.forward(size)
pen.left(120)
def square(pen, size):
@typosone
typosone / breakout.js
Last active August 14, 2017 01:47
2017 1-2期 の Programming Trainingのやつ
window.addEventListener('DOMContentLoaded', function () {
console.log('breakout.js loaded!');
// 実装
class Paddle {
constructor() {
this.x = 240;
this.y = 600;
}
draw(context) {