Skip to content

Commit 5d51e08

Browse files
committed
..
1 parent be257db commit 5d51e08

File tree

35 files changed

+539
-528
lines changed

35 files changed

+539
-528
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Numerics;
3+
using System.Text;
4+
5+
public class ConvertFromBase
6+
{
7+
public static void Main()
8+
{
9+
string[] input = Console.ReadLine().Split();
10+
11+
int @base = int.Parse(input[0]);
12+
BigInteger number = BigInteger.Parse(input[1]);
13+
14+
StringBuilder converted = new StringBuilder();
15+
16+
while (number > 0)
17+
{
18+
BigInteger remainder = number % @base;
19+
converted.Append(remainder);
20+
number /= @base;
21+
}
22+
23+
for (int i = converted.Length - 1; i >= 0; i--)
24+
{
25+
Console.Write(converted[i]);
26+
}
27+
28+
Console.WriteLine();
29+
}
30+
}

09.Strings and Text Processing/Exercises/01.ConvertFromBase/Program.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Numerics;
3+
4+
public class ConvertFronNBase
5+
{
6+
public static void Main()
7+
{
8+
string[] input = Console.ReadLine().Split();
9+
10+
int @base = int.Parse(input[0]);
11+
string number = input[1];
12+
BigInteger sum = 0;
13+
int pow = 0;
14+
15+
for (int i = number.Length - 1; i >= 0; i--)
16+
{
17+
char current = number[i];
18+
int currentNumber = int.Parse(current.ToString());
19+
BigInteger currentSum = currentNumber * BigInteger.Pow(@base, pow);
20+
sum += currentSum;
21+
pow++;
22+
}
23+
24+
Console.WriteLine(sum);
25+
}
26+
}

09.Strings and Text Processing/Exercises/02.ConvertFronNBase/Program.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

09.Strings and Text Processing/Exercises/03.UnicodeCharacters/Program.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
public class UnicodeCharacters
4+
{
5+
public static void Main()
6+
{
7+
char[] input = Console.ReadLine()
8+
.ToCharArray();
9+
10+
for (int i = 0; i < input.Length; i++)
11+
{
12+
Console.Write("\\u{0:x4}", (int)input[i]);
13+
}
14+
15+
Console.WriteLine();
16+
}
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Linq;
3+
4+
public class CharacterMultiplier
5+
{
6+
public static void Main()
7+
{
8+
string[] input = Console.ReadLine()
9+
.Split()
10+
.ToArray();
11+
int sum = 0;
12+
char[] first = input[0].ToCharArray();
13+
char[] second = input[1].ToCharArray();
14+
15+
for (int i = 0; i < Math.Max(first.Length, second.Length); i++)
16+
{
17+
if (first.Length < i + 1)
18+
{
19+
sum += second[i];
20+
}
21+
else if (second.Length < i + 1)
22+
{
23+
sum += first[i];
24+
}
25+
else
26+
{
27+
sum += first[i] * second[i];
28+
}
29+
}
30+
31+
Console.WriteLine(sum);
32+
}
33+
}

09.Strings and Text Processing/Exercises/04.CharacterMultiplier/Program.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

09.Strings and Text Processing/Exercises/05.Magic/05.Magic.csproj

Lines changed: 0 additions & 8 deletions
This file was deleted.

09.Strings and Text Processing/Exercises/05.Magic/Program.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
public class MagicExchangeableWords
5+
{
6+
public static void Main()
7+
{
8+
string input = Console.ReadLine();
9+
string[] token = input.Split();
10+
string first = token[0];
11+
string second = token[1];
12+
string isEqual = CompareStrings(first, second);
13+
14+
Console.WriteLine(isEqual);
15+
}
16+
17+
static string CompareStrings(string firstString, string secondString)
18+
{
19+
var words = new Dictionary<char, char>();
20+
string result = "true";
21+
int minLenght = Math.Min(firstString.Length, secondString.Length);
22+
int maxLenght = Math.Max(firstString.Length, secondString.Length);
23+
string minString = null;
24+
string maxString = null;
25+
26+
if (firstString.Length > secondString.Length)
27+
{
28+
maxString = firstString;
29+
minString = secondString;
30+
}
31+
else if (firstString.Length < secondString.Length)
32+
{
33+
maxString = secondString;
34+
minString = firstString;
35+
}
36+
else
37+
{
38+
minString = firstString;
39+
maxString = secondString;
40+
}
41+
42+
for (int i = 0; i < minLenght; i++)
43+
{
44+
if (!words.ContainsKey(maxString[i]))
45+
{
46+
words[maxString[i]] = minString[i];
47+
}
48+
else if (words[maxString[i]] != minString[i])
49+
{
50+
result = "false";
51+
return result;
52+
}
53+
}
54+
55+
for (int i = minLenght; i < maxLenght; i++)
56+
{
57+
if (!words.ContainsKey(maxString[i]))
58+
{
59+
result = "false";
60+
break;
61+
}
62+
}
63+
64+
return result;
65+
}
66+
}

09.Strings and Text Processing/Exercises/05.MagicExchangeableWords/Program.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)