Last active
March 31, 2020 15:29
-
-
Save deevis/0655993eb75b18115936592e0ec0ca0c to your computer and use it in GitHub Desktop.
Program to display a frequency histogram of rational values determined by month divided by day values over the course of the next year
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
| # Program to display a frequency histogram of rational values | |
| # determined by month divided by day values over the course of the next year | |
| # For example, March 30 is 3/30 = 0.1 | |
| require 'active_support/all' | |
| vals = (0...365).map{|x| d = x.days.from_now; [d.strftime("%m/%d"), d.strftime("%m").to_f / d.strftime("%d").to_f]} | |
| # print the results | |
| # vals.each{|v| puts "#{v[0]} #{v[1]}"};nil | |
| counts = Hash.new(0); vals.each{|v| counts[v[1]] += 1} | |
| counts.sort{|a,b| b[1] <=> a[1]}.each{|val, count| puts "#{count} ==> #{val}"};nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment