Created
March 23, 2020 06:50
-
-
Save yuki-yano/11c97d8f9fa2ca2602c4a6311d14f3e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require 'gruff' | |
| def calc_score(start_day, stop = 1000) | |
| score = [] | |
| card = 0 | |
| 0.step(1000, 20) do |day| | |
| card += 6 if start_day < day && day < stop | |
| score << (score.last || 0) + (1000 - day) * card * 200 | |
| end | |
| score | |
| end | |
| g = Gruff::Line.new | |
| g.labels = {} | |
| 0.step(1000, 20).to_a.each_with_index do |n, i| | |
| g.labels[i] = n | |
| end | |
| g.data('0 > 1000', calc_score(0, 1000)) | |
| g.data('0 > 500', calc_score(0, 500)) | |
| g.data('200 > 500', calc_score(200, 500)) | |
| g.data('200 > 1000', calc_score(200, 1000)) | |
| g.data('300 > 1000', calc_score(300, 1000)) | |
| g.data('500 > 1000', calc_score(500, 1000)) | |
| g.write('bar.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment