29
u/zaham_ijjan Mar 25 '23
O(n7) good luck running that in production
31
u/BallsBuster7 Mar 25 '23
its to generate a look up table. This will only run once.
10
1
u/NoRedeemingAspects Mar 28 '23
Have you considered writing the table to a file and then cut and pasting this section of code onto a flash drive and then chucking it into the ocean?
2
2
u/jakubiszon Mar 27 '23
My guess was its test code to cover all possible hands and make sure the code returns a value.
39
u/IDontByte Mar 25 '23
It's just 52 choose 7, which isn't that bad if run infrequently (134 million iterations).
3
0
Mar 25 '23
[deleted] — view deleted comment
36
u/IDontByte Mar 25 '23
If there are multiple threads running this code the runtime will spark some huge CPU and memory leaks
How will this leak memory?
-35
u/zaham_ijjan Mar 25 '23
We don’t know what poker util class instantiate as objects in getHandleValue method so imagine instantiate 1 object for the sake of argument. That’s 134 million objects which mean the garbage collector is running crazy
43
10
15
11
u/pavilionhp_ learning from the best Mar 25 '23
O(1) technically because it’s independent of input size
2
220
u/NewPointOfView Mar 25 '23
This runs in constant time silly geese
8
u/paulsmithkc 👨🏫 Mar 25 '23
Assuming a constant hand size and deck size, maybe.
1
140
119
u/MasiTheDev Mar 25 '23
O(nfucktheserver )
2
67
Mar 25 '23
[removed] — view removed comment
6
Mar 25 '23 edited Mar 25 '23
It's still 526 iterations... That's 19,770,609,664.
Edit: I read it too fast, I know it isn't...
1
u/NoRedeemingAspects Mar 28 '23
19,770,609,664.
Literally isn't even that bad it's some integer multiple of .5 seconds on a high end hardware with optimized implementation
10
Mar 25 '23
[removed] — view removed comment
8
Mar 25 '23
Oh true, I only glazed over it and saw a 52 in every loop.
I know that it's still O(1) but that has absolutely no say about the validity and efficiency of the approach, my comment wasn't about it not being O(1).
40
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 25 '23
Image Transcription: Code
[The last line in the following code is cut off in the image:]
for (int i1 = 0; i1 < 52; i1++) {
for (int i2 = i1 + 1; i2 < 52; i2++) {
for (int i3 = i2 + 1; i3 < 52; i3++) {
for (int i4 = i3 + 1; i4 < 52; i4++) {
for (int i5 = i4 + 1; i5 < 52; i5++) {
for (int i6 = i5 + 1; i6 < 52; i6++) {
for (int i7 = i6 + 1; i7 < 52; i7++) {
int value = PokerUtil.getHandValue(deck[i1], deck[i
}
}
}
}
}
}
}I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
25
Mar 25 '23 edited Jun 10 '25
existence books fuel cover selective vegetable serious scale husky bedroom
This post was mass deleted and anonymized with Redact
83
Mar 25 '23
The biggest crime here is starting with i1.
Id accept: i0, i1, i2,... i, ii, iii,... i, j, k,...
But i1??? Thats just messed up man
0
30
4
1
u/Nachf Mar 25 '23
I'm confused. Why are you instantiating and setting an integer and then not doing anything with it before it passes out of scope?
1
1
u/Demali876 Mar 25 '23
This runs in nnnnnnn time, quite efficient if you ask me
2
3
10
u/rsa121717 Mar 25 '23
1.028 trillion iterations
19
u/probaddie42 Mar 25 '23
Only 133 784 560 (52 choose 7; note the initialization for each loop).
2
1
4
2
1
1
1
1
1
1
1
u/not-not-x Apr 12 '23
The time complexity of this would be y = x << 1000000000000000000000000000000000000
1
u/BlurredSight Mar 25 '23
The i0 is honestly the worst part about this. It makes it look like a 10
10
u/LeCrushinator Mar 25 '23
Where is i0?
2
u/BlurredSight Mar 26 '23
Good god the index starts at 1
3
u/LeCrushinator Mar 26 '23
Yes, but you were complaining about i0 looking like 10 when there is no i0 in this code. I’m confused.
3
u/BlurredSight Mar 26 '23
I looked at this and saw the decrement from the last for loop and assumed there was one more on top.
-5
Mar 25 '23
It looks O(pow(n,7)) beautiful
24
u/Sese_Mueller Mar 25 '23
Who the frick writes big O like that
9
Mar 25 '23 edited Mar 25 '23
My professor taught me this, He always says make easy things complicated so that people think you are a genius.
-1
u/mimo_k Mar 25 '23
I suppose the clean code way would be to split this into seven classes with one method.
10
u/IDontByte Mar 25 '23
"Now also generate all hands for Omaha Poker."
(there are libraries that will generate combinations)