How can a jigsaw have two distinct solutions?

Поделиться
HTML-код
  • Опубликовано: 17 сен 2024
  • Learn more about Jane Street’s internship opportunities: jane-st.co/SUM...
    Check out Steve’s video: • This new type of illus...
    This is Ryan’s Diffusion Illusions site: diffusionillus...
    And here is the full “Diffusion Illusions: Hiding Images in Plain Sight” paper by Ryan Burgert, Xiang Li, Abe Leite, Kanchana Ranasinghe and Michael S. Ryoo. diffusionillus...
    Download of the jigsaw: www.dropbox.co...
    Here’s the layout of the different edge types: www.dropbox.co...
    Huge thanks to my Patreon supporters. They provide all the valid solutions I need. / standupmaths
    CORRECTIONS
    - None yet, let me know if you spot anything!
    Filming by Alex Genn-Bash
    Editing by Gus Melton
    Written and performed by Matt Parker and Steve Mould
    Produced by Nicole Jacobus
    Music by Howard Carter
    Design by Simon Wright and Adam Robinson
    Dice on loan from the Bec Hill collection
    MATT PARKER: Stand-up Mathematician
    Website: standupmaths.com/

Комментарии • 1,1 тыс.

  • @standupmaths
    @standupmaths  3 дня назад +135

    Jane Street's paid internships are amazing! Tell people graduation by 2026/2027. jane-st.co/SUM-internships
    And yes, I'll visit at least the Hong Kong interns this June 2025. Maybe other Jane Street offices as well.

    • @Deragaergadgfadsfasd
      @Deragaergadgfadsfasd 3 дня назад +3

      I think M.C. Escher would have loved all this, especially the bit about assembling the puzzle. 🧩

    • @wbfaulk
      @wbfaulk 3 дня назад +3

      What exactly is "quantitive trading" (24:16) and how does it differ from "quantitative trading"?

    • @AexisRai
      @AexisRai 3 дня назад

      Anyone interested in jigsaw puzzles and pure deduction should look up the puzzle "Cornered" by game developer Portponky.

    • @cicik57
      @cicik57 3 дня назад +1

      nice puzzle, sorry very bad programming :D

    • @smithsmith6402
      @smithsmith6402 3 дня назад +3

      I would desperately love to see this image generation applied to a Hexaflexagon for multiple finished images in the various configurations.

  • @IceMetalPunk
    @IceMetalPunk 3 дня назад +2502

    Matt: "I wrote some terrible Python code."
    Me: "You're always so hard on yourself, Matt. I'm sure it's not *that* bad."
    Matt: "It brute-forces a combinatorics problem by exploring millions of permutations for guess-and-check at every iteration."
    Me: "...why must you Parker it again?"

    • @MatheusC1729
      @MatheusC1729 3 дня назад +232

      Matt wrote MiracleSort Wikipedia page

    • @sixty502
      @sixty502 3 дня назад +109

      this would be so faster if it included not rechecking the same permutation twice...

    • @bawilson999
      @bawilson999 3 дня назад +77

      I'm a seasoned developer. Heavy use of copying data and recursion will kill performance. Especially in interpreted (managed) languages like Python.

    • @bandana_girl6507
      @bandana_girl6507 3 дня назад +117

      Hey, the *code* isn't terrible, it's the algorithm

    • @billybionicle
      @billybionicle 3 дня назад +65

      ​@@bawilson999thats like pointing out there's chip in the paint of a car when the entire engine is missing

  • @NigelMelanisticSmith
    @NigelMelanisticSmith 3 дня назад +2119

    "Terrible Python Code" is at "Say The Line, Bart" levels by now lol

    • @brianphelps2415
      @brianphelps2415 3 дня назад +87

      I'm not complaining, it helps me with Parker Bingo!

    • @RavenMobile
      @RavenMobile 3 дня назад +48

      Maybe bad Python code should be called Monty Python code.

    • @guiorgy
      @guiorgy 3 дня назад +16

      Parker Code?

    • @1st2nd2
      @1st2nd2 3 дня назад +5

      Cowabunga!

    • @vincentpelletier57
      @vincentpelletier57 3 дня назад +5

      I didn't do it.

  • @SJrad
    @SJrad 3 дня назад +1510

    Topologically consistent jigsaw puzzle

    • @aleksitjvladica.
      @aleksitjvladica. 3 дня назад +47

      What everybody thought but as a sentence.

    • @Supermath101
      @Supermath101 3 дня назад +34

      You forgot to add the adjective "bistable" to the phrase.

    • @seventoast
      @seventoast 3 дня назад +3

      I am pleased that someone beat me to this comment 😂 What an audience Matt has

    • @hilburn-
      @hilburn- 3 дня назад +22

      I think they should be called "ambigsaws"

    • @gm2407
      @gm2407 3 дня назад +3

      ​@@seventoastI am pleased there are so many topologist comments.

  • @Thagrynor
    @Thagrynor 3 дня назад +789

    The look of Matt's soul dying just a little when Steve uttered the phrase "public code review" is priceless lol .....

  • @Rubrickety
    @Rubrickety 3 дня назад +1191

    I wrote what I thought was improved code for this problem, but when I ran it the lights on my Christmas tree went insane.

    • @LeeAnnC
      @LeeAnnC 3 дня назад +16

      😆

    • @dinhero21
      @dinhero21 3 дня назад +3

      I don't get it, are you referring to the quality (or lack thereof) and inconsistency (not really the word I was looking for but whatever) of the original code?

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад +13

      ​@@dinhero21 or perhaps the lights are flickering on and off in an attempt to create two distinct patterns simultaneously?

    • @user-hm6hv3qh2r
      @user-hm6hv3qh2r 3 дня назад +125

      @@dinhero21I think he’s refering to when a fan made matt’s code like a billion times better, and that fans made programs to light his christmas tree

    • @patu8010
      @patu8010 3 дня назад +2

      I thought it was a reference to Stranger Things. Like your code was so cursed, your house is haunted now.

  • @ares395
    @ares395 3 дня назад +888

    Oh I can't wait for the "a viewer made my code *obscene number*% better"

    • @Thk10188965
      @Thk10188965 3 дня назад +14

      Fairly sure that is a past video. Possibly with christmas lights if I remember correctly

    • @3nertia
      @3nertia 3 дня назад

      @@Thk10188965 That's the joke!

    • @EggBastion
      @EggBastion 3 дня назад

      @@Thk10188965/videos Yes, it's referenced right here in the video 12:48, but it'll happen again. Believe me. Unless Matt really turns a number of corners with his coding... it'll happen again.

    • @TheRenegade...
      @TheRenegade... 3 дня назад

      @@Thk10188965 You're thinking of "Someone improved my code by *obscene number*%". Completely different concept

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад +35

      If he makes code that doesn't work, and a random guy improves it to make it work, we can just say the guy improved his code by ∞% which is probably the ultimate victory.

  • @Zarunias
    @Zarunias 3 дня назад +361

    And now I wish that a jigsaw publisher takes this concept and publish a little series of these with different pictures.

    • @KenLieck
      @KenLieck 3 дня назад +9

      JIGAZO from Hasbro.

    • @danhorus
      @danhorus 3 дня назад +28

      Somebody call Karen Puzzles

    • @Stratelier
      @Stratelier 3 дня назад +23

      As a kid, I could've sworn Mom had a jigsaw puzzle which advertised the ability to assemble it in like six different ways (including a semblance of the Mona Lisa). And this was back in the 80s. I think the picture(s) had a square-tile-based mosaic aesthetic, with colors ranging from black to brown to orange to yellow.
      BUT as a childhood memory it is unreliable at best ... unless, of course, I actually find it again.

    • @AdnanAli-rb3lt
      @AdnanAli-rb3lt 3 дня назад +4

      ​@Stratelier it might be Tenyo Jigazo. Not sure how old that puzzle is

    • @KenLieck
      @KenLieck 2 дня назад +1

      @@AdnanAli-rb3lt 2010.

  • @pseudo_goose
    @pseudo_goose 3 дня назад +363

    The Python code isn't as bad as the "version control"

    • @Bobbias
      @Bobbias 3 дня назад +30

      I felt a chill run up my spine when I saw that.

    • @lindhe
      @lindhe 3 дня назад +1

      Love that! 😂

    • @hentielover
      @hentielover 3 дня назад +32

      At first I though Matt implemented some sort of version control software for whatever reason, so I thought "Sounds kinda difficult, it makes sense that it would suck", but then I read your comment again and understood that you meant 16:18, where you can see the interesting "version control"

    • @v0id_d3m0n
      @v0id_d3m0n 3 дня назад

      oh lord

    • @icefreez3r815
      @icefreez3r815 3 дня назад +1

      amongus

  • @aidenkoh2426
    @aidenkoh2426 3 дня назад +85

    I love that the mathematician in you felt the need to say “distinct” in the title.

  • @apokatastasian2831
    @apokatastasian2831 3 дня назад +393

    this has made me question every puzzle i've ever assembled. what lovecraftian horror, or forbidden knowledge eluded perception once again, simply because i followed the picture on the box

    • @nikkiofthevalley
      @nikkiofthevalley 3 дня назад +36

      Nothing, because all normal jigsaw puzzles will only have one solution.

    • @5thearth
      @5thearth 3 дня назад +99

      Fun fact: companies often reuse cutting patterns on different puzzles, so two puzzles with different images may have pieces of the same shape. So you can mix the pieces from one puzzle with another and make a combination image.

    • @bzboii
      @bzboii 3 дня назад +4

      goated comment

    • @wintersxlstice21
      @wintersxlstice21 3 дня назад +9

      this would be an awesome scp

    • @dinklebob1
      @dinklebob1 3 дня назад

      ​@@nikkiofthevalley Look up The Magic Puzzle Company. Technically different (and certainly not normal), but still mind blowing.

  • @WizoML
    @WizoML 3 дня назад +103

    Even though it gets called terrible python code, I think this is a beautiful thing about python that lets people solve interesting problems with computing power. Putting optimization aside, 1. the problem statement and 2. an approach to solving it both show incredible creativity on Matt's part. That's why people click on the video in the first place. I'd be proud of writing "terrible" python code that can actually solve an interesting problem.

  • @Imperial_Squid
    @Imperial_Squid 3 дня назад +267

    16:44 it causes me physical pain to see Matt naming his python files the way people label their English essay drafts lol

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад +3

      What would you name yours?

    • @LethalChicken77
      @LethalChicken77 3 дня назад +11

      Honestly still better version control than github 😂

    • @bigsmoke6414
      @bigsmoke6414 3 дня назад +52

      ​@@LethalChicken77lol no

    • @Anohaxer
      @Anohaxer 3 дня назад +3

      amongus

    • @stefanalecu9532
      @stefanalecu9532 3 дня назад +15

      ​@@LethalChicken77 you're as """good""" of a programmer as Matt is with that opinion

  • @SupercriticalSnake
    @SupercriticalSnake 3 дня назад +311

    5:18
    Person with a British accent: Open source.
    My brain: Mmmm.... open sauce.

    • @bacon.cheesecake
      @bacon.cheesecake 3 дня назад +42

      William Osman has a convention for you

    • @MichaelPiz
      @MichaelPiz 3 дня назад +3

      Language barriers are fun. 😁

    • @ares395
      @ares395 3 дня назад +6

      @@MichaelPiz That's not... relevant here...?

    • @jameswise9171
      @jameswise9171 3 дня назад +15

      @@ares395The distinctions between language, dialect, and accent get VERY blurry

    • @gswcooper7162
      @gswcooper7162 3 дня назад +21

      I, a British person: Wait, you pronounce "sauce" and "source" differently?

  • @not_David
    @not_David 3 дня назад +380

    I’m about half way through the video and really loving it but I’m starting to think/realize that years of blender donut tutorials have really done some irreparable psychological damage…

    • @chemistrymickey
      @chemistrymickey 3 дня назад +25

      Oh my gosh, not_David! I love your maths videos too!

    • @WoolyCow
      @WoolyCow 3 дня назад +20

      rare footage of an elusive not david spotted in the wild!

    • @oyora
      @oyora 3 дня назад +9

      sprinkles 🥹

    • @mtarek2005
      @mtarek2005 3 дня назад +4

      those blender donuts!!!

    • @Brandon-oc8lr
      @Brandon-oc8lr 3 дня назад +2

      I can’t look at a sprinkle donut without a shiver going down my spine

  • @Sjoerd-gk3wr
    @Sjoerd-gk3wr 3 дня назад +410

    they are 2 donuts I dont see the difference

    • @mimasweets
      @mimasweets 3 дня назад +4

      Lol

    • @XxKilleredxX
      @XxKilleredxX 3 дня назад +30

      I don't even plan on watching this video until later; just came here to make sure someone made this joke.

    • @Carbon_Crow
      @Carbon_Crow 3 дня назад +42

      We found the topologist!

    • @Fanny-Fanny
      @Fanny-Fanny 3 дня назад +22

      That is no way to speak about these two announcers 😉

    • @orterves
      @orterves 3 дня назад +16

      Nonsense, those are two coffee mugs

  • @wiiza4ever
    @wiiza4ever 3 дня назад +77

    If we don't require the edge of the jigsaw to be straight, there should be a pleasant cut that achieves the rotating square effect from Steve's demonstration.

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад

      With all those holes and lumps, we can say they're already not straight, so let's do it.

    • @lrizzard
      @lrizzard 3 дня назад +11

      if the puzzle includes false edges, it might be possible to have both have straight edges with different edge pieces. but that makes it very complicated

  • @NonTwinBrothers
    @NonTwinBrothers 3 дня назад +122

    A simple 'context' or 'result' would do, but Matt books it with SPUD.
    Very on brand

    • @baksatibi
      @baksatibi 3 дня назад +9

      It reminds me of how you make a non-tail recursive function tail recursive. It doesn't really matter because jigchecker is a backtracking algorithm so it uses the call stack to store state and Python doesn't support tail call optimization anyway.

    • @johnrehwinkel7241
      @johnrehwinkel7241 3 дня назад +2

      Every time it has a vision, it adds an eye. So eventually you end up with a potato with many eyes, or the Lovecraftian horror @apokatastasian2821 mentioned.

    • @HaloInverse
      @HaloInverse 2 дня назад +2

      "It took _how_ long to complete? What are you running your code on, a potato?"

  • @larspos8264
    @larspos8264 3 дня назад +127

    Now we want a three solution jigsaw puzzle

    • @SupremeInvigilator
      @SupremeInvigilator 3 дня назад +1

      Infinitely many!

    • @d3vitron779
      @d3vitron779 3 дня назад

      @@SupremeInvigilatorpixels

    • @dropkickedmurphy6463
      @dropkickedmurphy6463 3 дня назад +2

      Yes, a puzzle with n solutions

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад

      ​@@SupremeInvigilator would you need to break the initial photo into a continuum?

    • @terry_the_terrible
      @terry_the_terrible 3 дня назад +4

      I think it would be much easier to find a 4 solution puzzle rather than a 3 solution puzzle.

  • @NolieRavioli
    @NolieRavioli 3 дня назад +88

    my 4k video buffered for a minute when you introduced the noise to the screen thats pretty epic

    • @bacon.cheesecake
      @bacon.cheesecake 3 дня назад +22

      Being a mess with no patterns, noise is really hard to compress, so it takes a lot more data than video of a couple blokes sitting in front of a still background

    • @OmateYayami
      @OmateYayami 3 дня назад +9

      Ooohhhhh, so that's why the video stuttered... I thought I need to check my WiFi signal and router antenna lol.

    • @NolieRavioli
      @NolieRavioli 3 дня назад +2

      @OmateYayami I thought it was part of the video for a couple seconds, ngl

    • @dielaughing73
      @dielaughing73 2 дня назад

      That's entropy for ya

    • @NolieRavioli
      @NolieRavioli 2 дня назад

      @@dielaughing73 what's entropy?

  • @genericgamer2003
    @genericgamer2003 3 дня назад +131

    Haha 12:48 poor Matt is never going to live down the fourty billion percent increase in code efficiency

  • @dojelnotmyrealname4018
    @dojelnotmyrealname4018 3 дня назад +63

    Fun fact: Jigsaw puzzle makers often reuse cuts. So you can replace pieces of one jigsaw pieces with pieces of a different jigsaw puzzle, as long as they have the same amount of pieces and came from the same manufacturer.

    • @dankeseb4825
      @dankeseb4825 3 дня назад

      A point noticed by Dave Gorman (and family members who receive jigsaws as gifts from him) 😊
      ruclips.net/video/wRxslt5XLnk/видео.htmlsi=e3BqV5yiTEX6sLFG

    • @amarissimus29
      @amarissimus29 2 дня назад +2

      And the same picture on them.

    • @richardking4514
      @richardking4514 2 дня назад +8

      ​@@amarissimus29There's a fun series where someone combined two puzzles at a time to make creative mashups. I just did a quick search, the artist is Tim Klein.

    • @Caltor_Storm
      @Caltor_Storm 2 дня назад +2

      Dave Gorman did it too in Modern Life is Goodish

  • @Dalemoooooon
    @Dalemoooooon 3 дня назад +40

    "Technically, there is a better one out there"
    So is this one the Parker Puzzle? Close to perfect, but not quite.

  • @brandyballoon
    @brandyballoon 3 дня назад +13

    As a software engineer currently studying intelligent systems and path finding search algorithms at post graduate level, this was fascinating and has given me a new problem to attack! Often the greatest challenge with something novel like this is figuring out how to make it fit an established algorithm. Sometimes you have a "oh it's just that one in disguise" moment, other times it truly is a unique problem.

  • @matthewmilunic612
    @matthewmilunic612 3 дня назад +165

    The hidden joke that to a mathematician a coffee mug and a donut are the same is very sneaky.

    • @andrasbiro3007
      @andrasbiro3007 3 дня назад +15

      You can tell he's a mathematician, because he used a coffee mug instead of a teapot (famous computer graphics object).

    • @elementw74
      @elementw74 2 дня назад +3

      @@andrasbiro3007 A teapot has a genus of 2 (handle + spout) while donuts and mugs have a genus of 1 (handle), so the joke would fall apart.

  • @Ryan25116
    @Ryan25116 3 дня назад +19

    'Matt Parker - lower third enthusiast' while placed in the lower third is a deep level of humor that tickles my brain in just the right way

  • @geothermie_
    @geothermie_ 3 дня назад +64

    Now I want to see the version with 10 solutions : the mug and the donut plus
    - A mario pipe
    - A watch
    - An unknnot
    - A top hat with the closing part ripped like in old disney shorts
    - The chaos emerald minigame from sonic 3
    - The twisty scares on a 2x2 grid
    - A pair of trousers with one leg knotted (bc why not?)
    - A squircle
    (I would have loved to find all 15 of them but that's all for me)

  • @oasntet
    @oasntet 3 дня назад +95

    It's an interesting application of AI, but I wonder if an artist could now step in and drastically improve both solutions, using a drawing application that shows both permutations side-by-side.

    • @hoebare
      @hoebare 3 дня назад

      I would love to see that process and hear the artist's thoughts before, during and after.

    • @Bedinsis
      @Bedinsis 3 дня назад +17

      Probably someone like John Langdon (who made the ambigrams for the Dan Brown novel Angels and Demons).

    • @lucbloom
      @lucbloom 3 дня назад +15

      That tool exists, in Steve’s video. Need to find the artist.

    • @geekjokes8458
      @geekjokes8458 23 часа назад +1

      it's not exactly the same, but it reminds me of those drawings of like "how many people" where you move something and count, then there are 11 or 12... (i think there's even a numberphile video on that)

    • @eragon78
      @eragon78 23 часа назад

      It would be extremely difficult, but maybe its possible.

  • @mikerich32
    @mikerich32 3 дня назад +23

    1:11 this needs to become a meme, I swear 😂

  • @uninable
    @uninable 3 дня назад +35

    I enjoy the unnecessary rotoscoping on Steve's hand and the mug at 1:43

    • @MichaelJM
      @MichaelJM 3 дня назад +9

      Ha nice catch. I appreciate it though. Makes for a cleaner video. I didn't even notice.

    • @MichaelDarrow-tr1mn
      @MichaelDarrow-tr1mn 3 дня назад +3

      Pretty sure that's done with luma keying

    • @gus_melton
      @gus_melton 3 дня назад +2

      ⁠@@MichaelDarrow-tr1mn my money is on roto

  • @LinusBoman
    @LinusBoman 3 дня назад +56

    In and out combos? I prefer the technical term "knobbly bits".

    • @lrizzard
      @lrizzard 3 дня назад +1

      oh it's you!

  • @konstanty8094
    @konstanty8094 3 дня назад +13

    The code is good if it does the job if you don't intend to reuse it.
    some simple fixes:
    - instead of int(a/b) you can do a // b
    - instead of using lists to represent the pieces, you can use tuples (they are easier on the memory)
    - instead of putting a large portion of code in the body of `if candidate_poential`, you can do `if not candidate_poential: continue` to make the code less nested.

    • @daniel.lupton
      @daniel.lupton День назад +3

      You could massively save time with a bit of numpy. Start by representing each "pair" as a byte where they are each other's compliment (bitwise inverse). It would fit in a byte or even a nibble.
      Then you can pre-calculate an array of the top-two edges of every price in its four orientations (so 25x4 or 100 bytes/16-bit uints). Then for each iteration of the "checker" all it needs to do it concat the left and top edge for that slot and then bit-wise OR against the array. Then logical NOT the result and you'll have a logical array of every match.
      If you pass down a list of "already used" indicies (or a boolean array) then you don't have to copy the puzzle or the pieces with each recursion step.
      Finally, wrap the whole thing up in a numba decorator so it can JIT-compile the recursive part of the function and you've got a ~1000x speed improvement without changing any of the behaviour or doing anything particularly fancy.
      Of course the best way to save time would be to turn the problem on its head and generate a puzzle with the properties you want rather than find one in randomness. Matt's approach is the equivalent of trying to generate a sudoku puzzle by randomising all the numbers and checking if it's still valid. It's conceptually easier but so many orders of magnitude slower.

  • @Yatornado
    @Yatornado 3 дня назад +13

    One obvious optimisation if you haven't done so. When you fit a piece it only depends on the pieces to the left and to the top. You could've precalculate answers to each combination of 3 pieces incliding empty space (26*25*24 combinations) and get a precalculated answer instead of computing them each time. All this rotations etc done only 26*25*24 times instead of 25! times.

  • @MeisterKleisterHeisstEr
    @MeisterKleisterHeisstEr 3 дня назад +5

    This reminds me of an idea I read in a philosophy book. It's theoretically possible via radical translation to create two very different dictionaries of some foreign language x, both equally valid. The book also contained a 4x4 crossword puzzle that had 2 possible solutions. He called it a "Quinian Crossword Puzzle", in case you wanna look it up.

  • @furbyfubar
    @furbyfubar 3 дня назад +8

    I feel like I'm *probably* missing something crucial here? Couldn't this problem be solved with just pen and paper? If we select two different piece orders that are sufficiently different and then simply pair up the edge shapes so that we have the 7:50 "terrible way to do it" of having each edge fit in exactly two places?
    If we do that naively I can see that we will run into one issue with parity, but I think I found two different ways around it. So here's my best solution explained with way more words:
    1. We start with a single jigsaw layouts with all (non edge/corner) pieces have alternating innie and outie edges when going around the piece. Let's say all innies are identical for now so pieces can be moved around.
    2. We then move around and rotate the pieces so that we break up as many edges as possible. But we take care to preserve the the parity of innies and outies. A rotation of 90 degrees changes the parity, as does one more left, right, up, or down. If we want to be able to swap corner pieces around this means that we need a puzzle size that has an even number of pieces along each side, so 5x5 is out. But that's OK, I'm looking to draw a proof of concept on paper, so 2x2 is probably a better size to start. Let's name the pieces ABCD in reading order and make a terrible ASCII representation that youtube not having uniform character width will no doubt mess up. (You can copy paste this comment to notepad if you need to make it easier to read.)
    A | B
    -----
    C | D
    3. Let's number all the (non-straight) edges of the pieces. Since we care about innie and outie, (as an innie can't become an outie when later make some edge shapes identical), we make all the innies even numbers and all the outies odd numbers.
    A1|2B
    4 | 5
    -----
    3 | 6
    C8|7D
    In the ASCII above I'm *trying* to show that I made the pairs (1,2) (4,3) (5,6) (8,7) connect.
    4. So having drawn up a 2x2 jigsaw it looks like any corner piece can now be moved to any other corner; the rotation to make the corners be rotated correctly to still end up with a square puzzle afterwards works out for the parity of having the innie and outie edges always stay in the same place on the grid. This should still work for any jigsaw size where the side lengths are even.
    5. Time to move some pieces: So we have 4! possible orderings on the 4 pieces. But 4 re-orderings are out since they either *are* the original ordering, or a rotation of it. So we now semi-arbitraryly select to swap places of the top two pieces, and then also swap places of the bottom two pieces. This isn't obvious without drawing it, but this means all original connected edges have been broken up.
    This gives us:
    B5|4A
    2 | 1
    -----
    7 | 8
    D6|3C
    All the pieces are now moved and rotated 90 degrees, and our new edge pairs are: (5,4) (2,7) (1,8) (6,3). As all the odd numbers are still in positions where they were odd before we haven't accidentally changed any innie to be an outie.
    6. This means that to make our four piece jigsaw with two solutions we should only need to make these edges be identical:
    (1,7) (2,8) (3,5) (4,6)
    So, am I missing something? Is there some reason why this couldn't scale up to a puzzle of bigger size?
    Oh right, I wrote that I found two different ways around the parity issue. The other solution is to make it so that each edge shape is rotationally symmetrical. But this means that all edges are both innies and outies, so that solution didn't feel like it was in the spirit of the problem Matt was trying to solve.

    • @georgelionon9050
      @georgelionon9050 3 дня назад +3

      I'm thinking the same, the problem is solveable manually, just first make up which pieces you want to switch, then draw the in/out edges as duplicates of those edges, every pair with a unique in/out.

    • @Txyxy1
      @Txyxy1 2 дня назад +1

      You can try it, but I guess you would end up with puzzle that has more than two solutions.

    • @furbyfubar
      @furbyfubar 2 дня назад +2

      I just drew up a 4x4 example to see if you were right. You don't seem to be, but proving that it can't happen with any rigor isn't all that easy. Or not easy enough that I'm about to get nerd sniped into trying to do it at 1:40am. I can tell for sure that the first quick 4x4 example I drew up only has two unique solutions though.
      I can sort of see why you'd think that it might cause multiple solutions though, as each piece goes into subgroup of spaces it can be moved to. (For 4x4 the groups are: Corners, even edges, odd edges, and middles. The two edge groups can't swap between each other without swapping innies for outies. For a bigger puzzles the number of subgroups seem to stay at 4 though.) So I agree that it *feels* like this might mean that since the multiple smaller subgroups will have to have their own loops/swaps of what pieces they trade places with, these groups could be independent for the solutions as well creating multiple unintended solutions. But that would only be true if puzzle pieces only had a single edge each. Since each puzzle piece has 2 to 4 edges each decision you make force the decisions for other edges.
      So the way it actually works out is that since each edge is only possible to connects to two other edges, once you select two pieces to connect, this leaves some other piece with only one possible connection. So since that connection is forced we make it. But using that piece removes the only possible connection from some other piece and so on. (The thing I can't prove with much rigor is that this *always* happens no matter what swap choices I make for the two solutions.)
      Or the other way to look at it: If I connect two edges that only go together in the first solution and I also connect another edge on one of *those* pieces with an edge it only goes with in the seconds solution I will quickly run into a contradiction where some edge either needs to be connected to two different edges, or it will lead to some unused edge that won't have any legal connection left.

  • @lexbailey
    @lexbailey 3 дня назад +6

    14:15 "fade from reality" is my new favourite synonym for "terminate"

  • @thefoxoverlord
    @thefoxoverlord 3 дня назад +38

    i wonder if you could make an art program that shows two simultaneous viewports, one in each puzzle arrangement, of the same canvas, so that you could draw both solutions at the same time

    • @egodreas
      @egodreas 3 дня назад +20

      There are many image editing applications that can apply ST maps and show both the original and remapped image. I work in VFX, and can do it with the industry standard compositing application called Nuke, for example. And I can paint on it while viewing both images simultaneously. Not sure what the simplest available program would be though. All the ones I can think of are rather specialized, and perhaps a bit technical (not to mention expensive).

    • @Gudine
      @Gudine 3 дня назад +5

      I know Blender has UV Map support, so maybe it can do that

    • @potetopancakes
      @potetopancakes 3 дня назад +15

      yes !!! the AI images are interesting but i would love to see someone draw one of these themself, since a lot of people are iffy on the morals of generative AI

    • @Purplesquigglystripe
      @Purplesquigglystripe 2 дня назад +1

      It would be cool if you could input your own images too and the computer finds a way to make them compatible.

    • @eragon78
      @eragon78 23 часа назад +1

      @@potetopancakes I mean this is one of the best applications of AI, I dont think there really is much of a moral problem with this specific use case.

  • @mimasweets
    @mimasweets 3 дня назад +20

    Make a 500 piece one and take it to the speed puzzle solving world championship 😂

  • @Nacimota
    @Nacimota 3 дня назад +53

    lol "Lower Third Enthusiast"; you're killing me already, Matt

    • @dpatts
      @dpatts 3 дня назад +21

      For those (like me) who didn't know:
      The lower third is the area of the screen that videographers use for text and graphics, usually to identify who's on camera and what they do. It's a frivolous and self-referential joke, and yes it's very funny, but nobody tell Matt. It will only encourage him

    • @lucbloom
      @lucbloom 3 дня назад +3

      @@dpatts thank you captain 🫡

    • @metactal
      @metactal 3 дня назад +4

      @@dpatts ty

  • @fudgesauce
    @fudgesauce 3 дня назад +19

    I have a puzzle that has 1280x1024 pieces and the number of images I can generate by rearranging the pieces is astounding.

  • @thedayb4tomorrow
    @thedayb4tomorrow 3 дня назад +7

    The Matt Parker Process:
    Strange idea -> terrible python code -> spreadsheets -> magic 🙂

  • @andrasbiro3007
    @andrasbiro3007 3 дня назад +7

    Reminds me of old factories that were primarily making civilian stuff, but could be quickly reconfigured to make weapons. There's an old joke about this, where a guy working in a sewing machine factory steals pieces one by one, but when he tries to put it together at home he always gets an assault riffle.

  • @M4TCH3SM4L0N3
    @M4TCH3SM4L0N3 3 дня назад +14

    Variants #15 and #20 were my preferred mug/donut examples.

  • @wdvorak
    @wdvorak 23 часа назад +3

    I'm a coder by passion and training. I love a simple bit of program code -- C, Python, Pascal, Forth, Lisp, Basic -- that does a simple operation (usually in the nature of a "tool"), but it can be easily followed (doesn't need excessive amounts of documentation), that fits on a screen or a couple of screens, that computes something quite complex. I actual like your coding. With time it can be optimized and refined, but it's not about the code, but the solution that you were after.

  • @theminecraft4202
    @theminecraft4202 3 дня назад +11

    I like to imagine Steve got the coffee mug again when reassembling it and had to give it another go around

  • @BramCohen
    @BramCohen 3 дня назад +20

    If you're going the route of simply taking random assignments of edges and checking if that has other solutions then you can get a big speedup by having the alternate checker start in the upper left corner then go right, down, left, down, right, right, up, up, right, etc. forming a sort of zig-zag going out. But I suspect that's not a great overall approach. Far more promising is to a priori decide what the remapping is between the two solutions, check for what the different potential assignments of edges can be given those restrictions (there will be a lot of chains of 'these edges must be the same' and you can specifically tailor it so the chains are 'good' lengths) then check those to see if they have extraneous solutions.

  • @TeagueChrystie
    @TeagueChrystie 3 дня назад +10

    Watching that puzzle UV animate blew my mind.

  • @theyruinedyoutubeagain
    @theyruinedyoutubeagain 3 дня назад +10

    With all this effort, Matt will eventually become a half-decent programmer 😄FWIW the code is indeed terrible, but that's why we love you

  • @ahirshfield
    @ahirshfield День назад +1

    I like the little circle with realtime reaction of Steve’s expressions whilst Matt takes him through the graphs and code. Just so that we can all see if Steve does one of those stifled internal yawns through clenched teeth.

  • @weaselcon
    @weaselcon 3 дня назад +5

    Oh man, I feel like a Collab between Matt and Stuff Made Here would be EPIC!!!

  • @jonathanjoestar1938
    @jonathanjoestar1938 2 дня назад +3

    This jigsaw has 2 solutions.
    Topologist: no it doesn’t.

  • @joseywales6168
    @joseywales6168 3 дня назад +33

    Why is Steve EVERYWHERE
    I love all the science tuber collabs

    • @insu_na
      @insu_na 3 дня назад +12

      Matt and Steve have been friends for a very long time, probably before RUclips even existed. They've been doing maths comedy together for many years

    • @lucbloom
      @lucbloom 3 дня назад

      Where is he else?

    • @xerfrex7869
      @xerfrex7869 3 дня назад +1

      @@lucbloom He recently made an Assasin's Water Bottle with Vsauce

  • @riuphane
    @riuphane 2 дня назад +2

    Steve's video was fascinating, but i did not expect this video to be so dramatically different for being related and having overlap

  • @minaballerina
    @minaballerina 3 дня назад +28

    omg karen puzzles needs to do this

    • @mracin24
      @mracin24 3 дня назад +2

      Came here to add this comment and saw it's already here!

  • @JoachimFavre
    @JoachimFavre 3 дня назад +2

    Great video! Can't wait for the follow-up video where viewers optimise your code o/

  • @MichaelJM
    @MichaelJM 3 дня назад +5

    12:14 "Technically there is a better one out there." I'd expect nothing less from a Parker Puzzle!

  • @mister19stick
    @mister19stick 3 дня назад +2

    i like the way you convinced Steve it's inTERNship, and kept it up in person. Matt, well played.

  • @vighneshsivakumar3418
    @vighneshsivakumar3418 3 дня назад +13

    I would love to see an artist take a crack at drawing a two solution puzzle

  • @asitisrequiredasitisrequir3411
    @asitisrequiredasitisrequir3411 3 дня назад +4

    genuinely amazing. I want one of those block things that steve played with halfway through

  • @joseville
    @joseville 3 дня назад +5

    You could model the edges as positive numbers for outies and negative numbers for innies. Outie A fits into innie alpha iff outie A is represented by +n and innie alpha is represented by -n. A solved puzzle will have all outie and innie pairs adding to 0.
    15:50 If that's all SPUD is doing, and it doesn't ever get modified, then you can just define SPUD outside your recursive function (no need to pass it in as a parameter), and it can be accessed from any call to the function.

  • @feffy380
    @feffy380 3 дня назад +4

    If anyone's wondering why the images look kinda distorted (oversaturated, noisy, etc), this is because Stable Diffusion's VAE (image encoder) is not robust to transformations on the encoded latents. Some of the latent pixels encode global information that gets corrupted when you rearrange things. I think the only way to avoid this would be to perform the transformations in pixel space instead of latent space, but this is incredibly expensive because that means you need to decode and re-encode the image on every single denoising step

    • @dave7038
      @dave7038 13 часов назад

      How expensive are we talking, and do you suppose that the resulting image would be substantially better?
      If it's only, like, an order of magnitude or two more expensive it seems like it would be worth trying.

    • @dave7038
      @dave7038 9 часов назад

      Partially answering my own question, it appears to take around 3 times longer to decode/re-encode on each step.
      Since I don't have a clue how to use this thing, I'm doing something wrong and can't get a valid image out of a step-by-step image generation, but the basic process isn't absurdly slow.

  • @sociallysupreme7101
    @sociallysupreme7101 3 дня назад +8

    donut and a mug, do i smell topology?

  • @Pleeze
    @Pleeze 3 дня назад +2

    Can't wait to see everyone's better Python code.
    I don't know if it helps much, but I could create Photoshop Actions for rearranging the pieces in 1 go.
    Also, maybe it's worth a try to make human art the same way, so like, the artist starts sketching something loosely, rearranges the pieces, continues the drawing, rearranges the pieces again and continues... repeat until both versions look decent

    • @whyitisme2410
      @whyitisme2410 3 дня назад

      Sounds so cool to draw both version at the same time manually

  • @avramlevitter6150
    @avramlevitter6150 3 дня назад +3

    Something that's both a donut and a coffee cup? You've just summoned the topologists!

  • @dolphinbro3300
    @dolphinbro3300 2 дня назад

    I love that warm chuckle that Steve gave when seeing how Matt named his constant for mutations per round ( 17:02 )

  • @atomic3691
    @atomic3691 3 дня назад +6

    I can't wait until Matt comes out with his 10th Jigsaw sequel

  • @jonasla4011
    @jonasla4011 День назад

    Is there anything better than this duo? The smile on my face every time I see a new collab on one of the channels

  • @thedead456321
    @thedead456321 3 дня назад +8

    2:56 I could swear when i was younger I had a toy like this that wouls display two differents images with this sytem. But I was like 5 or 6 and it was a time at the peak of cassette tapes.

    • @xinpingdonohoe3978
      @xinpingdonohoe3978 3 дня назад +1

      I feel like I did, but then I realised it might have just been those sliding square puzzles.

  • @olegyakunin3849
    @olegyakunin3849 3 дня назад +10

    16:14 wait, "amongus" folder? what's inside? WHAT'S INSIDE WE NEED TO KNOW

    • @dorol6375
      @dorol6375 3 дня назад +6

      I think the amongus folder would be from when he tried to find amongi in the digits of pi using python

    • @olegyakunin3849
      @olegyakunin3849 3 дня назад +1

      @@dorol6375 ahhh, indeed! that explains it

  • @davidfinch7418
    @davidfinch7418 3 дня назад +3

    Them talking about taking the noise and leaving a donut reminds me of how to carve an elephant out of marble.
    1. Take a block of marble
    2. Remove all the parts that don't look like an elephant
    3. Done.

  • @Marconius6
    @Marconius6 2 дня назад +2

    15:30 Matt slowly discovering functional programming...

  • @paulosebresos7864
    @paulosebresos7864 3 дня назад +4

    This all looks like a super advanced captcha

  • @MK73DS
    @MK73DS 3 дня назад +2

    « They're the same picture » _a topologist_

  • @platinummyrr
    @platinummyrr 3 дня назад +3

    matt: technically there is a better one out there
    everyone: so what you're saying is that this is the parker jigsaw puzzle?

  • @maht0x
    @maht0x 3 дня назад +2

    I need a Sodoku solver, I know I'll enumerate all the possible 9x9 grids and see which ones are valid Sodoku solutions!

  • @matt_miles
    @matt_miles 3 дня назад +5

    Computer science student here.Your jig checker quite fundementally is a jig solver. What you're doing is a version of the backtracking algorithm where rather than trying to solve as much as possible and then going back (depth first search) you're finding all the solutions for the next step first and testing those (breadth first search), which is to say you're doing all the same steps but in a different order. It's a little misleading to say that just because you thought of a different order to do the same operations in, it makes it an entirely different concept (checker vs solver) but I totally understand the confusion.

  • @ruolbu
    @ruolbu 3 дня назад +1

    I like variant 15 the most. It still clearly has artifacts, but it looks the cleanest in pure shape difference

  • @Nolan-3835
    @Nolan-3835 3 дня назад +6

    The image of a Yoda becomes itself a Yoda

  • @gcewing
    @gcewing 2 дня назад +2

    Now we just need the Banach-Tarski version that can be reassembled into two identical pictures of the same size.

  • @MrMastergeek
    @MrMastergeek 3 дня назад +6

    The "hello darkness" bit killed me 🤣

  • @VaughanMcAlley
    @VaughanMcAlley 2 дня назад +1

    The history of music is full of people creating musical lines that will fit in more than one context, and (usually) mathematically inclined theorists showing how to do so. Jacob Gran recently did a series of videos about the late 19th century Russian theorist Taneev which I found very interesting.

  • @KenLieck
    @KenLieck 3 дня назад +14

    I picked up a fascinating thing at a thrift store -- it's a jigsaw puzzle, but comes with software (horribly out of date and obsolete, unfortunately) that enables you to take any photograph and process it so that by renumbering the pieces, the puzzle can be assembled to match the photograph. So you can go much farther than the mug/donut combo -- to infinity, I suppose -- with the help of a computer, and a commercially available novelty product allowing you to do so came out a couple of decades ago.

    • @diestormlie
      @diestormlie 3 дня назад +9

      So, basically, it's a bunch of physical pixels?

    • @KenLieck
      @KenLieck 3 дня назад

      I managed to dig the thing up out of my stuff! It's called JIGAZO from Hasbro, came out in 2011 based on a Japanese design from the year before. The software is now available free on the Internet Archive but I don't know if that's of any use without the puzzle pieces themselves.
      The Hasbro site described it thusly:
      "JI GA ZO's 300 pieces have varying levels of Sepia-colored gradations on one side and distinguishing symbols on the other. When the pieces are locked together, any face can be created. The key to this puzzle is the advanced JI GA ZO software. Upload a digital image to the JI GA ZO CD-ROM included in the box, and the software will produce a unique map that shows where each of the 300 pieces should be placed on the assembly grid to complete the JI GA ZO image.
      "The symbols make it possible for the JI GA ZO pieces to be individually identified and arranged in the correct position. In
      under an hour, the approximate time needed to place all of the pieces together, the JI GA ZO image will be revealed. Since the puzzle is assembled based on a custom map, the pieces can be continuously reshuffled and put back together to create new designs based on new maps."

    • @cosmicjenny4508
      @cosmicjenny4508 3 дня назад +1

      That sounds amazing! Do you have any more information about it please?

    • @KenLieck
      @KenLieck 2 дня назад

      @@cosmicjenny4508 Its called JIGAZO from Hasbro. There's plenty of info online including demo videos on RUclips.

    • @natescode
      @natescode 2 дня назад

      ​@@cosmicjenny4508just use mini Rubik's cubes

  • @Apophlegmatis
    @Apophlegmatis 2 дня назад

    I am especially pleased the fact that the solutions have the same implied topography

  • @nanamacapagal8342
    @nanamacapagal8342 3 дня назад +4

    Now I know the point of generative AI was to make things quick, but I'm already curious about a hand-drawn version.

  • @Kratokian
    @Kratokian 3 дня назад +1

    Ooh I do really like that Variant #21, there's a slight bit more mind blowing when the two objects aren't actually the same color.

  • @gardenofava
    @gardenofava 3 дня назад +3

    23:30 the parker puzzle

  • @jonathanfontaine2325
    @jonathanfontaine2325 3 дня назад +1

    With the given transformation of the jigsaw pieces, to go from the mug to the donut, you cannot have 20 pairs of identical in-out edge pairs. That would require all pieces to swap neighbours in pairs, which is not the case here. In fact in this specific transformation you have rather long chains of neighbour swaps, allowing for at most 14 distinct edge types.
    To illustrate, I'll number the pieces in the assembled mug picture from left to right and top to bottom by their x,y-coordinates as follows:
    11 12 13 14 15
    21 22 23 24 25
    31 32 33 34 35
    41 42 43 44 45
    51 52 53 54 55
    I'll label each of their edges by their cardinal direction N, W, S, E. So for example, in the mug assembly the edges 12E and 13W are matched, so their in and out must match. But in the donut picture that same edge 12E is matched with 11S, and 13W is matched with 35S. So we must have 11S=13W and 12E=35S. In turn, in the mug picture 11S is matched with 21N, and 35S with 45N, so 21N=12E and 45N=13W. Continuing this way in both directions we find a chain/loop:
    11E-54E-55W-45N-35S-13W-12E-11S-21N-14W-13E-12W-11E
    In this chain every edge must match with both its neighbours, and so all odd-indexed edges are the same, and all even-indexed edges are the same. Going over all edges we find the following chains:
    11E-54E-55W-45N-35S-13W-12E-11S-21N-14W-13E-12W-11E
    14E-15W-14E
    12S-43W-42E-22E-23W-34W-33E-22N-12S
    13S-33W-32E-22S-32N-23N-13S
    14S-23E-24W-32S-42N-24N-14S
    15S-53E-54W-25N-15S
    21E-32W-31E-44N-34S-22W-21E
    24E-41E-42W-25W-24E
    21S-45S-55N-41N-31S-52W-51E-31N-21S
    23S-53N-43S-33N-23S
    24S-45W-44E-35W-34E-44W-43E-42S-52N-34N-24S
    25S-41S-51N-35N-25S
    33S-44S-54N-43N-33S
    52E-53W-52E
    So in the best case, the maximum number of distinct edge pair types is the number of chains, which is 14. There might of course be a different transformation with more chains.

  • @kailomonkey
    @kailomonkey 3 дня назад +3

    The title really gives away the reveal near the start.

  • @SeanHoulihane
    @SeanHoulihane День назад

    I do like the way that you show how functional code beats performant code, at least if you only need it to run once, and if you have enough time. For non-programmers, this is important. Its probably important to know there are more optimal solutions, but all to often its not really worth the final stages of optimisation.

  • @LuxFerre4242
    @LuxFerre4242 3 дня назад +19

    4:30 it's weird seeing Perlin noise as TV static.

  • @scottwright7177
    @scottwright7177 День назад

    A couple of my favorite RUclipsrs together! Amazing!

  • @existenceisillusion6528
    @existenceisillusion6528 3 дня назад +4

    Saying 'terrible python code' is like saying 'wet water'. Fight me!

    • @existenceisillusion6528
      @existenceisillusion6528 3 дня назад +1

      @@georgihristov4415 didn't say it wasn't. I'm saying python is good for rapid ideation, which coincides with 'not elegant'.

    • @stefanalecu9532
      @stefanalecu9532 3 дня назад

      Facts

    • @lukew6725
      @lukew6725 2 дня назад

      Water is not wet, water makes other things wet.

    • @existenceisillusion6528
      @existenceisillusion6528 2 дня назад

      @@lukew6725 You are technically correct, the best kind of correct.

  • @arturtrzebinski2112
    @arturtrzebinski2112 День назад +1

    Innie and outie battle. Didn't expect it on RUclips.

  • @SpencerTwiddy
    @SpencerTwiddy 3 дня назад +8

    I bet the people that make that art in Vsauce shorts would (or maybe has already) be able to make one of these without the artifacts!

    • @SpencerTwiddy
      @SpencerTwiddy 3 дня назад +2

      I’m referring to the ambigrams and such.

  • @permalost4059
    @permalost4059 День назад

    I was thinking about laser cutting it on cardboard as Matt was talking about making it yourself. Very happy when Steve mentioned it directly afterward, and devastated when I found out there is no already made file.

  • @erwinjohannarndt4166
    @erwinjohannarndt4166 3 дня назад +6

    2am Europe time video? OH GOD YES!

  • @jakeruss331
    @jakeruss331 2 дня назад

    I love it when Steve Mould is in a video, then it makes sense that it is Stand-up Maths instead of Stand-up Math

  • @TannerJ07
    @TannerJ07 3 дня назад +4

    Now make a puzzle that can be solve by rotating every piece 90 degrees

  • @jrouquie
    @jrouquie 2 дня назад +1

    Another approach :
    1. postulate a reordering of the pieces. E.g. piece (x,y) goes to new position (a×x % p, b×y %p) where prime p is the puzzle side length.
    2. compute the constraints on which piece edges must be identical
    3. check (with your existing code) there aren't spurious new solutions. If there are, back to step 1. Maybe also rotate the pieces.
    Maybe you tried it already ?

  • @AdamBourke25
    @AdamBourke25 3 дня назад +5

    Ahh, I thought it was too coincidental that you both released videos about similar topics at basically the same time... made sense as soon as I saw both of you sat there!