LoginSignup
1
0

More than 3 years have passed since last update.

Pythonで「大石泉すき」を何回で揃えられるかゲームをつくる

Last updated at Posted at 2020-04-14

概要

「大石泉すき」Advent Calendar 2019にてExcel VBAでつくったものを、Pythonの勉強がてら焼き増ししただけのものです。

import random

STRING = '大石泉すき'
i = 0
output = ''

n = len(STRING)
max = n - 1

while output != STRING:
    output = ''

    for _ in range(n):
        location = random.randint(0, max)
        output += STRING[location]

    print(output)
    i += 1

print('「{}」が揃うまで{}回かかりました。'.format(STRING, i))

定数STRINGに好きな文字を入れて遊べます。

結果

スクリーンショット 2020-04-15 2.41.06.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0