YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Make A Combination Lock - Intro to Algorithms

Get Embed Code
3 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. Here's one example of a possible solution for our program to create a combination lock.
  2. And this code is based on a code from Amit Gupta.
  3. So we take on a list of nodes. We'll use 6 nodes in this example.
  4. On the first line, we create an empty graph.
  5. On the next line, we create a length between zero node and the first node
  6. and then we have a loop that runs through the rest of the nodes.
  7. On this part of the loop, we make a chain connecting the first node
  8. with the second node, the second node with the third node,
  9. the third node with the fourth node, and so on.
  10. And on this line, we create the star part connecting zero node with the second node,
  11. zero node with the third node, the fourth node, etc.
  12. And this is the combination lock we wanted.