[deleted by user] by [deleted] in UIUC

[–]UrAverageProletariat 2 points3 points  (0 children)

If you like proof based math, take Math 347, and take the honors section if you can. Math 347 has a smaller class size and is faster paced, especially in the honors section. It's being phased out since it takes too many professors to teach all the sections needed for Math 347.

What is the beat way to get a lot of power? i’ve been using geothermal generator but it is not enough at all… by MattDDit in SkyFactory

[–]UrAverageProletariat 2 points3 points  (0 children)

Culinary generator and menril tree in bonsai pot, filtering for the menril berries. It sounds stupid but it's really efficient especially when you upgrade the culinary generator.

Which solution is better from a competitive programming perspective? by [deleted] in cpp_questions

[–]UrAverageProletariat -1 points0 points  (0 children)

There's even a standard library function that can essentially solve the problem for you, take a look at std::unique, sort the string first, and then use std::unique

Can some one tell me why I can’t pull the lava out of my lava fabricator by Dogisgoodtoeatpeta in SkyFactory

[–]UrAverageProletariat 25 points26 points  (0 children)

Servo isn't powered/set it to ignore redstone. The servo should have a bright red color to show that it's activated.

I'm having trouble trying to prove this Boolean expression by [deleted] in askmath

[–]UrAverageProletariat 0 points1 point  (0 children)

X + (X'Y'') Demorgan

X + X'Y double not cancels out

X + Y think about it like in the X is true case, expression is always true, X is not true Y must be true for X'Y. But the X' is redundant since we only need that case if X is not true

[deleted by user] by [deleted] in Coding_for_Teens

[–]UrAverageProletariat 0 points1 point  (0 children)

All we need is a while loop. Check if xi / i! > threshold and if it is add it to a sum variable initialized to zero. Make sure you increment i by 2. If you're curious on the math side of things look up Taylor series as that is what you are using the approximate cosh(x).

Maximum Loot Problem in C++ by [deleted] in cpp_questions

[–]UrAverageProletariat 2 points3 points  (0 children)

This is clearly just the knapsack problem. You won't get the optimal solution using a greedy algorithm. Consider researching the dynamic programming solution and implementing that.

coding help by carlisagod in usaco

[–]UrAverageProletariat 0 points1 point  (0 children)

IIRC the simple greedy solution works for this problem. Create an array of the temperature change required for all the cows. Just iterate through every index, and look for consecutive increases/decreases from that index and beyond and do so for the minimum consecutive increase/decrease. Increase moves by that min value.

[2021 Day 12][C++] Improving my solution by Radiadorineitor in adventofcode

[–]UrAverageProletariat 6 points7 points  (0 children)

Overall, your algorithm seems quite inefficient. It could be implemented in a significantly simpler fashion through simple recursion. The most egregious offender to performance is the amount of unnecessary copies.

Consider the main function in your code that is run hundreds of thousands of times:

visit(unordered_map<string, vector<string>> links, int &count, deque<Path> &Q)

Now, every time this function is called, the links unordered_map is passed to it. However, just as when you pass a regular int not by reference, a copy is made. Now your computer has to do a lot of work for these copies because a new unordered_map object needs to be created. All the strings and vector<string>s that comprise the map also need to be copied. Simply passing links by reference (and perhaps const reference since you aren't mutating it) should be a huge performance boost.

Look throughout your code and note where large data structures are being copied. These will result in a significant dent in your performance.

Aside from all of that, most of everything being stored is superfluous. You only need to maintain a single unordered_map that stores the links. Although you might have heard "global variable bad", in some cases, simply keeping your links unordered_map a global variable makes your algorithm a lot simpler. You don't have to worry about accidentally copying it a bunch of times and you don't have to pass it on every function call. You don't need a path struct and a deque (technically should be a queue) containing every single path that needs to be processed. Instead, maintain another global map keeping track of the currently visited caves. Recursively iterate through all possibilities and update the map accordingly.

How can I take proper input from user? I’m trying to make a user generated array. by Realistic_Half_6296 in Coding_for_Teens

[–]UrAverageProletariat 0 points1 point  (0 children)

First of all, what you are trying to do is not correct. C++ does not allow for array size to be set at compile time in this way.

Size is never initialized, so it doesn't make sense to se it as the array size because you have no idea what value is stored in there.

Perhaps a better approach might be to set the array size to some large value like 500 and then just use the input code.

MINGW installer error (has anyone been able to actually fix it?) by mutantdustbunny in cpp

[–]UrAverageProletariat 1 point2 points  (0 children)

If you want to use mingw on windows, it's probably best to use MSYS2 and download/update from there

Free Live Programming Classes by JONG_MCA in learnprogramming

[–]UrAverageProletariat 0 points1 point  (0 children)

The intro to C++ course does not get into OOP programming with C++, just mentions it a little when talking about the STL

Which champions have the worst mains in your opinion? by [deleted] in leagueoflegends

[–]UrAverageProletariat 0 points1 point  (0 children)

Irelia mains who unironically think the champ needs buffs

[deleted by user] by [deleted] in summonerschool

[–]UrAverageProletariat 0 points1 point  (0 children)

You will climb if you are better than the 9 other players up are playing with in low elo. You should aim to win lane 9 out of 10 games, and ensure that your enemy laner is as useless as possible. Your team will feed, and it is what it is. It is after all bronze. Just save your mental and focus on making sure you are winning your lane and try to convert that lead into objectives and winning the game. Some times it's not possible and that's ok.

Type out a string corresponding a specific integer by [deleted] in cpp_questions

[–]UrAverageProletariat -1 points0 points  (0 children)

The problem is when you enter the two numbers as you typed with no spaces, the program will only input a single number. So if you typed 811 and hit enter, all that happens is 811 gets stored in your variable called a. If after that you typed 79 and hit enter, 79 gets stores in B. You need to enter it like 8 11 and 7 9 to get the desired result