LoginSignup
3
2

More than 5 years have passed since last update.

3.14 πの日なので、Pythonでの出力を試みる

Posted at

前置き

Facebookの高専時代の研究室OBグループに以下のお題が投稿された.

"Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." という文章の、それぞれの単語の文字数を数えると円周率になっている。

JavaScript, Rubyがすでに登録されてたのでPythonで頑張ってみた。
Twitterに貼れるサイズじゃなかったのでQiitaに書く。

ワンライナー

解説するまでもないのでワンライナー。

$ python -c "import re; print map(len, re.compile('[a-z]+', re.I).findall('Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.'));"

バージョン

python --version
Python 2.7.8
3
2
2

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
3
2