There are 27 points, and their coordinates are , where
I choose 3 points from them, and they form an equilateral triangle.
How many equilateral triangles can be formed like this?
Bonus: This is the case. Generalize the case.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Generate the lattice points.
p = Flatten [ Table [ { x , y , z } , { x , − 1 , 1 } , { y , − 1 , 1 } , { z , − 1 , 1 } ] , 2 ] ;
Generate the triangles.
t = Flatten [ Table [ { p [ [ i ] ] , p [ [ j ] ] , p [ [ k ] ] } , { i , 1 , Length [ p ] } , { j , i + 1 , Length [ p ] } , { k , j + 1 , Length [ p ] } ] , 2 ] ;
Write a test for a triangle being equilateral.
equilateralQ = SquaredEuclideanDistance [ $#$1 [ [ 1 ] ] , $#$1 [ [ 2 ] ] ] = SquaredEuclideanDistance [ $#$1 [ [ 1 ] ] , $#$1 [ [ 3 ] ] ] ∧ SquaredEuclideanDistance [ $#$1 [ [ 1 ] ] , $#$1 [ [ 2 ] ] ] = SquaredEuclideanDistance [ $#$1 [ [ 2 ] ] , $#$1 [ [ 3 ] ] ] & ;
Apply test triangles and count the successful cases.
Length [ Select [ t , equilateralQ ( $#$1 ) & ] ] ⟹ 8 0
No overt recursion was required. This could have been done in most computer languages.