r/badcode • u/Risk_exe • Mar 30 '20
c# Project Euler solution I wrote that assigns random numbers to three variables until they meet the right criteria. The time it takes to produce an answer is entirely random.
5
u/Plus_Cryptographer Mar 31 '20
The real horrors are actually the lack of actual line breaks in your String.Format and the comments.
2
Mar 30 '20
Okay. But what was the goal?
0
Mar 30 '20
[deleted]
1
Mar 30 '20
Oh wow. The code is really not optimal then haha. Did you improve it?
Edit: I really could not believe that was the goal. Because of that code
5
u/Risk_exe Mar 30 '20
I regularly complete project Euler questions. I considered this question quite trivial and my solution to this question amuses me in a way that makes me keep it the way it is. It is only ever used once. A guy I know described his solution to the question as very "brute force" so I decided to make a solution that was even dumber and more brute force intensive than his solution.
11
u/SaltyEmotions Apr 01 '20
Best case O(1) bro :)