using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TELTest {
    internal class Utilities {
        const string LETTER_ORDER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const string ALPHANUMERIC = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890";
        public static Random SharedRandom { get; } = new Random();
        public static string RandomString(int length = 7) {
            StringBuilder sb = new StringBuilder(length);
            for (int i = 0; i < length; i++)
                sb.Append(ALPHANUMERIC[SharedRandom.Next(0, ALPHANUMERIC.Length)]);
            return sb.ToString();
        }
        public static string NumberToLetter(int num) {
            if (num < 26) return LETTER_ORDER[num] + "";
            else {
                int remain = num;
                string res = string.Empty;
                while (remain > 0) {
                    int let = remain % 26;
                    res = LETTER_ORDER[let] + res;
                    remain -= let;
                }
                return res;
            }
        }
        public static string OdmianaPL(int number, string str = "Punkt") {
            return str + (
                            number == 0 ? "ow" :
                            number == 1 ? "" :
                            number >= 2 && number < 5 ? "y" :
                            "ow"
                        );
        }
    }
}
