Advertisement
JeffGrigg

Untitled

Jan 23rd, 2023
2,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.50 KB | None | 0 0
  1.     private static final int TOTAL_NUMBER_OF_DOTS = 10;
  2.  
  3.     // https://twitter.com/NabheetS/status/1616461311139016710
  4.     private static String getPercentageRounds(final double percentage) {
  5.         final var blueCircles = max(min((int) ceil(percentage * TOTAL_NUMBER_OF_DOTS), TOTAL_NUMBER_OF_DOTS), 0);
  6.         final var result = new StringBuilder(10);
  7.         for (int i = 0; i < 10; ++i) {
  8.             result.append(i < blueCircles ? "🔵" : "⚪");
  9.         }
  10.         return result.toString();
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement