Coding Challenge 161: Estimating π from Random Numbers with Euclid's Algorithm

  Рет қаралды 46,413

The Coding Train

The Coding Train

Күн бұрын

🥧 Happy Pi Day 2021! This year I estimate the digits of π with random numbers and the probability of two integers being co-prime. thecodingtrain.com/challenges...
🎥 Matt Parker's Generating π from 1,000 random numbers: • Generating π from 1,00...
🎶 Pi Day song by Will from America: willfromamerica.com
🎨 Character design and animations by Jason Heglund jasonheglund.com/
🎬 Editing by Mathieu Blanchette
p5.js Web Editor Sketches:
🕹️ Estimating π from Random Numbers: editor.p5js.org/codingtrain/s...
🕹️ Estimating π from Digits of π: editor.p5js.org/codingtrain/s...
🎥 Previous video: • Coding Challenge #160:...
🎥 All videos: • Coding Challenges
Links discussed in this video:
🔗 Probability of Two Integers Being Coprime: www.cut-the-knot.org/m/Probab...
🔗 Euclidean Algorithm: en.wikipedia.org/wiki/Euclide...
🔗 A Million Random Digits with 100,000 Normal Deviates: www.rand.org/pubs/monograph_r...
🔗 Quantum random numbers: qrng.anu.edu.au/
Other videos mentioned in this video:
Timestamps:
0:00 Happy Pi Day!
1:26 Explain! What does co-prime mean?
4:21 Explain! Euclid's Algorithm
8:40 Example! Finding the greatest common divisor.
9:55 Code! gcd() function with Euclid's Algorithm.
12:23 Code! Let's load the random digits.
14:39 Code! Let's use draw() for our loop.
16:13 Code! Co-prime or Co-factor?
17:44 Explain! How we are going to estimate π.
18:50 Code! Estimating π.
21:59 Code! Trying with digits of π.
22:54 Ideas! Thanks for watching!
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/Guides/com...
🚩 Suggest Topics: github.com/CodingTrain/Rainbo...
💡 GitHub: github.com/CodingTrain
💬 Discord: / discord
💖 Membership: kzbin.infojoin
🛒 Store: standard.tv/codingtrain
📚 Books: www.amazon.com/shop/thecoding...
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 Coding Challenges: • Coding Challenges
🎥 Intro to Programming: • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
🎶Pi Day song by / willfromamerica
🎶Music by Epidemic Sound: epidemicsound.com/creator
#PiDay #PiDay2021

Пікірлер: 157
@kabirbatra
@kabirbatra 3 жыл бұрын
I'm in love with this editing style
@tompov227
@tompov227 3 жыл бұрын
If you choose substrings of 4 digits instead of 5 the estimation becomes 3.14159 🤯
@gabenugget114
@gabenugget114 3 жыл бұрын
It adds one digit?!??!?!?!?!?!?!🤯🤯🤯🤯🤯🤯🤯🤯
@rainbowskeppy5292
@rainbowskeppy5292 3 жыл бұрын
3.14159265358979323846264338
@hikari1690
@hikari1690 2 жыл бұрын
It creates 10 times more data points so the estimate becomes more accurate. Sorry if you already know this 🤣
@DerMathematicker
@DerMathematicker Жыл бұрын
i think we should just use 1 digit numbers
@adsoyad2607
@adsoyad2607 3 жыл бұрын
I did this exact thing inspired by the exact same video a year ago!
@Rydergomes11
@Rydergomes11 3 жыл бұрын
same bruh
@AliAli-wi2ys
@AliAli-wi2ys 3 жыл бұрын
same 6 months ago
@standupmaths
@standupmaths 3 жыл бұрын
That’s great to hear! I hope you enjoyed some random π.
@adsoyad2607
@adsoyad2607 3 жыл бұрын
@Stand-Up Maths Well you can't get enough of pi can you? :D
@grumpyparsnip
@grumpyparsnip 4 ай бұрын
Using the randomness of the digits of pi to estimate the digits of pi. That is beautiful.
@gamesvrtech6666
@gamesvrtech6666 3 жыл бұрын
This morning the date on our clock showed us 3.14 and I immediately thought about you and your great videos. Thanks for beeing who you are, wish you all the best! Happy PiDay🍰🅿️ℹ️
@anthonycannet1305
@anthonycannet1305 3 жыл бұрын
It would take longer to run but instead of increasing index by 2, just increase it by one. Currently the program checks gcd(a,b) then gcd(c,d) and so on. Increasing by 1 would check every consecutive pair, so gcd(a,b) then gcd(b,c) then gcd(c,d) and so on. You get almost twice as many pairs of numbers which is one of the two things that affects how accurate this is. The other thing being how big your random numbers are. Another way to improve the estimation would be checking every number against every other number but that would take much much longer to run...
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
Great suggestion!
@pvic6959
@pvic6959 3 жыл бұрын
I was thinking this too!
@NStripleseven
@NStripleseven 3 жыл бұрын
If you compared every number against every other, you wouldn’t even really need the random numbers, you could just use the numbers between one and whatever other number.
@pvic6959
@pvic6959 3 жыл бұрын
@@NStripleseven I think the random numbers was more for fun.. though now I wonder what the results would be like if you used the first 10000 real integers :P
@NStripleseven
@NStripleseven 3 жыл бұрын
@@pvic6959 Could be interesting to try
@user-fw7ky1hd6f
@user-fw7ky1hd6f 3 жыл бұрын
"The Best Video of the Coding Train Ever"
@ncot_tech
@ncot_tech 3 жыл бұрын
You're not the only one who gets modulus/modulo mixed up. When I teach it, I just call it "mod" and avoid the whole problem ;-)
@jacobcowan3599
@jacobcowan3599 2 жыл бұрын
The post-processing on this whole video is great XD love all the gags and running jokes And what a fun program, too!
@footballknight7
@footballknight7 3 жыл бұрын
Daniel you can use the series 3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8)... to estimate PI! I did it in p5.js and got amazing results!
@Carlosdreaming
@Carlosdreaming 3 жыл бұрын
The video production is getting just better and better. Thanks. Great finale 🤯
@xnick_uy
@xnick_uy 3 жыл бұрын
I haven't visiting this channel for a while, and now I found a superb edition!! It was magnificent.
@meher94
@meher94 3 жыл бұрын
These videos are so underated.
@CedLePingouin
@CedLePingouin 3 жыл бұрын
I'm a regular viewer, but I enjoyed this video even more. Love the animation at the beginning, the song, and the funny animated characters during the video. Great job :-)
@darthtorus9341
@darthtorus9341 3 жыл бұрын
i love all the new cute animations added to the videos
@cortiazz5906
@cortiazz5906 3 жыл бұрын
Yo, nice intro! I love the whole "world" that you built up to this channel
@rhevel
@rhevel 3 жыл бұрын
Happy PI day! Great video as always ;)
@kirby6551
@kirby6551 3 жыл бұрын
Awesome keep up the videos man!
@gouravchouhan1790
@gouravchouhan1790 3 жыл бұрын
Short function for GCD, function GCD(a,b){ if(b == 1) return a; return GCD(b,a%b); }
@egietje
@egietje 3 жыл бұрын
That wouldn't work if the random number b is 1 though, for example you put in a = 21 and b = 1, it'd output the greatest denominator being 21 whilst it is 1 Edit: I think you meant if (b == 0) return a;
@j0code
@j0code 3 жыл бұрын
function GCD(a, b) { return b == 0 ? a : GDC(b, a%b); }
@bastibob660
@bastibob660 3 жыл бұрын
@@j0code what does the "?" do
@bastibob660
@bastibob660 3 жыл бұрын
@Free pizza for So as an example b=2 runs GDC again b= 0 returns a
@hetsmiecht1029
@hetsmiecht1029 3 жыл бұрын
@@bastibob660 Precisely. It's called the ternary operator, in case you want to look it up.
@ar25k46
@ar25k46 3 жыл бұрын
The song is so awesome lol
@tomg0
@tomg0 3 жыл бұрын
Another excellent video
@straybasilisk2689
@straybasilisk2689 3 жыл бұрын
Loved PI-ception at the end there!
@realcygnus
@realcygnus 3 жыл бұрын
Nifty as usual !
@beron_the_colossus
@beron_the_colossus 3 жыл бұрын
Great video! I didn't get a notification for it, strange. Maybe because it's a premiere?
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
yeah, i think that might be the case
@RenatoSousaRS
@RenatoSousaRS 3 жыл бұрын
Love it!!!
@ramkumars2329
@ramkumars2329 3 жыл бұрын
Hi Dan!!... i liked it!! especially the animations that you included in the video!!! plz keep those animations in the future videos as well!!.. Thanks a lot!
@luismiguelgallegogomez8000
@luismiguelgallegogomez8000 3 жыл бұрын
Just love the song!
@fakenamerealguy7084
@fakenamerealguy7084 3 жыл бұрын
Fwiw, when you said recursion I smiled happily
@lachainedudeveloppeur2556
@lachainedudeveloppeur2556 3 жыл бұрын
Great video
@singstardancestar1462
@singstardancestar1462 3 жыл бұрын
Sir you explain very well, so I like your channel
@samuelgunter
@samuelgunter Жыл бұрын
I would cache the results of the gcd call to prevent having to calculate the same gcd multiple times. this sounds crazy because you probably won't get many times of having the same 5 digit number, but the chance of a cache hit increases as it gets down to fewer digits. you can also do this cache check after the reordering of a and b to make sure it hit both (384, 78) and (78, 384)
@sub-harmonik
@sub-harmonik 3 жыл бұрын
lol love the editing
@bokkenka
@bokkenka 3 жыл бұрын
If b>a, just get the gcd(b,a).
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
ah, i wish i had thought of this!
@poof65
@poof65 3 жыл бұрын
Yeah, that's what I thought at first. Make a smart use of the recursion 👍
@minghaoliang4311
@minghaoliang4311 3 жыл бұрын
Invoking an additional call stack may use more memory than swapping 2 variables xd
@mickjames01
@mickjames01 3 жыл бұрын
If b > a, then gcd(a,b): a%b -> 'b' goes into 'a' 0 times remainder 'a', therefore the next recursive call will be gcd(b,a). Thus, there is no need to worry if one is larger then the other.
@cnoize314
@cnoize314 3 жыл бұрын
Blueberry is my favorite kind of pie too!
@beethovennine
@beethovennine 3 жыл бұрын
You rock!!!!
@emmanuelkoutsoudakis4614
@emmanuelkoutsoudakis4614 Жыл бұрын
Cool 🌈tutoring
@fiopio2422
@fiopio2422 3 жыл бұрын
Hey! I am a big fan of you! I started learning javascript because of you, and sometimes I migrate your codes into python version with courses interface! I would like to propose you one possible topic fore some coding challenge, what about one virtual humanoid learning how to walk? really big project! or maybe something slightly easier, I would love to see that!
@hrishinadgouda3358
@hrishinadgouda3358 3 жыл бұрын
Love ❤️ it
@jfdio29
@jfdio29 3 жыл бұрын
I thought it was going to be the version with Euclid's distance + Monte Carlo algorithm to estimate Pi. I'm happy to have learn something new!
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
maybe next year!
@Operaatoors
@Operaatoors 3 жыл бұрын
10:39 - just min and max functions. Or sort the array and then pick in order. Although, this version is good as well :)
@roamingcelt
@roamingcelt 3 жыл бұрын
You were so happy to use recursion and didn't use it in your if statement... if(b>a){ return gcd(b,a); } This would flip the two and bring in recursion.
@aashsyed1277
@aashsyed1277 2 жыл бұрын
6/pi^2 is the reciprocle of sum of reciprocle squares!
@haval00
@haval00 3 жыл бұрын
N8ce bro ♥️
@liberto7077
@liberto7077 3 жыл бұрын
Random digits book: exists Chaotic functions: am i a joke to you?
@JohnWasser
@JohnWasser 3 жыл бұрын
Someone should publish “A Million Random Digits” but tweak the sets of 5 digits so that every adjacent pair is coprime. Imagine the delight of someone who does this experiment on the tweaked numbers. I wonder if the tweaking could be done so the digits and numbers still pass all usual tests for randomness. :)
@xnick_uy
@xnick_uy 3 жыл бұрын
I'm guessing they would fail the p(gcd(a,b)==1) -> 6/pi^2 test :)
@joserubens6512
@joserubens6512 3 жыл бұрын
hello good afternoon good video: I have a question and it is possible to use these codes in Buildbox 3d since it is js.
@martinkuhk
@martinkuhk 3 жыл бұрын
While I personally prefer to use iteration to implement the Euclidean algorithm, the recursive solution does point out the essence of the algorithm clearly: gcd(a, b) = gcd(b,r).
@grazzt519
@grazzt519 3 жыл бұрын
coprimecount starts at 0, so until a coprime pair is found, isnt there a division by zero going on? or am I missing something? (for pidigits, the first two 5 digit pair are not coprime, so javascript allows division by zero with no errors?)
@angelcaru
@angelcaru 3 жыл бұрын
In JS, x / 0 returns Infinity
@hetsmiecht1029
@hetsmiecht1029 3 жыл бұрын
A non recursive version of the gcd function: function gcd(a, b) { if (b > a) [a, b] = [b, a]; while (b != 0) { [a, b] = [b, a%b]; } return a; } To be honest I don't really understand why some people think recursion is the answer to everything (slight exaggeration, but please do answer if you have an idea): if you can use a loop instead of using recursion, why would you not use a loop to save memory on the stack?
@jetison333
@jetison333 3 жыл бұрын
Sometimes recursion is easier to write and understand, and in some languages like c++ tail call recursion gets optimized into a loop by the compiler anyway.
@dabs4270
@dabs4270 2 жыл бұрын
Recursion is cooler than loops Therefore, recursion > loops
@Brahvim
@Brahvim 3 жыл бұрын
10:38 Apparently, in my Computer Science book (About writing pure Java Console programs. It was for Grade 9, from the ICSE Board, India, since I am Indian, xD!) they had this question where they wanted us to swap two numbers WITHOUT using a temporary variable! I scratched my head a lot, tried to solve using addition and subtraction...some multiplication, but failed. Then I found the answer on stackoverflow. Here is the algorithm, (modified with shorthand operations!) ..it's simple and fun! Mind that 'a' stores the first number, and 'b' stores the second. a += b; b = a - b; a -= b; Although this just seems useless since it just puts useless load on the machine running the code, it is a great way to exchange the numbers stored in two variables without having to use a third, .....and looks smart, xD!!! Hope this *_IS_* a good way to handle it! :sweat_smile: And I don't think it works for negative numbers....maybe it does, but maybe it doesn't!!! Immediate edit: Here's another problem from the book I solved my self in a minute: Add two positive integers, (...or natural numbers xD) *WITHOUT* using the '+' operator!!! I DO NOT allow you to use a secret function that uses the '+' operator; I myself did it with some simple math :sweat_smile: (I should stop with the Discord emojis :grimacing:) Answer:
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
what a cool solution!!!!
@JonathanMandrake
@JonathanMandrake Жыл бұрын
In german, the problem with modulus and modulo doesn't exist, I don't even know if the german word modulus exists or is used in some fields of math I haven't learned yet, so there's no room for confusion : )
@krccmsitp2884
@krccmsitp2884 Жыл бұрын
Without recursion, gcd() can be much faster and stack-friendly: function gcd(a, b) { while (b > 0) { [a, b] = [b, a % b]; } return a; }
@DeeJayTeeLME
@DeeJayTeeLME 3 жыл бұрын
Hi there Dan, hope you are well, my name is Thomas, I'm loving your videos and tutorials on javascript. I'm reaching out because I'm am trying to make a chrome extension but I am getting stuck. And was wondering if you could help me out with the parts Im getting stuck on. P.s I am pretty new to programming in general I have learned to program the basics in c# but some of the Concept of C-sharp don't always work in javascript. I would really appreciate it if you could help. Thank you Thomas.
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
Come and join the discord, it's a great place for getting help! thecodingtrain.com/discord
@MAZ01001
@MAZ01001 3 жыл бұрын
[13:45] could use Array.splice(start_index,count); let digits=[1,2,3,4,5,6,7,8,...]; let num = digits.splice(0,4); //num >> [1,2,3,4] //digits >> [5,6,7,8,...]
@oc_ociruiq6571
@oc_ociruiq6571 3 жыл бұрын
Is it possible to suggest the basis that a beginner should begin with????
@NaNa-it9mi
@NaNa-it9mi 3 жыл бұрын
very funy
@strex2062
@strex2062 3 жыл бұрын
22:00 oh yes var pie = TWO_PI / 2
@RajJaiswal538
@RajJaiswal538 3 жыл бұрын
Coding challenge idea: Make a random number generator WITHOUT using any random number generator Libraries or even the default one from js. If you think it does not deserve a seperate vid then please give any resources that explains how can any random number be generated Edit: spelling mistake
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
Yes, I 100% would like to do this!
@daniellebarker7205
@daniellebarker7205 3 жыл бұрын
Probably easiest way would be with the current time. in JS, Date.now() % 1000 will give you a pretty random number from 0 to 999
@ricksidwell
@ricksidwell 3 жыл бұрын
There are several ways to do this. Do a web search for "generate random number without math.random". (I tried posting a link, but I think KZbin flagged it as spam and deleted it.)
@RajJaiswal538
@RajJaiswal538 3 жыл бұрын
@@ricksidwell okay, I'll check it out. What I was trying was actually a kind of cheating. I calculated the xMousePosition and divided it by width of screen to get a random number from 0 and 1 but it's definately not that random
@mateothode5603
@mateothode5603 Жыл бұрын
@@TheCodingTrain don’t forget hahaa
@susmitkumarmishra339
@susmitkumarmishra339 3 жыл бұрын
Hmm using 1 million digits of pi to get 3 digits of pi!, couldn't get more inefficient 😁
@S197Bryan
@S197Bryan 2 жыл бұрын
Is there a video where he uses luhn algorithm. I would love to see him implement it
@charliejulietdavies8715
@charliejulietdavies8715 3 жыл бұрын
here's my obligatory two cents: javascript lists work kind of like tuples which makes swapping values easy: [a, b] = [b, a] boom
@charliejulietdavies8715
@charliejulietdavies8715 3 жыл бұрын
doh, i should have kept watching, i would have seen you remember that 😅
@DerMathematicker
@DerMathematicker Жыл бұрын
if you have 2 numbers a*10+b and c*10+d, they aren't coprime if d*a-c*b is divisible by c*10+d, maybe, i think, possibly
@DerMathematicker
@DerMathematicker Жыл бұрын
i've checked it again and it is true, but not the other way around.
@ShaneDavisDFTBA
@ShaneDavisDFTBA 3 жыл бұрын
Does this imply that the digits of pi approach random and are equally represented?
@pvic6959
@pvic6959 3 жыл бұрын
ive always been a bit confused with that random numbers book. If a person were to "randomly" flip to a page, wouldnt it be more likely that the person chooses a page near the middle (I have no proof for this)? For instance, i dont think people will choose the first page 1% of the time out of a 100 page book. So how do we know that random numbers book is actually random? I wonder if there is a number there that is more likely to be chosen vs all the other numbers. Like "page X is most likely to be chosen. and the Yth number on a page is most likely to be chosen. So Yth number on Xth page is the most likely number to be chosen in the random numbers book.. making it not truly random"
@tissuepaper9962
@tissuepaper9962 Жыл бұрын
The way to use the random numbers book is as follows: 1. Start from page 1, digit 1 and take as many digits as you need. 2. *Mark* or otherwise keep track of which is the next digit that you didn't use. 3. Next time you need random numbers, start from the place you marked instead of the beginning. 4. If you reach the end of the book, wrap right back around to the beginning. 5. Repeat 2-4 ad infinitum. Something I'm not sure about is what kind of distribution the random digit book claims to contain. Is a.) the distribution of digits uniform over the whole book, or b). is the *sequence* of digits constructed such that for any digit, the next digit has a uniform probability of being any number 0-9. Those might sound like the same statement, but they aren't. You could satisfy (a) and not satisfy (b) by constructing a book where the numbers go "0123456789" over and over forever, for example. You could satisfy (b) but not (a) by constructing the book from an ideal source of randomness, because it's highly unlikely that the number of each digit is exactly the same in a true random sample of digits. If (b) is true (which is my assumption, because it makes the book more useful), then the procedure I described above ensures that you don't influence the distribution by your choice of page. If (a) is true then it shouldn't matter where you start as long as you use an entire "unit" of digits, i.e. page, column, etc depending on how the numbers are grouped together when they're generated, i.e. if each individual page is guaranteed to have a uniform distribution, you need to use a whole page. If each chapter is guaranteed to have a uniform distribution, then you have to use a whole chapter, etc.
@jakubkurdziel2407
@jakubkurdziel2407 3 жыл бұрын
13:45 you could use the regex
@markusosterle3958
@markusosterle3958 3 жыл бұрын
Hey I am new to the whole p5.js thing and am using the online editor. Somehow I am getting really bad performance and low framerate with the same code (on a good pc) any ideas how to fix it?
@pvic6959
@pvic6959 3 жыл бұрын
17:15 a pair of numbers with GCD 442 :o
@willemkossen
@willemkossen 3 жыл бұрын
Does that second test prove the digits of pi actually represent random numbers?
@fulvioabrahao
@fulvioabrahao Жыл бұрын
No
@vilkillian
@vilkillian 3 жыл бұрын
The way that you used to make an array of random numbers isn't actually random. bc it's not random numbers, it's random digits. Probability of some digit being 0 is 1/10 Probability of only first digit in a 5-digit slices being 0 is lesser than 1/10, so you expect lesser 4 digit numbers than uniform distribution would give you Probability of only first 2 digits being 0 is way less than 1/100. So you expect way less 3 digits than uniform distribution would give you And so on... So your values absolutely not random and won't do for such an experiment and will create an error. But don't mind old programmer like me, i'm just picking :)
@vilkillian
@vilkillian 3 жыл бұрын
and also, the less digits you use to make a number, the more "uniform" becomes resulting array, that's why people get really good estimates using 4 digit numbers
@MrSefsdf
@MrSefsdf 2 жыл бұрын
I was searching for this comment :)
@Wecoc1
@Wecoc1 3 жыл бұрын
Pi is the only number you can eat [Newton cookie left the chat]
@perkarlo
@perkarlo 3 жыл бұрын
wow
@EnDirectDeMaTete
@EnDirectDeMaTete 3 жыл бұрын
If you use 4 digits numbers you have 250000 numbers, by chance the estimate is then 3.14159... Happy Pi !
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
oh wow! I wish I had tried that!
@polaris6777
@polaris6777 3 жыл бұрын
Please help me, there is this annoying feature in p5 I just cannot turn off. Whenever I write something,it overwrites what was previously written instead of displacing it. I don't know what to do?
@jetison333
@jetison333 3 жыл бұрын
Press the insert key on your keyboard. That happened to me once and it was very annoying haha.
@devinshrees7060
@devinshrees7060 3 жыл бұрын
6:34 🤣🤣🤣🤣🤣
@Moonbrony
@Moonbrony 3 жыл бұрын
Hmm, I wonder if I could use an Arduino to read white noise to generate random numbers...
@ayanbahukhandi1869
@ayanbahukhandi1869 3 жыл бұрын
This man reminds me of Murray in the Stranger Things series, agree?
@Palontras
@Palontras 3 жыл бұрын
He is actually spelled "Oiclid" :D
@j0code
@j0code 3 жыл бұрын
Are you German? Weil "eu" spricht man im Deutschen "oi" :p
@ratuldbro
@ratuldbro 3 жыл бұрын
can anyone please tell which software he uses
@jwrm22
@jwrm22 2 жыл бұрын
It hurts a bit, he solves the /0 by adding 1 to every number read from the book, instead of writing an exception in gcd().
@NStripleseven
@NStripleseven 3 жыл бұрын
22:00 You used the Pi to calculate the Pi
@saksham01
@saksham01 3 жыл бұрын
Did you mean half tau day?
@Fun-Planet
@Fun-Planet 3 жыл бұрын
String.split would work, right?
@TheCodingTrain
@TheCodingTrain 3 жыл бұрын
Yes? Can you split by a number of characters rather than delimiter?
@Fun-Planet
@Fun-Planet 3 жыл бұрын
@@TheCodingTrain oh haha for a moment I forgot how split works (can't use split). Another solution could be str.match(/.{5}/g) Good ol' regex magic
@ratuldbro
@ratuldbro 3 жыл бұрын
can anyone please tell me which software he uses 🤝🤝🤝
@toastyPredicament
@toastyPredicament 2 жыл бұрын
3.14228
@toastyPredicament
@toastyPredicament 2 жыл бұрын
It's Valentine's day here c:
@toastyPredicament
@toastyPredicament 2 жыл бұрын
Almost
@toastyPredicament
@toastyPredicament 2 жыл бұрын
If you run a sine wave its value is 1 every second making it a timestamp measure c:
@toastyPredicament
@toastyPredicament 2 жыл бұрын
I mean at 1 Hz
@himanishmandal9556
@himanishmandal9556 3 жыл бұрын
Hey all this is ok but could we have a pacman challenge next please.
@moshly64
@moshly64 3 жыл бұрын
Can't you just wrap around on the random data and continue processing ?
@pseudotaco
@pseudotaco 3 жыл бұрын
Technically yes, but that brings some problems. After running through the data any number of times, you will have the exact same pi estimation as after the first one, since the numbers just repeat. You would have to alter the data, for example by offsetting it
@JasimGamer
@JasimGamer 3 жыл бұрын
10:45 this better 😃 [a,b] = [b,a];
@TheGreatAtario
@TheGreatAtario 3 жыл бұрын
Hmm, someone either hired video production people or else has been spending COVID time learning it
@Rydergomes11
@Rydergomes11 3 жыл бұрын
same
@toastyPredicament
@toastyPredicament 2 жыл бұрын
Could I ask you out some day
@vincenzochiaramida5389
@vincenzochiaramida5389 2 жыл бұрын
Why no one is interested in estimating 6 using pi^2 instead
@Ferdyn94
@Ferdyn94 3 жыл бұрын
hm.. did he just make a pi(e) out of a pi(e)?
@toastyPredicament
@toastyPredicament 2 жыл бұрын
I wish I could go out with you c:
@levantatanashvili6057
@levantatanashvili6057 3 жыл бұрын
da
@toastyPredicament
@toastyPredicament 2 жыл бұрын
Don't click on the gf please
@abbasmohamadelkarsifi8099
@abbasmohamadelkarsifi8099 7 ай бұрын
He overcomplicated this too much
Coding Challenge 162: Self-Avoiding Walk
38:27
The Coding Train
Рет қаралды 151 М.
Coding Challenge 95: Approximating the Value of Pi
27:32
The Coding Train
Рет қаралды 631 М.
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 80 МЛН
Be kind🤝
00:22
ISSEI / いっせい
Рет қаралды 23 МЛН
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 3,3 МЛН
Final increíble 😱
00:39
Juan De Dios Pantoja 2
Рет қаралды 43 МЛН
Coding Challenge #136.1: Polar Perlin Noise Loops
22:02
The Coding Train
Рет қаралды 193 М.
Coding Challenge 167: Ulam Spiral of Prime Numbers
24:13
The Coding Train
Рет қаралды 749 М.
Coding Challenge 124: Flocking Simulation
42:27
The Coding Train
Рет қаралды 324 М.
How do you prove a prime is infinitely fragile?
28:30
Stand-up Maths
Рет қаралды 477 М.
The biggest hand calculation in a century! [Pi Day 2024]
36:50
Stand-up Maths
Рет қаралды 423 М.
Bézier curves (Coding Challenge 163)
22:59
The Coding Train
Рет қаралды 264 М.
Coding Challenge #158: Shape Classifier Neural Network with ml5.js
36:03
The Coding Train
Рет қаралды 137 М.
What's special about 277777788888899? - Numberphile
14:24
Numberphile
Рет қаралды 2,2 МЛН
I made it FASTER // Code Review
38:46
The Cherno
Рет қаралды 516 М.
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 80 МЛН