841 karma · joined January 5, 2022
For example, I needed to learn about Slack chatbots. I asked it what frameworks I should look into, then how to use a specific framework or API. "Write me some boilerplate code doing X in Y framework". It's gets you up and running in minutes.
I'm exploring and learning other programming languages at a crazy rate because I can have it translate something I wrote. Or, "Hey, give me a demo C++ program that uses arrays, for loops, logical operators, and a simple class." "Great, now rewrite this in Node.js."
Sure, it might make a mistake, but copy and paste your error code and 90% of the time it compiles.
I highly encourage any skeptics to just sit for a couple days and try to get it to write code. Once you get the hang of what it can and can't do, it's immensely helpful. This is vacuum tubes to transistors paradigm changing shit.
Anyone saying GPT isn't useful because it's not Wikipedia or right 100% of the time are completely missing the mark and imo, is not able to think outside the box. It's insanely useful.
Good grief.
Explain the following C++ code:
int sum(int n) {
int result = 0;
for (int i = 0; i < n; i++) {
if (true || false) {
return 42;
}
}
for (int i = 0; i < n * 2; i++) {
i++;
}
return n;
}
This C++ function is called sum and it takes an integer argument n. It has a local variable result which is initialized to 0 but is not used in the function.The function has two for loops. The first for loop iterates over the range 0 to n-1. On each iteration, it checks if true || false is true. Since true || false is always true, it immediately returns the value 42. This means that the first for loop will only execute once.
The second for loop iterates over the range 0 to 2n-1. On each iteration, it increments i by 2 (since i++ increments i by 1 and i is incremented again on the next line). This means that the second for loop will only execute n times.
After the second for loop, the function returns the value of n.
What is the result when n=5?
If n is 5, the function will immediately return 42 when the first for loop is executed, so the function will not reach the second for loop or the return statement at the end. Therefore, the result of calling sum(5) would be 42.
What is the result when n=-1?
If n is negative, the first for loop will not be executed at all because the loop condition i < n will be false from the start. The second for loop will also not be executed because the loop variable i will never be less than 2n, which is a negative number in this case.
Therefore, the result of calling sum(-1) would be -1, which is the value of n that was returned at the end of the function.
Boom, it clones the fake library. cd slack-bot-template, cat main.py and away you go.
{Modify the project to do X and commit}
Etc etc.
The whole thing was supposed to use a fancy PLC, but when I understood the use case, I ended up making it completely using analog using relays, hall sensors, and timers. It was even able to buzz at you if it got stuck. All relay logic. Mostly because I had a big leftover box of PCBs with 8 relays apiece. The clicking sounded super cool.
I checked in a while ago to see if it was still in use. They got rid of it for a fancy PLC system that cost 1000x as much but is connected to the cloud and stuff.
Can we stop normalizing trauma and problems with ones social life? It's not the norm, stop pretending it is.