gumi Inc. が Erlang & Elixir Fest 2018 の会場で配布しているクイズを掲載しています。
あなたはプログラマーとして、とあるゲーム開発プロジェクトに配属された。 プロジェクトに配属され、はじめに与えられた業務は、次のような ASCII アートで記述された迷路を入力として受け取り、点数を出力するコマンドを作成することだった。 この業務には前任者がいたようだが、現在は連絡がとれない。幸いなことにコードは残されているようだ。
maze.txt:
| # Description: | |
| # Auth allows you to assign roles to users which can be used by other scripts | |
| # to restrict access to Hubot commands | |
| # | |
| # Dependencies: | |
| # None | |
| # | |
| # Configuration: | |
| # HUBOT_AUTH_ADMIN - A comma separate list of user IDs | |
| # HUBOT_AUTH_ROOM - A comma separate list of room IDs |
| >>> from redis import Redis | |
| >>> from ranking import Ranking | |
| >>> | |
| >>> ranking = Ranking(Redis(), 'event1') | |
| >>> | |
| >>> ranking.push('p1', 200) | |
| >>> ranking.push('p2', 100) | |
| >>> ranking.push('p3', 300) | |
| >>> ranking.push('p1', 1000) | |
| >>> ranking.push('p4', 1000) |
| class MutexError(Exception): | |
| pass | |
| class DuplicateLockError(MutexError): | |
| """ | |
| 既に lock() 実行済みの Mutex オブジェクトで lock() を再実行すると発生. | |
| 一度, unlock() を実行するか, 別の Mutex オブジェクトを作成する必要がある. | |
| """ |
| import random | |
| class InverseDoesNotExist(Exception): | |
| pass | |
| def generate_salt(): | |
| """ |
| -module(inproc_vs_message). | |
| -author('[email protected]'). | |
| -export([run/2]). | |
| run(TryCount, SRCount) -> | |
| MPid = spawn_link(fun message_server/0), | |
| RPid = self(), | |
| C = start_zmq(), |
| -module(dirty_read_and_transactional_write). | |
| -author('[email protected]'). | |
| -export([run/3]). | |
| -record(store, {key, value}). | |
| run(TryCount, ProcessCount, ReadWriteCount) -> | |
| WriterPids = spawn_runner(ProcessCount), | |
| ReaderPids = spawn_runner(ProcessCount), |
| -module(sticky_write_vs_write). | |
| -author('[email protected]'). | |
| -export([init_primary/0, init_secondary/0, run/3]). | |
| -record(store, {key, value}). | |
| init_primary() -> | |
| {ok, _} = net_kernel:start(['primary@localhost', shortnames]), | |
| true = erlang:set_cookie(node(), 'secret_cookie'), |
| -module(process_vs_ets_vs_mnesia). | |
| -author('[email protected]'). | |
| -export([run/3]). | |
| -record(store, {key, value}). | |
| run(TryCount, ProcessCount, ReadCount) -> | |
| Pids = lists:map( | |
| fun (_) -> spawn_link(fun reader_process/0) end, |