Ruby

Summarized using AI

Solving The Rubik's Cube in 20 Seconds

Chris Hunt • November 28, 2013 • Earth

In this engaging talk from GoGaRuCo 2013, Chris Hunt, a developer from GitHub, shares his expertise on how to solve the Rubik's Cube in under 20 seconds. He aims to equip participants with foundational knowledge and practical strategies for becoming proficient speedcubers.

Key points of the talk include:

- Introduction to the Cube: Chris begins by familiarizing the audience with the anatomy of the cube, highlighting center pieces as reference points and differentiating between edge pieces and corner pieces.

- Turning the Cube: He emphasizes the importance of getting comfortable with manipulating the cube before attempting to solve it. This step is crucial for developing the muscle memory needed for speedcubing.

- Learning Algorithms: Chris introduces the concept of algorithms (referred to as 'algs'), explaining how memorizing specific move sequences can drastically improve solving times.

- Two-Cycle Solution: The bicycle solution is presented as a practical method to solve the cube in under two minutes. The audience learns to focus on swapping just two pieces at a time and to use a setup, fix, and undo methodology to achieve the desired configuration.

- Speedcubing Methods: He advises learning the CFOP method (Cross, F2L, OLL, and PLL) for refining their solving technique. Illustrated by Chris’s real-time scrambling and solving, the session demonstrates how beginners can transition from the bicycle method to competitive speedcubing practices.

- Competitive Preparation: Chris wraps up by discussing tools, techniques, and resources that can enhance one’s speedcubing skills, such as investing in quality speed cubes and obtaining timers for practice. He also directs the audience to additional online resources and communities for further engagement.

Overall, Chris’s talk not only provides practical steps to solve the Rubik's Cube quickly but also fosters a sense of community among aspiring speedcubers. The key takeaway is that with the right methods, tools, and practice, anyone can improve their Rubik's Cube-solving skills significantly.

Solving The Rubik's Cube in 20 Seconds
Chris Hunt • November 28, 2013 • Earth

Come to San Francisco as a Rubyist, leave as a speedcuber. We are going to use Ruby, a video camera, and an insane amount of live demonstration to learn how to solve the Rubik's Cube in less than 20 seconds. You will leave this talk knowing which cube to buy, which of the five most popular solving methods you should be learning, how to practice for speed, where to ask questions, and how Ruby can help teach you to be the fastest speedcuber in town. People are solving the Rubik's Cube quicker today than any time in history and there's a reason why.

Help us caption & translate this video!

http://amara.org/v/FG8T/

GoGaRuCo 2013

00:00:20.600 Okay, cool! We're ready for our next talk. Our next speaker is Chris Hunt. He's a developer at GitHub and lives in Portland, where he moved after getting tired of San Francisco. He has the unique distinction of being the first person ever to recognize me in a bar by my voice. He asked, 'Where do I know your voice from?' and I replied, 'Do you listen to podcasts?' He said, 'Ruby Rogues—you’re David Brady!' So that's Chris. This year, GoGaRuCo comes with a surprise inside the swag bag. If you got a swag bag, look inside because you should have a Rubik's Cube. Now, Chris has been doing Ruby for five years, but he's been solving the Rubik's Cube for much longer—about seven years. He is one of the best in the world, ranking fifth or sixth for solving the cube blindfolded. That's pretty impressive. I can't even solve it at all anymore. Please give a big hand for Chris, and get your cubes ready.
00:01:56.280 Oh, damn it! Sorry about resetting the timer; I got really excited. I'm Chris from GitHub, and I'm going to teach everybody how to solve the Rubik's Cube in less than 20 seconds. We're going to do this in five steps. Follow along if you can, but we're going to move a little quickly. This will be more like something to reflect on later.
00:02:09.360 So, step number one is to buy a cube. I already did this for you, so we're already on to step number two.
00:02:14.800 Step number two is to turn the cube. Notice I didn't say 'solve' the cube; this is just about turning the cube because right now, most of you probably have no idea how to actually solve it. What you want to do is just turn it, mess with it, and you're going to notice a few things. The first is that the centers don't move; they're your reference point. Look at the center, and that will tell you what color that side is supposed to be when solved. If the center is green, then that side is going to be green. If the center is red, then that side is going to be red. That's a core concept, so get familiar with that.
00:02:45.440 The second thing you're going to notice is two types of pieces: the first is an edge piece, which has two colors. There are 12 edge pieces—four on the top, four in the middle layer, and four on the bottom layer. Notice I’m referring to them as layers, not sides. The second type of piece is a corner piece; those have three colors, and there are eight of them—four in the top layer and four in the bottom layer. That’s it for step number two, so learn that. You can try doing basic stuff like moving a piece from the top layer to the bottom layer with just one turn—just practice moving a few pieces around. Don’t even worry about solving it; that doesn't matter.
00:03:02.599 On this note, step number three is to learn some algorithms. By 'algs,' I mean algorithms. Believe it or not, there are a ton of people in the world who can solve the cube in less than 20 seconds, and many can do it in less than 10 seconds. Some even solve it in under 5 seconds, and they don't just make stuff up—they teach each other how to do this by sharing move sequences that perform very specific actions, which are called algorithms. Each letter in these algorithms represents a move, and it's easy to learn. For instance, on the cube, each side has a letter associated with it: the front is 'F,' the back is 'B,' the left side is 'L,' the right side is 'R,' the top side is 'U,' and the bottom side is 'D.' If you see an 'R,' that just means to turn the right face one turn clockwise.
00:03:54.840 If you see a 'U,' that means to turn the U face one turn in a clockwise direction. If you're confused about which direction is clockwise, just look at the face. This is the right side; if I see an 'R,' I just look at 'R' and turn it clockwise. Same with 'U.' You’re also going to see a couple of different modifiers. For example, if you see a prime symbol (') after a letter, like 'R',' it means to turn that face one turn in the opposite direction, or counterclockwise. The only other modifier you will see is a '2,' and that means to turn that face two times. Direction doesn't matter when you see a '2' because two turns clockwise is the same as two turns counterclockwise; you’re just turning that face over.
00:05:05.000 There is one special move you need to be aware of: the 'M' move. This stands for 'middle' and refers to the middle slice—not a side. So, if you see 'M,' that means you’re turning that middle slice one turn clockwise and similarly with 'M'. If you see 'M',' then you’re turning it one turn counterclockwise. I’m going to show this one too because it’s a little complicated. Use the right side as your reference point for 'M' because you can’t just look at 'M' and know which side is clockwise, right? Looking at this face, I see this is the clockwise direction, so for an 'M,' I’m doing this. For 'M',' I’m going the opposite direction, so 'M' and then 'M' prime (M').
00:06:00.000 That's like a pro move right there! This is what you’ll see in almost every algorithm you encounter. With this knowledge, you can now solve any algorithm you want. We’re going to apply this and learn a two-cycle solution. This will help you solve the cube in less than two minutes. Some of you might just stop here because two minutes is impressively fast in front of friends and family. This is called a two-cycle solution because it deals with only two pieces at any given time, completely ignoring the rest of the cube. You won't pay attention to anything else happening; you’ll just focus on two pieces and do something very specific with these two pieces before moving on.
00:07:01.520 I like to call this the bicycle solution or the bicycle solution T. You won't be able to Google this because I made it up. We have four steps to the bicycle solution—each involving only two pieces at a time. We will focus on these four steps, but first, here’s some trivia. How many positions are on the Rubik's Cube? Seven? Incorrect! There are 43 quintillion positions on the Rubik's Cube. A lot of you might not understand how vast this is, so here’s an analogy: if I had 43 quintillion little hot cocoa marshmallows and started stacking them, I would create a stack four miles high that would cover the entire surface of the Earth, including the water. That's a lot of positions—pretty amazing! Moving on!
00:07:44.000 We’re continuing with the bicycle solution. If you want to follow along on your phone, we’ll be going through the slides kind of fast, so you can use that. Here’s the URL—chrishunt.bicycles. These slides will be available later, so if you’re not a quick typist, I’ll put it up in a second. Step number one of the bicycle solution involves swapping the edges, and remember we’re only focusing on two pieces at a time. The algorithm we’re going to learn here will show exactly what it does: it simply swaps the edge in the upper left with the edge in the upper right. That’s it! Totally ignore everything else happening on the cube because it doesn’t matter. You’re going to use this single algorithm to move every single edge piece. Remember, there are 12 edge pieces. You’ll move every single edge piece to the correct location using just this algorithm.
00:08:01.120 You might be asking how you’ll use an algorithm that only swaps two edges in the top layer to position every edge; it doesn’t seem to make sense. And you’re right—it doesn’t. However, if you use a process I call 'setup, fix, undo', you can do it. You set up the cube in such a way that this algorithm swaps the pieces you want it to swap, and then you undo those setup moves in reverse order to get back to where you started. Let me show you what I mean. Ignore what I’m doing right now because I'm just doing setup to illustrate this example. Here we are with the cube, and our goal is to position every edge piece. Notice I have an edge piece that's out of place. I know my algorithm will swap these two—that's all it does. I always hold the cube the same way and focus on the upper right-hand spot because I know that’s where my algorithm will swap the pieces. Looking for the blue and red centers, the edge piece has to be located between those two centers. I keep my finger on that spot and return the cube to the home position, then ask what setup move I need to execute to get this piece into that location.
00:10:02.200 This will blow your mind but will become clear later. We’re going to do an L' (L prime), and now the piece is here. Another L' places it on the top. Now, I'm going to do that one memorized fixing algorithm, which will move the piece to the correct location before undoing those setup moves in reverse order by doing L, L again. Now, looking at the cube, you’ll see that piece is solved. Awesome! Now we repeat the same process: looking at that exact spot where we just moved the piece out to find the next piece. This piece is now green and red, so I search for the green center, the red center, and determine it must be placed right there. Look, we don’t need to do any setup moves this time, so I’ll just do that fixing algorithm and now the cube is solved! We're progressing nicely.
00:11:03.680 Now we’re on to step number two; it's exactly the same as the last step but now we’re working with corners, applying the same concepts. Notice this algorithm is longer than the previous one, but it feels nice on the fingers. This algorithm will swap the corner piece in the front left with the corner piece in the back right—that’s all it does! Let me set this up to demonstrate. Here’s how we proceed: the edges are looking amazing, but our corners are not positioned correctly. Now, we know an algorithm that just swaps the two corners, and we’ll use the same method as we did with the edges. Look at this spot and ask where this corner needs to go. This piece is blue, red, and yellow. After locating the blue center, red center, and yellow center, we determine that this is the piece that belongs there, so I’ll keep my finger on it and return the cube to the home position.
00:12:20.600 Next, I’ll figure out what setup move to make in order to swap these corners. I’ll do a B' (B prime), which moves it here, followed by another B' to move it to the top layer! Now, it’s in place and I can execute my fixing algorithm—the same one as displayed on the screen—then undo those setup moves by reversing them with B, B. Now taking a look at that corner, it’s solved! We do this again for the next corner. It’s green, orange, and yellow. So, I look for the green, orange, and yellow centers—aha, this must be where it needs to go. Once again, there are no setup moves to do, so I’ll just do that fixing algorithm and now our cube is completely solved! We've placed all the edges and corners correctly.
00:13:36.840 Even so, sometimes it’s not solved because you’ve moved the pieces to their correct positions but they can be facing the wrong direction. For instance, an edge can be between the right centers, but the upward color is facing out and the outer color is facing up—it’s just the wrong way! Fortunately, we have an algorithm that will flip two edges in this step. We’ll flip edges two at a time until they’re all oriented in the correct direction. So in this example, the front edge and the back edge are where we want them relative to the green and white centers, but they’re flipped. Next, another edge piece is in the right location—green and yellow between the correct centers—but it's also flipped incorrectly. Luckily, we know an algorithm that flips just these two edges, so let’s proceed.
00:15:11.920 Here’s another case to consider: notice this edge piece is flipped incorrectly, and over here we have another edge that's flipped incorrectly, but our algorithm only flips these two edges, not this edge piece. To fix these together, we need to use setup, fix, and undo. We’ll start by moving this edge piece over here so that our fixing algorithm can flip them both. I’m going to do an L' which will move it here, then a B' which moves it to the top. Now they are across from each other, I will execute the fixing algorithm and undo those two moves: B, L. Now the cube is solved.
00:16:47.760 Finally, the last step of our bicycle solution is rotating the corners. All our corners are currently located correctly as we achieved in step two, but they may be facing the wrong direction. So we have an algorithm that rotates the corner in the front left and rotates the corner in the front right. Let’s look at an example for this. Here we have two corners that are correctly located: green, white, and red. Here’s my green center, white center, and red center—none of them need to be moved, but they’re incorrectly rotated. The same applies for the other corner. I understand the algorithm will rotate both corners, and voila! Now they are properly positioned.
00:17:57.200 That’s it! That’s the bicycle solution. You really only need to memorize four algorithms—that’s it! With those, you can solve the cube in under two minutes. Now, the hardest part of this process is probably the setup and undo moves. You might feel perplexed if you’re thinking, 'How would I perform this if I have a cube displaced awkwardly in front of me?' That is definitely the hardest part. However, there is a gem that’s going to help you learn—if you go to GitHub and search for Chris Hunt Rubik’s Cube, you’ll find a Ruby implementation of the bicycle solution that you learned today! You can create a new Rubik's Cube that always starts in the solved position. Feel free to apply any algorithm you want using the same syntax you’ve learned or call methods that perform the same actions.
00:18:59.920 For instance, suppose you totally messed up your Rubik's Cube today and you have no idea how to solve it. You could reset your cube's state in your Ruby application to match that of the cube in your hand. Though I didn’t include it on this slide because it’s kind of a hassle, you can do it! It can create a new two-cycle solution known as the bicycle solution we practiced today, passing your cube in, and it will print every single step needed to resolve it, showing you the setup, fix, and undo moves. You’ll likely need this maybe 10 times, and then I promise it will click, and you’ll think, 'Oh! I got this down, this is great!'
00:20:19.920 However, as programmers in the room, there's a good chance you’ll become addicted to my amazing gem and want to write your own solutions. We’re going to go on a quick tangent to discuss how computers solve the Rubik's Cube because it really is very different. When I first designed a cube solver, I wrote the bicycle solution, musing on what would work best for a computer to solve it since it's different than how we do it by hand. The first idea was creating a massive table of all potential cube states, attaching solutions to each state. Then, when you take a picture of your cube, you could just look it up in the table and display the solution. This makes sense, but even if you could somehow compress the entire state of the cube and the solution into a single byte of storage, you would need over 39 million terabytes for that table!
00:21:23.920 I’ve discovered a more feasible method, which is to divide the solution into two phases. The widely recognized approach is known as the two-phase algorithm; if I pronounced that incorrectly, feel free to correct me afterward! The two-phase algorithm uses two lookup tables instead of one. In the first phase, we have a table aiming to take the cube from a scrambled position to an oriented position, meaning all pieces are facing the correct direction but not necessarily in the correct location. This is a reduced-size table since we only endeavor to orient the pieces, ensuring they face correctly when moved into the right locations.
00:22:30.800 Here’s how it works: we go through each algorithm one by one, attempting them until one works. Once a functional algorithm is selected, we transition to the next step—moving from an oriented state to a solved state, which again is a smaller table than maintaining multiple states. The quality of a solution can be evaluated by summing the move counts in the first and second phases, allowing it to indicate our total moves. Typically, someone employing this solution will run it multiple times, as you could choose different solutions in phase one while still orienting the cube. Since numerous ways exist to orient a cube via distinct moves, varied outcomes in phase two can lower your total moves to the solution.
00:24:04.080 This method is so efficient that people usually run it 20, 30, or more times depending on how much you're willing to wait. You set a threshold to gauge how low you’d like your move count to be, and when it meets that criteria, you conclude your task. It’s a phenomenal algorithm, not too complicated. If you’re curious about the underlying math, go to co.org for intriguing details and even a Java implementation. They also have a program called Cube Explorer, which allows you to take pictures of your cube and outputs a solution with as few as 19 moves. It’s amazing!
00:25:23.960 Now that we have learned the bicycle solution, let's refocus on how to solve the Rubik's Cube in under 20 seconds. As previously noted, the bicycle solution only gets you to about two minutes due to all the turns you must perform. Therefore, it's time to get serious and learn real speed cubing methods. There are four popular techniques, and anyone who you’ve seen solve the cube quickly is likely using one of these four methods—or they’re some sort of genius. I'd recommend you learn the method known as CFOP (Cross, First Two Layers, Orientation of the Last Layer, and Permutation of the Last Layer), also known as Freedrich. While I'd love to claim that's the one I use personally, it's popular for good reason!
00:26:51.480 The reason I recommend it is that the progression is natural from the bicycle solution. All four algorithms you’ve memorized can continue to be utilized in the Freedrich method. The setup and undo moves you previously struggled with will serve you well here too, so it turns out quite reasonably from one to the other. In the CFOP method, the first step is creating a cross appearance on one of the faces, which involves solving four edge pieces. After building this base, you’ll construct the first two layers; this means you will complete building upward from that cross to finalize the bottom two layers of the cube. The only unsolved pieces at that point will be on the top layer.
00:28:01.920 These first two steps—cross and F2L—are accomplished using intuition alone without requiring rote memorization. Even if this sounds daunting initially, the setup and undo moves you learned earlier should be sufficient for accomplishing these initial steps of CFOP. I’ll demonstrate what this looks like live. First, I need to scramble the cube. I’m using a professional scrambling technique. Now that I scrambled it, you’ll notice it’s essential to hold the cube the same way each time so that when you create the cross, you’ll always search for the same colors. This makes the process a little faster; being forced to search for varying colors can complicate matters.
00:29:25.080 I start with the blue side. The goal in creating the cross is to solve all four edges on the bottom, so I’ll locate the four edge pieces required, positioning them down as quickly as possible. You probably won’t understand precisely what I’m doing, I just want to display the process. Here is the cross—totally solved. The next step involves solving the bottom two layers. I’ll now look for each piece that belongs in the bottom two layers and move it into place. At this step, no algorithms should be memorized; using the earlier setup, fix, and undo processes will suffice.
00:30:54.000 Now, notice that the only unsolved section left is this top layer while both bottom two layers are completed. We then move to the third step, which is to orient the last layer. At this point, we flip all remaining pieces in the top layer so that the upward colors face up. For this step, you’ll need to memorize 57 different algorithms, although you already know two from the bicycle solution. You can effectively finish this step using merely your existing two algorithms, while mastering any additional ones will gradually speed up the process.
00:31:41.000 Looking at this, I’ll apply one of the new algorithms I memorized to orient the top layer. Boom! The only remaining task is positioning pieces within the appropriate space. The final step, PLL, or Permute Last Layer, is when we move all pieces that are now oriented correctly in the last layer into their respective spots. There are only 21 algorithms to memorize for this step, and similar to the previous step, you'll recall that you already know two from the bicycle solution—you learned one that flips two edge pieces and another that swaps two corners! That's all you’ll truly need for this step, but learning additional algorithms will increase speed.
00:32:55.960 Now, using one of the 21 algorithms I have memorized, I can permute the pieces in the top layer. And just like that, our cube is now solved using the Freedrich method. Thank you very much for following along! If you’re curious to learn more about Freedrich, check out this short URL I made: bitly/cfop-freedrich. Some of you may be eager about this and want to dive straight into it, skipping the bicycle process altogether—and that’s totally fine! Nevertheless, for those who want quicker results and to complete the cube under two minutes before attempting to master overly complex algorithms, I suggest starting with the bicycle solution first.
00:34:21.760 Before we wrap up, let’s engage in some trivia. What is the current world record for solving the Rubik's Cube? Incorrect! The current world record is 5.55 seconds, set in March of this year. It’s constantly going lower. This individual is phenomenal! Okay, we’re almost done. We’re in the last stage of solving the Rubik's Cube in under 20 seconds. By now, you’ve learned Freedrich, memorized all 57 orientation algorithms and all 21 permutation algorithms. Your local news station has probably featured you multiple times! But if you want to step it up and get competitive, here are some last steps to refine your solution and prepare for competitions.
00:35:21.000 First, take that regular Rubik's Cube you own and put it on a shelf—then get a real speed cube! Head over to lupixcube.com and spend about 25 dollars on a quality speed cube. If you want to see what it feels like, I assure you it’s excellent! These companies will break down the cubes, sanding all pieces down to eliminate imperfections. They will reassemble the cube, adjust its tension, and apply some lubricant. Additionally, they include what are termed torpedoes, which are little locking mechanisms preventing your pieces from popping out during high-speed moves; once you’re around the 30-second mark, the pieces tend to pop and fall apart.
00:36:31.200 This is particularly essential for your speed cubing proficiency. Once you’ve adjusted your cube, consider buying new stickers. You might not have noticed, but I use fluorescent stickers—bright yellow and orange—because these shades are more visible and tend to last longer. If you’re colorblind, you may prefer stickers that cater to your sensitivity, and for those who are blind or know someone who is, you can get Braille stickers or tiles. For a solution to worn stickers, visit Cubsmith.com, a great resource for silicone lubricant. Silicone lubricant is excellent for all plastics; spray a bit inside your cube, work it in, and for about six months, it’ll feel fantastic! After that, you would merely need to apply a little more.
00:37:38.440 Additionally, when you’re solving in under 20 seconds, and thinking about attending competitions or meeting fellow speed cubers, you should definitely obtain an official competition timer. Speedstacks.com provides timers originally designed for cup stacking, but they have now expanded into professional Rubik's Cube competitions. This timer includes a flat mat and features a timer you can place your hands on to start it. When you release it, the timer will begin, and this display feature is merely optional; I got it for your benefit!
00:39:04.000 If you have any questions regarding speed cubing or looking for guidance, visit speedsolving.com, which fosters a very active community eager to assist. They can provide insights regarding both hands-on and computational speed cubing. They’ll know a ton more than me! Nonetheless, if you have questions for me specifically, feel free to reach out to me on Twitter: @ChrisHunt. That’s all I have, thank you!
00:40:05.680 Okay, wow! We still have a couple minutes left. How many more times do you want to solve the cube? Was that six? One more? Can you do it just one more time? Oh my god! Okay, somebody's got to scramble it.
00:40:52.720 Wow, this feels great! Amazing speed cube!
00:41:00.000 Okay, starting with blue! Let me just turn my mic back on because I should be yelling—I don’t want to kill anybody.
00:41:09.000 Do you want me to time it or do you want to do it yourself? No? Okay, I think I’ve got it—can everyone hear me?
00:41:15.000 In a competition, you get 15 seconds to examine the cube before starting to solve. That’s what I’m doing now: identifying the edge pieces for the cross, and I’ve successfully found them.
00:41:29.000 In competitions, the cube is covered with a plastic lid designed to look like a Rubik's Cube—this helps avoid distractions during solving.
00:41:49.000 Put your hands down, the light will go green, and you can start solving!
00:41:58.600 Oh wait! Wait! I didn’t actually solve it!
00:42:30.000 Ugh, I’m sorry—I really want to apologize for this.
00:42:38.080 Okay, we’re good! Totally done. Sorry!
Explore all talks recorded at GoGaRuCo 2013
+14