A Rubik cube usually have 6 sides. Take 3×3 rubik cube because that example, each side has actually 9 tiny squares (1×1), 4 tool squares (2×2) and also 1 large square (3×3). Therefore, there are 6 x (9 + 4 + 1) = 84 squares top top a 3×3 rubik cube.
You are watching: How many squares on a rubik cube
How around counting the rectangles? the is a bit tough to count. Let’s write a function to counting it. The algorithm is to bruteforce a pair of clues (from optimal left edge to the best bottom). Then us compute the two sides the the rectangle to view if it is a square.
|function countSquaresAndRectangles(N) let squares = 0; let rectangles = 0; because that (let a = 0; a N; a ++) because that (let b = 0; b N; b ++) because that (let c = a + 1; c N; c ++) because that (let d = b + 1; d N; d ++) if (d - b === c - a) squares ++; rather rectangles ++; return <6 * squares, 6 * rectangles>;let ans = countSquaresAndRectangles(3);console.log(\"There room \" + ans<0> + \" squares, and \" + ans<1> + \" rectangles.\");|
See more: How Much Is A 1898 Penny Worth, 1898 Indian Head Cent
There room 840 squares, and also 3864 rectangles for a 7×7 rubik cube.
–EOF (The Ultimate computing & technology Blog) —
382 wordsLast Post: find the 10001st element Number following Post: exactly how to usage Priority Queue in Java or C++ come Compute Last rock Weight?
Leave a answer Cancel reply
Coding because that Speed
This domain is hosted proudly top top QuickHostUK & Namesilo Domain