WEBVTT
Kind: captions
Language: en

00:00:00.200 --> 00:00:05.800
I'm here with Steve mold because I have made&nbsp;
a jigsaw puzzle I'm very proud of I going to&nbsp;&nbsp;

00:00:05.800 --> 00:00:09.920
get Steve to try it out it's on the back&nbsp;
of the board currently solved so Steve if&nbsp;&nbsp;

00:00:09.920 --> 00:00:15.720
you could look away for one second everyone&nbsp;
at home you can see that it's a picture of&nbsp;&nbsp;

00:00:15.720 --> 00:00:21.400
a coffee mug now don't tell Steve what it is&nbsp;
I'm going to take the pieces oh it's magnetic&nbsp;&nbsp;

00:00:21.400 --> 00:00:30.360
so they all they stick on the board so I'm&nbsp;
going to break it up into a shuffle pattern&nbsp;&nbsp;

00:00:30.360 --> 00:00:35.640
okay so Steve yes this is the jiga puzzle&nbsp;
you can see it now there it is you have to&nbsp;&nbsp;

00:00:35.640 --> 00:00:41.360
put these pieces back together into a picture&nbsp;
of a thing that we already know what it is so&nbsp;&nbsp;

00:00:41.360 --> 00:00:44.760
uh off you go and I'm very proud of this if&nbsp;
you no some of the pieces look like they're&nbsp;&nbsp;

00:00:44.760 --> 00:00:50.320
very Jagged uh low resolution that's because&nbsp;
it was a a complex process making it and we'll&nbsp;&nbsp;

00:00:50.320 --> 00:00:56.520
explain exactly what into it and why it looks&nbsp;
like a kind of a weird abstract art version of&nbsp;&nbsp;

00:00:56.520 --> 00:01:01.000
the thing that it is but first of all we'll&nbsp;
just um give evil moment to try and solve

00:01:01.000 --> 00:01:11.920
it finished oh all right so I do a big&nbsp;
reveal yeah well I know what it looks like so

00:01:11.920 --> 00:01:25.400
what this video is supported by Jane Street and&nbsp;
their fantastic internships which are open to&nbsp;&nbsp;

00:01:25.400 --> 00:01:30.360
applications now and I've got an announcement&nbsp;
relating to me and the Hong Kong internships&nbsp;&nbsp;

00:01:30.360 --> 00:01:36.520
that's at the end of the video isn't that&nbsp;
donutty absolutely incredible okay so we'll&nbsp;&nbsp;

00:01:36.520 --> 00:01:43.480
in post we will show the before which was&nbsp;
very much a coffee mug are you doing that&nbsp;&nbsp;

00:01:43.480 --> 00:01:48.760
maths thing where you say oh it's a coffee&nbsp;
mug it's a donut yeah because it's because&nbsp;&nbsp;

00:01:48.760 --> 00:01:54.200
you look at a donut and you go oh it's a mug&nbsp;
ha okay so obviously Steve we both knew I both&nbsp;&nbsp;

00:01:54.200 --> 00:02:00.120
sols yeah yeah yeah cuz this has taken a very&nbsp;
long time to make it work and there are there&nbsp;&nbsp;

00:02:00.120 --> 00:02:05.160
the same pieces there's no trickery between them&nbsp;
and we have an animation showing exactly these&nbsp;&nbsp;

00:02:05.160 --> 00:02:13.800
pieces can be rearranged from a mug into a donut&nbsp;
I am uh disproportionately proud of the fact that&nbsp;&nbsp;

00:02:13.800 --> 00:02:19.720
this works and while it may not look like it in&nbsp;
this animation not all of the knobbly In-N-Out&nbsp;&nbsp;

00:02:19.720 --> 00:02:25.600
bits of the jigsa puzzle are the same there are&nbsp;
different types I can guarantee this only fits&nbsp;&nbsp;

00:02:25.600 --> 00:02:31.360
together in two arrangements and we'll go into the&nbsp;
mathematics of that in a moment moment but first&nbsp;&nbsp;

00:02:31.360 --> 00:02:37.600
this all started when Steve showed me something&nbsp;
called a diffusion illusion so uh I had this&nbsp;&nbsp;

00:02:37.600 --> 00:02:44.920
twisty puzzle uh and I wanted to see if you could&nbsp;
come up with an image you could put on there and&nbsp;&nbsp;

00:02:44.920 --> 00:02:51.960
it would make sense in both orientations of this&nbsp;
twisty squares thing and after I mentioned it in&nbsp;&nbsp;

00:02:51.960 --> 00:02:56.680
a video I got a lot of people trying to create&nbsp;
images that would work and then I got an email&nbsp;&nbsp;

00:02:56.680 --> 00:03:04.720
about uh using generative art or AI generation of&nbsp;
art to create an image that would work in in both&nbsp;&nbsp;

00:03:04.720 --> 00:03:11.640
yeah so that's what my video is about it's uh&nbsp;
twisty Square illusions that that work using AI&nbsp;&nbsp;

00:03:11.640 --> 00:03:15.800
but these other things that use transparencies&nbsp;
and stuff like that that video is out now on&nbsp;&nbsp;

00:03:15.800 --> 00:03:22.280
Steve's Channel I'll link to it below but Steve&nbsp;
has brought some to show us weeping angels weeping&nbsp;&nbsp;

00:03:22.280 --> 00:03:29.920
angels y from uh Dr Who uh no Yoda is it baby Yoda&nbsp;
or is it Yoda regular Yoda I think it's regular&nbsp;&nbsp;

00:03:29.920 --> 00:03:35.920
okay yeah um you know what I actually have a&nbsp;
donut as well no yeah and you'll be very pleased&nbsp;&nbsp;

00:03:35.920 --> 00:03:43.120
to see it becomes an ice cream but these are so&nbsp;
they're just incredible yeah it works incredibly&nbsp;&nbsp;

00:03:43.120 --> 00:03:47.240
well doesn't it well let's do look let's this&nbsp;
is a good one oh my gosh uh this is a good one&nbsp;&nbsp;

00:03:47.240 --> 00:03:56.600
it's a a winter scene and then uh a bit falls off&nbsp;
but it becomes most off most of kitten it's got&nbsp;&nbsp;

00:03:56.600 --> 00:04:02.160
a real homemade Vibe I love it oh look I thought&nbsp;
mine was going to look a bit unprofessional given&nbsp;&nbsp;

00:04:02.160 --> 00:04:08.800
us like cut out bits of card with magnets on the&nbsp;
back but no well uh how does this work Steve yeah&nbsp;&nbsp;

00:04:08.800 --> 00:04:14.400
now before we get to ambiguous images we just&nbsp;
understand how does AI make like how do you&nbsp;&nbsp;

00:04:14.400 --> 00:04:20.400
give it text and it turns that into a picture of&nbsp;
something out ofwhere text to image generation so&nbsp;&nbsp;

00:04:20.400 --> 00:04:25.680
it's this Den noising thing oh and it's kind of&nbsp;
surprising that it works at all but you train a&nbsp;&nbsp;

00:04:25.680 --> 00:04:30.000
model to figure out how to remove noise from an&nbsp;
image right noise being like you know the grain&nbsp;&nbsp;

00:04:30.000 --> 00:04:35.080
might see and then you just add more and more&nbsp;
noise progressively until it's just pure noise&nbsp;&nbsp;

00:04:35.080 --> 00:04:39.720
and then you say to the model get rid of that you&nbsp;
just give it absolute noise and say hey this is&nbsp;&nbsp;

00:04:39.720 --> 00:04:44.760
actually a picture of a donut yes get rid of that&nbsp;
noise yeah but there's no donut there's no donut&nbsp;&nbsp;

00:04:44.760 --> 00:04:51.000
so what happens is actually it's not great if you&nbsp;
just say remove all the noise the result that you&nbsp;&nbsp;

00:04:51.000 --> 00:04:57.320
get when you try to remove all the noise in one&nbsp;
go is it's a blurry blob right and so you do that&nbsp;&nbsp;

00:04:57.320 --> 00:05:03.840
step several times you add a a most of the noise&nbsp;
back and then you try to remove that try again you&nbsp;&nbsp;

00:05:03.840 --> 00:05:08.240
add a bit less of the noise back remove again each&nbsp;
time adding less and less of the noise back and&nbsp;&nbsp;

00:05:08.240 --> 00:05:13.720
each time you get a sharper and sharper image of&nbsp;
a donut right um I'm but you don't care about that&nbsp;&nbsp;

00:05:13.720 --> 00:05:17.400
stuff when you generate an image using stable diff&nbsp;
Fusion or whatever you just put the prompt in you&nbsp;&nbsp;

00:05:17.400 --> 00:05:23.480
get the image but uh what you can do because it's&nbsp;
open source you can uh interrogate the code right&nbsp;&nbsp;

00:05:23.480 --> 00:05:29.200
you can say halt at this point right uh instead&nbsp;
of just going straight to the last image show me&nbsp;&nbsp;

00:05:29.200 --> 00:05:33.440
the first thing that you came up with right yep&nbsp;
that's going to be the blowy thing that's kind&nbsp;&nbsp;

00:05:33.440 --> 00:05:40.440
of like a donut right uh and then you say okay for&nbsp;
the next step uh I don't want to Donut anymore and&nbsp;&nbsp;

00:05:40.440 --> 00:05:48.240
actually in fact just rearrange all these pieces&nbsp;
I want that to be a mug oh okay now do that now&nbsp;&nbsp;

00:05:48.240 --> 00:05:53.040
do that and then you say actually I know what I&nbsp;
was talking about actually put them back the way&nbsp;&nbsp;

00:05:53.040 --> 00:05:59.640
they were I just back and forth oh actually on&nbsp;
second thoughts yeah mug yeah so the whole time&nbsp;&nbsp;

00:05:59.640 --> 00:06:04.880
it's like these little baby steps uh where you're&nbsp;
approaching a mug but you're also approaching a&nbsp;&nbsp;

00:06:04.880 --> 00:06:10.400
donut at the same time with the the the rearranged&nbsp;
pieces and a little bit of selection bias cuz you&nbsp;&nbsp;

00:06:10.400 --> 00:06:15.080
do that a bunch and then you pick the ones&nbsp;
that look good yeah so maybe you do this&nbsp;&nbsp;

00:06:15.080 --> 00:06:21.800
and actually get a lot of rubbish results I can&nbsp;
actually say we did with the same jigsaw pieces&nbsp;&nbsp;

00:06:21.800 --> 00:06:29.760
lots of mug donut combos this was my favorite but&nbsp;
here's a bunch of the other ones all of these IM&nbsp;&nbsp;

00:06:29.760 --> 00:06:34.800
are based on exactly the same underlying jigsaw&nbsp;
structure that I discovered we just had to pick&nbsp;&nbsp;

00:06:34.800 --> 00:06:40.720
our favorite one to actually print on it let&nbsp;
me know if you would have picked a different

00:06:40.720 --> 00:06:50.040
one here's the thing I don't understand though now&nbsp;
um we need to talk about this jigsaw though yes&nbsp;&nbsp;

00:06:50.040 --> 00:06:56.920
when you when you uh do a jigsaw puzzle and you&nbsp;
try and put an Outi in an inie technical phrase&nbsp;&nbsp;

00:06:56.920 --> 00:07:02.440
yeah sometimes the shapes don't match correct uh&nbsp;
and that's by Design and actually the only time&nbsp;&nbsp;

00:07:02.440 --> 00:07:07.000
the in will match the ATI is if those two pieces&nbsp;
are supposed to be together right but this has&nbsp;&nbsp;

00:07:07.000 --> 00:07:14.240
two solutions which means that you somehow have&nbsp;
duplicate pairings of like in and ouy shapes yes&nbsp;&nbsp;

00:07:14.240 --> 00:07:19.720
so this is a 5x5 grid yeah and if people have a&nbsp;
quick think about it you can realize there are 40&nbsp;&nbsp;

00:07:19.720 --> 00:07:27.800
internal edges right which means if this was like&nbsp;
a handmade chel puzzle there'd be 40 unique ins&nbsp;&nbsp;

00:07:27.800 --> 00:07:35.240
and 40 unique outs this however has far fewer&nbsp;
distinct types and they appear multiple times&nbsp;&nbsp;

00:07:35.240 --> 00:07:43.240
there are actually seven different in andout&nbsp;
Combos and they all appear five or six times&nbsp;&nbsp;

00:07:43.240 --> 00:07:48.640
each oh cuz so in my mind the optimum thing&nbsp;
was you the each pairing just needs to appear&nbsp;&nbsp;

00:07:48.640 --> 00:07:53.680
exactly twice that's a good point yeah but that's&nbsp;
a terrible way to do it so when you first showed&nbsp;&nbsp;

00:07:53.680 --> 00:07:57.640
me this idea and I thought I wonder if there's&nbsp;
Axel puzzle with two solutions I was like well&nbsp;&nbsp;

00:07:57.640 --> 00:08:05.720
hang on it must exist well probably exists because&nbsp;
if these are all different one solution only but&nbsp;&nbsp;

00:08:05.720 --> 00:08:13.280
then imagine a jigsaw puzzle where these are&nbsp;
all the same you could put any piece anywhere&nbsp;&nbsp;

00:08:13.280 --> 00:08:18.440
if you had like systematic obviously you got the&nbsp;
edges but if all of these were always in in out&nbsp;&nbsp;

00:08:18.440 --> 00:08:23.360
out in the same orientation for every single&nbsp;
piece yeah the pieces are fungible you could&nbsp;&nbsp;

00:08:23.360 --> 00:08:27.200
put them anywhere and there too many solutions&nbsp;
that's boring it would be an outrageous number&nbsp;&nbsp;

00:08:27.200 --> 00:08:33.520
of solutions and so I was like oh okay in the&nbsp;
extreme if one way if they're all the same you&nbsp;&nbsp;

00:08:33.520 --> 00:08:37.560
got an outrageous number of ways you can put it&nbsp;
together yeah and at the other end you've only got&nbsp;&nbsp;

00:08:37.560 --> 00:08:44.280
one way yeah I know it's not strictly guaranteed&nbsp;
but it feels like in the middle there should be&nbsp;&nbsp;

00:08:44.280 --> 00:08:51.760
a bunch with two so what I did was I can I know&nbsp;
I can hear it coming would you believe I knocked&nbsp;&nbsp;

00:08:51.760 --> 00:08:58.080
together some terrible python code yeah and I&nbsp;
explored what happens if you vary the number of&nbsp;&nbsp;

00:08:58.080 --> 00:09:02.200
different types of edges in a jigel puzzle right&nbsp;
would you like to see some results yes please yeah&nbsp;&nbsp;

00:09:02.200 --> 00:09:10.640
they come so the way I thought about this was if&nbsp;
I had a random 5x5 jigsaw except I can choose how&nbsp;&nbsp;

00:09:10.640 --> 00:09:16.640
many different types of ins and outs what's the&nbsp;
average number of solutions it would have right&nbsp;&nbsp;

00:09:16.640 --> 00:09:21.680
so if every jigsaw only ever has one solution&nbsp;
then on average you make one at random it's&nbsp;&nbsp;

00:09:21.680 --> 00:09:28.120
just got that one solution you start with there's&nbsp;
no more yeah if very occasionally there'll be a&nbsp;&nbsp;

00:09:28.120 --> 00:09:35.840
second solution or maybe a third solution then on&nbsp;
average you'd have like 1 something Solutions on&nbsp;&nbsp;

00:09:35.840 --> 00:09:41.680
average and the bigger that number is it gives&nbsp;
you an indication of how many solutions you get&nbsp;&nbsp;

00:09:41.680 --> 00:09:48.080
so this is a plot let me talk you through this&nbsp;
yeah on the bottom here this is the number of&nbsp;&nbsp;

00:09:48.080 --> 00:09:53.880
different types of edge right so this is a 5x5&nbsp;
with six different types of ins and six types of&nbsp;&nbsp;

00:09:53.880 --> 00:10:00.080
outs that matter okay yeah so the maximum is&nbsp;
like however many yeah it would be 40 40 and&nbsp;&nbsp;

00:10:00.080 --> 00:10:05.520
then the minimum is uh is uh you know one so I&nbsp;
didn't go all the way down to the minimum cuz as&nbsp;&nbsp;

00:10:05.520 --> 00:10:11.680
you can see this is an exponential graph that goes&nbsp;
flying up actually I didn't even think I was going&nbsp;&nbsp;

00:10:11.680 --> 00:10:18.760
to get six cuz I ran the code to do a million of&nbsp;
each and then the million of six cuz I started at&nbsp;&nbsp;

00:10:18.760 --> 00:10:26.080
18 and work my way down was taking so long I just&nbsp;
made the graph from 7 to 18 and moved on with my&nbsp;&nbsp;

00:10:26.080 --> 00:10:29.560
life yeah but then the next day I happened to&nbsp;
look at my laptop and I left the code running&nbsp;&nbsp;

00:10:29.560 --> 00:10:34.680
and it had the results for six oh nice I was like&nbsp;
oh great Ino six yes because the fewer different&nbsp;&nbsp;

00:10:34.680 --> 00:10:40.600
connections there are the more ways there are&nbsp;
arranging it in terms of your code it's got to&nbsp;&nbsp;

00:10:40.600 --> 00:10:47.080
explore all the solutions we'll get to that in a&nbsp;
moment yeah it's not good so in the end I decided&nbsp;&nbsp;

00:10:47.080 --> 00:10:51.240
to go for seven which is why if you ignore the&nbsp;
outside edge this has seven different types of&nbsp;&nbsp;

00:10:51.240 --> 00:10:58.520
internal nobly bits right I then did a bu chart&nbsp;
just for seven to see what kind of a distribution&nbsp;&nbsp;

00:10:58.520 --> 00:11:04.560
I was dealing with right and the bar chart looks&nbsp;
like this so vast majority one solution yeah

00:11:04.560 --> 00:11:13.840
96.36% of the time yeah you got one solution&nbsp;
nothing else down here is the golden Zone this&nbsp;&nbsp;

00:11:13.840 --> 00:11:21.240
is what I want 3.7% of the time which is not bad&nbsp;
like if a computer's just generating these at a&nbsp;&nbsp;

00:11:21.240 --> 00:11:27.400
phenomenal rate 3.7% of them being what you're&nbsp;
after but I can say for the cases where you&nbsp;&nbsp;

00:11:27.400 --> 00:11:33.880
get lots of solutions they're going to be pretty&nbsp;
similar just like switching two things or exactly&nbsp;&nbsp;

00:11:33.880 --> 00:11:38.320
so that's when I realized hang on I've got an&nbsp;
issue here I want to have a jigel puzzle that's&nbsp;&nbsp;

00:11:38.320 --> 00:11:44.080
got two different solutions but I want them to&nbsp;
be as different as possible yeah so I then had&nbsp;&nbsp;

00:11:44.080 --> 00:11:52.520
to measure the difference between the solutions&nbsp;
and then try to get the maximum difference between&nbsp;&nbsp;

00:11:52.520 --> 00:11:59.760
them yeah this one there are only two joins that&nbsp;
are the same in both Solutions right I then did&nbsp;&nbsp;

00:11:59.760 --> 00:12:05.920
find one that only had one that was the same&nbsp;
because I foolishly left my code running but&nbsp;&nbsp;

00:12:05.920 --> 00:12:13.120
I was already too deep in committed to this one&nbsp;
we've done too much work finding the image I&nbsp;&nbsp;

00:12:13.120 --> 00:12:17.920
wasn't about to jump ship to the other one but&nbsp;
technically there was a better one yeah so in&nbsp;&nbsp;

00:12:17.920 --> 00:12:23.960
summary the fewer duplicate Edge types the better&nbsp;
because it makes it a more interesting puzzle a&nbsp;&nbsp;

00:12:23.960 --> 00:12:28.280
less frustrating puzzle where you know two pieces&nbsp;
might fit together but actually it's that's not a&nbsp;&nbsp;

00:12:28.280 --> 00:12:34.160
solution for either of the two correct in a&nbsp;
perfect world I would have had 20 different&nbsp;&nbsp;

00:12:34.160 --> 00:12:40.800
ones each in there twice very pleasing yeah but&nbsp;
that's very hard to find at least with my code&nbsp;&nbsp;

00:12:40.800 --> 00:12:48.000
so let's make it easier to find using public&nbsp;
code review it's worked for you so well in the

00:12:48.000 --> 00:12:59.480
past I I just think and then you you know&nbsp;
you might find this beautiful uh jigsa&nbsp;&nbsp;

00:12:59.480 --> 00:13:04.760
okay fine fine fine okay now I know you're going&nbsp;
to suggest my code could be better but let me&nbsp;&nbsp;

00:13:04.760 --> 00:13:09.840
explain how I did it okay and then everyone can do&nbsp;
it better than me sounds good so the first thing&nbsp;&nbsp;

00:13:09.840 --> 00:13:15.920
I needed was some code that could just solve a&nbsp;
jigsa puzzle yes so a bit like stable diffusion&nbsp;&nbsp;

00:13:15.920 --> 00:13:21.640
You could argue being able to den noise an image&nbsp;
is a useful process in its own right yeah I just&nbsp;&nbsp;

00:13:21.640 --> 00:13:27.840
needed the process which was take some jigsaw&nbsp;
pieces and solve that puzzle I wrote a program I&nbsp;&nbsp;

00:13:27.840 --> 00:13:34.560
called The Jig check Decker into which you can put&nbsp;
a partially soft jigsaw all the remaining pieces&nbsp;&nbsp;

00:13:34.560 --> 00:13:39.960
and then it will start checking what fits it's&nbsp;
not called jig solver it's not trying to solve&nbsp;&nbsp;

00:13:39.960 --> 00:13:44.800
the jigsa puzzle it just picks one spot the&nbsp;
next spot along as you go from left to right&nbsp;&nbsp;

00:13:44.800 --> 00:13:51.440
top to bottom and then it starts seeing which of&nbsp;
the remaining pieces fit in that spot eventually&nbsp;&nbsp;

00:13:51.440 --> 00:13:56.960
one of them will and you might think oh now it'll&nbsp;
start checking the next spot over no that's what a&nbsp;&nbsp;

00:13:56.960 --> 00:14:03.400
jig solver would do The Jig Checker just takes&nbsp;
a complete copy of everything done so far and&nbsp;&nbsp;

00:14:03.400 --> 00:14:11.360
puts that into a new instance of itself and it's&nbsp;
the new one that checks the next spot along the&nbsp;&nbsp;

00:14:11.360 --> 00:14:16.400
first jig Checker will keep checking that same&nbsp;
spot until it's checked every single piece its&nbsp;&nbsp;

00:14:16.400 --> 00:14:23.200
job now complete it will simply fade from reality&nbsp;
and the new one will start checking the new spot&nbsp;&nbsp;

00:14:23.200 --> 00:14:28.480
well I say start checking it doesn't necessarily&nbsp;
happen in this exact order in the processor the&nbsp;&nbsp;

00:14:28.480 --> 00:14:34.280
point is just recursive code and against my better&nbsp;
judgment here is my actual python code you can see&nbsp;&nbsp;

00:14:34.280 --> 00:14:40.280
at the top I've defined something called The Jig&nbsp;
Checker you tell it how big the jiga puzzle is you&nbsp;&nbsp;

00:14:40.280 --> 00:14:44.640
give it all the pieces that are already solved&nbsp;
they've been placed all the pieces remaining&nbsp;&nbsp;

00:14:44.640 --> 00:14:49.080
and something called spot I'll get to that in a&nbsp;
moment and then the code goes through works out&nbsp;&nbsp;

00:14:49.080 --> 00:14:54.320
what the requirements are checks which pieces&nbsp;
fit like rotates them to make sure it's checked&nbsp;&nbsp;

00:14:54.320 --> 00:14:59.560
all the orientations if one of them fits you can&nbsp;
see here it takes the copy of all all the placed&nbsp;&nbsp;

00:14:59.560 --> 00:15:05.280
pieces so far adds in the new one that fits copies&nbsp;
the remaining one removes the one that we've now&nbsp;&nbsp;

00:15:05.280 --> 00:15:12.080
put into the solution and then just puts that into&nbsp;
jig Checker it just passes it into itself I love&nbsp;&nbsp;

00:15:12.080 --> 00:15:17.640
recursing programming I should explain Spud though&nbsp;
I it's a ridiculous name I don't know why I use it&nbsp;&nbsp;

00:15:17.640 --> 00:15:24.040
I think previously had like a hot potato being&nbsp;
passed around that is a global list that exists&nbsp;&nbsp;

00:15:24.040 --> 00:15:30.480
separate from all the recursive jig checking going&nbsp;
on and that means if if any one instance of jig&nbsp;&nbsp;

00:15:30.480 --> 00:15:38.600
Checker solves the very last piece of the puzzle&nbsp;
that solution can be put into Spud and that means&nbsp;&nbsp;

00:15:38.600 --> 00:15:44.000
I can just run all the Dig Checkers until they're&nbsp;
eventually finished and then I look at Spud This&nbsp;&nbsp;

00:15:44.000 --> 00:15:49.120
Global folder to see how many solutions it has&nbsp;
and the vast majority of the time it will come&nbsp;&nbsp;

00:15:49.120 --> 00:15:56.120
back with a single solution but every now and then&nbsp;
another solution will be in there as well and that&nbsp;&nbsp;

00:15:56.120 --> 00:16:02.000
is what I'm looking for and given I've now shown&nbsp;
you some of my terrible python code I may as well&nbsp;&nbsp;

00:16:02.000 --> 00:16:06.080
show Steve as well you know what against my B of&nbsp;
judgment I'm going to show you some of the code I&nbsp;&nbsp;

00:16:06.080 --> 00:16:10.200
don't know why I'm doing this so I was going&nbsp;
to say I won't understand it but it's python&nbsp;&nbsp;

00:16:10.200 --> 00:16:15.840
Codey basically you can read it yeah it's Pros&nbsp;
so you know what just so you get a sense of what&nbsp;&nbsp;

00:16:15.840 --> 00:16:22.640
I was doing I've written a bunch of other stuff&nbsp;
elsewhere which is jig Checker is the process that&nbsp;&nbsp;

00:16:22.640 --> 00:16:27.120
solves the jigsaw puzzle and gives you back all&nbsp;
the solutions right and there's some other code&nbsp;&nbsp;

00:16:27.120 --> 00:16:33.120
it can rotate it it can generate jigsaw it can&nbsp;
name a jigsaw and it can mutate a jigsaw so what&nbsp;&nbsp;

00:16:33.120 --> 00:16:40.440
I did was first of all the code starts randomly&nbsp;
generating jigel yeah looks at the ones that come&nbsp;&nbsp;

00:16:40.440 --> 00:16:46.640
back with two solutions checks how distinct they&nbsp;
are and calculates what percentage of edges have&nbsp;&nbsp;

00:16:46.640 --> 00:16:52.560
changed and I've set here a threshold to start&nbsp;
is 25% so it does that at random until it finds&nbsp;&nbsp;

00:16:52.560 --> 00:16:57.840
one with more than a quarter of the edges are&nbsp;
different yeah and then it spits that this is&nbsp;&nbsp;

00:16:57.840 --> 00:17:05.000
it finding that here it then spits it into this&nbsp;
code that generates what have I got it set to&nbsp;&nbsp;

00:17:05.000 --> 00:17:13.200
some number of children let's have a look here uh&nbsp;
6,000 it mutates it 6,000 different ways yeah and&nbsp;&nbsp;

00:17:13.200 --> 00:17:20.840
it can vary the number of mutations and it looks&nbsp;
at all 6000 Offspring finds the one with the best&nbsp;&nbsp;

00:17:20.840 --> 00:17:26.520
Improvement in how different the solutions are&nbsp;
makes that the new parent that has babies 6,000&nbsp;&nbsp;

00:17:26.520 --> 00:17:33.360
babies okay finds the one of those that's the most&nbsp;
different yeah than 6,000 babies and the babies&nbsp;&nbsp;

00:17:33.360 --> 00:17:40.320
all have I did a bunch of tests six mutations&nbsp;
so it does six swaps at random is the best way&nbsp;&nbsp;

00:17:40.320 --> 00:17:45.640
to maximize the Improvement nice but then you got&nbsp;
to hone in on a solution so if it can't improve it&nbsp;&nbsp;

00:17:45.640 --> 00:17:50.720
anymore with sex it then does five mutations and&nbsp;
then four mutations and then two and all the way&nbsp;&nbsp;

00:17:50.720 --> 00:17:56.760
down to one nice okay and then then it's got some&nbsp;
Grand one it's evolved towards and then it spits&nbsp;&nbsp;

00:17:56.760 --> 00:18:01.400
that out and then starts again ah and it spits&nbsp;
it out and it starts again spits it out I did a&nbsp;&nbsp;

00:18:01.400 --> 00:18:08.680
bunch of tests because if you have more children&nbsp;
it evolves better but it takes longer per test is&nbsp;&nbsp;

00:18:08.680 --> 00:18:12.280
if you have fewer children you can bang through&nbsp;
the tests but each one's not as good I would&nbsp;&nbsp;

00:18:12.280 --> 00:18:19.120
assign ins and outs to one solution yeah and then&nbsp;
I would adjust them as I was then building into&nbsp;&nbsp;

00:18:19.120 --> 00:18:24.600
the second solution you know what I will show on&nbsp;
screen what this looked like when it came out of&nbsp;&nbsp;

00:18:24.600 --> 00:18:31.680
my code because all it is is a list of lists where&nbsp;
each list is just it starts in the west and there&nbsp;&nbsp;

00:18:31.680 --> 00:18:39.600
four numbers so this one from memory is like 001&nbsp;
two or something else over here and then that's&nbsp;&nbsp;

00:18:39.600 --> 00:18:46.560
it it just boom spits small out Ah that's cool&nbsp;
yeah math but the dream the absolute ideal would&nbsp;&nbsp;

00:18:46.560 --> 00:18:54.560
be for some jigsaw ratio I did all squares&nbsp;
could be anything to have two of every type&nbsp;&nbsp;

00:18:54.560 --> 00:19:02.560
of In-N-Out match and have two solutions with no&nbsp;
repeat matches in a non-trivial way just in case&nbsp;&nbsp;

00:19:02.560 --> 00:19:06.200
there's some trivial way where you can just like&nbsp;
shunt everything yeah if you're going to improve&nbsp;&nbsp;

00:19:06.200 --> 00:19:11.520
on what I've done write your code from scratch I&nbsp;
wouldn't use what I've done to do it you might be&nbsp;&nbsp;

00:19:11.520 --> 00:19:17.840
wondering two things now which are actually the&nbsp;
same thing which is how on Earth do you actually&nbsp;&nbsp;

00:19:17.840 --> 00:19:26.800
take this solution I found for jigsa puzzles and&nbsp;
put it into the AI image generator like how do I&nbsp;&nbsp;

00:19:26.800 --> 00:19:32.120
tell it where the nobly bits are yeah yeah and&nbsp;
you might be wondering why if you have a close&nbsp;&nbsp;

00:19:32.120 --> 00:19:37.400
look at these pieces they're clearly quite low&nbsp;
resolution they are they're like quite Jagged&nbsp;&nbsp;

00:19:37.400 --> 00:19:42.440
around the ins and outs are quite uh pixel camera&nbsp;
person Alex and producer Nicole spent a very long&nbsp;&nbsp;

00:19:42.440 --> 00:19:50.000
time with scalpel cutting out actual pixels&nbsp;
so well done them that's an artifact of how&nbsp;&nbsp;

00:19:50.000 --> 00:19:58.960
we had to run the coat and by we you put me in&nbsp;
touch um with the Fantastic Ryan yes and Xiang&nbsp;&nbsp;

00:19:58.960 --> 00:20:05.120
yeah and uh they explain to me how you can&nbsp;
actually enter your two different states&nbsp;&nbsp;

00:20:05.120 --> 00:20:10.520
whatever they may be into the code and get your&nbsp;
ambiguous image meet Ryan Berget the person&nbsp;&nbsp;

00:20:10.520 --> 00:20:15.480
who first came up with diffusion Illusions while&nbsp;
doing their PHD which involved computer vision and&nbsp;&nbsp;

00:20:15.480 --> 00:20:21.200
generative AI the way that diffusion models work&nbsp;
is they progressively refine images so if you can&nbsp;&nbsp;

00:20:21.200 --> 00:20:26.440
progressively refine an image in two different&nbsp;
ways at the same time then you can create two&nbsp;&nbsp;

00:20:26.440 --> 00:20:32.320
different image targets at the same time and it&nbsp;
occurred to me that flipping something upside down&nbsp;&nbsp;

00:20:32.320 --> 00:20:38.200
works really nicely because your vision system as&nbsp;
a human isn't used to seeing things upside down so&nbsp;&nbsp;

00:20:38.200 --> 00:20:42.920
you can hide some extra information there this&nbsp;
is Ryan's diffusion illusion website which has&nbsp;&nbsp;

00:20:42.920 --> 00:20:47.480
all sorts of phenomenal illusions on it I will&nbsp;
link to this in the description below you have&nbsp;&nbsp;

00:20:47.480 --> 00:20:52.960
the overlay ones here and some of my favorites are&nbsp;
these slidy ones where you move all the images on&nbsp;&nbsp;

00:20:52.960 --> 00:20:58.120
top of each other which I'm doing right now and&nbsp;
they give you a new image what could it possibly&nbsp;&nbsp;

00:20:58.120 --> 00:21:04.720
be oh For the Love of anyway do check it out&nbsp;
there's some really cool stuff on here but now&nbsp;&nbsp;

00:21:04.720 --> 00:21:10.760
the point is how are we going to make my jigsaw&nbsp;
puzzle illusion so UV map is a way of mapping a&nbsp;&nbsp;

00:21:10.760 --> 00:21:17.560
texture onto an object where we have two values u&nbsp;
and v which were image coordinates and each point&nbsp;&nbsp;

00:21:17.560 --> 00:21:22.400
on a surface of a mesh will have a different UV&nbsp;
coordinate and we can actually represent those UV&nbsp;&nbsp;

00:21:22.400 --> 00:21:27.160
coordinates with red and green respectively and&nbsp;
then use the red and green values of different&nbsp;&nbsp;

00:21:27.160 --> 00:21:35.120
images to assign where the texture pixels go&nbsp;
and in our case um we have two UV images images&nbsp;&nbsp;

00:21:35.120 --> 00:21:42.000
of movement within a UV map one is the basic&nbsp;
UV map which is just black on the corner and&nbsp;&nbsp;

00:21:42.000 --> 00:21:46.560
then yellow on the other corner with green in&nbsp;
one corner and red in the other which is the&nbsp;&nbsp;

00:21:46.560 --> 00:21:52.320
identity UV map where nothing changes and then we&nbsp;
have the second UV map in our case which is where&nbsp;&nbsp;

00:21:52.320 --> 00:21:58.920
we rearrange all the puzzle pieces and in that UV&nbsp;
map it basically gives a one toone correspondent&nbsp;&nbsp;

00:21:58.920 --> 00:22:06.200
of where each pixel moves a dense correspondence&nbsp;
to transport pixels from the unwarped image to&nbsp;&nbsp;

00:22:06.200 --> 00:22:11.800
the new warped image which is now the moved puzzle&nbsp;
pieces here is the unwarped UV map that Ryan sent&nbsp;&nbsp;

00:22:11.800 --> 00:22:18.080
me except now it's 255 in each Direction that's&nbsp;
because my puzzle is on a 5x5 grid says to be a&nbsp;&nbsp;

00:22:18.080 --> 00:22:26.280
multiple of five each of these boxes are 51x 51&nbsp;
pixels in fact here's the actual low res version&nbsp;&nbsp;

00:22:26.280 --> 00:22:33.040
of my jigel puzzle I did you can just just see&nbsp;
how how chunky these things are but while there&nbsp;&nbsp;

00:22:33.040 --> 00:22:40.640
are other ways to get higher resolution UV Maps&nbsp;
we just went with a 255x 255 and it meant I could&nbsp;&nbsp;

00:22:40.640 --> 00:22:45.000
then select a piece so for example this one here&nbsp;
and if you zoom in you can see I've turned off&nbsp;&nbsp;

00:22:45.000 --> 00:22:50.040
antialising and the like but still it ended up&nbsp;
not being completely perfect which is a little&nbsp;&nbsp;

00:22:50.040 --> 00:22:56.200
bit annoying but the point is I could then select&nbsp;
that from the UV map so we're going to cut it out&nbsp;&nbsp;

00:22:56.200 --> 00:23:06.040
there and I know because I got my code to spit out&nbsp;
destinations I know if I put that in here now I've&nbsp;&nbsp;

00:23:06.040 --> 00:23:13.960
got a rotate one to the side and that one ends up&nbsp;
going exactly there and so I went through there it&nbsp;&nbsp;

00:23:13.960 --> 00:23:21.680
is pixel by pixel moved it around and actually&nbsp;
here you can see these are the only two places&nbsp;&nbsp;

00:23:21.680 --> 00:23:27.680
where two pieces are still contacting the original&nbsp;
neighbors everything else has shifted around and&nbsp;&nbsp;

00:23:27.680 --> 00:23:34.480
my eventual result wasn't perfect but it was good&nbsp;
enough for us to get a first pass I would do it I&nbsp;&nbsp;

00:23:34.480 --> 00:23:39.280
do it a bit differently next time I will explain&nbsp;
how you can get a copy of this if you want to play&nbsp;&nbsp;

00:23:39.280 --> 00:23:44.240
with it yourself and do let me know if you write&nbsp;
better code but first we need to thank the sponsor&nbsp;&nbsp;

00:23:44.240 --> 00:23:49.360
of this video which is Jam Street Jam Street Jam&nbsp;
Street of financial I'm M I'm I'm sponsored by Jam&nbsp;&nbsp;

00:23:49.360 --> 00:23:55.240
Street well your video about yeah J really their&nbsp;
internships they're phenomenal internship program&nbsp;&nbsp;

00:23:55.240 --> 00:23:59.480
that you can apply to now yeah that's inredible&nbsp;
with a particular Focus on Hong Kong how about&nbsp;&nbsp;

00:23:59.480 --> 00:24:05.640
that yes Chaine Street's incredibly generous paid&nbsp;
internships for students graduating in the 2026&nbsp;&nbsp;

00:24:05.640 --> 00:24:14.120
2027 Academic Year are now open they have offices&nbsp;
in New York London and as Steve mentioned in Hong&nbsp;&nbsp;

00:24:14.120 --> 00:24:20.160
Kong so if you want an internship in things like&nbsp;
quantitive trading software engineering research&nbsp;&nbsp;

00:24:20.160 --> 00:24:25.920
and more you can apply for any of the internships&nbsp;
at any of the offices you don't need a background&nbsp;&nbsp;

00:24:25.920 --> 00:24:30.560
in finance to be part of the program a lot of&nbsp;
Jan streeters were in the same position as you&nbsp;&nbsp;

00:24:30.560 --> 00:24:36.560
before applying and they learned it all on their&nbsp;
internship or on the job so I highly recommend&nbsp;&nbsp;

00:24:36.560 --> 00:24:42.440
either you apply if it applies to you or you tell&nbsp;
someone else about it because it's a fantastic&nbsp;&nbsp;

00:24:42.440 --> 00:24:47.720
opportunity they pay all your expenses to get&nbsp;
where your internship is including Hong Kong&nbsp;&nbsp;

00:24:47.720 --> 00:24:53.600
and speaking of Hong Kong extra perk for that one&nbsp;
and if you do end up on the Jane Street Hong Kong&nbsp;&nbsp;

00:24:53.600 --> 00:24:58.520
internship you will get to meet me I've now booked&nbsp;
a trip to Hong Kong I'm on my way to Australia&nbsp;&nbsp;

00:24:58.520 --> 00:25:04.160
June 2025 so if you're there as an intern I'm&nbsp;
going to drop by the office give a talk I've&nbsp;&nbsp;

00:25:04.160 --> 00:25:07.560
done it twice before I'm very much looking&nbsp;
forward to it youve not been to the Hong&nbsp;&nbsp;

00:25:07.560 --> 00:25:12.520
Kong office not yet although we have done a talk&nbsp;
together at the London Jam Street office correct&nbsp;&nbsp;

00:25:12.520 --> 00:25:16.960
yeah Jam street they're good people check&nbsp;
out the link below that's it for the video&nbsp;&nbsp;

00:25:16.960 --> 00:25:21.880
I am going to make this available I will put&nbsp;
two documents linked Below in the description&nbsp;&nbsp;

00:25:21.880 --> 00:25:28.320
one is this in like the solved state so you can&nbsp;
still cut it out and try and solve it yourself&nbsp;&nbsp;

00:25:28.920 --> 00:25:34.480
and I'll do one where it's all jumbled up so&nbsp;
if you want the challenge get the downloaded&nbsp;&nbsp;

00:25:34.480 --> 00:25:40.480
one print them out cut them out good luck and&nbsp;
huge thanks to Steve M for being here I think&nbsp;&nbsp;

00:25:40.480 --> 00:25:45.080
you should also put the vector image of all the&nbsp;
cut lines so if anyone's got a laser cutter they&nbsp;&nbsp;

00:25:45.080 --> 00:25:51.800
could laser cut Pieces movie that file doesn't&nbsp;
exist okay because I manually move the pixels&nbsp;&nbsp;

00:25:51.800 --> 00:25:57.760
around by hand in Photoshop I'm not ready to talk&nbsp;
about it well thanks for having me thanks for&nbsp;&nbsp;

00:25:57.760 --> 00:26:04.760
watching the video check out Steve channel it's&nbsp;
just fun to think about uh how it could possibly&nbsp;&nbsp;

00:26:04.760 --> 00:26:09.840
work and it's interesting like the glaze here&nbsp;
yeah the glint could also be a background if it&nbsp;&nbsp;

00:26:09.840 --> 00:26:14.760
needed to be you know what I mean I love playing&nbsp;
spot the handle oh yeah cuz somewhere in here is&nbsp;&nbsp;

00:26:14.760 --> 00:26:22.800
the handle for the other solution I'm pretty&nbsp;
sure that's it there and that fills it in yeah

