r/learnprogramming • • 28d ago

How to train programming logic?

It's easy to learn syntaxis of a programming language, or buttons of a software, but it won't give you the skill, and programmer should learn how to solve problems, but even here it's possible to learn how to do it not in the best way possible, at least I have no idea what you need to do it in a very efficient way.

I just got my mind blown with this:

std::bitset<4> rotLeft(std::bitset<4> x, int n)
{
  return (x<<n) | (x>>(4-n));
}

It's a C++ function to rotate bitset, I would never figure out that it's possible to do it in THAT way, I did it with loop that stores bit that is about to get out of bounds and then putting in the beginning...

How do you even learn this kind of mentality / logic, to come up with such stuff? I just refuse to believe that it's done by practice alone

29 Upvotes

27 comments sorted by

View all comments

1

u/rbatts94 27d ago

I asked Claude to generate me some coding problems.

I had an old app from my apprenticeship and fixed the old bugs / updated the methods and technologies.

Built apps that really interested me / that my friends would find useful

1

u/Lemenus 26d ago

I asked how to train own brain, not about you using ai, nor how to throw brain into the trash bin

1

u/rbatts94 26d ago

If you don't understand the benefit of taking a decade old codebase and updating it to modern technologies. Find a new career bro

1

u/Lemenus 26d ago

I asked about completely different thing! 

Yet, you've come here to share about the thing nobody asked for, it's almost as if you would come here to share about how you walked out your dog today, and how everyone should have dogs because of how great it is, that's great, but that's completely off topic.

You just shown everyone once again that ai bros are insufferable people that cannot keep themselves shut

1

u/rbatts94 26d ago

Dude you need to chill. Asking an agent to generate you a function to solve, in the issue you're having is not slop or getting it to do the work for you. Also you asked how to solve problems in an efficient way. Thirdly reading through your own old code or someone else's legacy code on the topic you're trying to learn and fixing / updating it can solidify understanding. Finally building apps using the syntax you want to rep will give you understanding of how things can fit together / be achieved in different ways