Skip to content

Instantly share code, notes, and snippets.

View tomoasleep's full-sized avatar

Tomoya Chiba tomoasleep

View GitHub Profile
@tomoasleep
tomoasleep / 8queen.scm
Created November 11, 2012 18:20
8queen.scm
;; report 70 :8queen
;; (説明適当)
;;arrowと攻撃範囲の対応
;; arrow -1-> (dx, dy) = (1 , -1) (右上)
;; arrow 0-> (dx, dy) = (1 , 0)(右)
;; arrow +1-> (dx, dy) = (1 , 1)(右下)
;; for x in 0..7
;; for y in 0..7
;; でチェックするようなイメージ。
@tomoasleep
tomoasleep / nqueen.scm
Created November 17, 2012 14:49
Schemeによるn-queen問題の解法。
(define (n-queen n)
(n-queen-iter n 0 "" (list 0 0 0)))
(define (n-queen-iter n y queens atkmaps)
(cond
((= y n)
())
((= (string-length queens) n)
(list queens))
(else
@tomoasleep
tomoasleep / grass.pl
Last active December 19, 2015 13:49
grass interpreter (by prolog)
/* grass.pl */
interpreter(Input) :- grassParse(Input, Code), grassRun(Code).
grassParse(X, Y) :- string_to_list(X, P), parser(P, Y).
parser(Input, Code) :- parserLL(Input, Code, start, []).
grassRun(Code) :-
defaultEnv(Env), defaultStack(Stack), grassVM(Code, Env, Stack).
@tomoasleep
tomoasleep / mapSearch.hs
Last active December 20, 2015 01:59
迷路のstartからgoalまでの最短路を算出するアルゴリズム。(dijkstra法とA*法) だれかハスケルで綺麗なコードを書くやり方を教えて下さい(懇願)
{-# LANGUAGE PackageImports #-}
module KeimaSearch (runMaze
, runMazeMap
, dijkstra
, aStarSearch
, sampleMaze
, sampleMaze2
, sampleDijkstra
, sampleAStar
@tomoasleep
tomoasleep / reversi.coffee
Created July 23, 2013 08:57
ISのリバーシ課題用にnodeでリバーシサーバー立てようかなあと思って、リバーシプログラムまで書いたところ。
class UpdateStack
constructor: (@posPoint, @posColor, @next) ->
@revPoints = []
add: (pos) ->
@revPoints.push pos
class Reversi
@black = 1
@white = -1
@tomoasleep
tomoasleep / PKGBUILD
Last active December 20, 2015 09:09
curry package for arch build system
# Maintainer: Tomoya Chiba <tomo.asleep@gmail.com>
pkgname=curry-darcs
pkgver=0.9.11
pkgrel=1
pkgdesc="the declarative multi-paradigm language"
arch=('i686' 'x86_64')
url="http://danae.uni-muenster.de/~lux/curry"
license=('unknown')
makedepends=('darcs' 'noweb')
VhdlTestScript.scenario "../src/alu.vhd" do
dependencies "../src/const/const_alu_ctl.vhd"
ports :alu_ctl, :a, :b, :result
clock :clk
MAX = 0xffffffff
step "alu_ctl_add", 1, 2, 3
step "alu_ctl_add", 0xfffffffe, 1, 0xffffffff
step "alu_ctl_add", MAX, 1, 0
@tomoasleep
tomoasleep / fmul.vhd
Last active December 29, 2015 09:29
fmulリファクタリングしてみた
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity fmul is
port (A : in std_logic_vector(31 downto 0);
B : in std_logic_vector(31 downto 0);
clk : in std_logic;
R :out std_logic_vector(31 downto 0));
end fmul;
@tomoasleep
tomoasleep / decode_maker.rb
Last active December 31, 2015 07:39
パイプラインの各ステージごとの命令デコーダを作るスクリプトを書いた。.vhd.erbたのしい!
require 'yaml'
require 'erb'
require 'forwardable'
class Hash
def except_keys_in(*keys)
hash_clone = self.clone
keys.each { |k| hash_clone.delete k }
hash_clone
end
@tomoasleep
tomoasleep / PKGBUILD
Created December 21, 2013 14:14
AURのgvim-pythonに補完候補を自動挿入しないパッチを当てるよう追加してみた。
# $Id$
# Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
# Maintainer: tobias [ tobias at archlinux org ]
# Maintainer: Daniel J Griffiths <ghost1227@archlinux.us>
pkgname=gvim-python
pkgdesc='Vi Improved, a highly configurable, improved version of the vi text editor (with advanced features, such as a GUI) (Compiled with Python 3).'
_topver=7.4
_patchlevel=86
_versiondir="vim${_topver//./}"