Created
January 28, 2021 12:07
-
-
Save neoneye/92a956b02d3f6066d7e0476680d7a798 to your computer and use it in GitHub Desktop.
A340867 text scatter plot
This file contains 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
def plot_modulus(values, count) | |
puts | |
s = values.map {|v| v.to_s(count) }.join('') | |
count.times do |i| | |
value = i.to_s(count) | |
re = Regexp.new("[^" + value + "]") | |
puts '# ' + s.gsub(re, ' ') | |
end | |
end | |
require 'prime' | |
values = [0] | |
Prime.first(150).each do |prime| | |
values << (prime-values[-1]) % 4 | |
end | |
plot_modulus(values, 4) | |
# OUTPUT: | |
# 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
# 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | |
# 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 | |
# 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment