回答編集履歴
1
追記
answer
CHANGED
@@ -52,4 +52,22 @@
|
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
55
|
-
```
|
55
|
+
```
|
56
|
+
中心処理部からコメントを取り除くと次のようになっています。
|
57
|
+
```lang-ruby
|
58
|
+
in_index = 0
|
59
|
+
out_datas.each do |out_data|
|
60
|
+
pool = -out_data[:num]
|
61
|
+
while pool > 0
|
62
|
+
in_index += 1 if in_datas[in_index][:num] == 0
|
63
|
+
break if in_index >= in_datas.size
|
64
|
+
|
65
|
+
delta = min(pool, in_datas[in_index][:num])
|
66
|
+
puts "InLog: item_id:#{in_datas[in_index][:item_id]} from_item_id:#{out_data[:item_id]} diff_num:#{delta}"
|
67
|
+
puts "OutLog: item_id:#{out_data[:item_id]} to_item_id:#{in_datas[in_index][:item_id]} diff_num:#{-delta}"
|
68
|
+
|
69
|
+
in_datas[in_index][:num] -= delta
|
70
|
+
pool -= delta
|
71
|
+
end
|
72
|
+
end
|
73
|
+
```
|