This file contains hidden or 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
| USING: kernel sequences sequences.deep math math.order math.parser | |
| arrays splitting assocs sorting ; | |
| IN: 21lesson | |
| ! 希望リストから配属候補を求める | |
| : wish-list>candidate ( wish-list -- candidate ) | |
| { 1 2 3 4 5 } swap [ | |
| [ second first over = ] filter | |
| [ first ] map swap drop | |
| ] curry map ; |
This file contains hidden or 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(mafovafo). | |
| -compile(export_all). | |
| solve(Data) -> to_s(lists:foldl(fun unfold/2, [] , lists:reverse(Data))). | |
| to_s(L) -> [case C of 0 -> $V; 1 -> $m end || C <- L]. | |
| unfold($L, L) -> rev(L) ++ [0] ++ L; | |
| unfold($J, L) -> L ++ [0] ++ rev(L); | |
| unfold($Z, L) -> L ++ [1] ++ rev(L) ++ [0] ++ L; |
This file contains hidden or 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(foldcut). | |
| -compile(export_all). | |
| solve(Data) -> | |
| integer_to_list(solve2(string:tokens(string:to_upper(Data), "-"))). | |
| solve2([S, [AY, AX]]) -> | |
| trunc(holenum(filter("LR", S), AX) * holenum(filter("TB", S), AY)). | |
| filter([C1, C2], L) -> lists:filter(fun(X) -> (X =:= C1) or (X =:= C2) end, L). |
This file contains hidden or 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(sheh). | |
| -compile(export_all). | |
| solve(Data) -> bases(list_to_integer(Data)). | |
| bases(1) -> "-"; | |
| bases(X) -> to_s(lists:filter(fun(Base) -> | |
| X =:= rev(X, Base, 0) end, lists:seq(2, X - 1))). | |
| to_s([]) -> "-"; |
This file contains hidden or 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(zokugara). | |
| -compile(export_all). | |
| solve(Data) -> relation( | |
| [moms(list_to_integer(X)) || X <- string:tokens(Data, "->")]). | |
| relation([X, Y | _]) -> relation(X, Y). | |
| relation({X, _, _}, {X, _, _}) -> "me"; | |
| relation({_, X, _}, {X, _, _}) -> "mo"; | |
| relation({X, _, _}, {_, X, _}) -> "da"; |
This file contains hidden or 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(xysort). | |
| -compile(export_all). | |
| table() -> [ | |
| [4, 1, 4, 2, 1, 3], [7, 3, 2, 0, 5, 0], [2, 3, 6, 0, 6, 7], | |
| [6, 4, 5, 7, 5, 1], [3, 1, 6, 6, 2, 4], [6, 0, 5, 5, 5, 1]]. | |
| solve(Data) -> [X + $0 || X <- hd(lists:foldl(fun(C, Tbl) -> | |
| sort(C, Tbl) end, table(), Data))]. |
This file contains hidden or 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(boseg). | |
| -compile(export_all). | |
| solve(Data) -> | |
| string:join([integer_to_list(X) || X <- boundlen(oct2bin(Data))], ","). | |
| oct2bin([]) -> []; | |
| oct2bin([X, Y | T]) -> [string:right("00000" ++ | |
| integer_to_list(list_to_integer([X, Y], 8), 2), 6) | oct2bin(T)]. |
This file contains hidden or 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
| javascript:(function(){location.href=location.href.replace(/\?.*$/,'');})(); |
This file contains hidden or 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(lcove). | |
| -compile(export_all). | |
| %% 解く | |
| solve(Data) -> | |
| % 1の位と10の位に分ける関数 | |
| F = fun(SX) -> X = list_to_integer(SX), {X div 10, X rem 10} end, | |
| area([F(SX) || SX <- string:tokens(Data, ",")]). | |
| %% L字型の面積を求める |
This file contains hidden or 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
| # 数→椅子 | |
| s/1\([0-9]\)/55\1/ | |
| s/2\([0-9]\)/5555\1/ | |
| s/3\([0-9]\)/555555\1/ | |
| s/9/54/ | |
| s/8/53/ | |
| s/7/52/ | |
| s/6/51/ | |
| s/5/-----/g | |
| s/4/----/ |