This file contains 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
/** | |
* @file tact_switch.cpp | |
* @brief タクトスイッチ | |
*/ | |
#include "tact_switch.h" | |
#include <wiringPi.h> |
This file contains 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
CXX=clang++ | |
CXXFLAGS=-Wall | |
LDLIBS=-lopencv_core -lopencv_highgui -lopencv_imgproc | |
capture: capture.cpp | |
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS) |
This file contains 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
source = File.read('README.md') | |
m = source.match(/^Configuration options\n---------------------/) | |
raise 'Missing "Configuration options" headng' unless m | |
body = m.post_match.strip | |
# Adjust heading level | |
body.gsub!(/^##/, '') |
This file contains 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
require 'forwardable' | |
# ジョブを表すクラス | |
class Job | |
# ジョブの名前 | |
# @return [String] | |
attr_reader :name | |
# ジョブの所要時間 | |
# @return [Array<Numeric>] | |
attr_reader :length |
This file contains 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
; ジョブを作成する | |
(define (make-job name len1 len2) | |
(list name (cons len1 len2))) | |
; ジョブの名前を返す | |
(define (job-name job) | |
(car job)) | |
; ジョブの所要時間をペアの形で返す | |
(define (job-length job) |
This file contains 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 ruby | |
require 'optparse' | |
require 'json' | |
PlayRoom = Struct.new(:num, :name, :updated) | |
def pad(s, width) | |
char_lengths = s.each_char.map { |c| c.ord >= 8192 ? 2 : 1 } | |
length = char_lengths.reduce(0, &:+) |
This file contains 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
require_relative 'command_table' | |
# クライアントからのコマンドを定義するクラス | |
class ClientCommand | |
include CommandTable | |
# 部屋の状態を取得するコマンド | |
define_command('getPlayRoomStates') do | |
{ | |
minRoom: 0, |
This file contains 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
# 7 けたの整数 2004XXX は 2, 3, 4, 5, 6, 7, 8 すべての倍数です。 | |
# XXX に入る 3 けたの整数を求めなさい。 | |
# 2 で割り切れるので 2004XXX は偶数 | |
# 約数について | |
# * 8 で割り切れる => 4, 2 でも割り切れる | |
# * 6 で割り切れる => 3 でも割り切れる | |
# ので、[5, 6, 7, 8] で割り切れるものを選べばよい | |
nums = (0..999).select { |n| n % 2 == 0 } |
This file contains 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
# 問題 6. A は 0 でない整数とし、<A> は A の約数の和を表すものとします。 | |
# たとえば、<8> = 1 + 2 + 4 + 8 = 15 です。 | |
# 約数のリストを求める | |
def divisors(n) | |
# 1、n は必ず含まれる | |
# n/2 < d < n である d で n を割ると必ず 1 より大きく 2 未満になる | |
# ので、d は約数ではない | |
[1] + (2..(n / 2)).select { |d| n % d == 0 } + [n] | |
end |
This file contains 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
#include <stdio.h> | |
#include <string.h> | |
#include <assert.h> | |
// チェックディジットを返す | |
// [data] チェックディジットなしのデータ | |
// [length] データの長さ | |
int check_digit(char* data, int length) { | |
int sum_odd = 0; // 奇数の和 | |
int sum_even = 0; // 偶数の和 |