18/04/12 10:59:42.57 T93bDVFD.net
>>611
Ruby で作った
DIGITS = [4, 5] # number of digits 桁数
# 答え、567, 1,215
DIGITS.each do |digit|
count = 0
wrapper = Array.new digit - 1
# [*0..9] で、配列にする
[*0..9].combination(2) do |ary|
(digit - 1).times { |i| wrapper[i] = ary }
# 先頭が0 のものと、1つの数字だけを使ったものを排除する
# *wrapper で、外側の[ ] をはずす
count += ary.product(*wrapper)
.reject { |item| item[0] == 0 }
.reject { |item| item.uniq.length == 1 }.length
end
puts count
end