LoginSignup
2
2

More than 5 years have passed since last update.

「CodeIQ 2周年!」をWhiteSpaceで出力

Last updated at Posted at 2014-06-24
言語 CodeIQ 2周年おめでとうございます。
Brainf**k http://ideone.com/xwXeFp
https://github.com/cielavenir/codeiq_solutions/blob/master/q835/death2_bf.c
Intercal http://ideone.com/JbAqfF
http://qiita.com/cielavenir/items/0c9720f7df6d796a547a
Lazy K http://melpon.org/wandbox/permlink/kZSCbtHgnGnHxHeE
http://qiita.com/cielavenir/items/f4428c6a2aefbf8af532
Unlambda http://ideone.com/vQ1EQE
https://github.com/cielavenir/codeiq_solutions/blob/master/codeiq2nd_unlambda.rb
WhiteSpace http://ideone.com/VrQVsv
http://qiita.com/cielavenir/items/ebca62f3e689c049ac24
codeiq2nd_whitespace.rb
#!/usr/bin/ruby
#coding:utf-8

def gen_label(n)
    raise 'gen_label' if !n.is_a?(Integer) || n<0
    n.to_s(2).tr('01'," \t")+"\n"
end

def gen_number(n)
    raise 'gen_number' if !n.is_a?(Integer)
    (n<0 ? "\t" : ' ')+gen_label(n.abs)
end

STR="CodeIQ 2周年!\n"
STR.each_byte{|e|
    c = e
    print '  '+gen_number(c)
    print "\t\n  "
}
#ideoneだと正常終了時に末端に変な出力がある。
#なのでCodeIQの問題では(一部例外を除き)正常終了させてはいけないというローカルルールがある。
#print "\n\n\n"

出力:http://ideone.com/VrQVsv

なお、HaskellのputCharの仕様により、ローカル実行の場合はeach_codepointに変更してプログラムを生成しなおさなければなりません(怒)。

2
2
0

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