Skip to content

Instantly share code, notes, and snippets.

@evaldasg
Created February 14, 2018 11:25
Show Gist options
  • Save evaldasg/ca869954a44c19aaddbbe181dbef6408 to your computer and use it in GitHub Desktop.
Save evaldasg/ca869954a44c19aaddbbe181dbef6408 to your computer and use it in GitHub Desktop.
work days for last 3 months
[26] pry(main)> h
=> [19, 22, 19, 22, 20, 22, 21, 21, 22, 20, 23, 21, 18, 22, 20, 20, 21, 22, 19, 23, 21, 21, 23, 20]
[27] pry(main)> h[0..-3].each_with_index do |e,i|
[27] pry(main)* y = 2018 + (2 + i) / 12
[27] pry(main)* m = (3 + i) % 12
[27] pry(main)* m = m.zero? ? 12 : m
[27] pry(main)* dds = e + h[i+1] + h[i+2]
[27] pry(main)* p ["#{y}-#{m}", dds]
[27] pry(main)* end
["2018-3", 60]
["2018-4", 63]
["2018-5", 61]
["2018-6", 64]
["2018-7", 63]
["2018-8", 64]
["2018-9", 64]
["2018-10", 63]
["2018-11", 65]
["2018-12", 64]
["2019-1", 62]
["2019-2", 61]
["2019-3", 60]
["2019-4", 62]
["2019-5", 61]
["2019-6", 63]
["2019-7", 62]
["2019-8", 64]
["2019-9", 63]
["2019-10", 65]
["2019-11", 65]
["2019-12", 64]
=> [19, 22, 19, 22, 20, 22, 21, 21, 22, 20, 23, 21, 18, 22, 20, 20, 21, 22, 19, 23, 21, 21]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment