Try mplementing operator+= (broken but almost there).
This commit is contained in:
parent
9ea9743e95
commit
dbdc814049
4 changed files with 136 additions and 6 deletions
20
tools/calc_advance.rb
Normal file
20
tools/calc_advance.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
M = 2147483647
|
||||
|
||||
def calc(arr, m)
|
||||
v = M
|
||||
index = 0
|
||||
out = arr.dup
|
||||
while (v > 0) do
|
||||
v += arr[index]
|
||||
#puts "index #{index} - v is #{v}, m is #{m[index]}"
|
||||
out[index] = v % (m[index] + 1)
|
||||
v /= (m[index] + 1)
|
||||
index += 1
|
||||
end
|
||||
out
|
||||
end
|
||||
|
||||
p calc([540, 800, 1200, 710], [M - 10, M - 11, M - 12, M - 13])
|
||||
p calc([M, 800, 1200, 710], [M, 800, M, M])
|
Loading…
Add table
Add a link
Reference in a new issue