Skip to content

Instantly share code, notes, and snippets.

@hannahherbig
Created August 12, 2013 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannahherbig/6209303 to your computer and use it in GitHub Desktop.
Save hannahherbig/6209303 to your computer and use it in GitHub Desktop.
require 'bigdecimal'
max = min = count = start = last = bank = nil
$<.each_line do |line|
line.strip!
case line
when /^Starting with BANK of (.+) BTC$/
start = last = bank = BigDecimal.new($1)
count = 0
max = BigDecimal.new(-1) / 0
min = BigDecimal.new(1) / 0
when /^BANK: (.+)$/
count += 1
bank = BigDecimal.new($1)
profit = bank - start
change = bank - last
win = change >= 0
up = profit >= 0
print "\e[%dm%+d\e[m" % [change >= 0 ? 32 : 31, change]
last = bank
end
end
require 'bigdecimal'
count = start_bank = last_bank = bank = nil
$<.each_line do |line|
line.strip!
case line
when /^Starting with BANK of (.+) BTC$/
start_bank = last_bank = bank = BigDecimal.new($1)
count = 0
when /^BANK: (.+)$/
count += 1
bank = BigDecimal.new($1)
profit = bank - start_bank
change = bank - last_bank
win = change >= 0
up = profit >= 0
puts "%s | \e[%dm%+.8f\e[m | \e[%dm%+.8f\e[m | %.8f" %
[(Time.now.strftime '%H:%M:%S'), change >= 0 ? 32 : 31, change,
profit >= 0 ? 32 : 31, profit, bank]
# puts "\x03%d%+.8f\x03 | \x03%d%+.8f\x03 | %.8f" %
# [change >= 0 ? 3 : 4, change, profit >= 0 ? 3 : 4, profit, bank]
last_bank = bank
end
end
require 'bigdecimal'
max = min = count = start = last = bank = nil
$<.each_line do |line|
line.strip!
case line
when /^Starting with BANK of (.+) BTC$/
start = last = bank = BigDecimal.new($1)
count = 0
max = BigDecimal.new(-1) / 0
min = BigDecimal.new(1) / 0
when /^BANK: (.+)$/
count += 1
bank = BigDecimal.new($1)
profit = bank - start
change = bank - last
win = change >= 0
up = profit >= 0
print "\r%d | \e[%dm%+.8f\e[m | \e[%dm%+.8f\e[m | %.8f\e[K" %
[count, change >= 0 ? 32 : 31, change,
profit >= 0 ? 32 : 31, profit, bank]
if bank > max
puts
max = bank
end
if change < min
puts
min = change
end
last = bank
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment