I wouldn't be able to finish pset1 and pset2 without your help, in pset3 however, I was able to finish the first assignment all by myself and I watched your video to solve the 2nd assignment, I feel like I am getting better and you're helping me a lot, thank you so much.
By the first assignment do you mean the lab, or this problem? I still feel as lost on this one as I did with previous problem sets. I have a lot of pseudo code written out and have implemented some of it, but I get tripped up when it comes time to sort the data after the votes have been counted. If you figured that out on your own, props, because I am totally lost on it. Gonna watch this video to hopefully work it out. EDIT: Lol. This solution was much simpler than what I was attempting. Still so much to learn!
@@Jack_______oh yeah it always seem so easy after you realize the solution. I didn't know about nested loops so I couldn't do mario, but after the videos I went back to it and I could do it in minutes
This young man is the best on the net! He really breaks things down and makes them completely understandable! Thank you Rahul!!! I am sad that your last problem set walkthrough is this one. If I join your channel can I perhaps get access to subsequent walkthroughs?
I'm still in PSET1 but I love your explanations...they are on point, keep on the good work...you are unlocking many dreams...CS50 isn't for the faint-hearted, your push is welcomed wholeheartedly bro. Much love from KE
Dude 21:43 had me laughing so hard. Great video! I was able to get through updating the candidate vote count, but was unable to figure out that the "print winner" portion should be broken down in two steps. Your videos are extremely helpful, thanks so much for taking the time to create them.
I love how you walk through the problem. The main thing I have learnt from your videos is how to walk through the code and make sense of it. With Pset2 I relied a lot on your video. This time I tried to think the way you were thinking and got pretty far on my own. Thank you!
A very professional and simple way of explanation of not simple things ( I’m a beginner) thanks to you I started to understand and even sometimes know what we need to do the next step and etc , a very pleasant voice and high quality of the video thank you for your efforts , your video I want to watch again and again 👍🏻
Thank you for making these videos. I appreciate how you step through the expected outcomes and give some more explanation before showing your solution. I try to use your videos as a last resort and struggle as long as I possibly can.
thank you for all your videos! you have no idea how much they've helped me. Sometimes just semantics alone lead me to errors but you are able to explain concepts pretty well.
Your tutorials are great, thank you for making them. In this one, up to timestamp 19:43 you have this code for the for loop in your line 85: for (int i = 0; i < candidate_count < i++). This does not compile as it should be, (int i = 0; i < candidate_count; i++), but you don't explain that error in the code we watch you write in the body of the video. How come? Thanks.
Im here in 2024 and these videos have been great could you please finish the walkthroughs im struggling without your help I have watched all your walkthrough videos and I cant continue without these videos
I was trying to implement a merge sort algorithm to order all candidates of the array by the number of votes each one had, but it turned out I'd need to create another function to implement the divide part and then another to implement the merge part, this way is really more simple and makes more sense in a real life type of occasion since in a pluralized vote, the number of cadidates wouldn't be much bigger than 10, so it wouldn't make the program slow or something
hey brother you are an absolute lifesaver. thank you for all your hardwork. any chance you can make a video on problemset 3 runoff? thanks so much peace be upoon you
when I try to compile, I have an error on line 71 saying error: use of undeclared identifier 'i' if (strcmp(candidates[i].name, name) == 0) with the arrow pointing the [i] can someone help me ?
For the bool vote function, why is the condition set as "i < candidate_count" instead of "i < voter_count"? I understand it as if the number of votes is smaller than the total number of voters, then it should keep on counting. If "i < candidate_count", then it seems to be counting the number of votes up to the number of candidates. For example, if there are 3 candidates and 7 voters, by using "i < candidate_count", it feels like we are counting only 3 votes. Please let me know your thoughts. Thank you.
The loop is to find if the vote submitted by the user is actually a valid vote or not so we run through every candidate's name and how many names will there be? Equal to the no. of candidates and not voters. Hope it helps
Damn, you print_winner solution is nice. I did more complicated and it was so simple. I sorted the entire candidates array lol. But at least it worked and I am able to do sort function by mysefl, so I am happy :D I really like your way of thinking the problem to a simple solution on paper. I need to be better at that. Thanks for sharing your solution, so we can compare and learn more after we finished the problem ;)
I have expected you would have used some kinds of complex sorting algorithms like merge sort v.v. Are the trade-offs of time and space worth to implement these ?
Can someone pls explain (1)why my code was counting the vote of the first candidate only because I had the return true line outside of the curly bracket for(int j=0; j
return true; should be inside the curly brackets just below the candidates[i].votes ++ . This essentially means that the for loop will iterate all the candidates one by one and increment the vote count by one for the candidate whose name matches with the name the voter has voted for(hence a valid name) and return true and then for loop will keep on executing until all candidates have been iterated through. If you put return true; outside curly braces of if statement, the code iterates the first candidate ,counts its vote and then returns true (and moves on to next lines of code!) ,without iterating further. Hope this helps!
For anyone else who was confused, argc DOES NOT need to be greater than 2 as he stated in the video. Argc needs to be equal to or greater than two. The program is designed to run with only one candidate. Also, in case you get an error when you compile, in the video, he fixed a type-o on line 85 without showing it.
if 'name' is the only parameter being passed to the function vote, how does it work that you can compare 'name' to 'candidate[i].name'. Is 'candidate.name' a global variable?
:( vote returns false when given name of invalid candidate vote function did not return false :( vote leaves vote counts unchanged when voting for invalid candidate vote function modified vote totals incorrectly Does anybody knows why this is happening?
I know its been close to a year but I'm replying in case anyone else is having this problem. Both of your errors are connected, you're probably missing a return false line in the bool vote function: bool vote(string name) { for (int i = 0; i < candidate_count; i++) { if (strcmp(name, candidates[i].name) == 0) { candidates[i].vote++; return true } } return false; } If you don't have that line, the program counts a vote for an invalid candidate
You can't assign(=) a value to a data type. You need to write which variable you are assigning 0 to. In your case, int i = 0, i is name of variable, int - just data type
Man, you're awesome and the idea of this program is ultimately stupid and unreasonable. As , how come I enter the names of the candidates, and also chose each number of elected candidate? I know it's for educational purpose, but reality counts.
Basically, this function receives the input through the question: 'Vote.' It then compares the input with candidates[i].name in a loop that runs for the total number of candidates participating. Whenever the comparison is true, you just need to increment candidates[i].vote. After this, the vote function will return to the main function, increment the counter i, and perform the same process for the next input from the user.
From my understanding, anything other than "return 0" is used to show failure, and each different return/exit value, such as return 1 or return 2, shows different parts in code that there was a failure or invalid input.
Yes, it's normal!! but you have to have a growth mindset, go ahead and spend hours trying, then watch a video and go through another part on your own, in my case, it took me 2 hours to do this exercise, and I came here to realize that I could improve myself code and see how to use better logic.
// Print the winner (or winners) of the election void print_winner(void) { int max_votes = 0; // First pass: find the maximum number of votes for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes > max_votes) { max_votes = candidates[i].votes; } } // Second pass: print the names of all candidates with the maximum number of votes for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes == max_votes) { printf("%s ", candidates[i].name); } } }
These walkthroughs help me so much,
Can you please keep uploading the rest of the weeks of CS50.
thank you so much for helping everyone.
I wouldn't be able to finish pset1 and pset2 without your help, in pset3 however, I was able to finish the first assignment all by myself and I watched your video to solve the 2nd assignment, I feel like I am getting better and you're helping me a lot, thank you so much.
By the first assignment do you mean the lab, or this problem?
I still feel as lost on this one as I did with previous problem sets. I have a lot of pseudo code written out and have implemented some of it, but I get tripped up when it comes time to sort the data after the votes have been counted. If you figured that out on your own, props, because I am totally lost on it.
Gonna watch this video to hopefully work it out.
EDIT: Lol. This solution was much simpler than what I was attempting. Still so much to learn!
@@Jack_______oh yeah it always seem so easy after you realize the solution. I didn't know about nested loops so I couldn't do mario, but after the videos I went back to it and I could do it in minutes
These walkthroughs are extremely helpful. The way you write out the problems in a word document helps to visualize the actual code. Great videos
You're doing such a great job. Not having a CS background and still nailing the couree and teaching/helping others. It's such an achievement.
Still don’t understand what you get out of this, but you’re saving my life. Thank you!
You do a great job explaining the "why" as well as the "how to." Keep up the good work!
This young man is the best on the net! He really breaks things down and makes them completely understandable! Thank you Rahul!!! I am sad that your last problem set walkthrough is this one. If I join your channel can I perhaps get access to subsequent walkthroughs?
21:45 bruh 😂
to put your thinking into words that I can understand is a mystery that only you have been solving. thank you.
I'm still in PSET1 but I love your explanations...they are on point, keep on the good work...you are unlocking many dreams...CS50 isn't for the faint-hearted, your push is welcomed wholeheartedly bro. Much love from KE
Dude 21:43 had me laughing so hard. Great video! I was able to get through updating the candidate vote count, but was unable to figure out that the "print winner" portion should be broken down in two steps. Your videos are extremely helpful, thanks so much for taking the time to create them.
david malan handsome cs50 🤣🤣
I love how you walk through the problem. The main thing I have learnt from your videos is how to walk through the code and make sense of it. With Pset2 I relied a lot on your video. This time I tried to think the way you were thinking and got pretty far on my own. Thank you!
Cara, não desiste de fazer os vídeos, as explicações são maravilhosas.
Br tu acha em tudo quanto é lugar kkkk
o mlk é pica nas aulas
The best series of videos for CS50's problem sets since the explanations are from learners' perspectives. Thank you so much Rahul~
The sudo code you write in word document really help visualize the solution.....it need not let me look at the actual code....
Great video 🤞
20:20 watch out for the small change from < to ; at line 85
Our dude left us to become tiktok famous in his country. Thanks for all the help so far dude! Wish you completed the whole CS50 with us!
So sad 😢
For the first time , i did some coding in project by myself in C , Thanks for the walkthrough , i could understand the concept and finally able to it.
I would not have gotten this code without your video. I still don't understand it entirely, but I definitely learned something. Thank you!
Thanks again for explaining it so well. We missed you man! :)
A very professional and simple way of explanation of not simple things ( I’m a beginner) thanks to you I started to understand and even sometimes know what we need to do the next step and etc , a very pleasant voice and high quality of the video thank you for your efforts , your video I want to watch again and again 👍🏻
Killer maine! You're a beast! Wish we had more of your videos explaining general topics like functions. Hope you're doing well out there.
It would be great if you continue uploading these videos
You have no idea how helpful and simple your help is. Thank you.
thank you, man. i was beginning to feel I cannot understand this. you're a good teacher
Please keep uploading these walkthroughs they help so much! I understand it better when you explain it.
wooow tbh i never knew i could do it as a total beginner thank u soo muchhh
honestly this guy is my hero
love the videos man, there so helpfull. This is the first week i was able to go ahed by myslef and solve the print_winner section. Keep it up x
come back for the rest of cs50!!
us new coders need you!
Thank you for making these videos. I appreciate how you step through the expected outcomes and give some more explanation before showing your solution. I try to use your videos as a last resort and struggle as long as I possibly can.
thnks man you help me and make me understand more what i learnd in cs50.
my english not that good but i understand your clean language.
thanks for these walkthroughs, it is helping me a lot to learn and you are the best!
lol 21:45
amazing vid as always so grateful for these rahul!
You’re the best bro! Keep up these videos they are so helpful!
Perfect timing, I was looking for your walkthrough for this pset a few days ago
loving this videos! how come you haven't added any more since?
thank you for all your videos! you have no idea how much they've helped me. Sometimes just semantics alone lead me to errors but you are able to explain concepts pretty well.
thank you so much for the help throughout these courses
Your tutorials are great, thank you for making them. In this one, up to timestamp 19:43 you have this code for the for loop in your line 85: for (int i = 0; i < candidate_count < i++). This does not compile as it should be, (int i = 0; i < candidate_count; i++), but you don't explain that error in the code we watch you write in the body of the video. How come? Thanks.
Thanks..very nicely and thoroughly explained.....keep it up....
perfect. your videos are so helpful. and they help to think more logically
Please keep making man ! you are awesome
Next PSet coming soon :)
when he says " its very simple right " i want to jump out of a cliff , ITS NOT SIMPLE FOR BEGINNEEERS . hahah
Thanks alot tho you are helping alot
thanks! it really helped me understand another way of solving the problem
Im here in 2024 and these videos have been great could you please finish the walkthroughs im struggling without your help I have watched all your walkthrough videos and I cant continue without these videos
hi will you make a video on problem set 4?
Your videos are so helpful! I hope you upload more soon 🙂
I was trying to implement a merge sort algorithm to order all candidates of the array by the number of votes each one had, but it turned out I'd need to create another function to implement the divide part and then another to implement the merge part, this way is really more simple and makes more sense in a real life type of occasion since in a pluralized vote, the number of cadidates wouldn't be much bigger than 10, so it wouldn't make the program slow or something
You should post more of these, man
thank you so much! your explain is so helpful ! will you do more of these problem sets? :(
hey brother you are an absolute lifesaver. thank you for all your hardwork. any chance you can make a video on problemset 3 runoff? thanks so much
peace be upoon you
You are the best though...keep it up bruv
when I try to compile, I have an error on line 71 saying error: use of undeclared identifier 'i'
if (strcmp(candidates[i].name, name) == 0) with the arrow pointing the [i]
can someone help me ?
amazing video
Plzzz release the walkthrough of the other problem set.
I cant wrap my mind around pset3: runoff
awesome! thanks so much!
thank u so much bro
yoo bro this was very helpful can u do a video on lab4 and problem set 4 aswell ?
For the bool vote function, why is the condition set as "i < candidate_count" instead of "i < voter_count"? I understand it as if the number of votes is smaller than the total number of voters, then it should keep on counting. If "i < candidate_count", then it seems to be counting the number of votes up to the number of candidates. For example, if there are 3 candidates and 7 voters, by using "i < candidate_count", it feels like we are counting only 3 votes. Please let me know your thoughts. Thank you.
The loop is to find if the vote submitted by the user is actually a valid vote or not so we run through every candidate's name and how many names will there be? Equal to the no. of candidates and not voters. Hope it helps
thank you
Damn, you print_winner solution is nice. I did more complicated and it was so simple. I sorted the entire candidates array lol. But at least it worked and I am able to do sort function by mysefl, so I am happy :D I really like your way of thinking the problem to a simple solution on paper. I need to be better at that. Thanks for sharing your solution, so we can compare and learn more after we finished the problem ;)
hi bro will u be doing more ? this is really helpful and it makes it a lot easier for uws begginers. pls continue to help us out :D
Thanks.
man where are you ,
we are waiting for you
is line 85 correct? I'm getting a "plurality.c:85:46: error: expected ';' in 'for' statement specifier
for (int i = 0; i < candidate_count < i++)
He made a mistake and edited out himself fixing it. '< i++' should be '; i++'
I have expected you would have used some kinds of complex sorting algorithms like merge sort v.v. Are the trade-offs of time and space worth to implement these ?
can you please do runoff and following weeks ! i need the help
thank u bro
21:34 bro got humours
Thankyou!!
hi, what does it mean when the code is "return 2" in populate array of candidates?
Can someone pls explain
(1)why my code was counting the vote of the first candidate only because I had the return true line outside of the curly bracket
for(int j=0; j
return true; should be inside the curly brackets just below the candidates[i].votes ++ .
This essentially means that the for loop will iterate all the candidates one by one and increment the vote count by one for the candidate whose name matches with the name the voter has voted for(hence a valid name) and return true and then for loop will keep on executing until all candidates have been iterated through.
If you put return true; outside curly braces of if statement,
the code iterates the first candidate ,counts its vote and then returns true (and moves on to next lines of code!) ,without iterating further.
Hope this helps!
@@gatewaynippon thank you, this helps.
Please upload all.
For anyone else who was confused, argc DOES NOT need to be greater than 2 as he stated in the video. Argc needs to be equal to or greater than two. The program is designed to run with only one candidate. Also, in case you get an error when you compile, in the video, he fixed a type-o on line 85 without showing it.
which type o
@@DallasKeana should be a semicolon after candidate_count and no less than symbol.
if 'name' is the only parameter being passed to the function vote, how does it work that you can compare 'name' to 'candidate[i].name'. Is 'candidate.name' a global variable?
:( vote returns false when given name of invalid candidate
vote function did not return false
:( vote leaves vote counts unchanged when voting for invalid candidate
vote function modified vote totals incorrectly
Does anybody knows why this is happening?
I know its been close to a year but I'm replying in case anyone else is having this problem.
Both of your errors are connected, you're probably missing a return false line in the bool vote function:
bool vote(string name)
{
for (int i = 0; i < candidate_count; i++)
{
if (strcmp(name, candidates[i].name) == 0)
{
candidates[i].vote++;
return true
}
}
return false;
}
If you don't have that line, the program counts a vote for an invalid candidate
please post all problem sets and labs please please
i was stuck cuz i was typing for (i = 0; i < strlen(name); i ++) and it wasnt working untile i tried for (i =0; i < candidate_count; i ++)
I'm like 90% done pset 3 runoff but I'm stuck on a few things are you going to be making a video soon?
nice brooo
Hey, did you stop with the tutorials? :(
Please do 'credit' pset 1 assignment, I'm stuck, I don't know what to do
it weird how i follow step by step and the IDE always says my "int = 0" is a fatal error.
line 71. the "[i]" comes up as an error please help
You can't assign(=) a value to a data type. You need to write which variable you are assigning 0 to. In your case, int i = 0, i is name of variable, int - just data type
Man, you're awesome and the idea of this program is ultimately stupid and unreasonable. As , how come I enter the names of the candidates, and also chose each number of elected candidate? I know it's for educational purpose, but reality counts.
Can someone explain me this code
!vote(name)
Basically, this function receives the input through the question: 'Vote.'
It then compares the input with candidates[i].name in a loop that runs for the total number of candidates participating. Whenever the comparison is true, you just need to increment candidates[i].vote.
After this, the vote function will return to the main function, increment the counter i, and perform the same process for the next input from the user.
why do they use "return 2" instead of "return 1"?
From my understanding, anything other than "return 0" is used to show failure, and each different return/exit value, such as return 1 or return 2, shows different parts in code that there was a failure or invalid input.
watching you making your exercise, Im fell afraid off just like: "My God, Will I ever learn and begin to understand this?"😥
just my question is i cant do this alone i have to watch walkthroughs to be able to understand is that normal ???
Yes, it's normal!! but you have to have a growth mindset, go ahead and spend hours trying, then watch a video and go through another part on your own, in my case, it took me 2 hours to do this exercise, and I came here to realize that I could improve myself code and see how to use better logic.
No matter what I keep getting "use of undeclared identifier i" and it's so annoying...
noice!
my code all good but just one mistake i placed one comparison operator incorrect '' 😂😂😂😂😂😂
Bro where is runoff
where'd you go my friend lab4 is murder and I need your genius brain to hold my hand through this mess
where are you now my friend
// Print the winner (or winners) of the election
void print_winner(void)
{
int max_votes = 0;
// First pass: find the maximum number of votes
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].votes > max_votes)
{
max_votes = candidates[i].votes;
}
}
// Second pass: print the names of all candidates with the maximum number of votes
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].votes == max_votes)
{
printf("%s
", candidates[i].name);
}
}
}
NOO PLEASE MAKE WALK THROUGHS FOR THE REST OF THE PROJECTSSS
posting your Github account would be highly grateful, thanks
i love you
big like just for the picture with Trump ))
cornball