3. 99 shinichiroes of hamaji
228→222→221byte。
i=99;s=', %s.\n';f=lambda i:'%d shinichiro%s of hamaji on the wall'%(i,'es'[:i*2-2]) while(i):print f(i)+s%f(i)[:-12]+(i-1and'Take one down and pass it around'+s%f(i-1)or'Go to the store and buy some more, %s.'%f(99));i-=1
文字列の共通部分をくくり出して1byte、forとrangeに別れを告げて5byte短縮。
i=99;f=lambda i:'%d shinichiro%s of hamaji on the wall, '%(i,'es'[:i*2-2]) while(i):print(f(i)*2)[:-14]+(i-1and'.\nTake one down and pass it around, %s.\n'or'.\nGo to the store and buy some more, %s.')%f((i+97)%99+1)[:-2];i-=1
この方向性は望み薄だけども一応メモ。226byte。
追記:
i=99;f=lambda i:'%d shinichiro%s of hamaji on the wall, '%(i,'es'[:i*2-2]) while(i):print(f(i)*2)[:-14]+{1:'.\nGo to the store and buy some more, %s.'}.get(i,'.\nTake one down and pass it around, %s.\n')%f((i+97)%99+1)[:-2];i-=1
メモ追加。228byte。
追記その2:
i=99;s=', %s.\n';f=lambda i:'%d shinichiro%s of hamaji on the wall'%(i,'es'[:i*2-2]) while(i):print f(i)+s%f(i)[:-12]+{1:'Go to the store and buy some more'+s%f(99)}.get(i,'Take one down and pass it around'+s%f(i-1));i-=1
and-orの三項演算子もどきも消えた。221byte。