Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- //Your code goes here
- Console.WriteLine("Hello, world!");
- int a, b, c;
- for(int i = 0; i < 50; i++)
- {
- GetLevelFromStars(i, out a, out b, out c);
- }
- }
- static List<int> cumulativeStarsAtLevel = new List<int>{6, 15, 27, 42, 60};
- public static void GetLevelFromStars(int myStars, out int myLevel, out int starsToNextLevel, out int myProgressToNextLevel)
- {
- int lvlIndex = cumulativeStarsAtLevel.BinarySearch(myStars);
- lvlIndex = lvlIndex < 0 ? ~lvlIndex : lvlIndex+1;
- starsToNextLevel = myProgressToNextLevel = 0;
- myLevel = lvlIndex+1;
- int cumulativeStarsToCurrentLevel = lvlIndex > 0 ? cumulativeStarsAtLevel[lvlIndex-1] : 0;
- int cumulativeStarsToNextLevel = lvlIndex < cumulativeStarsAtLevel.Count() ? cumulativeStarsAtLevel[lvlIndex] : myStars;
- starsToNextLevel = cumulativeStarsToNextLevel - myStars;
- myProgressToNextLevel = myStars - cumulativeStarsToCurrentLevel;
- Console.WriteLine(String.Format("@{0},\tlvl{1},\t({2} / {3})", myStars, myLevel, myProgressToNextLevel, myProgressToNextLevel + starsToNextLevel));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement