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
% solve 8-queens problem. | |
-module(eq2). | |
-export([solve/0, solve_count/0, solve_display/0]). | |
% Solve and return answer as a list of lists. | |
solve() -> solve(1, [], []). | |
% Solve and return count of answers. | |
solve_count() -> length(solve()). |
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
-module(bus). | |
-compile(export_all). | |
solve(Data) -> adult_fee(Data) + child_fee(Data) + infant_fee(Data). | |
adult_fee(Data) -> lists:sum(fees($A, Data)). | |
child_fee(Data) -> lists:sum(fees($C, Data)). | |
infant_fee(Data) -> lists:sum(dropn(num_adult(Data) * 2, rev_sort(fees($I, Data)))). |
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
-module(dice). | |
-export([tests/0, test/2, solve/1]). | |
solve(Data) -> | |
{_Dice, L} = lists:foldl(fun rotate_add/2, {{1,2,3}, [1]}, Data), | |
[Digit + $0 || Digit <- lists:reverse(L)]. | |
rotate_add(Dir, {Dice, L}) -> | |
NewDice = rotate(Dir, Dice), | |
{NewDice, [element(1, NewDice) | L]}. |
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
;; 与えられた整数リストから4つを使った全組み合わせを返す | |
(define (combi4 unselected selected) | |
(define (delete-one x ls) ;; xを1つだけ削除したリストを返す | |
(cond | |
((null? ls) '()) | |
((= x (car ls)) (cdr ls)) | |
(else (cons (car ls) (delete-one x (cdr ls)))))) | |
(define (if6append9 x f) ;; xが6以外ならf(x)を、6ならf(6)とf(9)を連結して返す | |
(if (= x 6) | |
(append (f 6) (f 9)) |
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
-module(bitbomb). | |
-compile(export_all). | |
%% 問題を解く | |
solve(Data) -> | |
{Wall, Bomb} = list_to_tuple([list_to_integer(X, 16) | |
|| X <- string:tokens(Data, "/")]), | |
DirInfo = [ % シフト方向とシフト時マスクのデーター | |
{-6, 2#00000011111111111111111111111100}, % 上 | |
{-1, 2#01111101111101111101111101111100}, % 左 |
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
@echo off | |
rem 名前 | |
rem 自動バックアップ.cmd - BunBackupを使って自動バックアップをする | |
rem 書式 | |
rem 自動バックアップ.cmd | |
rem 説明 | |
rem BunBackupを使って自動バックアップを実行する。 |
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
-module(updown). | |
-compile(export_all). | |
solve(Data) -> | |
integer_to_list(op_count(list_to_integer(Data), 0)). | |
%% 結果が1か3になるまで2で割るか1を増減し、その回数を返す | |
op_count(1, Count) -> Count + 1; | |
op_count(3, Count) -> Count + 3; | |
op_count(Num, Count) -> |
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
UPDOWN START TEST ;TESTからスタートする | |
;解くルーチン | |
;GR1=値, GR2=カウンタ, GR0=戻り値 | |
SOLVE OR GR1,DC0 ;値が0ならカウンタ値を返す | |
JNZ NOT0 | |
LAD GR0,0,GR2 | |
RET | |
NOT0 CPL GR1,DC3 ;値が3ならカウンタ値に3を加えて返す | |
JNZ NOT3 |
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
-module(blocktub). | |
-compile(export_all). | |
%% 問題を解く | |
solve(Data) -> | |
integer_to_list(pit_count([Digit - $0 || Digit <- Data])). | |
%% 窪みの数を計算する | |
pit_count(Data) -> | |
Max = lists:max(Data), % 壁の最大高さ |
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
-module(crosscircle). | |
-compile(export_all). | |
%% 解く | |
solve(Data) -> | |
integer_to_list(solve([{X, 0} || X <- Data], 0)). | |
solve([], Total) -> | |
Total; | |
solve([{FirstChar, _} | Rest], Total) -> |