回答編集履歴
1
追記
test
CHANGED
@@ -107,3 +107,41 @@
|
|
107
107
|
end
|
108
108
|
|
109
109
|
```
|
110
|
+
|
111
|
+
中心処理部からコメントを取り除くと次のようになっています。
|
112
|
+
|
113
|
+
```lang-ruby
|
114
|
+
|
115
|
+
in_index = 0
|
116
|
+
|
117
|
+
out_datas.each do |out_data|
|
118
|
+
|
119
|
+
pool = -out_data[:num]
|
120
|
+
|
121
|
+
while pool > 0
|
122
|
+
|
123
|
+
in_index += 1 if in_datas[in_index][:num] == 0
|
124
|
+
|
125
|
+
break if in_index >= in_datas.size
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
delta = min(pool, in_datas[in_index][:num])
|
130
|
+
|
131
|
+
puts "InLog: item_id:#{in_datas[in_index][:item_id]} from_item_id:#{out_data[:item_id]} diff_num:#{delta}"
|
132
|
+
|
133
|
+
puts "OutLog: item_id:#{out_data[:item_id]} to_item_id:#{in_datas[in_index][:item_id]} diff_num:#{-delta}"
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
in_datas[in_index][:num] -= delta
|
138
|
+
|
139
|
+
pool -= delta
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
|