|
honey the codewitch wrote: Except I need to subtract instances. For example, when I have pair (A,B) and pair (B,A), I should only accept one.
You're looking for combinations not permutations. I really like this site for basic math stuff. They do a good job of making things approachable without getting too into the weeds.
TL;DR: You're looking for something like n!/(r!(n - r)!) where n is the number of things to choose from and r is how many you choose, where there are no repetitions and order doesn't matter.
|
|
|
|
|
Thanks actually. I just had someone on reddit clear it up for me. I'm crap at math/maths
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: I'm crap at math/maths
Given your knowledge of other areas I have no doubt you could be good if you wanted to Basic combinatorics is pretty straightforward compared to other stuff; the equations just look menacing.
|
|
|
|
|
Unfortunately, due to the size of the numbers w/ factorials it's not feasible for me to use that solution. I'll have to just allocate memory as I go.
Edit: NVM it can be reduced to eliminate the factorials.
Real programmers use butterflies
modified 17-Jun-21 2:05am.
|
|
|
|
|
It's kind of funny how my mind works. I'm great at some things, like I can think in several levels of abstraction at once, which helps immensely with coding. And simple arithmetic like pointer math I'm good at, as well as sets (usually though I still get tripped up sometimes) and (related) lambda calculus.
However, go to geometry or anything non-trivial in algebra and you lose me. Plus there are gaping holes in my knowledge due to my lack of schooling. I didn't even know trig was based around triangles until my 20s.
Real programmers use butterflies
|
|
|
|
|
For me, the trick to making math click was realizing the tools themselves are actually pretty simple. It's just specific examples/problems that make them look complex.
Like an integral in its basic form is just the summation of a bunch of rectangular area calculations. So integral_{a}^{b} (2x * 1dx) just means "from a to b, add up all the rectangles with a height of 2x units and a width of 1 unit." The "dx" is just there to let you know what the independent variable is. What you're integrating "with respect to." Line and surface integrals are just taking this same idea, and using geometry to figure out what the "1" should be since we're not doing the integral with respect to the x-axis anymore.
Not trying to pressure you into learning more math, I just think schools do a generally poor job at really teaching the basics. I mostly just memorized how to solve problems for a long time because that's what schools teach, but it wasn't until the why of the "how" clicked that I actually started enjoying math.
|
|
|
|
|
I have to learn the "why"s first or I don't retain anything. My associative memory is great, so if I understand how something works I can remember it, but the rest of my memory is pretty terrible. I wish I could learn the other ways too.
Real programmers use butterflies
|
|
|
|
|
I can help you with math/maths.
math/maths = 1/s
|
|
|
|
|
One of Neil deGrasse Tyson's quotes comes to mind here. You know? The one that ends with "illiterate dolt"..
Obviously doesn't apply to ya, but the reminder has left me laughing and the cat looking at me with a "wtf did you wake me up for?" look. Thanks
|
|
|
|
|
Quote: But it's weird to check it. It is simple to check it: you may choose the first color from the N ones, then you may choose the second color from the (N-1) remaining ones. So, I would go for the N(N-1) 'proposal'.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
I wasn't being very clear. I can't use a brute force method of iteration to check it because I actually want to use the resulting formula to check *that* against, if that makes sense.
Real programmers use butterflies
|
|
|
|
|
Brute force?!
So the argument in favour of N(N-1) does not convince you?
[update]
It definitely did not convince Caslen
[/update]
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
modified 17-Jun-21 7:20am.
|
|
|
|
|
I could be wrong but... shouldn't it be N(N-1)/2 to get the unique combinations? (ie discarding one of AB or BA combinations as required in the OP)
|
|
|
|
|
In fact, you are right and I was wrong
It is
C(N,k) = N! / ((N-k)! k! )
with k=2 .
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Even the best slip up sometimes
It also depends on whether you count the AA, BB combinations, I think not in this case, but if so then it would simply be N+N(N-1)/2.
Either way your are still correct in that no factorials have to be calculated!
|
|
|
|
|
You may find this useful: Permutations, Combinations, and Variations using C# Generics[^]
I use his code in a couple of projects, and the explanations are pretty good.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Ah thanks
Real programmers use butterflies
|
|
|
|
|
|
I know someone out there would buy this.
The password keyboard[^]
The Password Keyboard™️ Enter your password in record time with complete accuracy. We all know the feeling of messing up a password and starting over. With our super compact keyboard, simply type your password and only your password. Choose an ultra secure 8 character password and start tapping down the line. The integrated LEDs will alert you when you somehow still screw it up.
[Edit] Fixed link.
"When you are dead, you won't even know that you are dead. It's a pain only felt by others; same thing when you are stupid."
Ignorant - An individual without knowledge, but is willing to learn.
Stupid - An individual without knowledge and is incapable of learning.
Idiot - An individual without knowledge and allows social media to do the thinking for them.
modified 19-Nov-21 21:01pm.
|
|
|
|
|
I know someone who would throw that across the room every time "it screwed up" her password ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi All,
Looking at the Daily News Win 11 has leaked (?), Sorry but 'Huh? ' Win 10 was the last Windows released constant updates that you may or may not want, your PC being controlled from Redmond... I am amazed it took this long, Win 10 is not too bad (it does have the moments but mostly is well behaved) I'm guessing the connect via web to the mothership is causing the problems, At least it is not as dependant as a Chrome book. But...Come on... who drank the cool aid of the last version of Windows (hardware changes too much to release one OS wipe your hands and say 'That Done')
|
|
|
|
|
Meh. I like how Apple does it. I just get free updates.
|
|
|
|
|
Christian Graus wrote: Meh. I like how Apple does it. I just get free updates.
Provided you keep buying new hardware. I haven't been able to upgrade the OS on my old MacBook Pro in years. In that sense, I'd rather stick with the Windows model.
|
|
|
|
|
I have a super old iMac. One assumes you stop getting offers when it will kill the mac
|
|
|
|
|
...which is totally at Apple's discretion. They regularly leave their own users behind on a whim. "Buy new hardware" is always their solution.
I can still install the latest version of Windows on systems that are way too old to be appropriate for it. It shouldn't be done, but the decision is mine.
|
|
|
|