The Chasm | Think Like A Coder, Ep 6

TED-Ed · Intermediate ·🔍 RAG & Vector Search ·6y ago

Key Takeaways

Ethic, Hedge, and Octavia use problem-solving skills to cross a bottomless ravine

Full Transcript

[Applause] [Music] ethic hedge and Octavius stand on the edge of a bottomless ravine it's the only thing between them and the tower that houses the second of three powerful artifacts they've got a brief window of time to get across before the guards return with hedges fuel gauge on empty he won't be able to fly ethic across so the only option is to make a bridge fortunately the floating stacks of stones nearby are bridge components invented by Octavia herself called hover blocks activate a pile with a burst of energy and they'll self assemble to span the ravine as ethic walks across but there is of course a cache the hover blocks are only stable when they're perfectly palindromic meaning they have to form a sequence that's the same when viewed forwards and backwards the stacks start in random orders but will always put themselves into a palindromic configuration if they can if they get to a point where a palindrome isn't possible the bridge will collapse and whoever's on it will fall into the ravine let's look at an example this stack would make itself stable first the a blocks hold themselves in place then the bees and finally the sea would Nestle right between the bees however suppose there was one more a first two a blocks form up then two bees but now the remaining C and a have nowhere to go so the whole thing falls apart the note of power enables hedge to energize a single stack of blocks what instructions can ethic give hedge to allow him to efficiently find and power a stable palindromic stack examples of palindromes include anna racecar and madam I'm Adam counting the number of times a given letter appears in a palindrome will reveal a helpful pattern let's first look at a naive solution to this problem a naive solution is a simple brute-force approach that isn't optimized but will get the job done naive solutions are helpful ways to analyze problems and work as stepping stones to better solutions in this case a naive solution is to approach a pile of blocks try all the arrangements and see if one is a palindrome by reading it forward and then backwards the problem with this approach is that it would take a tremendous amount of time if Hedge tried one combination every second a stack of just 10 different blocks would take him 42 days to exhaust that's because the total time is a function of the factorial of the number of blocks there are 10 blocks have over 3 million combinations what this naive solution shows is that we need a much faster way to tell whether a pile of blocks can form a palindrome to start it may be intuitively clear that a pile of all different blocks will never form one why the first and last blocks can't be the same if there are no repeats so when can a given sequence become a palindrome one way to figure that out is to analyze a few existing palindromes in Anna there are two A's and two ends race car has two R's two A's to seize and one e and madam I'm Adam has four M's for a s 2 DS and 1 AI the pattern here is that most of the letters occur an even number of times and there's at most one that occurs just once is what if racecar had three e's instead of one we could tack the new ease on to the ends and still get a palindrome so three is okay but make that three e's and three c's and there's nowhere for the last C to go so the most generalized insight is that at most one letter can appear an odd number of times but the rest have to be even hedge can count the letters in each stack and organize them into a dictionary which is a tidy way of storing information a loop could then go through and count how many times odd numbers appear if there are less than two odd characters the stack can be made into a palindrome this approach is much much faster than the naive solution instead of factorial time it takes linear time that's where the time increases in proportion to the number of blocks there are now write a loop for hedge to approach the piles individually and stop when he finds a good one and you'll be ready to go here's what happens edge is fast but there are so many piles it takes a long time too long [Music] [Music] [Music] ethic and hedge are safe but Octavia is not so lucky continue the adventure in Episode seven of think like a coder or restart the journey with episode 1 and don't forget to subscribe [Music]

Original Description

The adventure continues! Episode 6: Ethic, Hedge, and Octavia must find a way to cross the bottomless ravine to get to the tower. Can they make it before the guards return? -- This is episode 6 of our animated series “Think Like A Coder.” This 10-episode narrative follows a girl, Ethic, and her robot companion, Hedge, as they attempt to save the world. The two embark on a quest to collect three artifacts and must solve their way through a series of programming puzzles. Lesson by Alex Rosenthal, directed by Kozmonot Animation Studio. Supported by Endless: https://endlessnetwork.com A special thank you to the programmers who assisted in the development of this series: Eric Wastl, Sara Kladky, Ryan Harvey, Dan Bernier, Eden Girma, Matt Gruskin, and James Griffith. The challenge in this episode was inspired by a problem found in Gayle Laakmann McDowell’s book "Cracking the Coding Interview." Sign up for our newsletter: http://bit.ly/TEDEdNewsletter Support us on Patreon: http://bit.ly/TEDEdPatreon Follow us on Facebook: http://bit.ly/TEDEdFacebook Find us on Twitter: http://bit.ly/TEDEdTwitter Peep us on Instagram: http://bit.ly/TEDEdInstagram View full lesson: https://ed.ted.com/lessons/the-chasm-think-like-a-coder-ep-6 Thank you so much to our patrons for your support! Without you this video would not be possible! zjweele13, Anna-Pitschna Kunz, Edla Paniguel, Elena Crescia, Thomas Mungavan, Alejandro Cachoua, Jaron Blackburn, Yoga Trapeze Wanderlust, Sandy Nasser, Venkat Venkatakrishnan, Nicolle Fieldsend-Roxborough, John Saveland, Jason Garcia, Robson Martinho, Martin Lau, Senjo Limbu, Joe Huang, SungGyeong Bae, Christian Kurch, Begum Tutuncu, David Matthew Ezroj, Sweetmilkcoco, Raphaël LAURENT, Joe Meyers, Farah Abdelwahab, Brian Richards, Divina Grace Dar Santos, Jessie McGuire, Abdullah Altuwaijri, Sarah Burns, Clement, Hadi Salahshour, FAWWAZ GHUWAIDI, Dino Biancolini, Reagen O'Connor, Nicu Boanda, Cindy O., Karla Brilman, Jørgen Østerpart, Sergi Páez,
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from TED-Ed · TED-Ed · 0 of 60

← Previous Next →
1 Weaving narratives in museum galleries - Thomas P. Campbell
Weaving narratives in museum galleries - Thomas P. Campbell
TED-Ed
2 Your brain is more than a bag of chemicals - David Anderson
Your brain is more than a bag of chemicals - David Anderson
TED-Ed
3 Biofuels and bioprospecting for beginners - Craig A. Kohn
Biofuels and bioprospecting for beginners - Craig A. Kohn
TED-Ed
4 Four sisters in Ancient Rome - Ray Laurence
Four sisters in Ancient Rome - Ray Laurence
TED-Ed
5 The brilliance of bioluminescence - Leslie Kenna
The brilliance of bioluminescence - Leslie Kenna
TED-Ed
6 Animation basics: Homemade special effects - TED-Ed
Animation basics: Homemade special effects - TED-Ed
TED-Ed
7 Pros and cons of public opinion polls - Jason Robert Jaffe
Pros and cons of public opinion polls - Jason Robert Jaffe
TED-Ed
8 Excuse me, may I rent your car? - Robin Chase
Excuse me, may I rent your car? - Robin Chase
TED-Ed
9 Could tissue engineering mean personalized medicine? - Nina Tandon
Could tissue engineering mean personalized medicine? - Nina Tandon
TED-Ed
10 The arts festival revolution - David Binder
The arts festival revolution - David Binder
TED-Ed
11 What's an algorithm? - David J. Malan
What's an algorithm? - David J. Malan
TED-Ed
12 Why do fingers become pruney? - Mark Changizi
Why do fingers become pruney? - Mark Changizi
TED-Ed
13 What is fat? - George Zaidan
What is fat? - George Zaidan
TED-Ed
14 Reasons for the seasons - Rebecca Kaplan
Reasons for the seasons - Rebecca Kaplan
TED-Ed
15 Mysteries of vernacular: Inaugurate - Jessica Oreck
Mysteries of vernacular: Inaugurate - Jessica Oreck
TED-Ed
16 Let's pool our medical data - John Wilbanks
Let's pool our medical data - John Wilbanks
TED-Ed
17 Science is for everyone, kids included - Beau Lotto and Amy O'Toole
Science is for everyone, kids included - Beau Lotto and Amy O'Toole
TED-Ed
18 Making a TED-Ed Lesson: Concept and design
Making a TED-Ed Lesson: Concept and design
TED-Ed
19 Making a TED-Ed Lesson: Creative process
Making a TED-Ed Lesson: Creative process
TED-Ed
20 Making a TED-Ed Lesson: Animation
Making a TED-Ed Lesson: Animation
TED-Ed
21 Is space trying to kill us? - Ron Shaneyfelt
Is space trying to kill us? - Ron Shaneyfelt
TED-Ed
22 Put those smartphones away: Great tips for making your job interview count - Anna Post
Put those smartphones away: Great tips for making your job interview count - Anna Post
TED-Ed
23 What on Earth is spin? - Brian Jones
What on Earth is spin? - Brian Jones
TED-Ed
24 Gyotaku: The ancient Japanese art of printing fish - K. Erica Dodge
Gyotaku: The ancient Japanese art of printing fish - K. Erica Dodge
TED-Ed
25 Mining literature for deeper meanings - Amy E. Harter
Mining literature for deeper meanings - Amy E. Harter
TED-Ed
26 What doctors don't know about the drugs they prescribe - Ben Goldacre
What doctors don't know about the drugs they prescribe - Ben Goldacre
TED-Ed
27 Why architects need to use their ears - Julian Treasure
Why architects need to use their ears - Julian Treasure
TED-Ed
28 How do you decide where to go in a zombie apocalypse? - David Hunter
How do you decide where to go in a zombie apocalypse? - David Hunter
TED-Ed
29 Tracking grizzly bears from space - David Laskin
Tracking grizzly bears from space - David Laskin
TED-Ed
30 The emergence of drama as a literary art - Mindy Ploeckelmann
The emergence of drama as a literary art - Mindy Ploeckelmann
TED-Ed
31 Why democracy matters - Rory Stewart
Why democracy matters - Rory Stewart
TED-Ed
32 Ethical riddles in HIV research - Boghuma Kabisen Titanji
Ethical riddles in HIV research - Boghuma Kabisen Titanji
TED-Ed
33 Mysteries of vernacular: Venom - Jessica Oreck and Rachael Teel
Mysteries of vernacular: Venom - Jessica Oreck and Rachael Teel
TED-Ed
34 Mysteries of vernacular: Dynamite - Jessica Oreck and Rachael Teel
Mysteries of vernacular: Dynamite - Jessica Oreck and Rachael Teel
TED-Ed
35 The promise of research with stem cells - Susan Solomon
The promise of research with stem cells - Susan Solomon
TED-Ed
36 What color is Tuesday? Exploring synesthesia - Richard E. Cytowic
What color is Tuesday? Exploring synesthesia - Richard E. Cytowic
TED-Ed
37 How do we experience time? - Matt Danzico
How do we experience time? - Matt Danzico
TED-Ed
38 The contributions of female explorers - Courtney Stephens
The contributions of female explorers - Courtney Stephens
TED-Ed
39 The security mirage - Bruce Schneier
The security mirage - Bruce Schneier
TED-Ed
40 Mysteries of vernacular: Window - Jessica Oreck and Rachael Teel
Mysteries of vernacular: Window - Jessica Oreck and Rachael Teel
TED-Ed
41 The punishable perils of plagiarism - Melissa Huseman D'Annunzio
The punishable perils of plagiarism - Melissa Huseman D'Annunzio
TED-Ed
42 Dare to disagree - Margaret Heffernan
Dare to disagree - Margaret Heffernan
TED-Ed
43 What we're learning from online education - Daphne Koller
What we're learning from online education - Daphne Koller
TED-Ed
44 The rise of human-computer cooperation - Shyam Sankar
The rise of human-computer cooperation - Shyam Sankar
TED-Ed
45 The happy secret to better work - Shawn Achor
The happy secret to better work - Shawn Achor
TED-Ed
46 Dissecting Botticelli's Adoration of the Magi - James Earle
Dissecting Botticelli's Adoration of the Magi - James Earle
TED-Ed
47 The game-changing amniotic egg - April Tucker
The game-changing amniotic egg - April Tucker
TED-Ed
48 Equality, sports, and Title IX - Erin Buzuvis and Kristine Newhall
Equality, sports, and Title IX - Erin Buzuvis and Kristine Newhall
TED-Ed
49 Neuroscience, game theory, monkeys - Colin Camerer
Neuroscience, game theory, monkeys - Colin Camerer
TED-Ed
50 Why global jihad is losing - Bobby Ghosh
Why global jihad is losing - Bobby Ghosh
TED-Ed
51 Want to help someone? Shut up and listen! - Ernesto Sirolli
Want to help someone? Shut up and listen! - Ernesto Sirolli
TED-Ed
52 Fighting with non-violence - Scilla Elworthy
Fighting with non-violence - Scilla Elworthy
TED-Ed
53 Mysteries of vernacular: Gorgeous - Jessica Oreck and Rachael Teel
Mysteries of vernacular: Gorgeous - Jessica Oreck and Rachael Teel
TED-Ed
54 Building unimaginable shapes - Michael Hansmeyer
Building unimaginable shapes - Michael Hansmeyer
TED-Ed
55 Behind the Great Firewall of China - Michael Anti
Behind the Great Firewall of China - Michael Anti
TED-Ed
56 How big is the ocean? - Scott Gass
How big is the ocean? - Scott Gass
TED-Ed
57 Is there a center of the universe? - Marjee Chmiel and Trevor Owens
Is there a center of the universe? - Marjee Chmiel and Trevor Owens
TED-Ed
58 Vermicomposting: How worms can reduce our waste - Matthew Ross
Vermicomposting: How worms can reduce our waste - Matthew Ross
TED-Ed
59 How to set the table - Anna Post
How to set the table - Anna Post
TED-Ed
60 How to fool a GPS - Todd Humphreys
How to fool a GPS - Todd Humphreys
TED-Ed

Related Reads

📰
Production RAG for enterprises: evaluation, safety, and cost
Learn how to evaluate and implement production-ready RAG for enterprises, focusing on safety and cost efficiency
Medium · AI
📰
RAG for Financial Docs Is Different. Here’s the Chunking Strategy That Finally Worked.
Learn how to apply a structure-aware chunking strategy to improve RAG for financial documents, overcoming the limitations of generic 512-token chunks
Medium · RAG
📰
RAG: Every Data Type You'll Actually Run Into (Part 2)
Learn to handle real-world data for RAG by understanding common data types and preparing them for vector stores
Medium · LLM
📰
RAG: Every Data Type You'll Actually Run Into (Part 2)
Learn to handle real-world data for RAG by preparing it for vector stores, a crucial step in implementing RAG effectively
Medium · RAG
Up next
OpenAI Embeddings and Vector Databases Crash Course
Adrian Twarog
Watch →