A Rubik cube normally have 6 sides. Take 3×3 rubik cube for example, each side has actually 9 little bit squares (1×1), 4 medium squares (2×2) and 1 significant square (3×3). As such, tright here are 6 x (9 + 4 + 1) = 84 squares on a 3×3 rubik cube.

You are watching: How many squares on a rubix cube


rubik-cube-3×3


How around counting the rectangles? It is a little bit difficult to count. Let’s compose a duty to count it. The algorithm is to bruteforce a pair of points (from top left edge to the right bottom). Then we compute the two sides of the rectangle to see if it is a square.


123456789101112131415161718192021

function countSquaresAndRectangles(N) let squares = 0; let rectangles = 0; for (let a = 0; a N; a ++) for (let b = 0; b N; b ++) for (let c = a + 1; c N; c ++) for (let d = b + 1; d N; d ++) if (d - b === c - a) squares ++; else rectangles ++; return <6 * squares, 6 * rectangles>;let ans = countSquaresAndRectangles(3);console.log("There are " + ans<0> + " squares, and " + ans<1> + " rectangles.");

Tbelow are 84 squares, and also 132 rectangles in a 3×3 rubik cube. For a 7×7 rubik cube, it will be hard to count. But the computers are really good at it (in truth, the over Javascript code runs pretty rapid, for a tiny N).

See more: Twd Season 7 Episode 1 Online Free, Watch The Walking Dead Season 7 Online


*

rubik-cube-7×7


Tright here are 840 squares, and also 3864 rectangles for a 7×7 rubik cube.

–EOF (The Ultimate Computing & Technology Blog) —


382 wordsLast Post: Find the 10001st Prime Number Next Post: How to Use Priority Queue in Java or C++ to Compute Last Stone Weight?

Leave a Reply Cancel reply

Notice: It seems you have Javamanuscript disabled in your Browser. In order to submit a comment to this article, please create this code along with your comment: 1e23bed56f3cc2e80a107cc30e4e617c


*
Free $25 credit once you authorize up with Vultr Cloud VPS (10 Months Giveaway!)Free $20 credit as soon as you sign up through Linode Cloud VPS (4 Months Giveaway!) - (Promotional Code: PodcastInIt2018)Free $10 credit when you authorize up with DigitalOcean Cloud VPS (2 Months Giveaway!)Free $10 credit once you authorize up with Aliyun Cloud VPS (2 Months Giveaway!)Get even more proactivity deals by using VPS Database and VPS Search Tool

*
Coding For Speed


This domain is hosted proudly on QuickHostUK & Namesilo Domain
*
Free $25 credit when you sign up via Vultr Cloud VPS (10 Months Giveaway!)Free $20 credit when you sign up through Linode Cloud VPS (4 Months Giveaway!) - (Promotional Code: podcastinit2018)Free $10 credit when you sign up via DigitalOcean Cloud VPS (2 Months Giveaway!)Free $10 credit when you sign up via Aliyun Cloud VPS (2 Months Giveaway!)Get even more promotion deals by utilizing VPS Database and also VPS Search Tool