SlideShare a Scribd company logo
1 of 74
Download to read offline
A Robot path problem
helped me realise I still love JavaScript
Water-Cooler Talk
Project Euler
One-minute Rule
"My program takes days to get to the answer!"
Each problem has been designed according to a
"one-minute rule", which means that although it
may take several hours to design a successful
algorithm with more difficult problems, an efficient
implementation will allow a solution to be obtained
on a modestly powered computer
in less than one minute.
Which programming language?
http://shootout.alioth.debian.org/u64/which-programming-languages-are-fastest.php
http://xkcd.com/568/
Project Euler - Problem 208
Project Euler - Problem 208
A robot moves in a series
of one-fifth circular arcs
(72°)
Project Euler - Problem 208
A robot moves in a series
of one-fifth circular arcs
(72°)
with a free choice of
■ a clockwise or
■ an anti-clockwise arc for each step
but no turning on the spot.
Project Euler - Problem 208
One of 70932 possible closed paths of 25 arcs
Project Euler - Problem 208
Given that the robot starts facing North:
How many journeys of 70 arcs in
length can it take that return it, after
the final arc, to its starting position?
(Any arc may be traversed multiple times)
http://projecteuler.net/problem=208
Move left, move right
5 possible moves:
Move left, move right
How many closed path?
5 possible moves:
Move left, move right
5 possible moves:
N levels
http://www.wolframalpha.com/input/?i=binary+tree+5
70 levels
Number of grains of sand on earth!
http://www.wolframalpha.com/input/?i=2%5E71
The plane
The plane
Sample elements
Default coordinates
Plane centered
Positive up and right
CSS code
http://jsbin.com/evinum/edit#html,live
http://jsfiddle.net/filippovitale/3z7Ln/embedded/
Arc left, Arc right
Arc left, Arc right
Arc left, Arc right
Arc left, Arc right
Basically we add:
Arc left, Arc right
Basically we add:
http://jsbin.com/abaxoy/edit#preview
Move left, move right
Model:
● Move = { L, R }
● StateI
= ( x, y, heading )
StateI
Move left, move right
Model:
● Move = { L, R }
● StateI
= ( x, y, heading )
● StateII
= ( lx, ly, rx, ry )
StateI
StateII
Move left, move right
Move left, move right
Move left, move right
Move left, move right
Move left, move right
Move left, move right
Move left, move right
How can we rotate a point on a plane?
http://www.wolframalpha.com/input/?i=%7B100%2C+0%7D+72%C2%B0+rotation
Move left, move right
How can we rotate a point on a plane?
http://www.wolframalpha.com/input/?i=%7B100%2C+0%7D+72%C2%B0+rotation
http://www.wolframalpha.com/input/?i=with+center+%7B-50%2C0%7D+rotate+72+deg+%7B50%2C0%7D
Move left, move right
http://www.wolframalpha.com/input/?i=%7B100%2C+0%7D+72%C2%B0+rotation
Move left, move right
Move left, move right
Move left, move right
Move left, move right
http://jsbin.com/anijuc/edit#preview
~0.000001
Brute force (naïve method)
Brute force (naïve method)
http://jsbin.com/ejebip/edit#preview
ABCDE Model
A B C D E
0 1 2 3 4
ABCDE Model
A B C D E
0 1 2 3 4 heading
0
1
2
3
4
ABCDE Model
A B C D E
0 1 2 3 4 heading
counter
0
1
2
3
4
http://jsbin.com/oyifem/edit#preview
A way to solve this problem
A way to solve this problem
A way to solve this problem
A way to solve this problem
A way to solve this problem
A way to solve this problem
MaxDistance!
A way to solve this problem
A way to solve this problem
ClosedPath!
A way to solve this problem
A way to solve this problem
A way to solve this problem
A way to solve this problem
http://jsfiddle.net/filippovitale/hS9KS/embedded/result/
http://underscorejs.org/ + CoffeConsole
Conclusion
~2 seconds
??? seconds
Conclusion
~2 seconds
~20 seconds
Conclusion
~2 seconds
~20 seconds
~89 seconds
Questions?
twitter / bitbucket / github @filippovitale
A Robot path problem
helped me realise I still love JavaScript

More Related Content

Similar to A Robot path problem – SydJS June 2012 by Filippo Vitale

Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Anna Shymchenko
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following RobotDivay Khatri
 
Robotics and Automation Introduction
Robotics and Automation IntroductionRobotics and Automation Introduction
Robotics and Automation Introductionanand hd
 
TP_Webots_7mai2021.pdf
TP_Webots_7mai2021.pdfTP_Webots_7mai2021.pdf
TP_Webots_7mai2021.pdfkiiway01
 
Domo Arigato, Mr(uby) Roboto
Domo Arigato, Mr(uby) RobotoDomo Arigato, Mr(uby) Roboto
Domo Arigato, Mr(uby) Robotoyamanekko
 
Robotic Platform for Appearance Editing
Robotic Platform for Appearance EditingRobotic Platform for Appearance Editing
Robotic Platform for Appearance EditingTharindu Mathew
 
Verilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdfVerilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdfAzeemMohammedAbdul
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-TransformationsMohammad Shaker
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCADVickyTGAW
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to CodingFabio506452
 
Metrics on the front, data in the back
Metrics on the front, data in the backMetrics on the front, data in the back
Metrics on the front, data in the backDiUS
 
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...Owen (Chih-Hsuan) Chen
 
Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Anna Migas
 

Similar to A Robot path problem – SydJS June 2012 by Filippo Vitale (20)

Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"
 
Mobile Robot Vechiles
Mobile Robot VechilesMobile Robot Vechiles
Mobile Robot Vechiles
 
Report - Line Following Robot
Report - Line Following RobotReport - Line Following Robot
Report - Line Following Robot
 
Lecture2
Lecture2Lecture2
Lecture2
 
Robotics and Automation Introduction
Robotics and Automation IntroductionRobotics and Automation Introduction
Robotics and Automation Introduction
 
Automatic Plowing System
Automatic Plowing SystemAutomatic Plowing System
Automatic Plowing System
 
TP_Webots_7mai2021.pdf
TP_Webots_7mai2021.pdfTP_Webots_7mai2021.pdf
TP_Webots_7mai2021.pdf
 
Domo Arigato, Mr(uby) Roboto
Domo Arigato, Mr(uby) RobotoDomo Arigato, Mr(uby) Roboto
Domo Arigato, Mr(uby) Roboto
 
Robotic Platform for Appearance Editing
Robotic Platform for Appearance EditingRobotic Platform for Appearance Editing
Robotic Platform for Appearance Editing
 
Verilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdfVerilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdf
 
OpenGL L02-Transformations
OpenGL L02-TransformationsOpenGL L02-Transformations
OpenGL L02-Transformations
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCAD
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Automatic P2R Published Paper P1277-1283
Automatic P2R Published Paper P1277-1283Automatic P2R Published Paper P1277-1283
Automatic P2R Published Paper P1277-1283
 
Metrics on the front, data in the back
Metrics on the front, data in the backMetrics on the front, data in the back
Metrics on the front, data in the back
 
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...
Intelligent Control Systems for Humanoid Robot: Master Thesis_Owen Chih-Hsuan...
 
REVIEW OF VIRTUAL ARTICULATED ROBOT
REVIEW OF VIRTUAL ARTICULATED ROBOTREVIEW OF VIRTUAL ARTICULATED ROBOT
REVIEW OF VIRTUAL ARTICULATED ROBOT
 
Quicksort
QuicksortQuicksort
Quicksort
 
ltspice basic practice.pptx
ltspice basic practice.pptxltspice basic practice.pptx
ltspice basic practice.pptx
 
Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017 Make Your Animations Perform Well - JS Conf Budapest 2017
Make Your Animations Perform Well - JS Conf Budapest 2017
 

More from Filippo Vitale

Send + More = Money – Let’s mash 2 monads to solve a simple CSP
Send + More = Money – Let’s mash 2 monads to solve a simple CSPSend + More = Money – Let’s mash 2 monads to solve a simple CSP
Send + More = Money – Let’s mash 2 monads to solve a simple CSPFilippo Vitale
 
Clojure REPL or cluster deployment with Docker
Clojure REPL or cluster deployment with DockerClojure REPL or cluster deployment with Docker
Clojure REPL or cluster deployment with DockerFilippo Vitale
 
Sydjs 2013-10 combining-generators_with_promises_and_channels
Sydjs 2013-10 combining-generators_with_promises_and_channelsSydjs 2013-10 combining-generators_with_promises_and_channels
Sydjs 2013-10 combining-generators_with_promises_and_channelsFilippo Vitale
 
One way to solve the problem 411 in clojure
One way to solve the problem 411 in clojureOne way to solve the problem 411 in clojure
One way to solve the problem 411 in clojureFilippo Vitale
 
Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Filippo Vitale
 

More from Filippo Vitale (6)

Polimorfismo cosa?
Polimorfismo cosa?Polimorfismo cosa?
Polimorfismo cosa?
 
Send + More = Money – Let’s mash 2 monads to solve a simple CSP
Send + More = Money – Let’s mash 2 monads to solve a simple CSPSend + More = Money – Let’s mash 2 monads to solve a simple CSP
Send + More = Money – Let’s mash 2 monads to solve a simple CSP
 
Clojure REPL or cluster deployment with Docker
Clojure REPL or cluster deployment with DockerClojure REPL or cluster deployment with Docker
Clojure REPL or cluster deployment with Docker
 
Sydjs 2013-10 combining-generators_with_promises_and_channels
Sydjs 2013-10 combining-generators_with_promises_and_channelsSydjs 2013-10 combining-generators_with_promises_and_channels
Sydjs 2013-10 combining-generators_with_promises_and_channels
 
One way to solve the problem 411 in clojure
One way to solve the problem 411 in clojureOne way to solve the problem 411 in clojure
One way to solve the problem 411 in clojure
 
Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015
 

Recently uploaded

How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

A Robot path problem – SydJS June 2012 by Filippo Vitale