Skip to content

Instantly share code, notes, and snippets.

@neoneye
Created January 28, 2021 12:07
Show Gist options
  • Save neoneye/92a956b02d3f6066d7e0476680d7a798 to your computer and use it in GitHub Desktop.
Save neoneye/92a956b02d3f6066d7e0476680d7a798 to your computer and use it in GitHub Desktop.
A340867 text scatter plot
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