Created
December 13, 2019 10:32
-
-
Save antimon2/d7ea28a319d66e007fafef5de1f90642 to your computer and use it in GitHub Desktop.
ZundokoChannelv1.2.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:04.748Z", | |
"end_time": "2019-12-13T19:29:08.474000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "versioninfo()", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Julia Version 1.2.0\nCommit c6da87ff4b (2019-08-20 00:03 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:10.713Z", | |
"end_time": "2019-12-13T19:29:11.713000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function zundokochannel()\n Channel(ctype=String, csize=32) do channel::Channel{String}\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:12.862Z", | |
"end_time": "2019-12-13T19:29:13.244000+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:14.705Z", | |
"end_time": "2019-12-13T19:29:15.809000+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:19.417Z", | |
"end_time": "2019-12-13T19:29:19.532000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "function zundokostrictchannel()\n Channel(ctype=String, csize=32) do channel::Channel{String}\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:20.261Z", | |
"end_time": "2019-12-13T19:29:20.346000+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:21.311Z", | |
"end_time": "2019-12-13T19:29:21.374000+09:00" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "collect(zundokostrictchannel())", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 7, | |
"data": { | |
"text/plain": "15-element Array{String,1}:\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": "ZundokoChannelv1.2.ipynb", | |
"public": true | |
} | |
}, | |
"kernelspec": { | |
"name": "julia-1.2", | |
"display_name": "Julia 1.2.0", | |
"language": "julia" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.2.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment