Skip to content

Instantly share code, notes, and snippets.

@bcho
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save bcho/eea095615e23ab812d46 to your computer and use it in GitHub Desktop.

Select an option

Save bcho/eea095615e23ab812d46 to your computer and use it in GitHub Desktop.

Sample:

1------2-------3----------4-------5--------6--------7
                          XX                        |
                           XX                       |
                            XX                      |
                             XX                     |
                              X---10--------9-------8

Run:

Slow Fast
1 1
2 3
3 5
4 7
5 9
6 4
7 6
8 8
8 1 (reset)
9 2
10 3
4 4 (collision point)

Explain:

                      the whole cycle path                                                                                           
                                                                                                                                 
                    +--------------------------------------------------------+                                                       
                                                                                                                                 
                      ran path in cycle during 1st meet                                                                               
                                                                                                                                 
                     +-------------------------------+                                                                               
                                                                                                                                 
1------2------3------4(s)------5------6-------7------8------9-------10------11(4)------12(5)-------13(6)-------14(7)---------15(8)(c)
                                                                                                                                 
                                                     +----------------------+ +-------------------------------------------------+    
                                                                                                                                 
                                                      remain cycle            ran path in cycle during 1st meet                      
                                                                                                                                 
                                                     +--------------------------------------------------------------------------+    
                                                                                                                                 
                                                            the whole cycle                                                          
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment