Binary Search in O(log n)
The dutch government was forced to release the source code of their DigiD digital authentication iOS app. It is written in C#. github.com/MinBZK/woo-bes... Ahh I see the problem is that there's are too many if statements. Here's a solution implementing binary search in O(log n) private static string GetPercentageAround(double percentage) { if (percentage == 0) { return "⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕"; } if (percentage > 0 && percentage < 0.1) { return "🔵⭕⭕⭕⭕⭕⭕⭕⭕⭕"; } if (percentage >= 0.1 && percentage < 0.2) { return "🔵🔵⭕⭕⭕⭕⭕⭕⭕⭕"; } if (percentage >= 0.2 && percentage < 0.3) { return "🔵🔵🔵⭕⭕⭕⭕⭕⭕⭕"; } if (percentage >= 0.3 && percentage < 0.4) { return "🔵🔵🔵🔵⭕⭕⭕⭕⭕⭕"; } if (percentage >= 0.4 && percentage < 0.5) { return "🔵🔵🔵🔵🔵⭕⭕⭕⭕⭕"; } if (percentage >= 0.5 && percentage < 0.6) { return "🔵🔵🔵🔵🔵🔵⭕⭕⭕⭕"; } if (percentage >= 0.6 && percentage < 0.7) { return "🔵🔵🔵🔵🔵🔵🔵⭕⭕⭕"; } if (percentage >= 0.7 && percentage < 0.8) { return "🔵🔵🔵🔵🔵🔵🔵🔵⭕⭕"; } if (percentage >= 0.8 && percentage < 0.9) { return "🔵🔵🔵🔵🔵🔵🔵🔵🔵⭕"; } return "🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵"; } private static string GetPercentageAround(double percentage) { if (percentage == 0) { return "⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕"; } if (percentage <= 0.1) { return "🔵⭕⭕⭕⭕⭕⭕⭕⭕⭕"; } if (percentage <= 0.3) { return "🔵🔵🔵⭕⭕⭕⭕⭕⭕⭕"; } if (percentage <= 0.5) { return "🔵🔵🔵🔵🔵⭕⭕⭕⭕⭕"; } if (percentage <= 0.7) { return "🔵🔵🔵🔵🔵🔵🔵⭕⭕⭕"; } if (percentage <= 0.8) { return "🔵🔵🔵🔵🔵🔵🔵🔵⭕⭕"; } return "🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵"; }
A screenshot shows a social media post about the Dutch government being forced to release the source code for its DigiD iOS authentication app, which is written in C#. The code uses a long chain of if statements to convert a percentage into blue and white circles. A reply jokes that the problem is too many if statements and presents a supposedly improved binary-search solution, making fun of inefficient government code and overengineering a simple task. EN: A screenshot shows a social media post about the Dutch government being forced to release the source code for its DigiD iOS authentication app, which is written in C#. The code uses a long chain of if statements to convert a percentage into blue and white circles. A reply jokes that the problem is too many if statements and presents a supposedly improved binary-search solution, making fun of inefficient government code and overengineering a simple task.
- @gentoomemes / 2020 2023-01-18
- @rzeczyzabawne / 5645 2023-01-18
- @right_wing_dev_squads / 9857 2024-06-18
- Type
- image
- Size
- 258×800 · 55.7 KiB
- Mood
- sarcastic, absurd
- Language
- en
- Added