r/firstweekcoderhumour
•
u/Outrageous_Permit154
🥸Imposter Syndrome 😎
•
May 03 '26
•
1
[🎟️BINGO]”this.codifyMylife()” Correct logic, wrong situation
47
20
10
u/Anastazja_Nya May 03 '26
btw the first quess being 40 would be more efficient(atleast in 2018 it was when i learned it)
1
5
4
1
1
u/Orwenn May 04 '26
Binary search is not really something you learn on the first week.
That's how I justify laughing at this.
1
u/One_Basis1443 May 04 '26
logic is wrong unless girl answers greater/ lower to every guess. only bruteforce makes sense for this situation
1
1
u/HiItsMe01 May 05 '26
obviously you need to use the unbounded binary search. dumbass. eg 0 -> 1 -> 2 -> 4 -> 8 -> 16 -> 32 -> 24 -> 20
1
1
87
May 03 '26
[removed] — view removed comment
22
u/Aln76467 May 03 '26
not nessasarily. afaik integer division rounds down, so 101 would still have a midpoint of 50.
9
u/1984balls May 03 '26
Everyone loves to 100 and then magically dies wdym
2
u/Gwarks May 04 '26
Age is stored in Packed Decimal when someone becomes 100 age overflows and he is 0 again.
2
2
u/AliceCode May 04 '26
Binary search doesn't need to be "linear", you can start your search close to where you estimate it to land, and then on one side you would have a larger range to split than the other side. So the first split could be 50, then the next split up could be 150, then 60, 90, and so on. You account for lower values being more likely than higher values and program in a wide margin of error.
1
1
May 04 '26
[removed] — view removed comment
2
u/FlySafeLoL May 04 '26
The oldest lady that is OK to be called girl in third person is barely much older than 50, but heuristics tend to fail when you least expect them to. So a buffer of x2 should cover all the reasonable risks.
Moreover, appearance of a clearly elderly person is hard to mistake in person, so when it's the case - I'd disregard the range of 0-35 entirely and add those values to the end of the new range, making the space of 100 go from 35-135.
With such optimization, to my mind a search should either start from 50 or 85 - based on the value of the predicate
IsLikelyAnElderly.1
u/TimGreller May 06 '26
This only holds if every age between 0 and 122 would have the same probability. But it's much less likely that she's > 100 then that she's between 60 and 80 for example.
39
u/Cephell May 03 '26
No I'm sorry that one is really good.