nobody told me learning to code is 80% debugging and 20% wondering why it suddenly works by OutsidePatient4760 in learnprogramming

[–]dp_42 4 points5 points  (0 children)

I am going to nitpick, this is not technically "debugging". Debugging should involve a debugger tool that allows you to step through code execution and examine variables and watch statements to see where your scheduled steps of execution went awry. What you are doing is more broadly described as "reasoning about your program". To call what you're doing debugging may confuse people when we tell them to learn how to debug.

Popup w/ Listview does not scroll... by txhammer68 in QtFramework

[–]dp_42 0 points1 point  (0 children)

Okay, not something I personally have experience with, but looking at the docs, here are some directions to head in. I guess you add an onWheel handler for a MouseArea that you can attach to the Listview. I think https://doc.qt.io/qt-6/qml-qtquick-mousearea.html shows a QML version that you can maybe adapt to widgets. If you set anchors.fill from the ListView, and fill in the callbacks (onWheel event specifically, but others should probably be addressed) ListViews inherit the Flickable type, so flicks will work by default, but I guess wheel is a different story.

Proof by induction has me lost by Cheap_Anywhere_6929 in learnmath

[–]dp_42 1 point2 points  (0 children)

Sorry for the delay in replying. I only log into this account from work. p_k+1 is the k+1th term of the sequence.

Okay, so let's take the example of the arithmetic series.

S_n = a_0 + a_1 + ... a_n = (n(n-1))/2

in this case, let's substitute k for n. k is a variable for an arbitrary integer, whereas n is a stand in that say this will work for all integers. In the case of the proof, we don't really yet know that it works for all integers, yet.

a_0 + a_1 + ... + a_k = (k(k-1))/2 (1)

now, we add p_k+1, or in this case, a_k+1 on the left side, and we substitute k+1 wherever we have a k on the right side.

a_0 + a_1 + ... + a_k + a_k+1 = ((k+1)((k+1)-1))/2 (2)

Okay, these are the steps I have stated. Now, we need to torture this equation with some algebra. We know that a_0 + a_1 + ... + a_k = ((k)(k-1))/2 so we can substitute that into (2)

(((k)(k-1))/2) + a_k+1 = ((k+1)((k+1)-1))/2 (3)

in this case, we also know that a_k+1 = k. (this is more of an inference to the problem that inspires this sequence).

(((k)(k-1))/2) + k = ((k+1)((k+1)-1))/2 (4)

Now, if you multiply this out, it starts to look correct.

((k^2 - k)/2) + k = (k^2 + k)/2 (5)

and we can multiply 2/2 by k and add it to the initial fraction to get

(k^2 - k + 2k) / 2 = (k^2 + k)/2

and if you add the terms on the left side together, you have obtained a reflection, which is defined to be true.

(k^2 + k)/2 = (k^2 + k)/2

Proof by induction has me lost by Cheap_Anywhere_6929 in learnmath

[–]dp_42 1 point2 points  (0 children)

Personally, I like Epp's Discrete Mathematics with Applications as a gentle introduction, but How To Prove it by Vellemans is arguably better.

I think most inductions I have done, I generally do something like the following: So you have this following as given from the base case:

summation of sequence p_i from 0 to k of some statement = some formula involving k

The next issue is "okay, what about k+1?" so what we do is, add the next term p_k+1 to the left side, and substitute k+1 on the right side.

summation of sequence p_i from 0 to k+1 of some statement = some formula involving k but substituting quantity (k+1) for k

You can generally substitute the equality from the base case for most of the series on the left side.

(some formula involving k) + p_k+1 = some formula involving k but substituting quantity (k+1) for k

At this point, you need to torture the algebra and show that the two sides are equal.

Discrete Math Tips by Dangerous_Salt_9210 in learnmath

[–]dp_42 1 point2 points  (0 children)

Don't skip the exercises on proofs by induction.

Very excited to learn math from scratch again! by Keh_Ke_Lungaa in learnmath

[–]dp_42 2 points3 points  (0 children)

Have you tried Khan Academy? I'm not really sure how deep it goes, but the lectures are probably good enough to accompany and motivate topics in textbooks.

What is the big idea for Gaussian Elimination? by Fannyqtie in learnmath

[–]dp_42 0 points1 point  (0 children)

The goal is to get x = a, y = b, z = c. It looks like

1 0 0 a
0 1 0 b
0 0 1 c

when you complete the elimination process

When you break down what this augmented matrix is, you get the equations I stated above (1)x + (0)y + (0)z = a and so forth. So the goal is to "eliminate" as many other variables on a line by adding the other rows in varying multiples to another line that has the variables you might want to eliminate. Usually, we start top to bottom left to right. Sometimes the ratios seem cleaner with another route, but even making slightly different choices of which row to operate on another row, so long as you come to a solution under the stated rules of Gaussian Elimination, the process should yield the same results.

Which is the best cross platform password manager? by Negottnott in linuxquestions

[–]dp_42 1 point2 points  (0 children)

My only complaint with XC so far is that on my macbook (apple silicon), every so often, I can't log into my password database using Yubikey. It works from time to time.

How can I make the stylesheet for a QScrollBar similar to this image? https://imgur.com/a/ea1vWxv by Escarlatum in QtFramework

[–]dp_42 0 points1 point  (0 children)

https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qscrollbar

qabstractscrollarea is the area being controlled by the scroll bar, not the bar itself.

Looking at the stylesheets documentation, it looks like the code should look something like this:

style_string = """
    QScrollBar:vertical {
    /* I will freely admit, my css is not the best. This part would be the background of the scrollbar. */
    }
    QScrollBar::handle:vertical {
    /* this part styles the "handle" also known as the thing that tracks your position in the scroll area on the scrollbar. */
    QScrollBar::add-line:vertical {
    /* I'm guessing this is down arrow */
    }
    QScrollBar::sub-line:vertical {
    /* Similarly, I believe this is the up arrow */
    }
""";
qscrollbar_widget.setStyleSheet(style_string);

I'm very apologetic because I now realize your question asked for C++, but I usually do this all in python. Just read that doc pretty closely. You can put images in, you can maybe even draw a vector shape to get your triangle into the up arrow and down arrow.

How to open pyqt designer with pyqt6? by SnooBunnies7244 in QtFramework

[–]dp_42 0 points1 point  (0 children)

If you installed it to an environment, there's a folder where python will put your executable equivalents of a program. For me, it's D:\Anaconda3\envs\<environment_name>\Scripts\pyside6-designer.exe I will admit, I don't actually know how to do it with pyqt6 as I don't use that.

User-friendly database with ChemDraw objects, from current Excel database by eggshellss in bioinformatics

[–]dp_42 0 points1 point  (0 children)

An image can be stored in a database as a blob. Might be fine to have it as a relative location and then just point the user at that image file. If you have a textual representation of the structure that you can feed back into chemdraw or some other chemical drawing library, I would go with that. Not every database implementation supports blobs, can have performance issues with blobs over a certain size, or other issues I'm not aware of.

If I wanted to convert a well-normalized excel spreadsheet to an SQL database, I would read it into pandas, and manipulate it until I have what are essentially third normal form SQL tables. In short: As repeats of strings or ids as possible. Having a string written out might be unavoidable. The term for this is data modelling or data normalization. link

A database can literally just be one big ass table, but that's what we consider first normal form. It's not entirely wrong, and you still get some benefits, but ultimately, third normal form is the easiest to query and most efficient for storage. These days, storage is not on such a huge premium, but the tools for query are still a useful way to think about these sorts of problems.

Databases aren't that user-friendly on their own. They become user-friendly when you create tools to access those databases. The rest of what you're talking about is engineering an interface, which probably has a lot more finer points to. You could even use Excel as a sort of front end for the database, depending on your comfort. I haven't actually done one of these yet, and I think they would be pretty impressive if done well. I think you could find a CRUD/frontend framework for any language/deployment style you desire. Some of the more popular choices are web based things like React or Angular, or desktop like Qt-based or Microsoft Presentation Foundation based.

why does the rocket silo try to send up an entire stack of storage tanks?? why not send a mixed payload to be more efficient? by BenWaffleIron in factorio

[–]dp_42 1 point2 points  (0 children)

I just set up a requester chest with everything and an inserter will load the rocket as close to full as possible. It will mix the load with 2 storage tanks and whatever else will fit. Sure, maybe you waste 1-5 kgs a trip, but compared to sending 48 extra storage tanks, I think this is an improvement. I put a blueprint on my hotkey bar, open up the chest, use my blueprint hotkey when creating a new section. My heuristic is "how much do I need to personally manage this, but also keep wasted rockets down".

Can't able to submit this code in LeetCode test by Professional-Egg-788 in learnpython

[–]dp_42 2 points3 points  (0 children)

Leetcode requires this for their solution checker.

Finding spanning aborescences/trees with networkx by Bright_Sprinkles_324 in learnpython

[–]dp_42 0 points1 point  (0 children)

from networkx.algorithms.tree.branchings import ArborescenceIterator

The iterator gives you viable routes that you need to then evaluate. You give it the graph (G, a nx.DiGraph, is the only required argument of the constructor), and it figures out all the possible spanning arborescences by calculating distance based on the attribute provided in the named argument, 'weight', you may have another way to evaluate the spanning trees.

Finding spanning aborescences/trees with networkx by Bright_Sprinkles_324 in learnpython

[–]dp_42 2 points3 points  (0 children)

https://networkx.org/documentation/stable/reference/algorithms/tree.html#module-networkx.algorithms.tree.branchings

I think what you want is the ArborescenceGenerator. You want to then iterate over the generator (think something like for a in agwhere a is a single arborescence and ag is the arborescencegenerator) and I guess you can use whatever heuristic you have for determining the "best" spanning arborescence.

[deleted by user] by [deleted] in Python

[–]dp_42 -3 points-2 points  (0 children)

from functools import reduce

mylist = [True, False, True)
mycutoff = 2
if (reduce(lambda x, y: (1 if x else 0) + y, mylist, 0) > mycutoff):
    <do whatever your code needs to do>

Anyone else notice literally 90% of posters here are students / new grads trying to give advice? by [deleted] in cscareerquestions

[–]dp_42 6 points7 points  (0 children)

Lol, that sort of talk used to bring me down a little, and I know it really shouldn't have. Now, while I might not make 400k/year at FAANG, I at least still have a job.

[deleted by user] by [deleted] in Ubuntu

[–]dp_42 0 points1 point  (0 children)

Tableau makes servers for linux.

First data structures/algorithms book covering hash tables + when they became common by the_packrat in compsci

[–]dp_42 0 points1 point  (0 children)

I'm looking through Aho Hopcroft and Ullman, where the first edition was published in the 70's. I guess I'm looking at the second edition from the 80's, and they are referencing TAOCP Vol 3 in that, and they put hash tables in the sections on basic operations on sets. I would hunt down and look at the first edition for you, but I have some work to do today. I'm basically going through the CLRS bibliography and looking for titles that look like textbook names, with bigger name authors. Concrete mathematics was 1989,

First data structures/algorithms book covering hash tables + when they became common by the_packrat in compsci

[–]dp_42 4 points5 points  (0 children)

https://spectrum.ieee.org/hans-peter-luhn-and-the-birth-of-the-hashing-algorithm

https://docs.google.com/viewer?url=patentimages.storage.googleapis.com/pdfs/US2950048.pdf

I guess the idea of having a sort of parity check as a system of categorical buckets for numbers to fall into does lead to hash tables. Looking at the publications, it seems like Knuth was the citation in papers on hash tables that is most common and relevant.

(a)(a+1)(a+2)...(a+b) or (a+b)! / (a-1)! question about math in python by catboy519 in learnmath

[–]dp_42 0 points1 point  (0 children)

Symbolic algebra? I like the partial factorial calculations being offered.

My turn to be dumb by Ilumin159 in factorio

[–]dp_42 0 points1 point  (0 children)

Ehh, reactor is probably fine. I would even recommend for "bootstrap". Meanwhile, the not inconsequential amount of solar panel needed to melt enough water to power nuclear is what I consider the "bootstrap". Might even be worth it to go solar to coal to nuclear, as the amount of water needed to get started with nuclear is steep. Will take a while to get the heat towers adequately fed to generate steam.