Skip to content

Instantly share code, notes, and snippets.

@tokland
Created May 8, 2011 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokland/961232 to your computer and use it in GitHub Desktop.
Save tokland/961232 to your computer and use it in GitHub Desktop.
Solution to challenge 8 from "El País"
# http://www.elpais.com/videos/sociedad/cubo/suma/cero/elpepusoc/20110505elpepusoc_2/Ves/
faces_vertices = [[0,1,2,3], [0,1,4,5], [4,5,6,7], [2,3,6,7], [0,3,4,7], [1,2,5,6]]
vertices_solution = ([+1, -1].repeated_permutation(8)).select do |vertices_values|
faces_values = faces_vertices.map do |vertices|
vertices_values.values_at(*vertices).inject(:*)
end
(vertices_values + faces_values).inject(:+) == 0
end
p vertices_solution #=> []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment