Last updated 2 years ago
Was this helpful?
func mosaic_matrix(n) { n.of {|k| var(a,b) = (k.is_even ? (1,0) : (0,1)) n.of {|j| j.is_even ? a : b } } } mosaic_matrix(5).each { .join(' ').say }; say '' mosaic_matrix(6).each { .join(' ').say }
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1