ぺーぺーSEのブログ

備忘録・メモ用サイト。

CheckiO

CheckiOっていうプログラマ向けのゲームがあるみたいなのでやってみた。[2014/02/17]

公式
http://www.checkio.org/

紹介ページ
http://plus.appgiga.jp/masatolan/2014/02/13/50594/

Pythonで課題に答えていくみたい。
僕がやったときはPython3.3。
アカウント作成のときにでた問題が下記。
# ちなみにブラウザは「Chrome」でないと動かなかった。バージョン込のバリエーションは試してないけど。

■問題
A simple task before we start the journey!
Edit the funciton checkio so that it returns the sum of the first tree elements in the list els.

#python3.3 is inside
def checkio(els):
    return els

if checkio([1, 2, 3, 4, 5, 6]) == 6:
    print('Done!')

なにも考えずに下記のように書き直してみたらなんかあってたっぽい。
# Python経験1年前に3日くらい、、、

#python3.3 is inside
def checkio(els):
    return els[0]+els[1]+els[2]

if checkio([1, 2, 3, 4, 5, 6]) == 6:
    print('Done!')

Pythonやるネタにもなるし、進めてみよーかなー。