How is the progress? Let's get on with the boom ?? in Python

Introduction

How is the progress?

Clojure that randomly displays "Progress, how, how," and when "How is progress" is completed A program that randomly displays "Progress, how, how," and incites when "How is progress" is completed I wrote "Progress, how, how" in Haskell How is the progress? Let's try ruby on the boom?

so

I wrote it in Python. It's just a matter of writing, so I tried using a lambda expression that I rarely use (list comprehension is too convenient).

code

shinchoku.py


 #coding: utf-8

import random


li =  ["progress","How","is","Or"]
LI_RAND_LENGTH =  len(li)-1
CHECK_NUM      = -len(li)
ret = []
itr = 0

shinchokuStr    = lambda       : li[random.randint(0,LI_RAND_LENGTH)]
appendShinchoku = lambda l     : l+[shinchokuStr()]
last4Strs       = lambda l     : "".join(l[CHECK_NUM:])
loopCheck       = lambda x, y : last4Strs(x) == last4Strs(y)

while(not loopCheck(li,ret)) :
	ret = appendShinchoku(ret)
	itr += 1
	print ret[-1],	
print "\n"+str(len("".join(ret))/3)+"Fanned by letters"

Execution result

$ python shinchoku.py
How is it? How is it? How is it? How is it progress? How is progress. Progress is progress. How is progress? Progress is progress. Progress is progress. Progress is progress. Progress is progress. Progress is progress. Progress is progress. It ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress, it ’s progress. Is it progress? How is progress? How is progress? How is progress? Progress is progress. Is it progress? Is it progress? How is it? How is it? Progress progress progress How is progress Progress is progress How is progress How is progress How is progress? It's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress, it's progress. How is it? Progress progress or progress is progress How is progress How is progress How is progress How is progress Progress is progress Progress is progress How is progress Progress is progress How is progress or is progress How is progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is the progress? How is it progress? How is progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it progress? Is it? How is it? Progress progress Progress progress Is it progress? Is it progress? How is it? How is it?
Fanned by 656 characters

Impressions

lambda expression is fun. By the way, I said that I should study Haskell, so I want to study. Also, it seems that the length of the Python character string varies depending on the character code (?). For the time being, it worked, so I put in a magic number.

Recommended Posts

How is the progress? Let's get on with the boom ?? in Python
[Python] Get the files in a folder with Python
How to get the files in the [Python] folder
How to get the date and time difference in seconds with python
How to get the variable name itself in python
How to get the number of digits in Python
[Python] Get the numbers in the graph image with OCR
In Python, change the behavior of the method depending on how it is called
Get the result in dict format with Python psycopg2
Get information on the 100 most influential tech Twitter users in the world with python.
How to get a list of files in the same directory with python
Differences in sys.path depending on how Python is started (v3.8.2)
Test.py is not reflected on the web server in Python3.
Let's get started with Python ~ Building an environment on Windows 10 ~
How to get the last (last) value in a list in Python
Automatically get the port where Arduino is stuck in Python
How to get into the python development environment with Vagrant
[Introduction to Python] How to get data with the listdir function
Get the desktop path in Python
Get the weather with Python requests
Get the weather with Python requests 2
Get the script path in Python
How to get the Python version
How to get started with Python
Get the desktop path in Python
Get the host name in Python
Get started with Python in Blender
Get started with the Python framework Django on Mac OS X
How to judge that the cross key is input in Python3
How to use python put in pyenv on macOS with PyCall
How to use the asterisk (*) in Python. Maybe this is all? ..
Get the number of readers of a treatise on Mendeley in Python
Get additional data in LDAP with python
[Python] Get the variable name with str
Display Python 3 in the browser with MAMP
How to work with BigQuery in Python
Let's read the RINEX file with Python ①
How to get a stacktrace in python
What is "mahjong" in the Python library? ??
Download files on the web with Python
Get Started with TopCoder in Python (2020 Edition)
Get the EDINET code list in Python
How Python beginners get started with Python with Progete
[Python] A progress bar on the terminal
How to use is and == in Python
Let's get along with Python # 0 (Environment construction)
[Blender x Python] Let's get started with Blender Python !!
Get the width of the div on the server side with Selenium + PhantomJS + Python
Get and convert the current time in the system local timezone with python
How to use the C library in Python
Python hand play (let's get started with AtCoder?)
Get the weather in Osaka via WebAPI (python)
Load the network modeled with Rhinoceros in Python ③
[REAPER] How to play with Reascript in Python
Strategy on how to monetize with Python Java
Let's parse the git commit log in Python!
Get the caller of a function in Python
What is wheezy in the Docker Python image?
[Automation] Extract the table in PDF with Python
About the difference between "==" and "is" in python
Get the X Window System window title in Python