I started watching your videos recently and I really DO admire your work. I like how you think and your ability to explain what you are doing. You are an inspiration to me and I believe to many more people. I hope I will become as good as you someday. Please keep up the videos and know that what you are doing is amazing!
I discovered The Coding Train a few weeks ago, and I've watched at least 15 coding challenge since then. It's so great to discover such awesome algorithms thanks to you ! Greetings from France :)
Oh, this is a bug, thank you! Feel free to pull request a fix to the code at github.com/CodingTrain/website! I just fixed it in the web editor version: editor.p5js.org/codingtrain/sketches/SJMl3u5xN
Huge optimization potential at 18:57 - you set available to false but don't break out of the loop, so when the amount of toothpicks gets large you have to check n^3 iterations which slows it down massively.
This is hilarious! Would have never guessed that a toothpick and a basically simple concept would outsmart THE compression algorithm of the internet in 2018. Also: Merry Chistmas!
I think it might have been nice to have toothpicks know their parents and then figure out if there is any easy way to determine free edges based off parents to reduce the search space for non-payment connections.
At 18:40 you could probably make it more consise and explicit by simply returning instead chaining ifs. E.g. return ( (ax == x && ay == y) || (bx == x && by == y) ); Alternatively: boolean aIntersect = (ax == x && ay == y); boolean bIntersect = (bx == x && by == y); return (aIntersect || bIntersect);
ArrayLists are super wordy, but you can save a few characters on your declarations. ArrayList picks = new ArrayList(); Specifying the generic class isn't needed the second time. Similarly if you have one as a member variable, ArrayList m_picks; And initialize it in the constructor (or elsewhere) m_picks = new ArrayList();
I would hace made lenghts even. If you make a toothpick 2 units long, its ends would be +- 1. And every endpoint and middlepoint of every toothpick would be perfectly aligned with the grid.
Is there any challenge about physics of atoms or molecules of specific matters? I mean, it may be so cool to visualize the real material reactions with their behaviours (behaviour means all the things about them like mol pH or magnetism or density etc.)
A vector (in maths, not in processing) is a point in space and a direction. This would be very useful for a toothpick object, instead of having 4 values and a direction. Since you know the length of a toothpick, you only need to know where the toothpick starts. This means you can skip bx and by completely. Since you know the toothpick will be in a right angle at all times, you only need to know the length of it and its origin point. The length is constant, since all toothpicks have the same length, this can therefore be hard coded. You are now left with 2 integers, ax and ay, along with a direction. Two points making up a coordinate, that's exactly what a Processing Vector is, so convert the 2 integers into a single pvector and your toothpick now consists of a point in space and a direction. All the information you need! Oh... look at that, your toothpick is a mathematical vector. Rename it to mvector or just vector and you can reuse it in any program where you need a mathematical vector!
picks should know if their ends are available. they only check once and then never again because either they were not available or they have created and fill the hole. so instead of foreaching all picks, you should maintain a list of edges (those that can have edges)
Since it’s symmetrical couldn’t you just calculate the picks for one corner then flip and draw for one corner then flip and draw for the other half of the screen?
I saw the problem completly different and I was wondering if we could juste add some varibles to the toothpick for know each of his edges are free or not. And in the loop when you place a toothpick you remove all toothpick from the array that have no free edge remaining. So you ll juste keep an array of the the toothpick that matters so you wont need to redraw the background again. I would like to know if it s efficient or if it s too long. Like this if you let it run for a while you will have less memory issu. Sorry for my english it s my sexondary langague i hope i was clear! By the way i love your videos!
Instead of looping for every other toothpick and computing if there is a collision, could you use something like the following: loadPixels(); If t.dir == 1 x_pixel = t.x + len /2 + strokeWeight + 1; else y_pixel = t.y + len /2 + strokeWeight + 1; if pixels[x_pixel][y_pixel] != white then next.add(next_one) I mean it's pseudocode but you get the idea. With some boundary check you should be 10x faster on huge iterations
Can you do a coding challenge with Arduino? Have a button in a browser that triggers the arduino to do something in real life. Love your work mr. Shiffman!
Hey! New to the programming scene. I am on processing and I am wondering how i can get the bottom section to go away. It says "Console" and "Errors" Is there any way for me to hide that without getting rid of it completely?
Question: Why don't you have to make a JFrame when you write the code? I've only been programming for a few months and I use eclipse for java so everytime I want to write a graphics program I need to specify the JFrame and then add a JPanel to it but you don't so I'm just wondering why. Thanks.
@meme I saw Microsoft engineer use Thinkpad (in the Visual Studio yt channel),... what's up with that? and, unfortunately... no... I develop for mobile... I need mac to develop for iOS (I use flutter btw)
Hey, I just downloaded Processing and I'm a bit confused about how to use it with Java or p5.js.. Do you have a series where you explain how to set them up once and for all? thanks in advance!
Admin add user details in his account then generate a uid for particular user .admin send that uid as a invite code to user by which user can sign up for that group. how can I do it. Sir can you tell me please please please please ?
@@L33tSauceProductions I did not expect anyone to answer, so thanks ;D I am aware of that fact, but then the length of one pick when len=9 is actually 8. Overall i don't want to acuse him of anything, but in my understanding he didnt quite explain (on the whiteboard) how it actually works in the code
Hi there. I have a Question for you. I am currently in 3 Year(6th Sem) of my Computer Science Engineering. I have learned Languages like HTML, CSS, JAVA(Android Programming) on a moderate level. I started learning Python but it does not provoke my interest. I wanted to ask you that i have decided to focus on any one Programming Language for the remaining time i am studying College, so which programming language should i go for? Thank You.
Hi Manish. I've completed a 4 year Software Engineering degree in Australia, (CS equivalent) as well as 4 years of my PhD and also working as a Software Engineer at the same time. Speaking from my personal experience, deciding on a specific language is not always the most important factor. Learning the fundamentals of programming including proficient design paradigms is significantly more important. Over the years I've worked on several projects ranging from PHP, Python, Javascript, C, C++ you name it. Eventually they all share common components in their syntax structure (with some exceptions). However I find understanding how to design a program or project to be efficient and elegant in its structure is far more important. I hope this helps. Without any sort of context into your question, being an expert in a specific language might get you hired from some companies. Understanding how to develop for a specific project with the knowledge of proficient design will get you hired at a lot more companies.
Hi Daniel! We need a number reading session like Michael Steven's one. Oh i just noticed, Should it not be p_n(x,y) = [x,y] +- (len-1)/2 to get integer coordinates rather than p_n(x,y) = [x,y] +- len/2?
can u tell me what kind of laptop do u use for ur programs and the operating system also.....plssss cause i want to buy one laptop which is very good for programming...pls sir....
Why declare your variables as ArrayList, when you are never using implementation specific functions? Not sure, if Processing is different from regular Java, but you should always code against the interface (List). Also, instead of comparing every toothpick with every other toothpick twice, wouldn't it be easier to compute all possible new ones and for each duplicate, discard all of them? Could then use a growing index in the picks list to ignore old generations during each iteration, instead of the hacky boolean.
This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org. I JavaScript + p5.js in my beginner series: ruclips.net/user/shiffmanplaylists?view=50&shelf_id=14&sort=dd
@@TheCodingTrain thank you, i was not expecting a reply from you at all, not to mention so quickly. This just proves how awesome of a youtuber you are.
This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ruclips.net/video/AmlAiKsiy0o/видео.html.
Hi Dan : ) , what macbook do you have? I am not apple fan and I wanna ask if apple is good for coding, I mean the compatibility with some IDEs, performance, ect.?
Wouldn't it have been easier for the toothpick class to keep track of its endpoints. So that they know if they are open or not. Then you wouldn't have to check the toothpick against all other toothpicks.
I don't know on windows or mac, but on linux you can go at the source folder, open lib folder and there is a file called theme.txt, that contains every single color for everything on the interface. Just look up the colors you want on hexadecimal and edit this file (good idea to make a copy beforehand).
javidx9 has many videos on C++ graphics/game programming based on his console game engine. He provides good explanations, but it assumes some prior knowledge of C++. Of course, it does not have the frivolity, energy, and showmanship of Daniel Shiffman, but I enjoy javidx9 English wit as well. C++ graphics will makes me really appreciate Processing and JavaScript.
@19:35 if you're tired and you know it clap your hands *clap clap* if you're tired and you know it clap your hands *clap clap* if you're tired and you know it and you don't know what a *- operator is clap your hands clap clap z.z
@@TheCodingTrain you are right. Proccesing not working on java 9. But the diamond operator inference is since java 7. I'm not sure if proccesing supports the sintax.
I started watching your videos recently and I really DO admire your work. I like how you think and your ability to explain what you are doing. You are an inspiration to me and I believe to many more people. I hope I will become as good as you someday. Please keep up the videos and know that what you are doing is amazing!
Thank you for the nice feedback!
This.
I love how Dan uses some of the RUclips channels I'm subscribed to in such a fluent way
And I watched all these videos, which makes it even better
I love these math based videos!
DEFINITELY!
I discovered The Coding Train a few weeks ago, and I've watched at least 15 coding challenge since then. It's so great to discover such awesome algorithms thanks to you ! Greetings from France :)
Thank you for watching!
Ah yes, reading numbers the content I came here for
near the end when you are trying to make the lines thicker, you put the formula in the stroke function instead of the stroke weight function
Oh, this is a bug, thank you! Feel free to pull request a fix to the code at github.com/CodingTrain/website! I just fixed it in the web editor version: editor.p5js.org/codingtrain/sketches/SJMl3u5xN
Huge optimization potential at 18:57 - you set available to false but don't break out of the loop, so when the amount of toothpicks gets large you have to check n^3 iterations which slows it down massively.
Oh great tip! I did not notice that at the time! If you would like to pull request this fix to the code I would incorporate it!
@@TheCodingTrain Sent a pull request including both the p5js version and the processing version.
this.is a better solution, I think
Toothpick createA(ArrayList others){
for(Toothpick other : others){
//endpoints
if(other.ax == this.ax && other.ay == this.ay) return null;
if(other.bx == this.ax && other.by == this.ay) return null;
//center
if(abs(other.bx - other.ax) == this.ax && abs(other.by - other.ay) == this.ay) return null;
}
return new Toothpick(this.ax, this.ay, - this.d);
}
In the for loop, when setting available to false, you could add a „break“ statement, which will increase performance a bit :)
This was the perfect video for showing tree data structures :)
Leaf nodes will be your "placeable/valid" toothpicks
Oh, good point!
You're the reason I got into coding. ☺️
Numberphile squad!
I feel like prof. Shifman over here is watching 3B1B Numberphile and all the other greats and stealing their content into a programming context :P
Here!
@@qxtr5853 He's not stealing it, he's just making programs out of it.
I know that the numberphile video contains the algorithm. Only if one adjacent pixel is toggled, toggle itself. Simple right?
What a coincidence, I created this fractal just a day before you uploaded this amazing video!
One easy optimization would be to break out of the loop in createA/createB when a collision is found
Good idea!
This is hilarious! Would have never guessed that a toothpick and a basically simple concept would outsmart THE compression algorithm of the internet in 2018.
Also: Merry Chistmas!
I think it might have been nice to have toothpicks know their parents and then figure out if there is any easy way to determine free edges based off parents to reduce the search space for non-payment connections.
best x-mas gift ever Daniel, a coding challenge with the magical Processing 3 environment
At 18:40 you could probably make it more consise and explicit by simply returning instead chaining ifs. E.g.
return ( (ax == x && ay == y) || (bx == x && by == y) );
Alternatively:
boolean aIntersect = (ax == x && ay == y);
boolean bIntersect = (bx == x && by == y);
return (aIntersect || bIntersect);
This is so cool! Awesome coding challenge choice!
Release an album of just you reading number sequences. Children can use it as a lullabye, and they'll become math prodigies.
ArrayLists are super wordy, but you can save a few characters on your declarations.
ArrayList picks = new ArrayList();
Specifying the generic class isn't needed the second time. Similarly if you have one as a member variable,
ArrayList m_picks;
And initialize it in the constructor (or elsewhere)
m_picks = new ArrayList();
Thanks for the tip!
@@TheCodingTrain or List picks = new ArrayList();
Daniel, you are better than my CS professors xD
"There's no reason for me to have two separate functions here, but... why not?"
DRY principle maybe :P
I would hace made lenghts even. If you make a toothpick 2 units long, its ends would be +- 1. And every endpoint and middlepoint of every toothpick would be perfectly aligned with the grid.
Is there any challenge about physics of atoms or molecules of specific matters? I mean, it may be so cool to visualize the real material reactions with their behaviours (behaviour means all the things about them like mol pH or magnetism or density etc.)
A vector (in maths, not in processing) is a point in space and a direction. This would be very useful for a toothpick object, instead of having 4 values and a direction.
Since you know the length of a toothpick, you only need to know where the toothpick starts. This means you can skip bx and by completely.
Since you know the toothpick will be in a right angle at all times, you only need to know the length of it and its origin point. The length is constant, since all toothpicks have the same length, this can therefore be hard coded.
You are now left with 2 integers, ax and ay, along with a direction. Two points making up a coordinate, that's exactly what a Processing Vector is, so convert the 2 integers into a single pvector and your toothpick now consists of a point in space and a direction. All the information you need!
Oh... look at that, your toothpick is a mathematical vector. Rename it to mvector or just vector and you can reuse it in any program where you need a mathematical vector!
Thanks for this feedback!
I just tweeted my program output to Daniel yesterday.
Super cool Dan! More processing please!!!
Man you're really good 😵
I really think you should use enumerators, because in the long run enumerators are amazing. Great video regardless!
I made it in JAVA Graphics component but when I use loop it's taking too long to regenerate each next pick.
30 seconds in the video and i feel happy
God you deserve sooo many more subscribers!
i love your videos
picks should know if their ends are available. they only check once and then never again because either they were not available or they have created and fill the hole. so instead of foreaching all picks, you should maintain a list of edges (those that can have edges)
Great point!
Why do you use available? You could simply return null in the loop. Simpler and faster
Since it’s symmetrical couldn’t you just calculate the picks for one corner then flip and draw for one corner then flip and draw for the other half of the screen?
what about to change toothpicks to triangles/squares/hexagons? what will happen then to the pattern?
Could you please make an QR-code scanner?? That would be really cool. :)
Yeah, I know exactly how. Watch a little video of Vsauce about it and it contains all you need
Finally the toothpicks video
Please make a video on visualising the Riemann zeta function in p5js or Processing.
Please suggest here! github.com/CodingTrain/Rainbow-Topics/issues
Only new gen can create future gen.
No need to go through all toothpicks.
This was on my birthday and i use toothpicks. crazy world we live in. anyways very interesting and helpful
I saw the problem completly different and I was wondering if we could juste add some varibles to the toothpick for know each of his edges are free or not. And in the loop when you place a toothpick you remove all toothpick from the array that have no free edge remaining. So you ll juste keep an array of the the toothpick that matters so you wont need to redraw the background again. I would like to know if it s efficient or if it s too long. Like this if you let it run for a while you will have less memory issu. Sorry for my english it s my sexondary langague i hope i was clear! By the way i love your videos!
Instead of looping for every other toothpick and computing if there is a collision, could you use something like the following:
loadPixels();
If t.dir == 1
x_pixel = t.x + len /2 + strokeWeight + 1;
else
y_pixel = t.y + len /2 + strokeWeight + 1;
if pixels[x_pixel][y_pixel] != white then next.add(next_one)
I mean it's pseudocode but you get the idea.
With some boundary check you should be 10x faster on huge iterations
Thanks for the optimization note!
(ax, ay) of one toothpick can never match (ax, ay) of another. You only have to check the other ends for intersect.
Can you make a list of your favorite websites?
lovely Japanese paper wall thing design
Can you do a coding challenge with Arduino? Have a button in a browser that triggers the arduino to do something in real life. Love your work mr. Shiffman!
Hey! New to the programming scene. I am on processing and I am wondering how i can get the bottom section to go away. It says "Console" and "Errors" Is there any way for me to hide that without getting rid of it completely?
Question: Why don't you have to make a JFrame when you write the code? I've only been programming for a few months and I use eclipse for java so everytime I want to write a graphics program I need to specify the JFrame and then add a JPanel to it but you don't so I'm just wondering why. Thanks.
Indeed I use Processing (processing.org) which takes care of all the windowing.
Hey Dan, love your videos and the way you explain things. Could you try rendering Julia 4D Quaternion Fractal using p5.js?
which macbook(s) do you use?
I need it for reference since I 'need' a macbook but not sure to buy the newest one (nor that I can buy it)
@meme I saw Microsoft engineer use Thinkpad (in the Visual Studio yt channel),... what's up with that?
and, unfortunately... no... I develop for mobile... I need mac to develop for iOS (I use flutter btw)
Hey bro in some of your videos you used a white-board...Where is it?
Hey, I just downloaded Processing and I'm a bit confused about how to use it with Java or p5.js.. Do you have a series where you explain how to set them up once and for all?
thanks in advance!
This is my workflow series (though I don't spend much time on Processing) ruclips.net/p/PLRqwX-V7Uu6Zu_uqEA6NqhLzKLACwU74X
Maybe easier to follow direction with Enum?
public enum Direction {
HORIZONTAL,
VERTICAL
}
Awesome video btw
May I ask you if you could try to remake Tic Tac Toe next week?
Admin add user details in his account then generate a uid for particular user .admin send that uid as a invite code to user by which user can sign up for that group. how can I do it. Sir can you tell me please please please please ?
That was awesome
Oh please do the snowflake one next time! Cheers!
Wouldn’t the length be even? Because you say ax = x + Len/2, so if x and ax are both integers, Len must be even?
with integer math in Processing (Java), for an odd number len/2 is equal to (len-1)/2. For example 5/2 = 2
The Coding Train
Oh right, integer division is a thing 😅 but still wouldn’t it be (len-1)/2 on both sides, so len-1 total?
Please explain this to me
How ax and bx are int type?
ex.
ax = 0 + 9/2;
Which is:
int ax= 4.5;
Yet it still works 😓
Whenever an integer is left with a decimal, it always throws away the decimal. Like 1/3 = 3.33333 but as int it would be just 3
@@L33tSauceProductions I did not expect anyone to answer, so thanks ;D
I am aware of that fact, but then the length of one pick when len=9 is actually 8. Overall i don't want to acuse him of anything, but in my understanding he didnt quite explain (on the whiteboard) how it actually works in the code
2:29 What happened to your cursor?
On a Mac if U move the mouse quickly it becomes larger. I presume this is so it is easier to track/locate.
Hi there. I have a Question for you.
I am currently in 3 Year(6th Sem) of my Computer Science Engineering. I have learned Languages like HTML, CSS, JAVA(Android Programming) on a moderate level. I started learning Python but it does not provoke my interest.
I wanted to ask you that i have decided to focus on any one Programming Language for the remaining time i am studying College, so which programming language should i go for?
Thank You.
Hi Manish. I've completed a 4 year Software Engineering degree in Australia, (CS equivalent) as well as 4 years of my PhD and also working as a Software Engineer at the same time. Speaking from my personal experience, deciding on a specific language is not always the most important factor. Learning the fundamentals of programming including proficient design paradigms is significantly more important. Over the years I've worked on several projects ranging from PHP, Python, Javascript, C, C++ you name it. Eventually they all share common components in their syntax structure (with some exceptions). However I find understanding how to design a program or project to be efficient and elegant in its structure is far more important. I hope this helps. Without any sort of context into your question, being an expert in a specific language might get you hired from some companies. Understanding how to develop for a specific project with the knowledge of proficient design will get you hired at a lot more companies.
@@nicholasjackson3959 Thanks for your Guidance Nicholas.
Hi Daniel! We need a number reading session like Michael Steven's one. Oh i just noticed, Should it not be p_n(x,y) = [x,y] +- (len-1)/2 to get integer coordinates rather than p_n(x,y) = [x,y] +- len/2?
If I ever get to 1,000,000 subscribers I'll do one!
Hi. Can I put HTML button into canvas using js?
Thats great sir 👌👌🤗
And now that you have a toothpick object, you can do all sorts of things, like Buffon’s needles and calculate pi!
I think he already did the pi calculation?
oof... RUclips really doesn't like the output data, luckily i do
How about starting a Java for beginners series ?
can u tell me what kind of laptop do u use for ur programs and the operating system also.....plssss
cause i want to buy one laptop which is very good for programming...pls sir....
I kicked a toothpick about a year ago and left half of it in my foot for two months
Why declare your variables as ArrayList, when you are never using implementation specific functions? Not sure, if Processing is different from regular Java, but you should always code against the interface (List).
Also, instead of comparing every toothpick with every other toothpick twice, wouldn't it be easier to compute all possible new ones and for each duplicate, discard all of them? Could then use a growing index in the picks list to ignore old generations during each iteration, instead of the hacky boolean.
Thanks for these suggestions!
What coding language do you use? I'm trying to get into coding on my own time but don't know what language to use.
In this video he uses "Processing" which is based on Java. For starters I recommend JavaScript. You can follow TheCodingTrain's "p5js" tutorials! :)
This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org.
I JavaScript + p5.js in my beginner series: ruclips.net/user/shiffmanplaylists?view=50&shelf_id=14&sort=dd
@@TheCodingTrain thank you, i was not expecting a reply from you at all, not to mention so quickly. This just proves how awesome of a youtuber you are.
@@mikee. thanks
Keep it up
Which programming language are you using in this video?
This video uses Processing (which is built on top of the Java programming language). For more info, visit processing.org and also this video might help ruclips.net/video/AmlAiKsiy0o/видео.html.
Write it using a gpu shader to speed it up.
Can we make these with shape of "v" and " hexagon"....🙄
How can i submit a coding challenge?
Here you go: github.com/CodingTrain/website/issues
Hi Dan : ) , what macbook do you have? I am not apple fan and I wanna ask if apple is good for coding, I mean the compatibility with some IDEs, performance, ect.?
I have a recent macbook pro. It works well for me, but there is no perfect computer.
Wouldn't it have been easier for the toothpick class to keep track of its endpoints. So that they know if they are open or not. Then you wouldn't have to check the toothpick against all other toothpicks.
This is an important optimization that I missed yes!
It should be maxX = max(t.bx, maxX); because that is the right point.
man, processing really needs a dark theme
I don't know on windows or mac, but on linux you can go at the source folder, open lib folder and there is a file called theme.txt, that contains every single color for everything on the interface. Just look up the colors you want on hexadecimal and edit this file (good idea to make a copy beforehand).
Do you know some chanel like this but based on C++?
javidx9 has many videos on C++ graphics/game programming based on his console game engine. He provides good explanations, but it assumes some prior knowledge of C++. Of course, it does not have the frivolity, energy, and showmanship of Daniel Shiffman, but I enjoy javidx9 English wit as well. C++ graphics will makes me really appreciate Processing and JavaScript.
can someone tell me which language is he using it doesn't seem javascript to me
It's in a software called Processing which uses Java based api
@@shreyasdetA a thank you . so it's java?
its a modified version of Java used by processing
@@CaelVK so i need java to watch this tutorial? i ve learnt python ,c ,c++ and javascript but not java
java is quite the easy language to understand
@19:35
if you're tired and you know it clap your hands *clap clap*
if you're tired and you know it clap your hands *clap clap*
if you're tired and you know it and you don't know what a *- operator is clap your hands clap clap
z.z
You could maybe use a linked list from java.util.* to iterate through them a bit faster?
Is it java?
In java 9 is much more simpliet to declare an array.
Oh, I should take a look! Not sure if Processing works with Java 9?
@@TheCodingTrain you are right. Proccesing not working on java 9. But the diamond operator inference is since java 7. I'm not sure if proccesing supports the sintax.
классные видео, очень благодарен,я с Украины не с России(cool videos, very grateful, I'm from Ukraine not from Russia)
I love you 😂❤
First smarter every day, now numberphile, what comes next? Jesus Christ being born on Christmas eve?
Which langage do he use ?
Java. Using the Processing context. See Processing.org 🐣
u r god
Ooo I just saw this video earlier today
please draw a slinky (3d) please
2:57 😂
In which language r u coding
its a modified version of Java used by processing
@@CaelVK how can we get that version
@@CaelVK i do coding in java in eclipse
@@ArpitDhamija processing.org/tutorials/eclipse/
btw, you should use Intellij Idea and not Eclipse
Daniel, java.util.Optional is something that you would want to look at sometime.
Awesome, thank you for the tip!
ha i just watched that numberphile vid.
Is it p5 js or processing?
Processing :)
Thanks.