Skip to content

Instantly share code, notes, and snippets.

View dproject21's full-sized avatar

Daiki Tanoguchi dproject21

  • Yokohama, Japan
View GitHub Profile
@dproject21
dproject21 / vending_machine.go
Created September 29, 2018 08:03
20180929 tddbc tokyo golang implementation
package vending
type VendingMachine struct {
haveMoney int
priceList map[string]int
}
func NewVendingMachine() *VendingMachine {
vendingMachine := new(VendingMachine)
m := make(map[string]int)
@dproject21
dproject21 / vending_machine_test.go
Created September 29, 2018 08:01
20180929 tddbc tokyo golang implementation
package vending
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test500円を入れる(t *testing.T) {
vendingMachine := NewVendingMachine()
import requests
import json
class Resas:
__ENDPOINT = "https://opendata.resas-portal.go.jp/"
__API_VER = "api/v1-rc.1/"
__address = ""
def __init__(self, api_key):
/*
* 回答の条件によって別フィールドの表示/非表示を切り替えるサンプルプログラム
* Copyright (c) 2014 Cybozu
*
* Licensed under the MIT License
*/
(function() {
"use strict";
//レコードの追加、編集、詳細画面で適用する
@dproject21
dproject21 / incenses.py
Last active December 11, 2015 17:57
こちらの記事(http://yoshiori.hatenablog.com/entry/2015/12/03/191621 )を読んで、Raspberry piを使って http://haka.yamashi.ro/ に線香上げる仕組みを作ってみた。(コードもうちょっと綺麗にする。)
import RPi.GPIO as GPIO
import time
import requests
import json
BUTTON = 7
LED_B = 11
LED_G = 13
LED_Y = 15
LED_R = 12
@dproject21
dproject21 / file0.cs
Created February 1, 2014 11:07
第18回オフラインリアルタイムどう書くの解答@ C# ref: http://qiita.com/dproject21/items/2ac35231595a47e9eae7
public class Register
{
public int CustomerCount;
public List<string> CustomerGroups;
public bool IsStop;
public int Minus;
public Register(int minus)
{
CustomerCount = 0;
@dproject21
dproject21 / CalcUnchin.cs
Created April 6, 2013 10:30
第9回オフラインリアルタイムどう書くの解答 問題はこれ http://nabetani.sakura.ne.jp/hena/ord9busfare/
using System;
using System.Text.RegularExpressions;
namespace yhpg9
{
public class MyClass
{
public MyClass ()
{
}
@dproject21
dproject21 / problem9.groovy
Created January 20, 2013 08:35
プロジェクトオイラー problem9の解答
a = 1
while(! (500000 % (1000 - a) == 0)) {
a += 1
}
b = 1000 * (a - 500) / (a - 1000)
c = Math.sqrt(a ** 2 + b ** 2).toInteger()
ans = a * b * c
println(ans)
@dproject21
dproject21 / problem8.groovy
Created January 20, 2013 08:14
プロジェクトオイラー problem8の解答
line = "73167176531330624919225119674426574742355349194934" +
"96983520312774506326239578318016984801869478851843" +
"85861560789112949495459501737958331952853208805511" +
"12540698747158523863050715693290963295227443043557" +
"66896648950445244523161731856403098711121722383113" +
"62229893423380308135336276614282806444486645238749" +
"30358907296290491560440772390713810515859307960866" +
"70172427121883998797908792274921901699720888093776" +
"65727333001053367881220235421809751254540594752243" +
"52584907711670556013604839586446706324415722155397" +
@dproject21
dproject21 / problem7.groovy
Created January 20, 2013 07:20
プロジェクトオイラー problem7の解答
primeList = [2]
intList = []
for (int i : 3 .. 200000) {
if (i % 2 != 0) {
intList.push(i)
}
}
while(intList.size() != 0) {
primeList.push(intList.first())
intList.removeAll{it % primeList.last() == 0}