moneybook 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/moneybook +4 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bin/moneybook
CHANGED
@@ -134,12 +134,13 @@ def get_exchanges(final,people)
|
|
134
134
|
# this person doesn't have to give or receive anything..
|
135
135
|
end
|
136
136
|
}
|
137
|
+
out = []
|
137
138
|
puts "\nPOSSIBLE (APPROX) EXCHANGES.."
|
138
139
|
while (eq=rich_v-(rich_v-poor_v)) != [] do
|
139
140
|
receives = rich_v.index eq[0]
|
140
141
|
gives = poor_v.index eq[0]
|
141
142
|
amount = eq[0]
|
142
|
-
|
143
|
+
out << "#{poor_p[gives]} gives #{amount} to #{rich_p[receives]}"
|
143
144
|
rich_p.delete_at receives
|
144
145
|
rich_v.delete_at receives
|
145
146
|
poor_p.delete_at gives
|
@@ -153,7 +154,7 @@ def get_exchanges(final,people)
|
|
153
154
|
gives = poor_v.index poor_v.max
|
154
155
|
receives = rich_v.index rich_v.min
|
155
156
|
amount = poor_v.max >= rich_v.min ? rich_v.min : poor_v.max
|
156
|
-
|
157
|
+
out << "#{poor_p[gives]} gives #{amount} to #{rich_p[receives]}"
|
157
158
|
rich_v[receives] -= amount
|
158
159
|
poor_v[gives] -= amount
|
159
160
|
#pp [poor_v, rich_v]
|
@@ -168,6 +169,7 @@ def get_exchanges(final,people)
|
|
168
169
|
end
|
169
170
|
timeout -= 1
|
170
171
|
end
|
172
|
+
out.sort.each{|x|puts x}
|
171
173
|
puts "--------------"
|
172
174
|
end
|
173
175
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneybook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- luca cioria
|