Shroomer

joined 1 year ago
[–] Shroomer@lemm.ee 1 points 1 year ago

After a few hours of work, I was able to improve the code by following your recommendations. I was genuinely surprised at how removing boilerplate code that I created at the beginning helped me see where the problems are and allowed me to see better solutions to problems.

For example: instead of copying each value into a temporary int array, sorting that array and then changing the original, I was able to just use C++ STL sort() with a function parameter to automatically sort structs based on their values when it came to the rows.

I touched on every point that you've made and made changes accordingly, some things like the char option I just removed and checked for the conditions in the function instead of waiting for the programmer to give the correct answer. The only thing left for me is to relax a bit since I was at it for a lot of time, and then properly comment the code.

[–] Shroomer@lemm.ee 3 points 1 year ago (1 children)

Thank you. Just the fact that you took all the effort into commenting is enough for me, thank you.

I didn't really implement comments since I didn't think it would expand that much (same goes for the namespace). As for some things which are unclear, number_matrix is a matrix I used to randomly generate the numbers that each horse would have to represent how fast they go, I didn't know exactly how to create a random matrix where each number was unique using random, so I just added each previous number into a vector and checked if that number already exists there. The reason I did this (at the time) was because I REALLY didn't want for the programmer to have access to the numbers, so I'd rather them being in a class that they can't even access (protected constructor) and otherwise the numbers were hidden in the Horse private structure with the only way to interact with them being the two Race function (essentially sort functions)

Also, I didn't use sets, because I remember doing a problem in LeetCode and when I used them there the Memory part of the submission was so bad that it essentially said that it only beats 0.5%, when I replaced them with a vector for the same function the memory recuperated back to 56% (I know that really the difference is only a few KBs of memory, but it still traumatized me haha )

I'll try to adress these issues and then I'll try to make another release on Github, although you might think that might be a waste of time on such a problem, I have nothing better to do since it's summer vacation.

I'm trying to learn programming, and it's more of a hobby for now since I'm still not in University yet, although this year might be if they accept me (still waiting for admission results)

 

I've found this interview question at GeeksForGeeks and decided to actually code it in C++. The program currently prints the "value" of the horses (which is inaccessible by the coder so they can't just look up who is number 1) and then proceeds to sort them and find the position of numbers 1,2 and 3 in a 5x5 matrix with the solution being a minimum of 7 races.

Here's the Github repo: https://github.com/Shroomerian/HorseRacing

[–] Shroomer@lemm.ee 1 points 1 year ago* (last edited 1 year ago)

Currently on Pop!_OS, you'd be suprised how much you can customize it, it's very user friendly and one of my favourite distros by far.

If you're worrying about the command line script, while it is true that the terminal can be really scary at first, little by little you end up understanding how they somewhat work by using examples from the internet and or the --help command. But on Pop!_OS you don't have to use the command line as much, since there's Pop!_Shop, an application which allows you to get new software, update your current applications and systems and also connect to popular software centers like Flatpak, the only times I tend to use the command line is when I git clone something or edit some configuration files through nano, other than that it's the inbuilt shop all the way.

Gaming is a treat on Pop!_OS. Was recentely running the Spider-Man Remastered at near max graphics with 80-90 fps average with no stuttering.

Also as far as programming goes, it can be as simple as Visual Studio Code + IntelliSense extensions. One advantage with Linux is once you get going you can easily link libraries and files since everything is neatly packaged in /usr/lib or /usr/local/lib if you install something yourself, and not have to find where in the C:\ is that one library you need.

[–] Shroomer@lemm.ee 1 points 1 year ago

Goddammit, you reminded me to water