プログラミングのお題スレ Part20at TECH
プログラミングのお題スレ Part20 - 暇つぶし2ch792:デフォルトの名無しさん
22/09/09 23:46:43.88 3788iROh.net
>>751 ruby
URLリンク(ideone.com)
def f(as, bs)
c = as.combination(2).map(&:sort).to_a.uniq.map {|x, y| [x * y, x, y]}.sort_by(&:first).each_cons(2)
bs.map do |b|
d = c.find {|e, f| e[0] < b && b <= f[0]}
"#{b}:#{d ? d[1][1..2].join(',') : 'error'}"
end
end
a = [17, 3, 3, 1, 6, 13, 11, 17, 2, 5, 7, 18, 16, 5, 8, 6, 5, 1, 11, 1]
b = [390, 240, 37, 396, 198, 99, 242, 53, 329, 202]
puts f(a, b)


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch