Skip to content

Instantly share code, notes, and snippets.

View ShayDavidson's full-sized avatar

Shay Davidson ShayDavidson

View GitHub Profile
@ShayDavidson
ShayDavidson / seven_boom.js
Last active December 10, 2015 04:08
7-boom test function.
sevenBoom = function(n) {
return xBoom(n, 7);
}
xBoom = function(n, boom) {
return dividedBy(n, boom) || containsDigit(n, boom);
}
dividedBy = function(n, x) {
return n % x == 0;
@ShayDavidson
ShayDavidson / gist:4277721
Created December 13, 2012 16:34
Print a spiral matrix.
def print_spiral(mat)
layers = (mat.length.to_f / 2).ceil
layers.times do |layer|
print_layer(mat, layer, layers)
end
end
def print_layer(mat, layer, layers)
if mat.length.odd? and (layer == layers - 1)
puts mat[layer][layer]