Created
December 13, 2019 10:31
-
-
Save antimon2/7cee2e0e1d7224c87357aa793c9931ae to your computer and use it in GitHub Desktop.
ZundokoChannel.ipynb
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
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:41.759Z", | |
"end_time": "2019-12-13T19:29:46.196000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "versioninfo()", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Julia Version 1.3.0\nCommit 46ce4d7933 (2019-11-26 06:09 UTC)\nPlatform Info:\n OS: Linux (x86_64-pc-linux-gnu)\n CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\n WORD_SIZE: 64\n LIBM: libopenlibm\n LLVM: libLLVM-6.0.1 (ORCJIT, skylake)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "## ズンドコキヨシ" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:47.897Z", | |
"end_time": "2019-12-13T19:29:48.879000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function zundokochannel()\n Channel{String}(32) do channel\n i = 1\n while i > 0\n zd, i = rand([(\"ズン\", i + 1), (\"ドコ\", +(i<5))])\n put!(channel, zd)\n end\n put!(channel, \"キ・ヨ・シ!\")\n end\nend", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 2, | |
"data": { | |
"text/plain": "zundokochannel (generic function with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:50.211Z", | |
"end_time": "2019-12-13T19:29:50.487000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "for cw in zundokochannel()\n print(cw)\nend", | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "ズンズンズンドコズンドコドコズンズンドコズンドコズンズンズンドコドコズンズンズンズンドコキ・ヨ・シ!", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:51.311Z", | |
"end_time": "2019-12-13T19:29:52.413000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "collect(zundokochannel())", | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 4, | |
"data": { | |
"text/plain": "32-element Array{String,1}:\n \"ズン\" \n \"ドコ\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ドコ\" \n \"ドコ\" \n \"ドコ\" \n \"ドコ\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ドコ\" \n ⋮ \n \"ズン\" \n \"ドコ\" \n \"ドコ\" \n \"ドコ\" \n \"ズン\" \n \"ドコ\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ドコ\" \n \"キ・ヨ・シ!\"" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "### ズンドコキヨシ(厳密版)" | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "refer-to: https://qiita.com/antimon2/items/b198076666b40c72cece#20160317-2020-%E8%BF%BD%E8%A8%98%E5%8E%B3%E5%AF%86%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3" | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:54.860Z", | |
"end_time": "2019-12-13T19:29:54.972000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function zundokostrictchannel()\n Channel{String}(32) do channel\n i = 1\n while i > 0\n zd, i = rand([(\"ズン\", i + 1), (\"ドコ\", +(i!=5))])\n put!(channel, zd)\n end\n put!(channel, \"キ・ヨ・シ!\")\n end\nend", | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 5, | |
"data": { | |
"text/plain": "zundokostrictchannel (generic function with 1 method)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:57.596Z", | |
"end_time": "2019-12-13T19:29:57.676000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "for cw in zundokostrictchannel()\n print(cw)\nend", | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "ズンドコドコズンドコドコドコズンドコズンドコドコズンズンドコドコドコズンドコドコズンドコドコドコドコズンドコズンドコズンズンドコズンドコドコドコドコドコズンズンズンドコズンズンズンズンドコキ・ヨ・シ!", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"start_time": "2019-12-13T10:29:58.411Z", | |
"end_time": "2019-12-13T19:29:58.429000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "collect(zundokostrictchannel())", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 7, | |
"data": { | |
"text/plain": "102-element Array{String,1}:\n \"ドコ\" \n \"ドコ\" \n \"ズン\" \n \"ドコ\" \n \"ドコ\" \n \"ズン\" \n \"ドコ\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n ⋮ \n \"ドコ\" \n \"ドコ\" \n \"ドコ\" \n \"ドコ\" \n \"ズン\" \n \"ドコ\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ズン\" \n \"ドコ\" \n \"キ・ヨ・シ!\"" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"_draft": { | |
"nbviewer_url": "https://gist.github.com/6944d60c126939b6704aa594466770be" | |
}, | |
"gist": { | |
"id": "6944d60c126939b6704aa594466770be", | |
"data": { | |
"description": "ZundokoChannel.ipynb", | |
"public": true | |
} | |
}, | |
"kernelspec": { | |
"name": "julia-1.3", | |
"display_name": "Julia 1.3.0", | |
"language": "julia" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.3.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment