[Music]
check 1 2 3 sorry about that I didn't
realize I had the volume down very low
this is my sound check of my voice how
are the levels can you hear me and is
the balance between me and the get
started in just about 2 or 3 minutes
[Music]
hello happy is a Thursday I am really
having trouble keeping track of what day
it is
welcome to the coding train with me your
host Dan I'll just take a deep breath
just take a big deep breath together
ready I don't know where you're watching
from this from where in the world you're
watching this I don't know what your
circumstances are what you did what time
of day it is what you did this morning
this afternoon at night how you slept
any of those things but all in all I
would just like to know how are you
doing are you doing okay I am based in
New York City specifically in Brooklyn
New York it has been quite a week of
chaos here if not a month or a year or
the last however many years whoever you
want to get started do you hear that
noise by the way I want to talk about
that noise in a second but things are a
little quite in flux in the city here
specifically where I work where my day
job is at New York University do you
hear that sound I would like to know
maybe you can't hear it hmm I'm gonna
wait for that sound to finish but by the
way that is literally the sound of
somebody washing their hands and I'm not
kidding just you know there's a lot of I
don't know irony or humor there you
gotta have a sense of humor sometimes
though it's important to take things
seriously and follow science or now Noah
dancing around the topic that is on my
mind which is what's going on with
coronavirus and specifically New York
City and New York University so nobody's
saying they can hear that sound oh yeah
I hear it says DT six let me address
that a second so New York University has
cancelled all in-person classes and
events and meetings there's a lot of
other changes going on in the city of
New York itself this has caused a lot of
us who work at NYU to have to change our
daily routines to revamp our curriculum
to think about different things I am a
person as you might have noticed who
happens to do a lot of online education
Edel adjacent stuff on the internet so
in many ways I am set up well to engage
in experiment with remote education but
I would say that I think it is something
very different to be caring for and
teach at caring for a class a cohort of
whether it's six students or eight or 12
or 16 or 20 or 50 or a hundred even
which is quite different than this sort
of live-streaming thing on YouTube there
are relationships and the things I do on
this channel I hope are resources to
people who are teaching courses that
they can create their community their
local community of their course around
but I do think it's it's a I want to be
careful about suggesting that oh it's
time to do remote education that's a
thing that I do already it's not I do a
kind of remote education and maybe a lot
of it's filled with like way too much
nonsense but
but yes so I don't want to I don't want
to belabor this story there is a huge
amount of stuff to say on it I am not
qualified to prognosticate and predict
the future I'm just kind of working with
what I need to do today and I think
actually some of the changes that are
happening based on looking at reducing
the spread of the virus will probably
ultimately open up a lot more time for
me to livestream or make video tutorials
but actually what's happened to me this
week is I'm having a lot less time
because there's a lot of things that
need to be changed I'm spinning up
actually a couple new classes for NYU
there's just a lot of meetings and not
to mention like my son's school closed
he's actually having classes with zoom
software at home he's in fifth grade and
so you know I don't have to be there
with him right now because I have that
covered but that's it's a the puzzle
pieces my daughter school is still open
but the puzzle pieces of family and all
that kind of stuff are become enormous
ly complicated but I wasn't minted
managed to stick to having a live stream
today I started about a half an hour
earlier than I originally intended and I
have to leave
absolutely 100% at 3:30 which is now
about one hour and 50 minutes if I can
still do math on some level loud think I
want that noise to happen again so
bizarrely I was in here the other day I
actually was making a quick video
tutorial for how to do video
conferencing with zoom which I might try
to do some more of that on the channel
itself but it was loud noise and I
thought you know we did shop there's
something sorry I hit the Bell by
accident there's a wood shop over there
and I thought it's weird that I never
hear the wood shop and all of a sudden
I'm hearing it today so I'm drilling and
I heard it again and hurt again and oh
maybe there's a construction going on
this building Mabel's construction then
uh later I was like I need to you know
go to the bathroom do it number one I
need to wash my hands I need to wash my
head a lot so I went in to wash my hands
burn when the water comes out for it so
right now during this live stream if we
hear the sound bar I mean somebody's
washing their hands and we should
applaud them applaud them for washing
your hands for not touching your face
now it could be something we could code
today a hand face detector but I don't
want to be do - I don't want to make
light of what is an incredibly
complicated and difficult and
life-changing for many people situation
right now
so that's all I have to say about that
I'm going to move on to back to my sort
of like usual programming which is a lot
of this stuff
with today's episode of the coding train
you have 1/2 day early pi day thing ok
whoa this is getting warm in here
oh good touched my face all right uh we
should let us let us now also transition
to reading the ceremonial book of random
numbers things are a little ominous
these days so we're gonna have to do it
[Music]
forty-nine thousand five hundred
fourteen fifty six thousand nine hundred
seventy seven sixty one thousand ninety
one okay oh boy Friday the 13th is
tomorrow okay you know I did I already
probably told my Friday the 13th story
when I was a little young lad along last
lassie laddie whatever whatever is you
say that I had a boo boo boo bad boo boo
on harder than 30 I don't want diarrhea
no live stream from a year or two years
ago somebody will find me so um this
Saturday is March 14th also known as pi
day 4 3 3 1 for being the 3.14 being the
first digits of pi i off I have in the
past done a live stream on pi day I
actually was supposed to travel this
weekend I am no longer traveling this
weekend that trip was canceled so but I
don't know what I'll be doing yet this
weekend and I I almost am sure I won't
be physically here in this building on
Saturday so no Pi Day livestream unless
I spend something up from home or
something like that but I thought what I
would do today is a coding challenge
related to PI so it would happen
today during this live stream in the
next hour and 45 minutes or so and then
machiya and I would work in the next 24
hours or so to edit it down to it's sort
of like core essential components which
would then be released as the pi day
coding challenge on Saturday so that is
my plan so that's what happened today
now either some people been asking the
thumbnail it says things like OBS basics
another see chapter 3 because I guess
turday and I woke up this morning I was
like I want to talk about live-streaming
and how I could use open broadcast
studio record a lecture and I'm a nature
of code I'm gonna be in chapter 3 so I
could do a little bit on nature of CO
chapter 3 the time the time the time the
time it got compressed I do want to
really think about and maybe come back
next week and focus on are there a set
of tutorials that I can do to help
teachers specifically who might be who
who might be doing remote learning might
want to record a video lecture are there
things that I that that I can make some
content about to help people so
specifically if you're a teacher and
there's like a thing I would love to
hear from you or if you have ideas for
me let me know and maybe next week you
know a lot of a lot of the what people
are doing with remote learning is
real-time interaction and questions and
feedback and smaller groups and that's
not something that I really actually
have a lot of experience with when I
have experience together this much more
like one-way broadcast although it there
is sometimes like a chat and different
things but but I would like to offer
some resources one resource I do want to
mention let me just try to find it for a
second because there have been a lot of
people putting together just hold off
sometimes I can't talk and search
by the way I have a question my kids say
search it up like who who won the World
Series in 1967 hey Dad just search it up
is that a thing do people say search it
up or did they invent Sega search it up
and now it's a thing that people are
gonna say because I'm telling you you
could say search it up today Kenny it's
sketchy trust me but maybe it's already
a thing and I'm an old old Internet man
who just says I will search for it but
now I'm gonna say search it up I'm
searching something up and I can't
concentrate well on sir did it up
[Music]
I'm doing I don't have my password
looking it up searching it up
[Music]
okay I found what I was looking for I
searched it up alright so this is a lot
of people been putting together
resources and there's a slack channel
that I know exactly Berman had put
together for people teaching online in
the age of Cova 19 but Melanie Hoff who
is one of the organizers of code
societies at school for Porter
competition and alum of the ITP program
and if you don't if you don't know her
work you should check out her work but
she put together this really excellent
arena compilation of all sorts of
resources for people who are teaching
online so I just wanted to highlight
that you can find it at arena slash
Melanie - hoff slash teaching online so
I would like to come back and add and
and maybe if there's time left over at
the end I will answer some questions
some nice questions came in on Twitter
and maybe next week I can make this the
subject of an entire live stream but
today I will be doing my PI day
challenge
[Music]
Oh Oh silly me
[Music]
silly me the thing that I'm searching up
is available playlists no private liked
videos
I gotta search it up
okay the other thing I want to mention
is that I am deep into whoops whoops
that shouldn't say one it should say why
I got to fix this I can fix this I'm
working on a entirely new set of nature
of code videos in JavaScript with p5
these are renewed urgency Ruiz that I
made almost eight years ago at this
point or actually eight years ago and so
if you're new to the channel expect a
lot of new videos to come out related to
this you can actually see they're all
there already so if the video has a
thumbnail that kind of all that means as
well a thumbnail was made a description
is there I made sure the code is online
it's linked but if you want to kind of
get ahead you can see all of these
videos are there and then the forces of
the chapter two has started as well so
one thing that I want to say about these
videos that some of them are unlisted
and some of them are listed especially
if a video is unlisted and there's a
significant mistake or issue with it
please let me know because if it's
unlisted it's very easy for me to delete
and re-upload a fixed version if it -
already published video it's harder for
me to do that but if there's a real
significant issue I will do that okay
I'm also gonna have to sing oh my
ukulele tuners battery is gone
we have to do some pi day singing maybe
today eating of some pie who knows I'm
out of sorts people out of sorts I
searched it up but I couldn't find it
Chris ray asks are you going to remake
genetic algorithm chapter uh not
probably no you know no I don't think so
so the genetic album chapter is actually
something that I revisited more recently
so there might be some added videos or I
might swap in and out a new version of
one of those videos but for the most
part that's going to be can stay what I
made a couple years ago but I do have
some ideas for some additional ones all
right so the first thing that I want to
do is I want to find myself a text file
with 1 million digits of hi let's try
this this is good 1 million digits of pi
just going to have to trust that this
file is correct let's put it on the
desktop and I want to find a 1 billion 1
billion digits of pi I don't think I
want to try with twenty two point four
trillion that would be nice
tied at 1.5 billion this looks like it
might be good oh here we go
PI billion this is gonna be a much
larger file right is gonna download it
effectively let's do it this way
okay this file is almost a gigabyte and
I have about two minutes left to
download it ok
ah recording two-disc time start
recording and multi quarter I am NOT
going to record to disk the whiteboard
view which I think you are now seeing
I'm not I don't have my preview up
anymore because I keep moving things
around and here we are over here okay
let's see does the whiteboard actually
working it is there it looks pretty
crooked to me I'm like skip using the
whiteboard today we'll see so this is my
plan so fathom information design
- org maybe no oppai de fathom comm
probably no all right fine fathom pie
pecan pie dot info fathom dot info / pie
this is where we are hi I am dot info
and in case I did forget which I did
forget lend me also before I get started
coding say thank you to glean org the
sponsor of today's coding train live
stream I will so brilliant is a
wonderful website and app and all sorts
of where you can learn a lot of stuff
and by the way if you need to learn
things remotely these days this is a
really good tool for you to use but they
have some new courses that I'm excited
to share with you and I always have a
daily challenge I always love to do
brilliants daily challenge and that's
something that I will be attempting
about halfway through this livestream
okay now and if it wasn't clear if you
want to take a look at brilliant go to
brilliant dot org slash coding train and
that will let them know that you found
this from from here and it will also get
you a 20% off even you can sign up for
free but if you're interested in the
premium subscription you can get 20% off
through that URL the first 200 people to
do so
okay so I want to make my own yeah Thank
You Simon so though I know that's one of
the reasons why I don't want to use the
whiteboard today there's something going
on with the lighting in this room
what I am interested in attempting to do
is make my own version of this wonderful
peek inside pi web application that was
created by fathom information design and
so if you don't know about fathom it's a
wonderful design firm cuffs started by
Ben Frey who is one of the creators of
processing itself and so here what I can
do is I can look for any sequence of
digits and find where they occur in PI
so I'm gonna type 1 4 and we're gonna
see if there they are it's the first
digit of pi and so if I keep searching
there we go but use their 1 4 1 5 9 but
instead of 2 1 4 1 5 9 6 and it was
found as the 731 thousand of thousands
406 digit of pi so this is good for us
to find because I now want to recreate
this exact thing I'm going to load in a
file with 1 million digits of pi and
then I want to create an interface where
I type this in I'm gonna have to say all
this again but I'm getting myself set up
because I'm gonna do that I'm gonna want
to create an interface where I type this
in and I want to find where if that
sequence exists in the number of digits
of pi that I have and if so where and
while I'm going to this in JavaScript
while I could just use the built in
index of function I'm going to write my
own search in a string algorithm because
um once I get to 1 billion digits am I
going to run into performance issues and
so here it is this was one of the spy
day suggestions and in this suggestion
there's also another website I think
that's actually where I downloaded the
digits from it looks like but there's
also other algorithms one known as Boyer
Moore which I actually have never heard
of until I saw it posted which may be
which optimizes this kind of brute-force
search so I don't know if I'm gonna have
time to actually implement this
and yeah hash and yes is asking that's
crazy you can't load this PI file into
the browser correct so I will be using a
node server once I get to the 1 billion
digits ok so this is the plan and I'm
gonna I would like this to be all one
video so all of that explanation
unfortunately for you the live viewer
I'm going to kind of read start
hopefully say it more succinctly and
then just get to coding and hopefully
I'll be done by an hour and a half from
now take a short break about a half an
hour 45 minutes from now and then this
will get edited and put together into a
video to be published on Saturday any
questions so many questions ok
what start this over
got my p5 sketch peak in PI 1 billion
digits PI search page
[Music]
I take challenge all right
okay um I think I'm ready
bill hem is asking why is he not using
processing for this good good point good
question I could use processing for this
I feel like using the browser so I could
do this in processing I could do that as
a follow-up video I'll mention it that's
it that's actually a great question
[Applause]
okay mmm here we go shake it up shake it
off shake a wee little we got happy pi
day welcome to today is this year's
2020s coding train pi coding challenge
and i thank you to fatima Bemis who
suggested this idea find a sequence in
pi so this is the challenge I'm going to
take on for this year's Pi Day I'm
saying the same thing many many times I
get one chance to start over one time I
get to start over now used I I used the
ukulele last year this will be more just
coding coding coding okay hi day hello
welcome to 2020 pi day coding challenge
thing that I'm about to do oh I really
got to get going because if I keep
restarting this we're gonna be a big
trouble because I have to no matter what
leave at 3:30
there's no and I mean when I say 3:30 I
mean I mean so I should really be saying
three I really gotta leave by 3:30 okay
happy pi day it's 2020 this year's pi
day it's today and I would like to do
it's not really today cuz I'm recording
this couple days early but I would like
you to see this on pi day a coding
challenge themed around the number pi
and thank you to fatin Bibi's who
suggested this one pi day
find a sequence in pi issue number one
for 64
if those numbers are where they are in
PI who will find out by the end of this
video how to look at how one might
search for any given sequence of numbers
in PI this can lead to a lot of other
things like what if those numbers were
encoded as music or what if music was
encoded as numbers or if you took a text
a message and encoded those numbers
could you find secret messages in PI
melodic phrases in PI there's so many
creative possibilities that you could
create from my code I'm gonna do
something really really basic now I'm in
this suggestion this particular website
I'm an geonet slash pi is mentioned it
has a bunch of different resources a
resource of where you can download all
the digits of pi a place to search for
pi but i this this whoops and it point
edit point this is what's going to be
edited out it'll be funny if we actually
keep that in c ah meta meta
this all reminded me of a wonderful
project from fathom information design
so if you don't know about fathom their
information design firm based in
Cambridge Massachusetts founded by Ben
Ben Frey who was one of the creators of
processing itself can find out more at
fathom dot info but they created this
project peek inside Pi which you can
play with at PI fathom info there's also
an app version a lot of the versions
I'll link to all those things in the
video's description so the idea here is
that I can type I could tap can I tap
let's see if I can fake it looks no the
point is for any given sequence like one
four one five nine look I can search for
it right here and there it is it's found
at the first digit of pi so now let's
pick another sequence like what's a
wonderful sequence it is today's date is
March 14 2020 and that is not in the
first 1 million digits of pi ah
if
we had more digits I must have more
digits so this particular web app is
searching through the first 1 million
digits of pi and that's what I want to
create first let's just try this so the
number 0 3 oops 0 3 1 4 2 oh 2 is
available is found
Simon's Simon's Simons
interrupting my flow you're interrupting
my flow with all the at mentions we all
the only really urgent at mentions
please but he doesn't Simon does have a
great suggestion did it to do good
[Music]
I'm told that I should search for the
number nine nine nine nine nine nine
which is the 760 second digit of pi so
let's remember that and make sure when I
write my own version of this that I find
the same digit so I'm gonna do this at
Fir I'm gonna do this with p5.js
JavaScript the browser I'm it's not
gonna be as nicely designed with a
beautiful interface like this but I'm
first going to recreate this exact thing
and then and then what I'm gonna do is
I'm gonna go from 1 million digits to 1
billion digits and see if I could still
search for edge in PI and probably I'm
gonna fail because we're gonna need some
kind of like optimization it's gonna
only run to slow everything's gonna come
crashing down but I'm gonna try
nonetheless
and we'll see where we get to by the end
of this video and I should mention just
in case I don't end up covering it
there are optimal ways to search for a
string to search for a string inside of
a larger string and one of those
algorithms called the boy or more
algorithm and so depending on where I
get I would get to the end of this video
I don't know why I'm talking about this
now it's not the end I'll know where
I've gotten to
[Music]
depending on where I get to that might
be something that you could also do as
your own as a contribution when I know
that could also be something that you do
as your own contribution on the coding
train com itself by making a optimized
version of this alright
okay here we go
let me just put this in applications
I'm starting with a simple p5 sketch and
two text files one with 1 billion digits
of pi which is just a megabyte and one
with 1 billion digits of pi which is a
gigabyte that's a much bigger file so
let's start with the one megabyte file
I've uploaded it I've uploaded that file
to the p5 web editor and I can load all
the text from that file right now using
preload
I'm going to just take away animation
here I'm going to get rid of the draw
loop and I'm gonna say no canvas and
then the file itself has all of the
digits of pi in one line buttload
strings loads text files into an array
with each element of the array being a
different line of the text file so what
I'm going to do here is create a
variable called digits and just say it
is the first element in that raw data
array let's console.log digits and just
see what happens
okay so all of the digits of pi are down
here in the console now what I want to
do is search for a given digit let's
make an interface a very very crude
simple interface for searching
so now I have this tiny tiny search box
up here can I make that bigger this is
one of the things I hate give me a
second here this is one thing I don't
love about using the web editor because
can i zoom an iframe can I just make
that bigger can I do it with the CSS I
don't want to go crazy here if I do
something like just say what is it like
text size or something I don't know CSS
somebody tell me how to put some global
CSS font size okay no that seem to work
but I didn't make the text file do I
need to do it for like input
hey there we go perfect that's probably
bigger than I need there we go that's
plenty visible now okay
I also just added a like I also just
increased the font size for any input
element on the page so it's a little
easier for you to see but that's you
know the interaction that I'm looking
for is anytime anyone types anything
into that search box I want to look for
that string that that those digits in PI
itself and p5 GS has a special event
function called input which you can call
on the search box and pass another
function that will be executed anytime a
change has been made so let me write
that search it up function because
that's when I was looking for something
I say search it up and then I'm going to
be a little silly and make these global
variables
and I'm going to then then let me get
what I'm searching for
from the search box and console.log that
so now whenever I type anything into
that search box I should see what I type
here in the console and that's working
this is gonna actually be a really easy
project to do you know why because I
could just use the index of function in
JavaScript to tell let me do that real
quick just please please guys real quick
I'll bet you that real quick digits
index of search so this is saying look
inside this search string and give me
back the index of where oh no no this is
saying look inside the long string
digits and give me the index of wherever
this string search happens to appear if
it doesn't appear I'll take a negative
one please so I'm gonna say create let's
make another element on the page
and
No
how do I make that people I don't know
CSS at all help me out here the leaf
it's making it red when it's wrong font
color no color should be collar right I
mean I could make a background color
that I know will work no oh this is
wrong
oh I need another that's a wrong number
of digits I'm the worst
I'm the worst there we go okay yeah just
don't
so now when I get that index back I can
say index P dot HTML that index which
will put the actual index where it's
found in the paragraph text there on the
webpage so for example if I say one four
one five nine hmm why does it think two
so really when counting the digits of pi
what seems to be the convention is the
first digit is the first digit after the
period so it's three point the first
digit is one so I should really say
index minus one and now one four one
five nine I got one and then what if I
say nein nein nein nein nein nein I got
200 all right so we got it man nine nine
ninety-nine appears at the 760 second
digit in pi
I'm also going to write a little if
statement here say if index is greater
than well I guess if I'm looking for
three if that's a bug so if I'm looking
for three that's a zero which minus one
how do I do I want to handle that bug
index of must let me start searching
from a certain character right
start from index - great
so if it's a three I don't want it to
find that zero digit so I'm gonna start
searching from index to and there oops
great so I guess I hope that's right but
a 3a doesn't appear until
[Applause]
the chat is also rightfully pointing out
that I could just chop off the first two
digits of the string it would be much
too easy I'm gonna do it this way so I'm
gonna start from looking at digit two
and I'm going to say as long as index is
greater than zero set that otherwise say
I'm going to say
otherwise I'll put a message about it
not being found okay so let's try one
four one five nine nine nine nine nine
nine nine not found so I now have
essentially without the care and thought
into the interaction design the visual
design the layout of the page all of
those elements recreated my my own
version of this peek inside by I got
this videos not over them I got two more
things I want to do number one is I want
to just investigate what does it mean
for me to actually perform this search
myself to write my own index of function
because maybe if I do that might unlock
some other creative possibilities and
also I might learn something about
programming and then once I do that let
me increase things up to 1 billion
digits and see if this still works which
it won't and I'm reading the chat I
shouldn't be reading the chat let me
increase things to 1 billion it's and
see what happens what breaks down once I
have a 1 gigabyte file that I'm loading
all the digits of pi in as opposed to 8
1 megabyte file right so let's first
write our own index of function so I'm
just going to change them to comic this
out and I'm going to say let index
equals index of a search in this string
for this search string okay
so search in the string digits for the
string search
and so the function looks like this it's
named as an ex uh it needs to receive a
block of text and the substring that
you're searching for in that text okay
I'm thinking about this let's say we do
this let's start with what's the first
character in the search string then I
want to iterate over the entire string
of text and say hey does this character
in the entire string of text match the
first character of the search string
if so I need another loop with J
starting at I plus one well actually
let's do it this way
let's bending to loop through all of the
characters of that search string I don't
have an error here bad assignment
Oh
they supposed to say four so I don't
need to start at zero because I've
already checked to make sure that's zero
and I want to check is text car at I
plus J the same as search car at J again
I'm I'm not worrying about running this
optimally or elegantly I just want to
get the core idea out I'm starting with
and I really should use the whiteboard
for this do I dare a whiteboard is all
like weird and shadowy this light for
there's like a nice bright light that's
always been in this room that is very
dim today
is it - oh you can't even see that
that's of sad
3.14159 let's say I'm looking for the
string for one five
so in the example and building this is
the text let me just start over okay
that person is I feel like a water they
should be riding the water a little bit
longer I would kind of short what comes
after the nine people is it - I hope
it's - so let's say this is my text and
what I'm looking for is I want to find
out where is 4 1 5 in that particular
string this is my search sorry my watch
is buzzing at me and I am going to turn
that off okay okay uh I'm a jolly happy
person I'm not actually bothered by
anything I just like to play act okay so
this is my text and this is my search
string what I have going on here is I
know the first character of what I'm
searching for is four so I the index I
is starting here and looking is that for
as that four is that four is that four
aha this is for now let's let's save our
let's save this spot and then based on
this length three which let's let's
iterate over this length with J zero one
two and let's add j2i zero one two and
see if all those digits continue to
match
okay so ultimately really what I'm
looking for here is any things any of
those digits that aren't the same so I
really want to look for first I'm gonna
be very strict about this and use the
triple equals there's a funny thing in
JavaScript if you haven't encountered
this before where if I use double equals
this will return true but if I use
triple equals they won't so it's a
little like double equals is a little
bit of a fuzzier truth and triple equals
like no no no no those things are really
really really really equal fuzzy or
equals I guess I don't know if that's
necessary to explain I can probably edit
that out and then I'm going to say not
equals so basically I'm I'm going to
make a I'm going to make a guess that I
found it right as soon as I find that as
soon as I find the first character as
soon as I find the first character be
the same aha I found it and then any
time I find any need to be different I
can now say found equals false so the
question becomes right here if found is
true then I can break out of things and
once one is not true I don't need to
check the rest so I can break out and
then if found return what so I'm gonna
say let found index equals negative one
I'll give a default value of negative
one and then actually if I've found it
right here found index should equal what
I wherever we started with I and then a
little bit lost in terms of all the
loops going on here
and then if I've gone through every
possibility and I haven't found it then
I'm gonna get to the end and I'm still
just going to return negative one but
found index will have negative one so if
I found it somewhere I'm gonna set it
equal to that first index get out of the
loop I don't need to check anymore
because I just looking for the first
instance and then return what I found I
must have made a mistake here somewhere
right there's no way this could be
correct and I'm gonna add a third
argument for offset and I can say
and just as a really quick hack I'm just
gonna start at index equals two to skip
the three I mean whatever let this is
fine let me just start it ah let's run
and see if this works
No found is not defined sketch line 22
this if statement has got to be inside
here right this is where I'm looking at
every single character in the large
string I'm searching through as soon as
one of those characters is equal to the
start check every check all the
subsequent characters and then if I
found it break out of that larger loop
and keep going so that this should be
right now I'm sure there's other
mistakes but that will be fixed all
right one four one five nine at digit
number one which is right weirdly enough
I didn't subtract out the one anywhere
right
so the chat is giving me a nice quick
optimization that the chat is give me a
nice suggestion where I could simplify
this code where I don't actually need
this found index because I could just
return I which will automatically break
out of the loop and then if I get to the
end I could just return negative one so
let's try that again yeah why is that
one shouldn't that be zero one shouldn't
that be getting to oh I'm already
subtracting the one there great great so
this works let's try the 999 thing there
we go
so this is done and this algorithm has
no problem with 1 million searching and
a string of 1 million characters be
interesting to think of what is the try
it different number
two-thirty excellent I'm gonna be taking
a break soon I'm trying to think
Oh Thank You Simon about the noting the
thing about brilliant I will check that
big o-notation
one thing I'd like to think about here
is what is the Big O notation for this
particular algorithm so when I talk
about Big O notation
why is it Oh again order that's what I
thought okay one of the things that I
would love to consider here is what is
the Big O notation for this particular
algorithm Big O for the order of the
algorithm how long how many
computational cycles are required to
search for a string of n characters in a
larger string also of of n characters
boy yeah way is there any moderators
here it can help me with this report
[Music]
oh and and yeah oh okay I'm trying to
moderate this know if anybody wants to
help me with that that would be great oh
my god so many of them
are there no moderators Ally watching it
okay
Topher jay is here thank you thank you
to forge a train whistle for you right
so let's think about this I'm gonna
start this thought over so before I move
on I want to think about the Big O
notation what I mean is what is the
order what is the computational
complexity of this particular search
algorithm so I have a string I'm
searching through and it has its length
is n the characters and then I'm
searching for another string whose
length is M characters and when work
when considering Big O notation the idea
is to think about the worst case
scenario how long does it take if I'm
not going to find it basically or if I
find it at the very very end of that
string so I know I need n checks 0 1 2 3
4 5 6 7 all the way up to N so it is at
least Big O order n but for every one of
these I've also got to check I mean if I
find one of them I've got to check all
of these so really I think it should be
how like if this 10 digits here and
there's 3 digits here that's 30 checks
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2
3 1 2 3
now of course it's less than that
because I only had to check these three
when I see the four matches but imagine
if this whole string were fours and then
this were also before I'd always have to
keep checking so it's really just n
times n n times M and let's remember
that for when we start looking at 1
billion digits Oh
so is that like reduced to just saying n
yeah you know I know there's some BOTS
in the chat I apologize about that I
have like really not usually had this
problem so I've never had to sort of
deal with it but there's some folks on
the case here so hopefully we could do
know it's crazy as the bots or just like
it's confusing because what they're
doing is they're taking other chat
messages that other people have posted
and then re posting them with some extra
emojis it's kind of amazing I don't know
how to permanently ban an IP so we'll
see what we do okay yeah and let me say
that and even though ultimately the
order is the big o-notation is n times m
because the idea here n is going to be
so much larger than when I'm looking for
an M this can be sort of reduced down to
a operation of order n which isn't so
bad to be perfectly honest
so to tie a little bow around this we
say that this is Big O notation n for
the length of the search string the
string that I'm searching in alright so
I'm gonna take a short break maybe this
will also help us get rid of the bots
they're very emotional needs bots and I
[Music]
and I am going to take a minute to tell
you about the sponsor of today's a
coding a train livestream which is
brilliant brilliant is as been a
longtime sponsor of the coding training
I'm very thankful for having the sponsor
it's a website an app and I really enjoy
if you're interested in interactive
learning as you're trying to do some
learning from home these days I this
could be a useful website to you they
have a lot of online courses and one of
the things that I really love is how the
courses are interactive so I want to
tell you about some some new stuff
whoops that is that that to highlight
for you that are different than maybe
what I've highlighted before and so
there's a new calculus in a nutshell
course in calculus is a language used by
colleges urban planners physicists you
need kind of calculus to do stuff on the
coding train to describe the world but
it's often a lot of formulas and a lot
of memorization so brilliant takes a
bird's-eye view using visual and
physical intuition by the way I mix
we're going to tell you about the neural
network one which is what's playing
right now to present major pillars of
calculus limits derivatives integrals
and infinite sums so in that calculate
calculus course there's a lot of sort of
background material through interactive
lessons I can really support the stuff
that I'm doing on my channel I'm really
excited about this new neural network
course a little behind and talking about
in terms of when the videos are
auto-playing but what you're seeing here
is a couple simple games that you could
play interactively in the browser to
learn the basics of how neural network
functions so wiring up neurons and a
process of feedback you can build net
where you could get to build your own
network
that classifies handwritten digits and
then there's another game which you just
saw called where are my keys so I'm
gonna come it doesn't take too long to
play something to come back and explain
you that one when it comes back on I'll
work on my timing next it's really bit
of rough week people but this is what
I'm talking about in terms of the
calculus course being able to play with
formulas and visualizations and graphs
in an interactive way it's a really fun
thing to do and and you know the
formulas can be scary but this is really
healthy so this is the neural network
course so let me tell you about this
this key is one which will show up in a
minute
so the the ideas you'd want to find your
keys in a messy room so the tiles the
color in as you search and this is still
doing the handwritten digits revealing
how close or far your last guess was
from the keys so it's gonna start so
that's what this is so you're looking at
ah is that close kind of like hot or
cold this game I mean I feel like my
kids play this game and basically
without any clear indication of how to
structure your guess is you can
nevertheless get better round after
round adjusting your response to
feedback eventually finding the keys and
this is really analogous to this sort of
feedback based process the way that
neural networks learn so you can just go
right ahead and you can sign up for
brilliant for free right now just by
going to brilliant org slash coding
train if you're in and a lot of the
content is there for free so for example
something that is for free are these
daily challenges I'm gonna try to do one
of them right now
a Simon was mentioning to me that
actually maybe my search string
algorithm is part of let me see if I can
find his message computer science
algorithms archive let's try looking
that up
brilliant org courses computer science
algorithms
- archive
so somewhere in this course maybe maybe
there's a section on substring finding
when I maybe I need a more a more direct
link right - or I might have typed in
something wrong but I will find it and
share it with with the community either
here in this live stream or on discord
if I don't get to before him but I want
to do one of the challenges these are my
favorite things to do let's just try the
one that's right here what is round and
spins with teeth all over so the
operation of a system of gears and I've
lost my chat here for a second
follows only one rule teeth in contact
always move in the same direction at the
same rate so based on the size you can
see us this is run ten revolutions per
per minute I guess rpms per second
whatever rotations per minute
yes ten rotations per minute revolutions
one Avenue shoals
per minute the larger one rotates at two
rpms because the ratio of the size the
bronze gear has ten teeth oh it's a
number of teeth and the gold gear has
fifty teeth okay so oh I think I see
what this is gonna be already and the
gear system below a set of silver gears
injuries having 20 teeth the silver gear
on the left turns clockwise at ten
rotations what speed and direction will
the one on the right half so I'm just
gonna be using my intuition here but one
thing let's say let's figure out which
direction it's going to move so if i
zoom in on this for a second this one's
moving clockwise so this one will move
counterclockwise so this one will move
clockwise so this one will move
counterclockwise so it's
counterclockwise so one of the things
that I work on with my kids is like if
you're taking a multiple-choice test you
can always good to eliminate things so
maybe I'm not gonna be able to figure
the rest out but I kind of now know it's
one of these two now my intuition is
it's going to be counterclockwise at ten
because ultimately the what is what what
is the way to calculate
the amount of rotations per minute has
to do with the relative ratio of teeth
and that one at the right is the same as
the ones the left so even if it's like
becomes a smaller number which becomes a
much bigger number which becomes back to
a smaller number it should be ten so I'm
guessing it is counterclockwise at ten
rpm I hope I'm right about this but like
I say it's great to be wrong because
when you're wrong that's when you really
learn so I should really be happy with
being wrong it sometimes can feel a
little embarrassing but guess what life
is embarrassing all right let's hit
submit probably all figure this out much
faster than me
correct whoo all right and let's see oh
look here someone's got a nice
explanation and formula which is that
okay so I guess you could count the
teeth so this is 10 which means this is
I should say 40 here but 20 here to
think about this there might be an error
somewhere here but you can see the idea
let's look at some other solutions yeah
20 divided by 10 10 divided by 50 50 by
20 get back to 10 yeah this is a nice
extinct way of saying it so anyway if
you have some clever ideas Vernal this
would be an awesome thing to simulate
with p5.js to make this animate that
would be really fun to do so if you are
interested that would be a great coding
challenge to do you could try it and if
you have other ideas for great answers
to put here you could you could put them
here and Florence I'm not going to
answer your question about what ide i
use you're always just chatting chatting
chatting florence okay when is the CNN
video coming oh I don't think I artists
flowing again I got to take a break let
me take a break and see if there's
anything I could do if anybody knows
Simon is telling me the course is called
algorithms during the break I'm going to
look for it to see if I can find it if
anybody knows any way that I could
effectively ban the box more
definitively let's see if I can try to
do that during the break as well so I'll
just say a 5-minute break and be back to
try to search through a billion digits
with no js' in about 40 minutes I don't
know if I'll be able to do it but I'm
gonna try
[Music]
all right folks I'm starting back up in
just a minute or two because my time is
super limited so
[Music]
okay I'm back I don't have a lot of time
so I'm taking a shortened break a couple
of things one is looks like I need to
get like something like nightbot or
something - which is a tool that I can
use so maybe manage to chat better the
only at present just manually with to
like hide users so if the new counts
keeping being being made so I'll look
for the next time I will look into
setting up nightbot for for the next
stream somebody please remind me of this
in discord if you haven't joined the
discord join the discord somebody can
hopefully post that that link to the
chat right now if you have moderator
privileges you can post a link to the
discord that's where all of the
community activity happens outside of
the actual live streams okay this is a
very bad idea what I'm going to attempt
to do right now because I probably
should just call today that was a nice
little thing that I made and I could
talk wrap it up and talk about other
things you could do but I am going to
just bear with me I'm going to get
myself set up to do a part two of this
[Music]
okay
[Music]
okay all right so what I am so let me
let me do something here and we get the
browser open oh did I mention by the way
so we found it in the algorithms course
on brilliant there's a whole course
section in the algorithms course under
substring searches so oh boy I really
wish I had gone through this before
where I started today but I will take a
look at it and come maybe maybe it'll
help come back to it Simon had mentioned
DFA and KMP algorithms I don't actually
know if it was hard but maybe I can look
those up in and offer them as things
suggestions okay all right so so you
know what I don't know that I'm just in
case I can't even come back to just in
case this needs to be a two-parter I'm
gonna I'm gonna record a little ending
as if I'm gonna do the next steps in in
a second part so huh I don't like having
a time pressure thing definitely do not
have enough time we'll see you I might
have to come back tomorrow somehow see
if I can figure it out okay
df8 let me just look at what these are
DFA algorithm search string is that
anything pattern searching PDF DFA based
algorithm and KMP I'll figure that out
alright so this really wraps up a small
piece of this coding challenge I have
made my own version of fathom
informations peek inside pi I even wrote
my own string search function there's so
much more that you could do with this to
be creative I mentioned at the top that
you could think about what if what you
weren't looking for were just numbers
but you were looking for some other
piece of data that's encoded into
numbers so we could you find secret
messages in PI or pieces of music and pi
are there other kinds of algorithms that
you could explore that you could
optimize this particular search
algorithm with foot with and I'll list
some of those in the video's description
that's a little challenge out to you to
research some of those and tell me about
your favorite substring search algorithm
in the comments but those are going to
be needed for when I take the next step
and attempt to get this working with a
billion digits of pi and for that I'm
also going to need a node server so I'm
going to come back and do that in a part
two to this video it might be right
there for you to watch right now but if
you're kind of watching this right when
the video came out it's probably not
there yet but don't worry I'm definitely
getting to this one so stay tuned for a
part two where I don't even know I've
done it yet so it might not actually
work but I'm gonna do my best to get a
version of this working where I can
search for any sequence of digits within
1 billion digits of pi and from there
the sky of pi is the limit
let's see you soon
all right I don't know let's see where I
get to
I'm Annie G's read stream I think I can
so we'll figure this out later it's good
to have a plan okay I just need like a
little extra time today I'm so close I'm
not leaving you don't have to say
goodbye all right I have an idea I have
an idea
so here I am in the sketch I wrote
previously what do I do I'm really I'm
obsessing just so you know I'm obsessing
in my head about what this is gonna
become later but you really should enjoy
just let the let the coding flow let it
just happen Oh today is one of those
days I'm really having a hard time okay
yeah this is gonna be - it's gonna be
two short videos part 1 and part 2 or
not I don't know I can't decide so
here's what I have so far
I made this sketch where if a digit
appears in the first so here's what I
have so far I made this sketch no go
away
Apple thingy so here's what I have so
far I've made a sketch where if I type
in any sequence of digits like eight
three six five one eight up it'll give
me the index into the first million
digits of pi where that sequence can be
found or if it's not found it'll tell me
it's not found and I'm doing this by
just loading a text file with the first
million digits of pi and searching in it
so at the very least I could be like
okay let's run this exact same code but
now let's take a text file that has a
billion digits of pi so I'm gonna go
back to add file here and I'm gonna go
back to my file system ignore that part
and I'm gonna come over here I'm gonna
find my billion billion dollar write my
billion digit PI file drag that into the
browser here and mmm
well I'm surprised and not really
getting an error message or anything but
the web editor will not let you upload a
file that big and even if it could am I
really gonna expect my client-side code
to load well one a one gigabyte file
with a billion characters in it
now this plenty weighs probably that
file could be compressed encoded a
different way I probably get down to
like 600 megabytes or something but
that's not really my concern my concern
is how can I load that file into memory
Oh David you're here I'm still here
welcome but whether it's 600 megabytes
or a gigabyte I've still really got the
same problem I have this like huge file
so rather than try to work with it
client-side in any type of clever way
I'm just going to use a node application
by the way I could probably do this in
processing because a desktop piece of
desktop processing is not gonna have any
problem loading a really large file but
I want to stay into JavaScript I'm going
to create a node server that can load
all the digits store them into memory
and then my client-side JavaScript code
could query that node server
now if you've never used node before I
do have a few basic beginner tutorials
about installing node and getting setup
with node and I'll refer you to those
but I'm gonna start from the point where
I have a directory with a blank
javascript file a package of JSON files
to describe my project that I'm building
and both a million digit and billion
billion digit file of Pi so I'm gonna
start by working in index touch I asked
to write some code to load that file so
first I need to require the filesystem
module and one thing that I could just
do is just with the million digits of pi
let's just read file sync let's just
read the whole file in and see what
happens
Oh interesting so the file has been read
in but look how it's being displayed
it's giving me the binary information
into the console so I want to tell it
that I want to read it as a string and
I'll use utf-8 so that's a second
argument to read file sync and now here
we go and there's all those digits of pi
all those 1 million digits now let's
just change it to why not keep it to a
billion what could possibly go wrong
Oh interesting did something but it
didn't print anything out so I know this
is just basically a bad idea I don't
know whether something crashed or memory
ran out but read file sync for a
gigabyte file is not a good idea and I
think what I want to investigate here is
create stream create read stream so let
me just look for that let's just find
this page no this is I don't want this
page I just want the documentation page
here we go
so I'm on the node documentation page
read stream or create yeah here we go
create read stream so create read stream
is a function I can call to create eight
so create read stream is a function I
can call to open up a stream for reading
the file so I can read it bit by bit I
can kind of track how long it's going to
take and get what I want and piece it
together just gives me a lot of options
so let me do that by saying stream
equals FS create read stream and let's
go back to the million and then once I
have a stream I believe that I can
basically handle different events so for
example I can say stream on data that's
when anything is actually coming in I
can then have a callback function and
just console.log the data
I've got a problem why is there a four
space tab what happened what happened to
you visual studio code I can't deal with
it
the number of spaces a tab is equal to 2
- based on the file contents when editor
detect and indentation is on somebody
help me I can't take it CJ are you out
there somewhere
I'll see Jason the chap help me help me
I can't go on I can't go on maybe
there's something wrong before space is
I just I can't handle it mind if I tag
here tab sighs - where do I get the
board I just hit the JSON file though
the interface has changed I'm so
confused
oh there we go tap size 2 to 4 now save
true-true - okay okay
bottom right bottom right bottom right
bottom right uh here we go thank you
how do we change this and don't use a
spaces whoo thank you everybody
oh no no huh well went back
there we go okay we're okay now I don't
know how do I permanently change that
yeah okay I don't know why I don't know
what I don't know what's going on okay
we're back
so now if I run this hopefully I'm gonna
see all those digits streaming out I'm
still just gonna use the million the
million digits file okay oh I'm getting
I'm getting the binary data so probably
I can say just data to string rate so
that's the million digits of pi you're
in I'm sort of curious to do console.log
like how big are the chunks that it's
reading this in yeah you can see so you
can see these are the chunks that it's
reading the data and they're pretty
large because I put some line breaks in
between each each each chunk of the
stream in fact I think a lot of examples
use the word sort of like a chunk here
so now let's try 1 billion digits of pi
yeah okay we have 1 billion digits up hi
boy this is taking a while oh there we
go
all 1 billion digits could I possibly
just put them all into one string
and then uh-huh if I have stream on I
believe it's end I think there's an end
and a closed and by the way if this
arrow syntax isn't familiar to you it's
a nice way of writing callback and
anonymous functions and there's a lot
more to it than that and I have a whole
video about arrow functions you could
watch let's just do digits dot length
and see if we get 1 billion digits digit
is not defined data digits
and look at that it's 1 billion in two
because the three and the one don't
actually count okay now let's just
search for a digit ah I might be able to
finish this fast fast fast huh
I gotta start a web server and all that
kind of stuff okay okay okay let's grab
my index of function that I wrote
previously and bring it into the node
code and then let's look for I'm just
going to hard code this let's search
what was I looking for nine nine now
let's look for $9.99 and then index of
digits search and then console dot log
index
763 old minus 1 minus 1 minus 1 minus 1
ok so that worked now here's the thing
that didn't take very long because that
is actually found at 760 - does anybody
know of a sequence of digits that's very
very far into the sequence of a billion
digits that would be helpful to know
while you're thinking about that for
those of you who happen to be watching
this live not in the recorded video that
you right now not you watching this live
but you're watching this later or
watching let's just quickly add in a web
server so I can make a call to ask for
the location of a given digit
yeah yeah yeah yeah where's my very
basic example take a selfie app this
works okay
so in this video I'm not going to go
through all of the pieces of adding a
web server and how HTTP requests work
and get requests and response and all
that stuff but guess what if you're
interested in a much lengthier series
about all of the details lemon add
quickly right now you can find that in
the working with data and AP is in
JavaScript a learning playlist that I
have on this channel but for now I'm
gonna go and copy paste but I'm copy
pasting from the code that I have for
those examples right here I want to
create an express app so I'm gonna add
an Express app I want I don't need this
database stuff so I just need to create
an app Express I want to listen that
port 3000 and then I need just a get
request so I'm gonna grab this I just
want to handle one route I'm gonna say
get whenever I do I'm gonna just call
this route search and then here how do I
find the digits wait hold on yeah
requests not body oh I just need a
simple get request
we're how do I do that thing you
thinking a Bob where if it's got
parameters does that not in this example
[Music]
and in this example
yeah this is what I'm looking for sorry
I want this one yeah okay
actually I'm gonna call this pie and
then I'm going to use one of those
things called rusty and routes something
like that to look for some sequence of
digits in let's call it search let's
keep it with search some sequence of
digits and what's going wrong here
oh this needs
request params digits right it's not how
that works yeah
so basically I have a simple get request
when if ever I run this server any time
somebody navigates to search slash some
sequence of digits I'm gonna pull out
those digits and just send them back so
let's run this server and let's get rid
of I'm gonna get rid of just this I'm on
end stuff right now I don't need this
actually I'm just gonna write
console.log billion digits loaded and
let me run the server mmm err oh I've
got to install Express so Express is a
nice framework for making web servers
and node then we run it again so I'm
listening at port 3000 the bindle
billion digits are loaded I'm gonna go
to localhost 3000 there's nothing there
but now if I go to slash search slash 1
like 4 3 3 to 5 or I see it I got it and
I sent it back guess what I can do now
this is really exciting so now if I go
back to sorry everybody
hmm
so if I take this code where I was
searching before and I bring it up here
and I can say search equals request
params digits search for it within the
digits and then send that response back
but ultimately I want to turn make this
JSON so I'm gonna say index I'm gonna
make this a nice little JSON object and
I'll also send back what was the search
string as well so let's try this one
more time and let's switch to a million
digits to make this I know that it runs
faster so I'm going to just change this
to a million digits go back to the
browser hit refresh oh I've got to
restart the server go back to the
browser and there we go
this particular sequence of digits was
found at that index let's double check
this with fathoms peak in PI the digits
were 4 3 3 2 4 it's found at the 35th
thousand third at the 35th thousands 570
second digit of pi is that what I got
yes that's what I got so my search is
working and now let's change it well
let's get it working from our interface
first then we'll try it with a billion
digits so now I don't want to just do
this by hard coding this into the
browser I want to go back to my p5 code
and in my p5 code I'm not going to load
the data file there I don't even need to
do the search there so index of can go
to way go away but whenever I want to
search it up instead of actually running
the search I'm going to make a get
request so I'm gonna say load JSON the
the URL is and HTTP well let's just grip
Gravatt localhost colon 3000 slash
search and then add in the actual search
value this is a string literal which is
an incredibly convenient way to put a
variable into a string I'm gonna I'm
gonna call low JSON got results and then
when I get the results the result comes
back in index and that is where I'm
going to put it in the paragraph
get rid of these things I don't need so
basically this is just the interface and
the interface whenever interface goes
and asks the server to look in the
digits with the server being the one
that can handle holding on to those
billion digits so but I need to host
this webpage and the way that I'm going
to do that it's use express the same
Express server that is serving up the
digits of pi that the index value into
the digits of pi to serve up these web
pages and that I can do with adding like
Express static something-or-other
let me go look back to my older
tutorials about this it's right here app
got use Express static public so I want
to host everything that's in a directory
called public which happens to be what I
just called it back into the server
there we go
and you can see I have this the p5
sketch that I've been working with is in
the directory public we don't need this
million digits of pi anymore there it's
not part of the clients at all just part
of the server let me restart the server
let me go to localhost 3000 mmm uncaught
error raw is not defined so I've got
some errors in my p5 code
oh I don't need the digits no longer
belongs here
there's some weird extra error about
style dot CSS I'm not concerned with
that let's just get rid of that there we
go okay now ooh okay it's searching it's
always finding negative 2 because it's
searching for this like : what what
weird that : come from where did I put
that in by accident oh look at that oh
it's just an extra : that I had actually
in the string that goes away by go away
:
it works it's searching in PI but the
searching is happening on the server so
now it's time this is the grand finale
of today's coding train hide a challenge
we are going to search in 1 billion
digits of pi to find any given sequence
of digits it is time I'm going to do it
to go back to my server code close
anticlimactic I'm gonna change it to
loading the billion digits of pi I'm
gonna restart the server I got to wait
it loaded the billion digits it's now
waiting for me going back to the webpage
let me just refresh this webpage and I
don't know let's try searching question
is has it found it no it didn't find
that so Kim somebody's a fact checks
this for me is that sequence not in the
first billion digits of pi
that sequence is not either
it was finding it before yep it found
that one so this so far is the longest
sequence I've been able to find let me
just change this to a five and found
that it takes a while it's slow it's
slow David suggested a string two oh
seven seven five five one zero let's see
if that works - oh seven seven five five
one zero there this is at digit number
176 million eight hundred sixty-six
thousand three hundred and seventy seven
that's pretty good
I suppose I could look up in that text
file I have well I have an idea
let's look at what's in that text file
the last few digits
digits dot well let's start digits dot
length minus ten I could use like
substring or something but I'm just like
afraid so let me print out the last ten
digits in the first billion digits of pi
wait what just happened there
oh no no digits car car at
okay I really have to be like this
I'm doing this in the weirdest most
nonsensical way
so with a little detective work I have
determined that these are the last ten
digits in the first billion digits of pi
so just to see how slow is the searching
I'm gonna refresh this page and I'm
going to paste those last ten digits in
here and we're gonna see how long it
takes there we go it found it and that's
not so terrible so we can't even with my
crude brute-force algorithm find any
sequence of digits in the first 1
billion digits of pi by having both a
server and client talk to each other so
many possibilities here
how could you optimize the search
algorithm how could you make the API do
all sorts of more fun creative things to
give you more information about what's
in pi
could you put this on to glitch so we
could maybe we could make this like the
glitch is a hosting website that allows
you to deploy different kind of creative
web applications so maybe I could make a
version of this that runs on glitch that
people could remix I will include a link
to that if I can get it to work in this
video's description
and you could just be much more creative
about the interface and once again what
are you actually really searching for
could you search for secret messages in
PI by thinking about encoding text into
digits music in PI by encoding musical
notes and melodies and rhythms into
digits
colors in the digits what data could you
search for in PI and what what wonderful
things could you discover that way and
maybe you could find a text file with
more than a billion digits and make your
own version that searches into even
larger number of digits of pi I hope you
enjoyed this pi day coding challenge I
will sing you out with my song about the
last ten digits in the first 1 billion
digits of pi which has not been
rehearsed or planned and as ukulele
hasn't even been tuned in like a month
so I really hope this doesn't end up in
the video and get to edit it out instead
[Music]
what did I do last year
[Music]
no we're not gonna do the song I don't
have time I'll come back tomorrow and do
the song if I have time thank you for
watching this coding train coding
challenge pi day thanks to fathom
information design for the inspiration
with peeking inside Pi and thanks also
to Fontan bibi's and all of all of you
watching this live on the lan during the
livestream with all of the suggestions
and help that you offered I'll see you
soon next time on the coding train have
a great day ride all aboard all that
nonsense look that catchphrase it's
coming one day oh this is my country
it's not a phrase it's a sound - train
whistle sound that's my country's okay
alright everybody I am really under the
gun in terms of time because I have to
pick up my daughter at school at 4:20
settle down people
that's the actual time I have to go pick
her up and it takes me a little while to
pack up everything and it takes me a
little while I'll take the subway or
walk there depending on what's happening
with the subway I mean if I don't
actually definitely don't have to it's a
45-minute walk from here so there's no
way I can walk the subway so thank you
everybody I'm gonna just like quickly
race out of here I'm gonna be doing
that's I'm gonna be doing some coding in
the Cabana video soon I was gonna spin
the wheel I'm like you're like a quick
I'd be home alone it seems like the way
things are coping as I discussed what
good vienna's livestream is I'm not
gonna be able to be at work
the studio is often or perhaps never for
the top for a period of time so I might
try to figure out live streaming from
home I might make more just putting the
Cabana videos stay tuned please join the
discord where I will announce all this
stuff and all of that and so I will see
you all soon thank you for watching this
I don't know if this is gonna be able to
get edited together into something by
Saturday if it can't then it can't but
I'm gonna give it a try so stay tuned
wait for Saturday and we'll add some
extra fun things in it you have any
creative ideas want to participate in
that join the discord join the discord
join the discord borrow everybody well
I'm not ready to leave you I'm gonna hit
stop recording I'll leave it open for a
second while I do some of my cleanup
stuff stop cording I hope this worked
what are you gonna do if it doesn't the
problem yeah the hole 1 million
subscriber thing you got to deal with
that too all right everybody did you see
you later time for the diss song thanks
again to brilliant sponsor of today's
livestream sorry
[Music]
I'm gonna do this this star this star
this star this star song never forget
the Vista this is somebody compose that
song for me
[Music]
I'm gonna say once again coordinates
[Music]
coordinates
[Music]
and auto-tune and the internet will fix
that for me
[Music]
coordinates
[Music]
unicorns and rainbows and cupcakes what
else is there
yes kittens thank you very much kittens
and rainbows and cupcakes notice that
look what I get I really lives in my
mind
[Music]
I feel just sort of like a nice feeling
of relaxation everything's gonna be okay
today dream is not broken it has not
frozen this isn't this is a wonderful
thing okay
we're gonna do it I'm really getting to
something I need my sound
[Music]
all sorts of generation analysis things
that I will use continuously over and
over again
[Music]