Activation Keys
Здравейте, изкарвам 60/100, ако може малко помощ.
using System;
using System.Linq;
using System.Collections.Generic;
namespace Activation_Keys
{
class Program
{
static void Main(string[] args)
{
List<string> keys = Console.ReadLine().Split("&").ToList();
for (int i = 0; i < keys.Count; i++)
{
if (keys[i].Length == 16)
{
string token = "";
string word = keys[i];
for (int j = 0; j < word.Length; j++)
{
if (j % 4 == 0 && j != 0)
{
if (char.IsDigit(word[j]))
{
int number = 9 - int.Parse(word[j].ToString());
token += "-" + number;
}
else
{
token += "-" + word[j];
}
}
else
{
if (char.IsDigit(word[j]))
{
int number = 9 - int.Parse(word[j].ToString());
token += number;
}
else
{
token += word[j];
}
}
}
keys[i] = token.ToUpper();
}
else if (keys[i].Length == 25)
{
string token = "";
string word = keys[i];
for (int j = 0; j < word.Length; j++)
{
if(j % 5 == 0 && j != 0)
{
if (char.IsDigit(word[j]))
{
int number = 9 - int.Parse(word[j].ToString());
token += "-" + number;
}
else
{
token += "-" + word[j];
}
}
else
{
if (char.IsDigit(word[j]))
{
int number = 9 - int.Parse(word[j].ToString());
token += number;
}
else
{
token += word[j];
}
}
}
keys[i] = token.ToUpper();
}
else
{
keys.Remove(keys[i]);
i--;
}
}
Console.WriteLine(string.Join(", ", keys));
}
}
}
You will receive one line with the keys of the games, divided by "&". You will have to see if the keys are valid. A valid key contains only numbers, letters and is 16 or 25 symbols long.
In order to fix the keys, you first have to put dashes ('-') in them. If the key is 16 symbols long, you should divide it into four groups of four symbols. If the key is 25 symbols long, you have to divide it in five groups of five symbols. Then you have to make all the letters in the key uppercase. The last thing you have to do is to take every digit from the key, subtract it from nine (9), and replace it with the new digit you have.
In the end you have to print all the keys, joined by ", ".
Input
One line with all the keys, divided by "&".
Output
One line with all the valid keys, joined by ", ".
Examples
Input |
Output |
Comment |
t1kjZU764zIME6Dl9ryD0g1U8&-P4*(`Q>:x8\yE1{({X/Hoq!gR.&rg93bXgkmILW188m&KroGf1prUdxdA4ln&U3WH9kXPY0SncCfs |
T8KJZ-U235Z-IME3D-L0RYD-9G8U1, RG06-BXGK-MILW-811M, KROG-F8PR-UDXD-A5LN, U6WH-0KXP-Y9SN-CCFS |
First you find the dividers '&' and then you take all the valid inputs (colored in yellow) |
xPt8VYhUDalilWLvb6uMSGEEf&KWQ{R.@/HZCbbV++1o]V+oG@@fF^93&y6fT5EGFgZHqlFiS |
XPT1V-YHUDA-LILWL-VB3UM-SGEEF, Y3FT-4EGF-GZHQ-LFIS |
|
Много ти, благодаря !