Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string Encode(string input)
- {
- string result = "";
- int counter = 0;
- for(int i=0; i<input.Length; i++)
- {
- if (!result.Contains(input[i]))
- {
- for (int j = 0; j < input.Length; j++)
- {
- if (input[j] == input[i])
- {
- counter++;
- }
- }
- result += counter.ToString() + input[i];
- counter = 0;
- }
- }
- return result;
- }
- public static string Decode(string input)
- {
- int counter = 0;
- string result = "";
- for(int i=0; i<input.Length; i++)
- {
- counter++;
- if (Char.IsNumber(input[i])){
- int b = (int)Char.GetNumericValue((input[i]));
- for (int j=0; j<b; j++)
- {
- result += input[i + 1];
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement