Skip to content

Instantly share code, notes, and snippets.

@antimon2
Created December 13, 2019 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antimon2/37c1db4e1f332e0527ac359abe344044 to your computer and use it in GitHub Desktop.
Save antimon2/37c1db4e1f332e0527ac359abe344044 to your computer and use it in GitHub Desktop.
ZundokoGenerator.py.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:18:19.535778Z",
"end_time": "2019-12-13T10:18:19.539445Z"
}
},
"cell_type": "code",
"source": "import random",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:18:21.216542Z",
"end_time": "2019-12-13T10:18:21.220975Z"
}
},
"cell_type": "code",
"source": "def zundokogenerator():\n i = 1\n while i > 0:\n zd, i = random.choice([(\"ズン\", i + 1), (\"ドコ\", +(i<5))])\n yield zd\n yield \"キ・ヨ・シ!\"",
"execution_count": 2,
"outputs": []
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:18:22.911458Z",
"end_time": "2019-12-13T10:18:22.917211Z"
}
},
"cell_type": "code",
"source": "for zdk in zundokogenerator():\n print(zdk)",
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": "ドコ\nズン\nズン\nドコ\nズン\nドコ\nドコ\nズン\nズン\nズン\nズン\nズン\nズン\nズン\nドコ\nキ・ヨ・シ!\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:18:24.547171Z",
"end_time": "2019-12-13T10:18:24.560668Z"
}
},
"cell_type": "code",
"source": "list(zundokogenerator())",
"execution_count": 4,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 4,
"data": {
"text/plain": "['ズン', 'ドコ', 'ズン', 'ズン', 'ズン', 'ズン', 'ドコ', 'キ・ヨ・シ!']"
},
"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": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:19:13.149929Z",
"end_time": "2019-12-13T10:19:13.155819Z"
}
},
"cell_type": "code",
"source": "def zundokogenerator_strict():\n i = 1\n while i > 0:\n zd, i = random.choice([(\"ズン\", i + 1), (\"ドコ\", +(i!=5))])\n yield zd\n yield \"キ・ヨ・シ!\"",
"execution_count": 5,
"outputs": []
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:19:17.039852Z",
"end_time": "2019-12-13T10:19:17.050223Z"
}
},
"cell_type": "code",
"source": "for zdk in zundokogenerator_strict():\n print(zdk)",
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": "ドコ\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ズン\nドコ\nキ・ヨ・シ!\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true,
"ExecuteTime": {
"start_time": "2019-12-13T10:19:22.391831Z",
"end_time": "2019-12-13T10:19:22.404159Z"
}
},
"cell_type": "code",
"source": "list(zundokogenerator_strict())",
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 7,
"data": {
"text/plain": "['ズン',\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": false
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.6.9",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "ZundokoGenerator.py.ipynb",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment