def valid_NIP?(nip)
return false if nip.size != 10

weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
nip = nip.split(//).map {|d| d.to_i }
checksum = 0
weights.each_with_index {|w, i| checksum += w * nip[i] }

return checksum % 11 % 10 == nip.last
end