2023-11-28
So as I mentioned on the card I got my push_swap evaluated today. It was my first real big project of 42 and I was pretty stressed. I knew the code was pretty solid but still I had the thought that some error must have slipped in to my code. But I was suprised after the first peer eval that no issues were found. Well after that all the stress went out of the window and I could just talk about my code and project without worrying. So let's talk about it some more here shall we?
Push swap is about parsing the data and then finding an algorithm to sort the data in the least amount of moves. My data structure of choice was a doubly linkd list. I chose this because it would be easier to make some of the operations. Well what I didn't know was that it would be harder when using a doubly linked list because some people on campus mentioned that we could also use a normal array. But yeah it would save me from some memory allocations but I really liked it in general to work with lists. Then let's talk a bit about the algorithm I chose. I found this amazing guide on medium of the Turk algorithm and followed it for a part. Then it was not optimised enough for me so I went a step further and added some own optimizations to it and on the end it worked out to get me down to under 5500. The algorithm is far from perfect but I am very happy with the result and I maybe even want to improve it more soon.
The project in general is fun and you really learn a lot out of it. It's also nice that you don't have to worry that moulinette will find some weird things in your code because it's not evaluated by it. This gives you a lot more freedom to work with then the previous projects. I hope you guys enjoy it as well and if you have any questions don't hesitate to contact me on slack (qraymaek) or just send me an email. I hope you guys enjoyed reading this blog post and I will see you guys next time!