« 日記 |Main| 日記 »

« Just Another Python Hacker, その3 | Python | Just Another Ruby/Python Hacker, »

キミならどう書く 2.0 - ROUND 3 -

>>> def graph(xs):
	print "\n".join([str(x).rjust(max([len(str(y)) for y in xs]))
			 + ": " + "*" * (20 * x / max(xs)) for x in xs])

	
>>> graph([2, 5, 9, 11])
 2: ***
 5: *********
 9: ****************
11: ********************

寝る前に発見したのでとりあえずあっさり目の回答をして寝ることにします。グラフ簡約が欲しい。

「グラフを出力する」の「グラフ」を「グラフ理論」の「グラフ」だと無理矢理に解釈してうねうねするのも一興か。

トラックバック(Trackback)

Trackback URL: http://www.nishiohirokazu.org/mt/mt-tb.cgi/246

ご意見・ご感想をお送りください(フィードバック)

(フィードバックはメールで送信され、基本的に表示されませんが、内容によっては公開させていただくこともございます。ご了承ください。Your comment doesn't appear the page immediately. If the comment has value to other people, it will be put on the page or subsequent entries. Thank you.)

上の情報は、いずれも未記入でかまいません。 All of above questions are optional.