r/programminghorror • u/w3mk • 43m ago
C++ Some times some crimes go sippin' through the teeth flanges
r/programminghorror • u/w3mk • 43m ago
r/programminghorror • u/babisme • 5d ago
r/programminghorror • u/GoddammitDontShootMe • 6d ago
r/programminghorror • u/HAximand • 12d ago
This was added when we translated the codebase from GDScript to C#, clearly some dead code slipped through. I did a double take when I came across it today
r/programminghorror • u/ABSOLUTE-DEVELOPER • 12d ago
I lost my words for this thing
BigInteger One = 1;
BigInteger ascend(BigInteger x, int n, int p) => ~((x ^ ~-(One << p >> 1)) << n);
BigInteger dscend(BigInteger x, int n, int p) => ~((x | ~~(One << p >> 1)) << n);
nfs = new(nfs.Where(kvp2 => kvp2.Item2["deleted"] == 0).OrderBy(kvp2 =>
ascend(kvp2.Item2["important"], 34, 2)
& ascend(kvp2.Item2["read"], 32, 2)
& dscend(kvp2.Item2["time"], 0, 32))
.Select(kvp2 => new TypesElement<string, StringDictionary<int>, NestedFolderRuntime>(kvp2.Item1, kvp2.Item2, kvp2.Item3)).ToList()); BigInteger One = 1;
BigInteger ascend(BigInteger x, int n, int p) => ~((x ^ ~-(One << p >> 1)) << n);
BigInteger dscend(BigInteger x, int n, int p) => ~((x | ~~(One << p >> 1)) << n);
nfs = new(nfs.Where(kvp2 => kvp2.Item2["deleted"] == 0).OrderBy(kvp2 =>
ascend(kvp2.Item2["important"], 34, 2)
& ascend(kvp2.Item2["read"], 32, 2)
& dscend(kvp2.Item2["time"], 0, 32))
.Select(kvp2 => new TypesElement<string, StringDictionary<int>, NestedFolderRuntime>(kvp2.Item1, kvp2.Item2, kvp2.Item3)).ToList());r/programminghorror • u/IanisVasilev • 13d ago
Hello,
This subreddit has had an identity crisis for some time. Sharing naturally occurring outrageous code was the primary purpose, however many posts feature code that is weird on purpose (which would belong in other subreddits like r/ShittyProgramming in olden times).
I remember an is_even "hackathon" we had in r/ShittyProgramming a few years ago. Since that subreddit is not doing well, I decided to try to reignite the spark here. I hope the moderators and regulars don't mind some creative malpractice.
Anyhow, here is my entry:
def chi_squared_is_even_test(n: int, sample_size: int = 300, p_threshold: float = 0.1) -> bool:
"""Determine if an integer `n` is even by using a χ² test on a random sample determined by `n`.
1. We generate a normally distributed sample.
2. We raise it to (1 + (−1)ⁿ), so the transformed sample should follow a χ² distribution if `n` is even and be constant otherwise.
3. We use a χ² test on the result.
"""
samples = sp.stats.norm.rvs(size=sample_size)
power = 1 + (-1) ** n
transformed = samples ** power
return sp.stats.chisquare(transformed).pvalue < p_thresholdI also have some older bad is_even implementations in this notebook.
r/programminghorror • u/Lines25 • 11d ago
r/programminghorror • u/BruhMamad • 16d ago
r/programminghorror • u/nvqanh9 • 16d ago
The amount of nesting is insane for something relatively simple
Edit: This subreddit has the "No Student Code" rule. Well my code is technically student code but I wrote it myself and I thought it would be fun to roast my own code so I guess it should be fine?
r/programminghorror • u/DroneCyn • 20d ago
this thing is cursed...
it is valid syntax (many things are hidden outside of the screenshot!)
r/programminghorror • u/Internal_Ear_4683 • 18d ago
r/programminghorror • u/Fmerch_74586 • 20d ago
Sometimes I think about saving the world
r/programminghorror
•
u/KeyIllustrious587
•
28d ago
r/programminghorror • u/MEGATH0XICC • 27d ago
r/programminghorror • u/S4N7R0 • 28d ago