Solving the "Lights Out" Problem

Ever run into this funny little puzzle? It appears in Legend of Zelda: Link's Awakening, LEGO Star Wars: The Skywalker Saga, and in a 1995 electronic toy called Lights Out. It turns out that this game has some pretty rich math. In this video, we'll learn about modular arithmetic and the matrix inverse. We'll also learn about substitution ciphers in cryptography, including the Hill Cipher.
Become a Patreon member: / physicsforthebirds
0:00 Intro
1:58 The Problem
6:10 Some Cryptography
8:52 Solving Each Puzzle
11:07 Your Linear Algebra Professor Was Wrong
14:38 Conclusion
Jaap's Puzzles Lights Out: www.jaapsch.net/puzzles/lomat...
Turning Lights Out With Linear Algebra: people.sc.fsu.edu/~jburkardt/...
Lights Out Online: www.chiark.greenend.org.uk/~s...
Modular Matrices: "Cryptography: A Primer", Alan G. Konheim Chapter 3.14-3.17
Hill Cipher Summary: www.math.utah.edu/~gustafso/s...

Пікірлер: 329

  • @mrphlip
    @mrphlip3 ай бұрын

    14:35 - "I'll leave it up to you to figure out of there are any more" When you try to Gauss-Jordan the matrix, you have a single row of zeros, so our null-space should have 1 dimension. Where, in this case, "1 dimension" means 3 options. The result is that only 1/3 of the initial starting states are solvable, and those that are solvable, are each solvable in 3 ways. You already mentioned the solutions [0, 1, 1, 2] and [2, 0, 0, 1], the third solution for our given starting state is [1, 2, 2, 0]. These are all achieved by taking any solution and repeatedly adding [1, 1, 1, 1], which has no net effect on the result.

  • @thecwd8919

    @thecwd8919

    3 ай бұрын

    Brilliant

  • @memesalldayjack3267

    @memesalldayjack3267

    3 ай бұрын

    i checked it, 0221 is a representation of how the puzzle looks like red blue blue yellow hit the 1st and all but the last change, hit the 2nd and all but the 3rd change, hit the 3rd and all but the 2nd change, hit the last and all but the 1st change 1st solution 1st column 0221 1022 1001 1001 2000 2111 2102 2111 2222 0200 2222 1211 2222 it checks out, nicely done i even repeated the 1111 solution 0221 1001 2102 0110 0221 it keeps resetting to 0221

  • @somegaiden

    @somegaiden

    3 ай бұрын

    I got super interested in the math behind these puzzles exactly from the Color Dungeon puzzle, so it's really cool to see it solved so easily and elegantly by linear algebra, including figuring out how and when multi-solution states like this pop up. Undertale Yellow has a 1x5 Lights-Out puzzle, and since it was just 32 states I found them by hand. I found half of the states were unsolvable and the other half had 2 solutions (Each pair linked by hitting all but the center switch [1,1,0,1,1]), which fascinated me, but I didn't know how to prove it. (My lin algebra is quite rusty and I didn't think to use it for this). But just now after doing some quick Gaussian elimination, sure enough the row [0,0,0,0,0|1,1,0,1,1] popped up like clockwork Big takeaway from this video: Never underestimate linear algebra. You never know when it'll make a problem 10x easier

  • @ValkyrieTiara

    @ValkyrieTiara

    3 ай бұрын

    I'm not much of a math person, but I do notice that if 1/3rd of states are valid and each state has 3 potential solutions, the result is still the "correct" number of solutions; ie the total solutions is the same as if ALL states were valid and had exactly ONE solution. I think that's pretty interesting!

  • @mrphlip

    @mrphlip

    3 ай бұрын

    @@ValkyrieTiara Yep, because the number of possible starting states is 3^4 = 81 (there are four lights, each of which can be one of three colours). And the number of possible solutions is also 3^4 = 81 (there are four things to hit, each of which you can hit 0, 1 or 2 times). The two are very closely related.

  • @boraturan5652
    @boraturan56523 ай бұрын

    I hope to take your linear algebra class one day. It sounds fun.

  • @adrianbik3366

    @adrianbik3366

    3 ай бұрын

    That assignment almost sounded like a threat :D

  • @pluieuwu

    @pluieuwu

    3 ай бұрын

    same here!

  • @uselesscommon7761

    @uselesscommon7761

    3 ай бұрын

    It is not

  • @a_soulspark

    @a_soulspark

    3 ай бұрын

    ​@@adrianbik3366 to me it sounded like a treat!

  • @Blancinnoir

    @Blancinnoir

    3 ай бұрын

    I had no idea this would turn out to be a maths class, so I initially found this comment confusing lol

  • @joehart3481
    @joehart34813 ай бұрын

    Oh golly. I was really excited to finally learn the general solution for these puzzles. Unfortunately, the part of my brain dedicated to linear algebra is deteriorating in a darkened basement with no stairs in a disused lavatory with a sign that reads "beware the leopard"

  • @gamemeister27

    @gamemeister27

    Ай бұрын

    Leper, as in someone with leprosy

  • @mekafinchi
    @mekafinchi3 ай бұрын

    About the outro, there's something of a fundamental shortcoming of education in that it's very difficult for most people to appreciate pure math. For most, you need to know what some mathematical tool does before you could appreciate it for what it is. But it's completely impractical to teach the applications before the tools they use - without the guarantee of preexisting knowledge of the tools, they'd have to be taught over and over during each application's course. But then to teach the tools in an application-agnostic way, no particular application can be explored in depth, and appreciation is left behind.

  • @TheMightyDozen

    @TheMightyDozen

    3 ай бұрын

    counterpoint: not every person is a pure mathematician most STEM undergrads, when they go to learn, they expect to learn whatever field they're enrolled in, not some random math topic they may have never heard of so at best such a student would believe there's a reason they're learning the math they're given, and that they'll use it later, and at worst they think they're wasting their time and energy on an irrelevant topic usually the truth is somewhere in the middle, and of course i neglected the M of that STEM: when you have a mathematics undergrad they don't necessarily care about application, and would usually be more about learning math for leaning math's sake, and then there's no problem now the question is what about pre-college math...

  • @mekafinchi

    @mekafinchi

    3 ай бұрын

    @@TheMightyDozenWe are in agreement. The typical student isn't going to see the applications when being taught the tools, and are thus disillusioned.

  • @flambambam3578

    @flambambam3578

    3 ай бұрын

    I learned a lot of calc 3 in my intro physics course (as a physics major) before I took the actual class the next semester. Literally all that I remember (and still currently use) is what I was taught in that first class.

  • @danieljensen2626

    @danieljensen2626

    3 ай бұрын

    I don't really think that's true though, in fact a lot of the applied math classes I took did include examples of why you might want to use a certain math tool, although some did that better than others. You can draw examples from any of the areas where the math topic is likely to be useful, and then it's more likely everyone will have at least one example that sticks with them. When I first took calculus our teacher set it up so we basically rediscovered calculus for ourselves. We started out by discussing some problem where we either needed to know the rate of change of something, or take a rate of change and figure out the total amount. We even started figuring out how we could approach the problems, and maybe started to figure out the answer for some simple case, and only then was he like "Just in luck, it turns out there already a tool for this, it's called a derivative/integral." I had almost not taken calculus because I didn't need it to graduate highschool. That teaching approach made me like math enough to go to college specifically to learn more math. Ended up double majoring in math/physics, and now I'm getting ready to schedule my dissertation defense for me physics PhD. All because of that teacher taking the time to show us why calculus was useful.

  • @elvinwisp

    @elvinwisp

    3 ай бұрын

    ​@@danieljensen2626Usually that's not the way math is taught, or at least in my experience. You're usually just taught what steps to do after other steps to get certain results, and it's not usually explained well enough to leave any lasting impression, sadly. It sounds like you got some great teachers and classes, though :]

  • @ohurspecial5404
    @ohurspecial54043 ай бұрын

    I am too excited for this silly number bird video

  • @rzeqdw
    @rzeqdw3 ай бұрын

    The ending of this video resonated with me. In college, linear algebra was the only math course I got bad grades in. It just didn't make any sense to me But over time, through watching channels such as this one, playing around with computer stuff, and reading some free online textbooks, I have built something of an intuition for it. It turns out that math is just taught really poorly in a lot of places, and when you can instead get intuitive explanations, anchored by practical applications, it's a lot easier to learn something

  • @MarioMastar

    @MarioMastar

    3 ай бұрын

    This. I flunked out of STEM and CS in undergrad (I do suspect racism may have been part of why but I won't get into that. One of the required professors did say "I will not pass his kind in my class" though), yet for 10 years I've been working in IT as a web developer and even a cloud developer for Microsoft for a few years with a Liberal Arts Degree. Personally I think that STEM should not be taught separately from Social Science, and in fact should better be mixed like my Masters program did. As if people don't know WHY we do the things we do and only teach the "WHAT" part, you fall into a lot of assumptions about the students that boil a logic class down to "Memorization and brute force". and all those math symbols fel more like gibberish at best and deliberately misleading for the sake of exclusion at worst. Though golly I will NEVER get the hang of matrix multiplication....and as a guy with a personal passion for image manipulation, I need to learn quick cause that's a MAJOR part of AI programming when it comes to images. Thank god for Python and people way smarter than me, but it's the rare case where I know how and why I need to use it, just not how...and fortunately that makes it easier to learn........ if videos would explain it better. XD (still not sure how vectors work in 3D space....how 3 numbers translate to an angle, length and direction. and GOSH do I need that for 3D stuff I want to build.)

  • @qwfp
    @qwfp3 ай бұрын

    Once again, you show how an advanced and seemingly abstract mathematical concept can be applied to situations encountered on the daily basis. That's why I'm here! So, thanks!

  • @Agrajag819
    @Agrajag8193 ай бұрын

    I’ve been using 5x5 Lights Out in the linear algebra class I’m teaching! What great timing for this video :D

  • @davidshi451
    @davidshi4513 ай бұрын

    It's funny that in practice, people avoid inverting (large) matrices, mostly due to time, memory, and numerical accuracy. John D. Cook wrote a nice blogpost on this, "Don't invert that matrix".

  • @05degrees

    @05degrees

    3 ай бұрын

    Yep when you have an equation it’s better not to invert the matrix but solve the particular equation. And if there are many equations A x = b₁, A x = b₂ and so on, then all bₖ can really be bundled into a big matrix and you again solve an equation A X = B just once. Which is also good when A is actually non-invertible (due to numerical shenanigans or other things), but you can use a method that gives you the closest thing to a solution which itself is unattainable.

  • @jyke321
    @jyke3213 ай бұрын

    Despite already knowing some of this as a comp sci student, I really enjoyed how this video was put together. Especially the very end when you describe your relationship with linear algebra. I am definitely not at the point where "I get it", and its frustrating, I'm actually taking the class for a second time, and although how to solve for things mechanically, I don't understand it all conceptually still. Honestly, the part on the determinant (something we just got to last week) was something I hardly understood the importance of with respect to invertible matrices, but it is neat seeing its application here.

  • @101arrowz
    @101arrowz3 ай бұрын

    Modular arithmetic with matrices also appears in the quadratic sieve, the fastest prime factorization algorithm for numbers under 100ish digits. One of the steps is essentially finding a linear dependency among a set of N vectors, each of length N, in GF(2). This boils down to finding the nullspace of an NxN matrix modulo 2, often using Gaussian elimination. I love that this silly-looking puzzle has so deep a connection to genuinely difficult fields in math :)

  • @tormodhag6824

    @tormodhag6824

    3 ай бұрын

    I love difficult math, it makes everything so much more interesting to work with

  • @angeldude101

    @angeldude101

    3 ай бұрын

    Integers modulo 2 is always fun to work with when programming since the bitwise AND and XOR operations are just component-wise (or one might say "SIMD"? 😉) multiplication and addition of vectors of integers mod 2.

  • @tormodhag6824

    @tormodhag6824

    3 ай бұрын

    @@angeldude101 i always loved how you can find the modulo 2 of a binary number without any calculations

  • @angeldude101

    @angeldude101

    3 ай бұрын

    @@tormodhag6824 Of course. It's as easy as finding the modulo ten of a decimal number. Or the modulo N of a base-N number. :P

  • @tormodhag6824

    @tormodhag6824

    3 ай бұрын

    @@angeldude101 yeah but computers, which are binary already have numbers in base 2 format so for base 2 its always that easy, just as easy as doing a odd or even check

  • @TheGodOfInsanty
    @TheGodOfInsanty3 ай бұрын

    Man math is great, it takes something you instinctually completely understand, and makes it totally incomprehensible

  • @TrashyDork
    @TrashyDork3 ай бұрын

    your videos have always (lovingly) been an exercise in seeing how far I can make it in before my understanding starts to fall off of a cliff. The parting segment makes me wonder if I should look into actually improving that for myself

  • @DaPigMasta

    @DaPigMasta

    3 ай бұрын

    Do it. What could it hurt?

  • @MarioMastar

    @MarioMastar

    3 ай бұрын

    I thought this would be a meme about zelda puzzle games. DId NOT expect a math lesson, but hey, I heavily respect it and did watch the whole video. Kind of a nice treat when these videos about games turn into an impromptu high level STEM lesson cause it's really fun to learn how these games work and realize there's some powerful logic behind it. Not just trivia like most game videos talk about. I think I learned more about memory manipulation from watching videos like "what happens after you beat tetris?/How do the slots work in Mario 3?/What determines RNG (numerous RNG videos)? etc).

  • @StopChangingUsernamesYouTube
    @StopChangingUsernamesYouTube3 ай бұрын

    As a kid I actually got a Lights Out for Christmas instead of a Gameboy (I wasn't the type to ask and was happy enough with it.) That thing prepared me for so many games down the line.

  • @hdswashere
    @hdswashere3 ай бұрын

    I'm glad you approached these puzzles formally. I've built Lights Out-style puzzles in Minecraft, but I didn't know they could be approached in this way. Well done!

  • @blue_birb
    @blue_birb3 ай бұрын

    I love your videos; just wanted to say that. I really do appreciate the things you upload; it's entertaining and thought provoking. I wish that some day I could look at the math problems I find in day to day life, gaming, or just thoughts of my own, and solve them the way you manage to do. I just need to acquire the right tools.

  • @Alceste_

    @Alceste_

    3 ай бұрын

    Yes.

  • @Tumbolisu
    @Tumbolisu3 ай бұрын

    Disclaimer: I'm not American, so my school experience is fundamentally different. I first learned about linear algebra in 12th grade. It was simplified, only talking about 2D or 3D math. We were just solving things like "What's the shortest distance between this point and this plane?". We rarely had to work with matrices, and one of the teachers only taught us about inverse matrices because there wasn't anything else left to do. Similarly, we learned about derivatives and integrals, always with the idea of solving specific questions. Using derivates as a tool to maximize/minimize a function, and that function could be the length of a curved fence given a few parameters. Stuff like that. In university, things quickly became simultaneously boring and stressful. I only had to take two purely mathematical courses, but they were by far the worst courses I have ever taken. Nothing but solving equations and writing proofs (ESPECIALLY writing proofs) without even a hint of a practical situation. I wrote 5 pages worth of proofs every week. My proofs were way too long, but there was no way to know what you can skip over without angering the prof, so it was always better to just write literally everything you could think of. I can imagine that anybody who was introduced to linear algebra this way will completely hate it. I love **using** math, but I still don't see why I had to do all of this nonsense of writing proofs. Like, I genuinely feel like I didn't learn anything in these math courses that I didn't already learn in school beforehand or learned by watching 3blue1brown's video series. I study computer science, btw.

  • @ivanjermakov
    @ivanjermakov3 ай бұрын

    Computer graphics with affine transformations is a very intuitive application of linear algebra.

  • @thespeedyyoshi
    @thespeedyyoshi3 ай бұрын

    I’m very lost but somehow watched the entire video before I realized it was done…so clearly you’re doing something right.

  • @AnimatedPlayer

    @AnimatedPlayer

    9 күн бұрын

    Same man, but I have set out to understand it . I will understand it and make it simpler for others , enabling the sharing of maths knowledge that had been previously locked behind complex algorithm and numbers

  • @spacenoodle8207
    @spacenoodle82073 ай бұрын

    I am learning linear algebra for the first time right now, and your videos are one of the few things encouraging me not to give up Thanks It is pure suffering for now though

  • @forever_stay6793

    @forever_stay6793

    3 ай бұрын

    Me too! I'm also suffering 😔

  • @mose3775

    @mose3775

    3 ай бұрын

    Real

  • @puckie643

    @puckie643

    3 ай бұрын

    Best of luck you guys!! Be the bright future we need :)

  • @MarioMastar

    @MarioMastar

    3 ай бұрын

    When you have something "fun" to apply the logic to, it's easier to learn the concept because you can think about these examples that interest you. Computer science got a lot more fun at the memory and hex manip level when took an AI corse in robotics and one of the assignments was using it to manipulate images. As an artist it was SUPER useful cause i could apply that to animation projects and save time on coloring. So that's where it really clicked for me and then it becomes cake.

  • @dotkomist
    @dotkomist3 ай бұрын

    Me: gets home at 2am after a 20hr day, prepares to sleep for another 20 Also me: *checks KZread, sees new PftB video is out* Me: sleep is for the weak

  • @anubhavkumarc
    @anubhavkumarc3 ай бұрын

    Linear Algebra is such a beautiful mathematical, when I first learnt about I thought it was just a tool to solve equations but every time you learn more about it it feels so much deeper. I also recommend people watch Gilbert Strang's 18.06 lectures on MIT OCW if they're starting Linear Algebra out, a lot of professors end up not teaching the concept well.

  • @asdfghyter
    @asdfghyter3 ай бұрын

    one fun thing i discovered when playing around with the puzzle is that a component of the solutions make up a cellular automation, where the number of clicks in each cell depends on the number of clicks in the cells in a plus shape above them. specifically, it’s what gives the answer to “if i click some of the top squares and then propagate it down, what pattern will the bottom squares have and what squares did i click on the way to make that pattern?”, which in turn can be used to find the LU-factorization or the inverse of the matrix, by using the fact that the matrix is already almost upper triangular you don’t actually have to solve the full matrix to get the optimal solution if the matrix is invertable, you only need to solve one of the edges and after that you can intuitively propagate the rest to the opposite edge

  • @mose3775
    @mose37753 ай бұрын

    I’m taking linear algebra for the first time right now; only a couple of weeks into the semester. It seems interesting, but like you said it’s kinda hard to see the big picture. I’m really glad I saw this video when I did. I’ll make sure to take the course again later from different perspectives!

  • @Buphido
    @Buphido3 ай бұрын

    There‘s a similar puzzle in Sonic Frontiers, at the end of World 1, with the light beam emitting pillars you have to rotate, and it has a nice mathematical solution as well. I commented the solution from any starting constellation under some video, along with the proof of why it works, and a KZreadr (I believe it was "Nintendo Switch Unboxing") saw it and asked for my permission to make a video on it, so that’s floating around youtube somewhere. But there are still people who don’t seem to be able to follow the instructions and claim that it doesn’t work. xD

  • @amazingdragon2767
    @amazingdragon27673 ай бұрын

    love every single video you put out! I took linear algebra recently, and a lot of the applications seemed boring but important, and you retaught this to me in a way that was both fun and useful!

  • @itsd0nk
    @itsd0nk3 ай бұрын

    As a producer and video editor, I’d usually say something like “this is some great content, but if you added some chill background beats, it would really elevate the project and make it more complete”, but these videos have such a distinct style by *not* including this element. It seems intentional, due to how well it works with your videos. So, bravo for knowing the rules before artistically breaking one... or for accidentally finding a distinct style 😂. Nicely done either way. It has a strikingly chill vibe the way you produce these.

  • @fonesrphunny7242

    @fonesrphunny7242

    3 ай бұрын

    We got a domestic series about crafting. Just some first hand explanation about the craft and usually some machine noises. No other audio. Music is just a distraction for people who can't focus on the presentation.

  • @itsd0nk

    @itsd0nk

    3 ай бұрын

    @@fonesrphunny7242 There’s a big difference between distracting background music and a properly edited music bed. Point was that he still has pristine audio in these vids, where you’d usually here soft well bedded music underneath, but that it works in a special way here.

  • @tedandzedrock
    @tedandzedrock3 ай бұрын

    “I can’t help but think that there’s some kind of interesting math here” and similar phrases get an instant sub from me because I know I’m about to learn something genuinely cool

  • @samuelumbaugh
    @samuelumbaugh3 ай бұрын

    I understood very little of Linear Algebra. Failed the course in undergrad, then had to work with it again in grad school for medical imaging. It finally clicked when I found a video about how they put the Line of Scrimmage and First Down Line on a football broadcast :) It's wonderful to see a similar experience from Zelda

  • @JerryFlowersIII
    @JerryFlowersIII3 ай бұрын

    Took me 60% of the video before I fully grasped how to understand the matrix. Might have to rewatch to fully grasp the rest of it. Interesting. My math education ends at 3rd year of Highschool with pre-algebra and I don't think I've heard of linear math before but I watch a few math channels on KZread and have a knack for math in general, just never pursued it.

  • @user-zo1kn8ob7h
    @user-zo1kn8ob7h3 ай бұрын

    very much like this. cadence, sonics, easement into deep concepts. this makes me feel hug

  • @reccaman
    @reccaman3 ай бұрын

    Once math can be applied, it just clicks for me. Sadly, i always had to go outside of school for it make sense. Im glad for channels like

  • @theawecat27
    @theawecat273 ай бұрын

    i loved this, your final explanation was really beautiful. matrices always scare me when they come up in math class and it's cool to see some ways they can be used, as well as seeing how they work in mod.

  • @Metros23
    @Metros233 ай бұрын

    This channel is gold! Great video and great explanation ❤

  • @Ri-ver
    @Ri-ver3 ай бұрын

    Same experience! Linear algebra through math...then electrical engineering..then quantum mechanics and beyond! So glad to see other people share that journey

  • @yasurikressh8325
    @yasurikressh83253 ай бұрын

    Very clear explanation. I love this vid 😊

  • @malcolmgruber8165
    @malcolmgruber81653 ай бұрын

    I started building a game around the lights out mechanic, changing patterns for what neighbors are affected. I added to the puzzle, non-affected blocks, and that was an interesting problem to solve for as the original maths solution will not solve for it.

  • @physics3632
    @physics36323 ай бұрын

    You’d be an amazing linear algebra teacher, each video you make helps open my eyes to more and more of maths true beauty. Thank you for this!

  • @sabotagedgamerz
    @sabotagedgamerz3 ай бұрын

    This video was really interesting and informative. I loved it

  • @TheDoctorAndALobster
    @TheDoctorAndALobster3 ай бұрын

    excellent ! you taught me modular right there, and the only other creator who made me "get" the maths that i got through cursus, was Michael Stephens. so thank you and congrats for the great vid as always

  • @bitten1406
    @bitten14063 ай бұрын

    I cannot describe how cool this is. I've already loved the lights out puzzle since a kid, and now I get this beautiful video with pretty drawings and a cool guy explaining the math (I love math) to me clearly!!!

  • @tzimmermann
    @tzimmermann3 ай бұрын

    I came upon this problem when I was a kid in an old Sega Genesis game called Light Crusader (and in Landstalker too, I believe). There's a grid of "switches" that can be in two states (cross and circles), when you hit them they swap symbol and so do their neighbors. And you have to put them all in the same state. I did not know linear algebra at the time of course, but I invented an algorithm to solve these puzzles. Just memorize which switches are not in the target state at step n, and hit them (independently of how they might change in the process), you get to step n+1 after hitting all the switches in your list. Iterate till done. Always works. I don't know how I came up with this, but it seemed natural at the time. Maybe I'll write a proof when I have some free time!

  • @3g0st
    @3g0st3 ай бұрын

    Another awesome video! I think you are a great teacher!

  • @besusbb
    @besusbb3 ай бұрын

    Nice video. I'm taking linear algebra proper for the first time now and I'm loving it so far for that my lecturer gave motivations behind concepts and that I sometimes have relevations about things I learned in the past that relates to it like solving minesweeper with LA and discrete Fourier transform, tho I can't yet claim that I have appreciated them to the fullest degree

  • @RoryDavidWatts
    @RoryDavidWatts3 ай бұрын

    Man this was a fantastic video, thanks

  • @plarfee
    @plarfee3 ай бұрын

    Man i just saw your video for the first time and im blown.i love how you know the fun of math and physics as i do a bit and nobody understands me

  • @ThatSkiFreak
    @ThatSkiFreak3 ай бұрын

    The absolute legend! He never misses!

  • @benruniko
    @benruniko3 ай бұрын

    Nice!! Beautiful work :)

  • @cheychc
    @cheychc3 ай бұрын

    This was such an interesting video!!!

  • @rabbitweasel
    @rabbitweasel3 ай бұрын

    I really enjoyed this. I came across the modulo issue of inversion in a non cryptography domain and found the referenced lights out paper as a solid reference. Then had the mentioned inverse issue that I was able to "handle" with linear combinations of the null space vectors to search through (some heuristical help too but not a deterministic process). It technically won't scale well with large null spaces but was consistent at solving problems in modulo space of non prime numbers for what I needed.

  • @grayfox2600
    @grayfox26003 ай бұрын

    That was a really cool video, thank you. I loved linear algebra when I took it in electrical engineering (and Link's Awakening is one of my all time favorite games). Thanks for reigniting my passion for the subject 😁

  • @RobBot00
    @RobBot003 ай бұрын

    Amazing. I took linear algebra about a year ago and this reinforced some of the fundamentals :)

  • @spaceface2918
    @spaceface29183 ай бұрын

    Taking math methods for physics and DEs rn and in math methods we are doing linear algebra review. I found this insightful and enjoyable, thanks!

  • @aurelia8028
    @aurelia80283 ай бұрын

    oh my god. I have been wondering about the math behind these kinds of puzzles for, like a year, and only now I just happen to find a video randomly about exactly this topic. Also the linear algebra here is pretty cool. I totally agree with you about only getting linear algebra once I took QM.

  • @42Tacos
    @42Tacos3 ай бұрын

    Right now I’m in Highschool so a lot of this goes over my head, but OMG ITS SO COOL! I enjoy watching your videos so much and I can’t wait until university when I’ll actually be able to understand them :)

  • @ebwvanced590
    @ebwvanced5903 ай бұрын

    For my electronics project in college I made the lights lights out game with wires, lights, and basic logic gates! Also my linear algebra experience was very similar to yours. Hated the class and it felt very contrived, but then it showed up in pretty much every class I took afterwards

  • @squorsh
    @squorsh3 ай бұрын

    Another very similar puzzle to this that shows up in many games is the rotary puzzle wheel. You need to line up all the rings in the same way but rotating one rotates some of the others

  • @NOMASTER1021
    @NOMASTER10213 ай бұрын

    Thanks so much, this was an amazing vid

  • @nameistaken
    @nameistaken3 ай бұрын

    Decades of playing games with this kind of puzzle has made me a genius of them to the point I can walk in and get the answer with the minimal number of moves brute force

  • @U.Inferno
    @U.Inferno3 ай бұрын

    This feels like a good segue into an RSA followup, which is also cryptography and modular arithmetic. But unlike Hill ciphers you cannot (easily) derive the decryption key from the encryption. Or more accurately, the encryption/decryption are not symmetric operations. I didn't take a cryptography class but it was a part of my compsci curriculum.

  • @shockthetoast
    @shockthetoast3 ай бұрын

    In Skywalker Saga, there is another Lights Out type puzzle. It's in the Yavin 4 base. I want to say it's 9x9 grid of tiles. The two positions for each tile are part of either the imperial crest or the rebel alliance crest. There's actually two puzzles on the same grid, to complete each crest, but with two different starting positions.

  • @TheUndeadFish1
    @TheUndeadFish13 ай бұрын

    I always brute forced the solution by memorizing the 2 lights on solutions on the 3x3, and for the 5x5 I solved from top to bottom by turning all the lights off, looking at the lights left on at the bottom and memorizing which lights to hit on the first row, then solved to the bottom lighting everything up on the way down. It might seem daunting, but using this method made only 7 configurations for child me to memorize for the 5x5, and 6 configurations for the 3x3. I played it way to much as a child, but was really fun solving the puzzle infront of friends later in life in other games by looking at the layout and "pressing" the lights in my head then hitting only the lights needed in seconds after finding what needed pressing.

  • @zirkq
    @zirkq3 ай бұрын

    amazing work

  • @dswcartoons
    @dswcartoons3 ай бұрын

    My sisters had that Lights Out handheld when we were kids. that thing was awesome. It also had modes were you could make your own design iirc.

  • @DolphinRepublic
    @DolphinRepublic3 ай бұрын

    love your videos!

  • @deltad3592
    @deltad35923 ай бұрын

    I can totally back the second bit, I started seeing linear algebra EVERYWHERE after my 1350 class in first year. It really put into perspective how useful any skill can be in seemingly unrelated fields!

  • @chillyman1459
    @chillyman14593 ай бұрын

    I loved matrix math in theory of elastic stability. What a beautiful merger of matrix math and calculus

  • @StephenRansom47
    @StephenRansom473 ай бұрын

    Excellent Lesson Mr Bird 🐦 The idea of teaching a thing till a student GETS IT, is a beautiful idea- the end of all teaching, really. 🥂

  • @connorsturgeon8863
    @connorsturgeon88633 ай бұрын

    im a senior in mechanical engineering, and sometimes i think about how math was taught to me in high school. i had some teachers that were really good at not only explaining how to do the math, but also its applications (i particularly really appreciated my old calc teacher). but i had some teachers who did such a bad job giving any kind of motivation as to why we were doing the kind of math we were doing. i remember learning the basics of linear algebra in 10th grade and wondering why on god's green earth we were doing numbers in boxes, and it wasn't until college that i realized how important and cool all that math was. but i look back now and wish that some of my teachers had done a much better job of conveying the importance and profundity of the subject they were teaching

  • @stagelights_
    @stagelights_2 ай бұрын

    i remember playing the mario rpg remake a few months back with a friend watching me play it, and i jokingly was like "hey its that puzzle thats in literally every video game on earth" when we got to the lights out puzzle. i've seen so many games with this puzzle, its ridiculous

  • @user-jc2lz6jb2e
    @user-jc2lz6jb2e3 ай бұрын

    To explain a bit about the determinant: It is a homomorphism. "Homomorphism" comes from Greek, meaning "same shape". Homomorphisms allow you to reduce a lot of information about a structure so you can start to see the similarities with a different structure. (See the "same shape") In this case, the determinant allows you to see the similarities between nxn matrices and the ring ("number system") that underlies them. That's why you have rules like det(A*B) = det(A)*det(B), det(I) = 1, and det(A^-1) = det(A)^-1. You are reducing these huge matrices into just a single "number" that encompasses a lot of their properties. Because of det(A*B) = det(A)*det(B) and det(I) = 1, the two defining properties of a homomorphism, if A has the inverse B, then det(A)det(B) = det(AB) = det(I) = 1, meaning det(A) has the inverse det(B). Written in another way, if det(A) has no inverse, then neither does A.

  • @TheBabelCorner
    @TheBabelCorner3 ай бұрын

    Although I understood Light Out game well beforehand, I still learnt new stuff in cryptography, thanks for your amazing video

  • @HotSauceBear
    @HotSauceBear3 ай бұрын

    The timing on this is really funny... just a couple weeks ago I learned about this area of linear algebra, and a few days ago, (around the time this video was uploaded!), I was watching a streamer struggle to complete one of those puzzles, and I thought that it can be applied... I didn't get any further than realizing that you don't need to press any more than once or that the order doesn't matter, though, before I got distracted and moved on. Great video, though.

  • @user-bw8ny3qg7i
    @user-bw8ny3qg7i3 ай бұрын

    Thank you, I never get to the 2nd part feeling about linear algebra. But I love all your video.

  • @qwe123337
    @qwe1233372 ай бұрын

    Hey, thanks for this video! I was able to finally solve my Rubik's Clock after all these years with the help from you and the paper you linked.

  • @ohno5559
    @ohno55593 ай бұрын

    I think the section at 11:07 is a bit misleading. The integers mod 3 are a field, so every nonzero element is invertible. It's just that -3 is zero. Taking the determinant of a matrix over a ring gives you an element of that ring, and in this case it's zero. Probably a better example would be, if you're working mod 4, a matrix with determinant 2 isn't invertible. 2 is nonzero, but it doesn't have an inverse since it divides 4. "A matrix is invertible iff its determinant is not zero" is true for all fields, but not for rings in general. So, it's also true for all vector spaces since a vector space is over a field (the Lego Star Wars one is a module). One neat thing is that you don't actually need any kind of specialized algorithm to invert these matrices, you can actually just find what the inverse would be over R and interpret it in the context of whatever ring you're in. This works because the mod map is a ring homomorphism from the integers to the ring of integers mod n. So for example, the inverse of the basic 4x4 legend of zelda one is 1/3 everywhere, except for where there are zeroes in the original, where it's -2/3. But in the context of the integers mod 2, 1/3 = (3 inverse) = (1 inverse) = 1, and -2/3 = -1 * 2 * (3 inverse) = -1 * 0 * 1 = 0. So after you invert you just get the original matrix back. But, mod 13 the inverse of 3 is 9 (3 * 9 = 27 = 1) so you'd end up with a different answer. Then this shows why the matrix isn't invertible when you look at it mod 3; all those (3 inverse) become (0 inverse) which is undefined. Obviously for this to work, though, your software that you're using to invert the matrices needs to leave everything as fractions rather than giving decimal approximations.

  • @lucianchauvin8587
    @lucianchauvin85873 ай бұрын

    A beautiful video! In linear rn and have been shown some cool applications

  • @PeperonyChease
    @PeperonyChease3 ай бұрын

    Great video. I think I first came across this puzzle in Black and White on PC

  • @puckie643
    @puckie6433 ай бұрын

    Yeah, I was (and still am) one of that kind of students. A Physics student that never got past that part of Algebra. I never got matrixes, I never got the determinant, I never got inverses and the applications. So much so that I failed the same class 5 years in a row and I couldn't get that subject ever again, so I unfortunately had to drop out from college. And to be honest, I kinda still don't, even though I can faintly grasp just how important it is for literally every other subject and outside of Physics (programming, engineering, and I guess cryptology now too, goddamn) This video at least did give me a small spark of hope that eventually "getting it" was possible, something I had completely given up on. Hope to become part of that other kind one day.

  • @kylepiddington6556
    @kylepiddington65563 ай бұрын

    Two minutes in and I’m hooked. I love games math

  • @dreadpiratery
    @dreadpiratery3 ай бұрын

    I did a computer science degree and it clearly wasn't enough to fully grasp this, but this is awesome

  • @notjerrett
    @notjerrett3 ай бұрын

    Great video as always! The only thing I would've liked to see you go more into depth with was how the modular inverse algorithm actually functions, though I know that wasn't really the point of the video.

  • @ducktormonty4603
    @ducktormonty46033 ай бұрын

    I failed last semester's Linear Algebra course and have to take it again this semester so it's interesting to see it applied to videogame puzzles... It certainly gives a new perspective to it...

  • @Amonimus
    @Amonimus3 ай бұрын

    I did think about it, but instead of matricies I was thinking closer to chart graphs. Similar to solving Tic-Tac-Toe, I was considering backwards what moves would turn the solution to the current configuration and going from there. It also helps that if one piece has all neighbours in the right position, unlike the sliding puzzles you no longer need to be concerned with them, so you can work on smaller scale first.

  • @danielh8261
    @danielh82613 ай бұрын

    After learning days for my algebra test tommorow, I get this zelda puzzle matrix video, thanks to the matrix videos i watched before. This is so funny and makes me a little bit happy to have this inbetween my math chaos.

  • @AZALI00013
    @AZALI000133 ай бұрын

    youre so cool thank you for making this video !!

  • @777themoose
    @777themoose3 ай бұрын

    I had a very similar experience with linear algebra. Once I used it for forward kinematics in robotics it all clicked for me. I really hope some engineers stumble upon your video as they're learning linear algebra so they can appreciate what they're learning.

  • @Kinkajou1015
    @Kinkajou10153 ай бұрын

    If I understood half of that, I'd go back in time to 1996, steal the Lights Out we had when I was a kid, and finally after all these years solve every puzzle in it. I was never able to solve every puzzle before the batteries needed replacing or it would get reset. I remember during bad thunderstorms a lightning strike being near enough could cause the game to turn itself on. I think that also reset it, I forget, it was nearly 30 years ago.

  • @klikkolee
    @klikkolee3 ай бұрын

    I've never been able to reason through a lights-out puzzle but I've always had an easy time with puzzles like the statues in Lego Star Wars. So it's pretty wild to see that they are variants of the same idea

  • @AuntBibby
    @AuntBibby3 ай бұрын

    i didnt understand any of the math in this video, but i guess its useful to know that in Lights Out puzzles, u never have to push a button as many times as it has states, or more times than that

  • @H0mework
    @H0mework3 ай бұрын

    There's a game that teaches programming called lightbot that does this too. I got stuck and hopefully after this I'll get the math for it too! Love your videos, I talk about turing patterns all the time now !

  • @jonathansiegel435
    @jonathansiegel4353 ай бұрын

    One of my math teachers in high school told us that Linear Algebra is the most applicable advanced math subject. As I took more coursework in Computer Science and Engineering, it just kept popping up over and over again.

  • @ThePenguinsKing
    @ThePenguinsKing3 ай бұрын

    This is cool. It’s awesome seeing linear algebra applied to solve video game puzzles. I’ve encountered the same puzzle in Genshin impact where cubes need to face the same direction

  • @diegoramirez7901
    @diegoramirez79013 ай бұрын

    Structural engineer here. Same thing happened to me with L.A. as freshman, then I had Structural Dynamics, Vibration Modes and Earthquakes. Later, the Jigsaw fell into place. Cool video

  • @xwtek3505
    @xwtek35053 ай бұрын

    13:08 Yes, this formula works for any field. You just calculated the determinant wrong. The determinant for that matrix is 1 for mod 2, and 0 for mod 3 case. It needs a slight modification for the more general case, commutative rings. You need the determinant to be invertible. So, the determinant of it the matrix is 1 for the mod 4 case, which is also invertible

  • @ObiwanNekody
    @ObiwanNekody3 ай бұрын

    This is the favorite puzzle type in Dungeons and Dragons online.

  • @jasminepsiidmon321
    @jasminepsiidmon3213 ай бұрын

    Another example of a modulo 3 puzzle in videogames is the death game escape room series Zero Escape - its third game Zero Time Dilemma has one with limited moves available in the 'relaxation room' escape room. You change flowers on a holographic calendar (a 3 x 4 grid) between seeds, budding and blooming - with a limited move counter if I recall correctly.

  • @biggiecheez6879
    @biggiecheez68793 ай бұрын

    Another banger

  • @noahdoss1967
    @noahdoss19673 ай бұрын

    I will share this with my proper linear algebra class next time. I teach a very basic linear algebra class every year and a proper linear algebra class once every 2 years or so

  • @AlphaPhoenixChannel
    @AlphaPhoenixChannel3 ай бұрын

    I'm going to date myself here by saying LA was my first Zelda game and I played it on a GBC, but I STILL remember that color dungeon puzzle. it was hard! after the previous room was so much simpler to teach you the mechanics, I think I went in pretty gung ho and just started hitting stuff in a horrible asymmetric way and got the whole board state completely messed up. once I finally got it back to symmetric, I think I just took random 2-fold or 4-fold actions until it happened to work by chance, not that i knew what "2-fold" or "4-fold" meant... At least once I think i got it to all red and was very happy with myself until realizing it actually needed to be all blue. There was this moment where I sat and tried to figure out how to invert the entire board from red to blue, and I want to say I attempted hitting every node once, then realized that they all have different connectivity and that didn't do it. Considering I was probably like 8 and still remember this thought process - the puzzle made an impression xD Great analysis!