2022, UTM, add tests + 2 solutions

This commit is contained in:
2022-06-16 21:18:18 +03:00
parent 65b15a011b
commit 5e7875aa33
82 changed files with 42357 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
#include <fstream>
#include <iostream>
using namespace std;
ifstream input_stream;
ofstream output_stream;
char numToChar(int num) {
char letter;
switch (num) {
case 15:
letter = 'F';
break;
case 14:
letter = 'E';
break;
case 13:
letter = 'D';
break;
case 12:
letter = 'C';
break;
case 11:
letter = 'B';
break;
case 10:
letter = 'A';
break;
default:
letter = '0' + num;
}
return letter;
}
string intToHex(int num) {
string res = "";
res += numToChar(num / 16);
res += numToChar(num % 16);
return res;
}
int main() {
input_stream.open("tests/input.7");
int rgb[3];
for (int i = 0; i < 3; i++) {
int tmp;
input_stream >> tmp;
if (tmp > 255) {
tmp = 255;
} else if (tmp < 0) {
tmp = 0;
}
rgb[i] = tmp;
}
cout << intToHex(rgb[0]);
cout << intToHex(rgb[1]);
cout << intToHex(rgb[2]) << endl;
return 0;
}

View File

@@ -0,0 +1 @@
255 255 255

View File

@@ -0,0 +1 @@
255 255 318

View File

@@ -0,0 +1 @@
76 20 211

View File

@@ -0,0 +1 @@
148 0 211

View File

@@ -0,0 +1 @@
0 0 0

View File

@@ -0,0 +1 @@
242 42 1

View File

@@ -0,0 +1 @@
-200 256 -1

View File

@@ -0,0 +1 @@
16 200 187

View File

@@ -0,0 +1 @@
13 33 26

View File

@@ -0,0 +1 @@
1000 899 254

View File

@@ -0,0 +1 @@
FFFFFF

View File

@@ -0,0 +1 @@
FFFFFF

View File

@@ -0,0 +1 @@
4C14D3

View File

@@ -0,0 +1 @@
9400D3

View File

@@ -0,0 +1 @@
000000

View File

@@ -0,0 +1 @@
F22A01

View File

@@ -0,0 +1 @@
00FF00

View File

@@ -0,0 +1 @@
10C8BB

View File

@@ -0,0 +1 @@
0D211A

View File

@@ -0,0 +1 @@
FFFFFE