push_swap TUTORIAL!

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 96

  • @thuggonaut
    @thuggonaut  7 дней назад +1

    I have a favor to ask!
    RUclips have put adds in this video (even though I'm not monetizing it). I liked my video being ads free, which was why I don't ask for likes or subscribes in my videos. But ads happened beyond my control.
    If you found this video helpful, please click subscribe to support, that would be so wholesome! I put a lot of time and effort in my videos (a week for push_swap) to help people and would love a little kindness in return.
    Thank you for you! ♥️

  • @melvinsmile27
    @melvinsmile27 Год назад +10

    I am now 3 months in 42....and this is the best Tutorial i have ever seen until today....for a 42 project to understand whats going on. You do it perfect in a slow and smooth mode to help us to understand. Thank you for that and please do more of that. So good. 😀👍🙏

    • @thuggonaut
      @thuggonaut  Год назад

      Thank you for your kind words and feedback. It makes my heart so glad you found it helpful 😊

  • @MESCGC
    @MESCGC Год назад +8

    It's a great video that was much needed for the community. Thank you for stepping forward and taking action. I appreciate the shoutout, and you pronounced my name 100% correctly. Thank you Thuy! 😃🙏

  • @onaecO
    @onaecO Год назад +20

    Amazing explanation 🔥 congrats, keep it up your channel will explode ! 👊🏻

  • @n1kito
    @n1kito Год назад +13

    Yay, more 42 tutorials ! 🎉 And this one must have been a lot of work. I really like how you structured the video and visuals, it’s great 👏🏻

    • @thuggonaut
      @thuggonaut  Год назад +1

      Thanks so much friend! You helped me massively with get_next_line (despite it not being English) and I linked your video in my github for it. I didn't know how to reach out to you, but I am so grateful for you!

    • @n1kito
      @n1kito Год назад

      ⁠@@thuggonautThank you so much for the kind words, I’m really happy the GNL video helped !

  • @giovannitroiano
    @giovannitroiano Год назад +1

    I didn't know it was you!!! When I figured it out, I was like: "Let's go, 42 Adelaide". Caring is sharing. Thanks so much for your effort.

    • @thuggonaut
      @thuggonaut  Год назад

      Haha 😊
      I hope it was helpful. See you around!

  • @jirapornjaroensutiyotin1490
    @jirapornjaroensutiyotin1490 9 месяцев назад +1

    I am currently working on this project and this is tremendously helpful. Thank you!❤

    • @thuggonaut
      @thuggonaut  9 месяцев назад

      Thank you for your kind words 😊

  • @jagggyjazz8010
    @jagggyjazz8010 Год назад +2

    This is great. Being someone at 42 and had taught before it would make way more sense why you want to do something and then how you do. Great work.

    • @thuggonaut
      @thuggonaut  Год назад

      Thank you for the kindness 😊

  • @nox_interior
    @nox_interior 8 месяцев назад +1

    Thanks so much for the video! It's really helpful, I am in the beginning stages of my project and it has helped me to have a clearer vision of how I should approach it. And for what it is worth, I really appreciate the calmness of your voice, there are already enough high speed and over stimulating videos all around 😄

    • @thuggonaut
      @thuggonaut  8 месяцев назад +1

      Thank you for your kindness! I'm so glad it can be helpful for you. All the best with aceing it😊

    • @nox_interior
      @nox_interior 8 месяцев назад

      @@thuggonaut thanks!! 🥰

  • @vryzz9725
    @vryzz9725 4 месяца назад +1

    this video carried most of the push_swap projects at 42 X) SOOO well explained thank you !

    • @thuggonaut
      @thuggonaut  4 месяца назад

      Thank you so much for the kind words 💛💛

  • @niranpiyapanichayagoon5143
    @niranpiyapanichayagoon5143 11 месяцев назад +1

    I passed this project by watching this video, thank you so much.

    • @thuggonaut
      @thuggonaut  11 месяцев назад

      Amazing work, yay!

  • @arturcarvalho7484
    @arturcarvalho7484 5 месяцев назад

    Amazing work on this tutorial.
    It was very well structured and the visual aid was really well thought. Thanks for your work!

    • @thuggonaut
      @thuggonaut  4 месяца назад

      @@arturcarvalho7484 you are so welcome and thank you for the kind words! Good luck with your project! 😊

  • @alanishadama
    @alanishadama 10 месяцев назад

    Thank u so much for the explanation I'm from 42 RIO, you helped me a lot!!!! 💖 I loved you're videos they're really well ilustrated pleeeese keep doin' it💕

    • @thuggonaut
      @thuggonaut  9 месяцев назад

      Thank you so much friend, I appreciate you 😊

  • @antoinem6654
    @antoinem6654 9 дней назад

    thanks for the help ! great video

  • @1337-rw6xh
    @1337-rw6xh 11 месяцев назад +1

    perfect tutorial keep it up

    • @thuggonaut
      @thuggonaut  11 месяцев назад

      Thank you! Cheers!

  • @fabocas
    @fabocas Месяц назад

    thank you for the video now i understand it better😁

    • @thuggonaut
      @thuggonaut  Месяц назад +1

      @@fabocas you're welcome friend, and good luck! 😊

    • @fabocas
      @fabocas Месяц назад

      @@thuggonaut trying.. to not be blackholed😭😂

  • @MelodyNeverEnd
    @MelodyNeverEnd Год назад +1

    Great video!

  • @raparaparapaDum
    @raparaparapaDum 10 месяцев назад

    min 19:18
    median is 7. so to bring 7 to top we will need to ra() twice or rra() three times so better use ra() if (target node >= median).

    • @AlexIriarteDiban
      @AlexIriarteDiban 4 месяца назад

      yes, but since index starts in 0 you get ra twice ;)

  • @davidalmeida5410
    @davidalmeida5410 Год назад

    Amazing explanation!!! Helped me a lot

    • @thuggonaut
      @thuggonaut  Год назад

      Thank you friend! That makes me happy 😊

  • @andrepedro1972
    @andrepedro1972 6 месяцев назад +1

    Hi there! Awesome video, thanks!!
    I just have one question: at the 14:00min you say that the cost of putting the number 25 from STACK A to STACK B is 0, which seems inaccurate to me, because the cost is 1. One operation is needed to push the number 25 to STACK B. Is it not?

    • @corentinlt7859
      @corentinlt7859 6 месяцев назад

      It technically cost one more but because it is the case of every numbers it is voluntary ignored

    • @andrepedro1972
      @andrepedro1972 6 месяцев назад

      @@corentinlt7859 Ok, thank you!

  • @xAthaz
    @xAthaz Год назад

    Awesome video, thank you!

  • @ansiosmenaj9274
    @ansiosmenaj9274 11 месяцев назад +1

    Hello, thank you for the tutorial very useful, although i have a question.
    Why in minute 15:45 you say that the pushcost of 7 is 3 when we can make rr and ra so 2 operations to put both in the top. Thank you in advance.

    • @thuggonaut
      @thuggonaut  11 месяцев назад

      Hello, thank you for dropping by!
      At that state of configuration, the push cost for 7 is 3 because we need to rr twice in stack a: 1st rr to bring 42 to top, 2nd rr to bring 7 to top. Let me know if I've missed something or if I've understood your question incorrectly and we'll try again, good luck friend! 😊

    • @ansiosmenaj9274
      @ansiosmenaj9274 11 месяцев назад +1

      @@thuggonaut ok now i understand but why we do not use only rotate in this case, so we make two moves till with 1 move we rotate both and with the other only a and we have 7 and 0 at the top.
      I make this think because i tried to fallow a logic on my code (not tested yet) where i add 1 to the median. Anyway thank you for your help and sorry for my english.

  • @user-jp4io9bq4u
    @user-jp4io9bq4u 3 месяца назад

    this video was so helpful !! thank you for making it :)
    may i know what application you used to create this video? what did you use to screen record, and to create the explanation slides in the beginning ? and to compile the clips together? x0

    • @thuggonaut
      @thuggonaut  3 месяца назад

      I'm glad, and you're welcome 😊😊
      Of course! I used Microsoft Powerpoint for the slides, and then windows capture to record the screen. I didn't need to compile things together because I just screen recorded the whole thing. If you have windows though, microsoft clipchamp is good for video editing, hope that helps!

  • @cigakuya1183
    @cigakuya1183 Год назад

    I like it a lot! 👍

  • @gabriela-807
    @gabriela-807 7 месяцев назад +1

    hey. Does this implementation fall below the limit for 100 and 500 numbers? Your explanation is very educational and helped me a lot.

    • @thuggonaut
      @thuggonaut  7 месяцев назад

      Hello friend, thank you for passing by, and your kindness.
      I believe it does. There may be the occasional case where it returns higher instructions, but I suggest running the case a few times (also recommended in the evals), and it should give you the desired average.

  • @Myxoceph
    @Myxoceph 8 месяцев назад

    I have another question. Why is mutable string important in split? When I try to do it with my ft_split in the input "./push_swap -" i encounter leak as still reachable but your split doesn't have any leaks. I couldn't figure out why is it different.

    • @thuggonaut
      @thuggonaut  8 месяцев назад

      Did you have any luck? I'll try to get back to you as soon as I can! The black hole is creepin on me 😅

  • @aminekar8447
    @aminekar8447 4 месяца назад

    u a legend, W

    • @thuggonaut
      @thuggonaut  4 месяца назад +1

      Thanks so much bro!

  • @ansiosmenaj9274
    @ansiosmenaj9274 10 месяцев назад

    Hello again, i have a question do we need to calculate the cheapest when we have to push from stack_b to stack_a ?

    • @thuggonaut
      @thuggonaut  10 месяцев назад

      Hi, sorry for the late reply! No, we only need to make sure [b] node is pushed on to the correct [a] node, so we move it (the [a] node) to the top before doing so @16:42

  • @GabrielRodriigues95
    @GabrielRodriigues95 Год назад +1

    nice

  • @rosshvidsten6481
    @rosshvidsten6481 6 дней назад

    i'm not sure if i'm missing something really obvious. But i think at the point where you're explaining the actual coding you say you covered already what 'a ''target node" is. But earlier in the video when talking about nodes you say you will explain it later....i cannot find where in the video it is actually explained.

    • @thuggonaut
      @thuggonaut  6 дней назад +1

      Hey friend! I explain target_nodes in the animation @10:20 Hope it helps 😊

  • @kiseijuu7420
    @kiseijuu7420 Год назад

    Hello, im still at b2br, i dont really like that project so during my free time i was wondering if i should start learning how to do the next project, push swap. I didnt watch the vid yet, do you recommand me to try push swap alone and then look at ur vid, or watching it first is a good way to start it well?

    • @thuggonaut
      @thuggonaut  Год назад

      Hi! Thanks for visiting :)
      B2BR is tedious, but I liked that I didn't have to "think" much with it haha.
      Always great to have a go at it first, for sure. You could even watch the first half which explains visually how the swap/push operations and linked lists work, then have a go at coding it. Even if your chosen sort algorithm is different to mine, it can be transferrable. Good luck with 42!

  • @Myxoceph
    @Myxoceph 8 месяцев назад

    I have a question, your push commands like pa pb takes boolean as parameters but they are always false. Is there a specific reason why dont they just print when they are called?

    • @thuggonaut
      @thuggonaut  8 месяцев назад

      Such a fair question! The bools were added as an option to print the commands, or not, which can be useful for debugging purposes. In hindsight though, going back to the scattered bools to change its value is tedious, and I wasn't experienced with global variables or custom macros. I'd use custom macros instead, something like '#define ENABLE_PRINT 1' in the .h file

  • @raparaparapaDum
    @raparaparapaDum 10 месяцев назад

    min 34:26 line 40 - 42. why to we need the "if check" twice ?

    • @thuggonaut
      @thuggonaut  10 месяцев назад +1

      Hello, thanks for visiting! We need to do it twice because the algorithm requires us to push the first two nodes to stack [b] (if [a] has >4 nodes), but only push the first node if [a] has 4 nodes.

  • @RiDOU-p2g
    @RiDOU-p2g Год назад +6

    Your code has a memory leak if you put all your arguments into one argument (due to the result of ft_split not being freed)

    • @thuggonaut
      @thuggonaut  Год назад +1

      Hello, thanks for your feedback 🙏
      I didn't test for memory leaks but knew that could be the case, what you've written. I chose the easiest route possible to get the project done and didn't want to worry about it too much as long as it worked, and so I created a different split() to ft_split(). split() is only responsible for splitting a string, and returns NULL at any point where malloc is unsuccessful. init_stack_a() is responsible for appending nodes if there are no errors. If there are errors the stack is freed.
      Thanks again and good luck!

    • @Ay_140
      @Ay_140 11 месяцев назад

      was you able to solve that matter? cause i have been spending hours working on that part to prevent the leak but i solved half of it only! if you did please share it and thanks in advance

    • @RiDOU-p2g
      @RiDOU-p2g 11 месяцев назад +1

      @@Ay_140 you have to free the result of ft_split if used (it should be used only if you have one argument)
      if your variable is **splited_str, then you free(splited_str[0]) and then free(splited_str[1]) until splited_str[i] is NULL, and then you free(splited_str)

    • @Ay_140
      @Ay_140 11 месяцев назад

      @@RiDOU-p2g i have done this but im still getting one block of memory not freed, searched everywhere but couldn’t fix it 😓
      When i fix it it affects the behavior of the full function.
      If you did it right share your git hub solution if you don’t mind 🙏🏻

    • @thuggonaut
      @thuggonaut  11 месяцев назад +2

      @@Ay_140 I'm sorry you had to do this as my code has flaws! Someone else opened an issue in my GitHub regarding this, I'm wondering if that will shed any helpful light as well. Please do let me know how you go to solve it 🙏🏼
      Also thanks @user-vh6rl1se8e for highlighting the leak and solution 😊

  • @liathecat7757
    @liathecat7757 Год назад +1

    can you explain get next line pls?

    • @thuggonaut
      @thuggonaut  Год назад +1

      Hello 😊 I won't be able to anytime soon, but I found this video super helpful m.ruclips.net/video/-Mt2FdJjVno/видео.html or check out my guide on the GitHub link that scored me 125%

    • @liathecat7757
      @liathecat7757 Год назад

      @@thuggonautthanks!

  • @abdokhairi7500
    @abdokhairi7500 Год назад

    Can you create video for projet minishell

    • @thuggonaut
      @thuggonaut  Год назад +1

      Hello! I'm not up to minishell yet, but will definitely consider it once I am.

  • @adamekhobba2156
    @adamekhobba2156 8 месяцев назад

    ❤ from 1337 students

    • @thuggonaut
      @thuggonaut  8 месяцев назад

      Right back at you 🥰

    • @adamekhobba2156
      @adamekhobba2156 8 месяцев назад

      @@thuggonaut which campus you're studying on it

    • @thuggonaut
      @thuggonaut  8 месяцев назад

      @@adamekhobba2156 I'm at 42 Adelaide. What about you?

    • @adamekhobba2156
      @adamekhobba2156 8 месяцев назад

      @@thuggonaut 1337 if you know it. it's 42 school in Morocco

  • @malikmouhiidine9828
    @malikmouhiidine9828 11 месяцев назад +4

    hai whos from 1337 lol

    • @Null.0000
      @Null.0000 7 месяцев назад

      Feen cv kh or bg or med hhhh

  • @yasuofedeer9851
    @yasuofedeer9851 10 месяцев назад +3

    I tested your code and it has a memory leak when you do a test that you expect the output to be "Error", example: "./push_swap "2 5 1 4 3 32 -42 ab"", I'm trying to solve it but I wasn't able to do so, if someone knows how to, please help me

    • @Myxoceph
      @Myxoceph 9 месяцев назад +1

      have you solved it?

    • @yasuofedeer9851
      @yasuofedeer9851 9 месяцев назад +1

      @@Myxoceph Yes, I was able to solve it

    • @Myxoceph
      @Myxoceph 9 месяцев назад

      @@yasuofedeer9851 how? Can you help me too?

    • @thuggonaut
      @thuggonaut  9 месяцев назад

      Hello! Thank you for visiting, and for this feedback, my program is definitely flawed! I'm glad you solved the issue, please share how so if you've the time 😊

    • @ServetTonga
      @ServetTonga 8 месяцев назад

      @@Myxoceph you should free argv if it was dynamically allocated (what's returned from split)