2007-10-29から1日間の記事一覧
p rand(6)+1
str =####ここから %Q{this green apple is an apple but is not an green apple }###ここまで matchword = "apple" notmatchword = "green apple" str.each do |line| word = line while /apple/ =~ word do if word.index(/#{notmatchword}/) + notmatchwo…
str =####ここから %Q{one, two, three, four }###ここまで str.each do |line| ary = line.split(",") ary.each do |word| print word.strip print "\n" end end
str =####ここから %Q{HELLO_WORLD THIS_IS_TEST_PATTERN TEST_METHOD }###ここまで str.each do |line| word = line while /[A-Z]*_/ =~ word do print $&.capitalize.chop word = $' end print word.capitalize.chomp print "\n" end
str =####ここから %Q{HelloWorld ThisIsTestPattern TestMethod }###ここまで str.each do |line| word = line /[A-Z][a-z]*/ =~ word while /[A-Z][a-z]*/ =~ word do print $&.upcase! if $'.chomp.length > 0 then print '_' end word = $' end print "\…
str =####ここから %Q{HashMap map = new HashMap(); map.put("0", "zero"); map.put("1", "one"); map.put("2", "two"); map.put("3", "three"); map.put("10", "ten"); }###ここまで str.each do |line| if /"[0-9]*"/ =~ line then print $` num = $&[1..…
str = ####ここから "getParentWindow getParentFrame init " ###ここまで str.each do |line| print "public void "+line.chomp+"(){ //TODO } " end
str = #↓↓↓↓ここから " getParentWindow getParentFrame init testPattern1 testPattern2 " #↑↑↑↑ここまで str.each do |line| print line end
print "Hello, warld"
a = Array.new(10000) normdist = 0.0 max = 0.0 include Math for i in 1..10000 a[i] = rand(6)+1 max += a[i] end ave = max / 10000 print "平均:"+ ave.to_s for i in 1..10000 normdist += (a[i] - ave) * (a[i] - ave) end normdist = sqrt(normdist…
仕事に反復作業が多くてとても悲しい ので、モチベ維持&効率化のためにRubyを少しずつ勉強中 でもすぐ忘れる100本ノックにしたいとこだが、どうせ続かないので10本くらい目標。