diff --git a/kattis/.gitignore b/kattis/.gitignore new file mode 100644 index 0000000..2aabc1c --- /dev/null +++ b/kattis/.gitignore @@ -0,0 +1,2 @@ +*.dll/ +vgcore* \ No newline at end of file diff --git a/kattis/.vscode/settings.json b/kattis/.vscode/settings.json new file mode 100644 index 0000000..d160145 --- /dev/null +++ b/kattis/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "stdlib.h": "c" + } +} \ No newline at end of file diff --git a/kattis/.vscode/tasks.json b/kattis/.vscode/tasks.json new file mode 100644 index 0000000..14f0948 --- /dev/null +++ b/kattis/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc build active file", + "command": "/sbin/gcc", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/kattis/README.md b/kattis/README.md new file mode 100644 index 0000000..a602244 --- /dev/null +++ b/kattis/README.md @@ -0,0 +1,2 @@ +# New automatic problem getter +## Deleted 52 problems \ No newline at end of file diff --git a/kattis/kattis.py b/kattis/kattis.py new file mode 100644 index 0000000..20413df --- /dev/null +++ b/kattis/kattis.py @@ -0,0 +1,76 @@ +from autokattis import Kattis +import argparse +from os import system +from requests import get +from bs4 import BeautifulSoup +from datetime import datetime + +def prepare_problem(problem): + system('firefox ' + problem['link']) + name = " " + try: + name = problem['pid'] + except: + name = problem['name'] + + # system('mkdir problems/' + datetime.now.strftime("%d_%m_%y") + "/" name) + + # TODO: Add inputs + r = get(problem['link']) + # tables = soup.find_all('table') + # soup = BeautifulSoup(r.text, 'html.parser') + # for table in tables: + # with open("problems/" + problem['pid'] + "/"+ str(count) + ".in", "w") as f: + # f.write(table[0].text) + # print(table.text) + +def find_user(ranklist:dict) -> int: + for i in ranklist: + if i['username'] == 'confestim': + return i['rank'] + return -1 + +parser = argparse.ArgumentParser(description='Kattis submission tool') +parser.add_argument('-p', metavar='problem', type=str, help='problem name') +parser.add_argument('-pl', action='store_true', default=False, help='plot problem') +parser.add_argument('-s', action='store_true', default=False, help='suggest problem') +parser.add_argument('-r', action='store_true', default=False, help='Show ranklist') +parser.add_argument('-u', action="store_true", default=False, help="ShowStarted, but Unsolved") + +args = parser.parse_args() + +kt = Kattis('confestim', 'not my actual password lol', ) +problem = args.p +plot = args.pl +suggest = args.s +unsolved = args.u + +if args.r: + uni = find_user(kt.ranklist(university='University of Groningen')) + country = find_user(kt.ranklist(country='Bulgaria')) + print("🎓:" + str(uni) + ", 🤻 :" + str(country)) +if plot: + print(kt.plot_problems(show_partial=False)) + +if suggest: + for i in kt.suggest(): + prepare_problem(i) + +def stars(problem): + return problem["difficulty"] + +if unsolved: + problems = kt.problems(show_solved=False, show_tried=True) + problems.sort(key=stars) + print(str(len(problems)) + " problems unsolved.") + for problem in problems: + print(f"✱ {problem['name']} {problem['difficulty']}✪") + yn = input("Do you want to open them in browser?(Y/n)") + if (yn == 'n' or yn == 'N'): + pass + else: + for problem in problems: + prepare_problem(problem) + +elif problem: + print(kt.problem(problem)) diff --git a/kattis/problems/01_11_23/filip/main.c b/kattis/problems/01_11_23/filip/main.c new file mode 100644 index 0000000..2fc1aff --- /dev/null +++ b/kattis/problems/01_11_23/filip/main.c @@ -0,0 +1,23 @@ +#include +#include + + +int reverse(int n) { + int reversed = 0; + while (n > 0) { + reversed = reversed * 10 + n % 10; + n /= 10; + } + return reversed; +} + + +int main(int argc, char **argv) { + int a, b; + scanf("%d %d", &a, &b); + a = reverse(a); + b = reverse(b); + + printf("%d\n", a > b ? a : b); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/filip/main.c.orig b/kattis/problems/01_11_23/filip/main.c.orig new file mode 100644 index 0000000..ed2ac75 --- /dev/null +++ b/kattis/problems/01_11_23/filip/main.c.orig @@ -0,0 +1,34 @@ +#include +#include +#include + +int powerOfTen(int a) { + int result = 10; + for (int i=0; i b%10) { + printf("%d", a%10); + } else { + printf("%d", b%10); + } + a /= 10; + b /=10; + } + printf("\n"); + +} + +// FIX: Reverse number + +int main(int argc, char **argv) { + int a, b; + scanf("%d %d", &a, &b); + findLarger(a, b); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/filip/program b/kattis/problems/01_11_23/filip/program new file mode 100755 index 0000000..bfd01e3 Binary files /dev/null and b/kattis/problems/01_11_23/filip/program differ diff --git a/kattis/problems/01_11_23/gcvwr/1.in b/kattis/problems/01_11_23/gcvwr/1.in new file mode 100644 index 0000000..bef7ad8 --- /dev/null +++ b/kattis/problems/01_11_23/gcvwr/1.in @@ -0,0 +1,2 @@ +12000 3000 5 +400 25 200 80 500 \ No newline at end of file diff --git a/kattis/problems/01_11_23/gcvwr/2.in b/kattis/problems/01_11_23/gcvwr/2.in new file mode 100644 index 0000000..3fb9b32 --- /dev/null +++ b/kattis/problems/01_11_23/gcvwr/2.in @@ -0,0 +1,2 @@ +10000 4000 7 +110 10 20 10 5 3 5 diff --git a/kattis/problems/01_11_23/gcvwr/main.c b/kattis/problems/01_11_23/gcvwr/main.c new file mode 100644 index 0000000..53f394e --- /dev/null +++ b/kattis/problems/01_11_23/gcvwr/main.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char **argv) { + int g, t, n; + scanf("%d %d %d", &g, &t, &n); + int sum = 0; + for (int i=0; i +#include + +int main(int argc, char **argv) { + int g, t, n; + scanf("%d %d %d", &g, &t, &n); + int sum = 0; + for (int i=0; i +#include + + +int main(int argc, char **argv) { + + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/1.in b/kattis/problems/01_11_23/keystrokes/1.in new file mode 100644 index 0000000..df0089d --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/1.in @@ -0,0 +1 @@ +iLnLnLeLb \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/2.in b/kattis/problems/01_11_23/keystrokes/2.in new file mode 100644 index 0000000..9c4c473 --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/2.in @@ -0,0 +1 @@ +arnarLLLBBun \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/3.in b/kattis/problems/01_11_23/keystrokes/3.in new file mode 100644 index 0000000..ad366d9 --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/3.in @@ -0,0 +1 @@ +password123 diff --git a/kattis/problems/01_11_23/keystrokes/main.c b/kattis/problems/01_11_23/keystrokes/main.c new file mode 100644 index 0000000..8865f01 --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/main.c @@ -0,0 +1,60 @@ +#include +#include +#include + +#define MAX 1000000 + +int transform(char *src, int len, char *dst) { + // Traverse the string + int i = len; + int j = 0; + while (i > 0) { + // printf("%c\n", src[i]); + // If we encounter a backspace, we need to remove the last character + // from the destination string + if (src[i] == 'B') { + if (j > 0) { + j--; + } + } else if (src[i] == 'L') { + // If we encounter a left button, we have to move back once + if (j > 0) { + j--; + } + } else if (src[i] == 'R') { + // If we encounter a right button, we have to move forward once + if (j < len) { + j++; + } + } + + else { + // Otherwise, we add the character to the destination string + dst[j] = src[i]; + j++; + } + i--; + } + return j; +} + +void printStr(char *s, int len) { + for (int i = 0; i < len; ++i) { + printf("%c", s[i]); + } + printf("\n"); +} + +int main(int argc, char **argv) { + + char s[MAX]; + scanf("%s", s); + int len = strlen(s); + printf("%d\n", len); + char corrected[MAX]; + + int newLen = transform(s, len, corrected); + printf("%d\n", newLen); + printStr(corrected, newLen); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/main.c.orig b/kattis/problems/01_11_23/keystrokes/main.c.orig new file mode 100644 index 0000000..7e63b9d --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/main.c.orig @@ -0,0 +1,58 @@ +#include +#include +#include + +#define MAX 1000000 + +int transform(char *src, int len, char *dst) { + // Traverse the string + int i = 0; + int j = 0; + while (i < len) { + // If we encounter a backspace, we need to remove the last character + // from the destination string + if (src[i] == 'B') { + if (j > 0) { + j--; + } + } else if (src[i] == 'L') { + // If we encounter a left button, we have to move back once + if (j > 0) { + j--; + } + } else if (src[i] == 'R') { + // If we encounter a right button, we have to move forward once + if (j < len) { + j++; + } + } + + else { + // Otherwise, we add the character to the destination string + dst[j] = src[i]; + j++; + } + i++; + } + return j; +} + +void printStr(char *s, int len) { + for (int i = 0; i < len; ++i) { + printf("%c", s[i]); + } + printf("\n"); +} + +int main(int argc, char **argv) { + + char s[MAX]; + scanf("%s", s); + int len = strlen(s); + char corrected[MAX]; + + int newLen = transform(s, len, corrected); + printf("%d\n", newLen); + printStr(corrected, newLen); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/main.py b/kattis/problems/01_11_23/keystrokes/main.py new file mode 100644 index 0000000..e5ba2aa --- /dev/null +++ b/kattis/problems/01_11_23/keystrokes/main.py @@ -0,0 +1,22 @@ +string = input() +string_list = [] +cursor = 0 +for char in string: + # If 'L' found in string, we move the cursor to the left + if char == 'L': + if cursor > 0: + cursor -= 1 + # If 'R' found in string, we move the cursor to the right + elif char == 'R': + if cursor < len(string): + cursor += 1 + # If 'B' found in string, we delete the character to the left of the cursor + elif char == 'B': + del string_list[cursor - 1] + cursor -= 1 + # If any other character found in string, we insert it to the left of the cursor + else: + string_list.insert(cursor, char) + cursor += 1 +# Print only the new string, without the initial one +print(''.join(string_list)) \ No newline at end of file diff --git a/kattis/problems/01_11_23/keystrokes/program b/kattis/problems/01_11_23/keystrokes/program new file mode 100755 index 0000000..2e32527 Binary files /dev/null and b/kattis/problems/01_11_23/keystrokes/program differ diff --git a/kattis/problems/01_11_23/pieceofcake/main.c b/kattis/problems/01_11_23/pieceofcake/main.c new file mode 100644 index 0000000..89f06bb --- /dev/null +++ b/kattis/problems/01_11_23/pieceofcake/main.c @@ -0,0 +1,13 @@ +#include +#include + +int main(int argc, char **argv) { + int n, h, v; + scanf("%d %d %d", &n, &h, &v); + + int max_h = h > n - h ? h : n - h; + int max_v = v > n - v ? v : n - v; + + printf("%d\n", max_h * max_v * 4); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/ratingproblems/main.c b/kattis/problems/01_11_23/ratingproblems/main.c new file mode 100644 index 0000000..f9e3d5f --- /dev/null +++ b/kattis/problems/01_11_23/ratingproblems/main.c @@ -0,0 +1,20 @@ +#include +#include + +int main(int argc, char **argv) { + int n, k; + scanf("%d %d", &n, &k); + int sum = 0; + for (int i = 0; i < k; ++i) { + int x; + scanf("%d", &x); + sum += x; + } + + int min = sum - (n - k) * 3; + int max = sum + (n - k) * 3; + printf("%.6f %.6f\n", min / (double)n, max / (double)n); + + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/refrigerator/main.c b/kattis/problems/01_11_23/refrigerator/main.c new file mode 100644 index 0000000..3ad17b6 --- /dev/null +++ b/kattis/problems/01_11_23/refrigerator/main.c @@ -0,0 +1,25 @@ +#include +#include + +int main(int argc, char **argv) { + int pa, ka, pb, kb, n; + scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n); + + int tripsA = 0, tripsB = 0; + int totalCost = 0; + int costA = pa/ka; + int costB = pb/kb; + + while (n > 0) { + if (costA < costB && ka < n) { + tripsA++; + totalCost += pa; + } else { + tripsB++; + totalCost += pb; + } + n--; + } + printf("%d %d %d\n", tripsA, tripsB, totalCost); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/refrigerator/main.c.orig b/kattis/problems/01_11_23/refrigerator/main.c.orig new file mode 100644 index 0000000..18ca917 --- /dev/null +++ b/kattis/problems/01_11_23/refrigerator/main.c.orig @@ -0,0 +1,26 @@ +#include +#include + +int main(int argc, char **argv) { + int pa, ka, pb, kb, n; + scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n); + + int tripsA = 0, tripsB = 0; + int totalCost = 0; + int costA = pa/ka; + int costB = pb/kb; + + + while (n > 0) { + if (pa < pb && ka < n) { + tripsA++; + totalCost += pa; + } else { + tripsB++; + totalCost += pb; + } + n--; + } + printf("%d %d %d\n", tripsA, tripsB, pa+pb); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/refrigerator/program b/kattis/problems/01_11_23/refrigerator/program new file mode 100755 index 0000000..f168c34 Binary files /dev/null and b/kattis/problems/01_11_23/refrigerator/program differ diff --git a/kattis/problems/01_11_23/weakvertices/main.c b/kattis/problems/01_11_23/weakvertices/main.c new file mode 100644 index 0000000..ed75924 --- /dev/null +++ b/kattis/problems/01_11_23/weakvertices/main.c @@ -0,0 +1,40 @@ +#include +#include + +#define MAX 21 + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + int matrix[MAX][MAX]; + int i, j, k; + while (n != -1) { + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + scanf("%d", &matrix[i][j]); + } + } + int weak[MAX]; + for (i = 0; i < n; i++) { + weak[i] = 1; + } + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + for (k = 0; k < n; k++) { + if (matrix[i][j] && matrix[j][k] && matrix[k][i]) { + weak[i] = 0; + weak[j] = 0; + weak[k] = 0; + } + } + } + } + for (i = 0; i < n; i++) { + if (weak[i]) { + printf("%d ", i); + } + } + printf("\n"); + scanf("%d", &n); + } +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/whichisgreater/main.c b/kattis/problems/01_11_23/whichisgreater/main.c new file mode 100644 index 0000000..31417bf --- /dev/null +++ b/kattis/problems/01_11_23/whichisgreater/main.c @@ -0,0 +1,11 @@ +#include +#include + +#define MIN(x,y) x>y ? 1 : 0 + +int main(int argc, char **argv) { + int a, b; + scanf("%d %d", &a, &b); + printf("%d\n", MIN(a, b)); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/whichisgreater/main.c.orig b/kattis/problems/01_11_23/whichisgreater/main.c.orig new file mode 100644 index 0000000..8a447cc --- /dev/null +++ b/kattis/problems/01_11_23/whichisgreater/main.c.orig @@ -0,0 +1,11 @@ +#include +#include + +#define MIN(x,y) x>y ? 1 : 0 + +int main(int argc, char **argv) { + int a,b; + scanf("%d %d"); + printf("%d\n", MIN(a,b)); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/01_11_23/whichisgreater/program b/kattis/problems/01_11_23/whichisgreater/program new file mode 100755 index 0000000..21588f9 Binary files /dev/null and b/kattis/problems/01_11_23/whichisgreater/program differ diff --git a/kattis/problems/02_11_23/cprnummer/1.in b/kattis/problems/02_11_23/cprnummer/1.in new file mode 100644 index 0000000..664e630 --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/1.in @@ -0,0 +1 @@ +070761-4285 diff --git a/kattis/problems/02_11_23/cprnummer/2.in b/kattis/problems/02_11_23/cprnummer/2.in new file mode 100644 index 0000000..103caea --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/2.in @@ -0,0 +1 @@ +051002-4321 diff --git a/kattis/problems/02_11_23/cprnummer/3.in b/kattis/problems/02_11_23/cprnummer/3.in new file mode 100644 index 0000000..b4c7ede --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/3.in @@ -0,0 +1 @@ +310111-0469 diff --git a/kattis/problems/02_11_23/cprnummer/main.c b/kattis/problems/02_11_23/cprnummer/main.c new file mode 100644 index 0000000..5a73209 --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/main.c @@ -0,0 +1,28 @@ +#include +#include + +int main(int argc, char **argv) { + // Do with scanf + + int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1}; + int sum = 0; + for (int i=0; i<10; i++) { + char s; + if ((s = getchar()) == '-') { + i--; + continue; + } else { + sum += (s - '0') * values[i]; + } + + } + printf("Sum: %d\n", sum); + + if (sum % 11 == 0) { + printf("1\n"); + } else { + printf("0\n"); + } + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/02_11_23/cprnummer/main.c.orig b/kattis/problems/02_11_23/cprnummer/main.c.orig new file mode 100644 index 0000000..24ec86f --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/main.c.orig @@ -0,0 +1,28 @@ +#include +#include + +int main(int argc, char **argv) { + // Do with scanf + + int values[10] = {4, 3, 2, 7, 6, 5, 4, 3, 2, 1}; + int sum = 0; + for (int i=0; i<10; i++) { + char s; + if ((s = getchar()) == '-') { + i--; + continue; + } else { + sum += (s - '0') * values[i]; + } + + } + printf("Sum: %d\n", sum); + + if (sum % 11 == 0) { + printf("1\n"); + } else { + printf("0\n"); + } + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/02_11_23/cprnummer/main.py b/kattis/problems/02_11_23/cprnummer/main.py new file mode 100644 index 0000000..754b546 --- /dev/null +++ b/kattis/problems/02_11_23/cprnummer/main.py @@ -0,0 +1,11 @@ +lol = input().replace("-", "") +values = [4, 3, 2, 7, 6, 5, 4, 3, 2, 1]; + +sum = 0 +for i in range(10): + sum += int(lol[i]) * values[i] + +if sum % 11 == 0: + print(1) +else: + print(0) diff --git a/kattis/problems/02_11_23/cprnummer/program b/kattis/problems/02_11_23/cprnummer/program new file mode 100755 index 0000000..1f56711 Binary files /dev/null and b/kattis/problems/02_11_23/cprnummer/program differ diff --git a/kattis/problems/02_11_23/horror/1.in b/kattis/problems/02_11_23/horror/1.in new file mode 100644 index 0000000..7a651f5 --- /dev/null +++ b/kattis/problems/02_11_23/horror/1.in @@ -0,0 +1,7 @@ +6 3 5 +0 5 2 +0 1 +1 2 +4 5 +3 5 +0 2 diff --git a/kattis/problems/02_11_23/horror/2.in b/kattis/problems/02_11_23/horror/2.in new file mode 100644 index 0000000..d93d813 --- /dev/null +++ b/kattis/problems/02_11_23/horror/2.in @@ -0,0 +1,5 @@ +6 2 3 +5 2 +0 5 +0 1 +3 4 diff --git a/kattis/problems/02_11_23/horror/main.c b/kattis/problems/02_11_23/horror/main.c new file mode 100644 index 0000000..0ca31b5 --- /dev/null +++ b/kattis/problems/02_11_23/horror/main.c @@ -0,0 +1,48 @@ +#include +#include + +void printArr(int *arr, int n) { + for (int i=0; i +#include + +void printArr(int *arr, int n) { + for (int i=0; i +#include + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + int sum = 0; + + for (int i=0; i +#include + +// Compare in order to sort from largest to smallest +int compare(const void *a, const void *b) { + return *(int *)b - *(int *)a; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + int prices[200001]; + + for (int i=0; i +#include + +// Compare in order to sort from largest to smallest +int compare(const void *a, const void *b) { + return *(int*)b - *(int*)a; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + int *prices = malloc(sizeof(int) * n); + + for (int i=0; i +#include + +int main(int argc, char **argv) { + int h, b; + scanf("%d %d", &h, &b); + + printf("%f\n", (h*b)/2.0); +} \ No newline at end of file diff --git a/kattis/problems/02_11_23/trianglearea/program b/kattis/problems/02_11_23/trianglearea/program new file mode 100755 index 0000000..cbb8bd3 Binary files /dev/null and b/kattis/problems/02_11_23/trianglearea/program differ diff --git a/kattis/problems/02_11_23/universityzoning/main.c b/kattis/problems/02_11_23/universityzoning/main.c new file mode 100644 index 0000000..664fbb9 --- /dev/null +++ b/kattis/problems/02_11_23/universityzoning/main.c @@ -0,0 +1,11 @@ +#include +#include + +int main(int argc, char **argv) { + int r, c, s, f, t, g; + scanf("%d %d %d %d %d %d", &r, &c, &s, &f, &t, &g); + + + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/03_11_23/countthevowels/main.c b/kattis/problems/03_11_23/countthevowels/main.c new file mode 100644 index 0000000..3a66b50 --- /dev/null +++ b/kattis/problems/03_11_23/countthevowels/main.c @@ -0,0 +1,16 @@ +#include +#include + +int main(int argc, char **argv) { + char c; + int vowels = 0; + while ((c=getchar()) != '\n') { + if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || + c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') { + vowels++; + } + } + + printf("%d\n", vowels); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/03_11_23/eyeofsauron/main.c b/kattis/problems/03_11_23/eyeofsauron/main.c new file mode 100644 index 0000000..c8ea294 --- /dev/null +++ b/kattis/problems/03_11_23/eyeofsauron/main.c @@ -0,0 +1,24 @@ +#include +#include + +int main(int argc, char **argv) { + + char c; + int count = 0; + int firstSide = 0; + while ((c=getchar()) != '\n') { + if (c == '(') { + firstSide = count; + count = 0; + } + if (c == '|') { + count++; + } + } + if (count == firstSide) { + printf("correct\n"); + } else { + printf("fix\n"); + } + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/classfieldtrip/1.in b/kattis/problems/06_11_23/classfieldtrip/1.in new file mode 100644 index 0000000..f86dda9 --- /dev/null +++ b/kattis/problems/06_11_23/classfieldtrip/1.in @@ -0,0 +1,2 @@ +ahjmnoy +acijjkll diff --git a/kattis/problems/06_11_23/classfieldtrip/main.c b/kattis/problems/06_11_23/classfieldtrip/main.c new file mode 100644 index 0000000..6b40484 --- /dev/null +++ b/kattis/problems/06_11_23/classfieldtrip/main.c @@ -0,0 +1,61 @@ +#include +#include + +// void concatForEach(char *a, char *b, char *target ) { +// int lenA = strlen(a); +// int lenB = strlen(b); + +// // We use the smaller one +// char *using = lenA > lenB ? b : a; +// int usingLen = lenA > lenB ? lenB : lenA; + +// int i; +// for (i=0; i < usingLen; i+=2) { +// target[i] = a[i]; +// target[i+1] = b[i]; +// } + +// // Now we use the bigger one +// char *new = lenA > lenB ? a : b; +// int newLen = lenA > lenB ? lenA : lenB; + +// for (; i < newLen-usingLen; i++) { +// target[i] = a[i]; +// } + +// return; + +// } + +int main(int argc, char **argv) { + char ann[100]; + char ben[100]; + + scanf("%s", ann); + scanf("%s", ben); + + char total[200]; + + // Concatenate + strcat(total, ann); + strcat(total, ben); + + // Alphabetical sort + int len = strlen(total); + int i, j; + for (i=0; i < len; i++) { + for (j=0; j < len-i-1; j++) { + if (total[j] > total[j+1]) { + char temp = total[j]; + total[j] = total[j+1]; + total[j+1] = temp; + } + } + } + + for (i=0; i < len; i++) { + printf("%c", total[i]); + } + printf("\r\n"); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/classfieldtrip/main.c.orig b/kattis/problems/06_11_23/classfieldtrip/main.c.orig new file mode 100644 index 0000000..f707e91 --- /dev/null +++ b/kattis/problems/06_11_23/classfieldtrip/main.c.orig @@ -0,0 +1,61 @@ +#include +#include + +// void concatForEach(char *a, char *b, char *target ) { +// int lenA = strlen(a); +// int lenB = strlen(b); + +// // We use the smaller one +// char *using = lenA > lenB ? b : a; +// int usingLen = lenA > lenB ? lenB : lenA; + +// int i; +// for (i=0; i < usingLen; i+=2) { +// target[i] = a[i]; +// target[i+1] = b[i]; +// } + +// // Now we use the bigger one +// char *new = lenA > lenB ? a : b; +// int newLen = lenA > lenB ? lenA : lenB; + +// for (; i < newLen-usingLen; i++) { +// target[i] = a[i]; +// } + +// return; + +// } + +int main(int argc, char **argv) { + char ann[100]; + char ben[100]; + + scanf("%s", ann); + scanf("%s", ben); + + char total[200]; + + // Concatenate + strcat(total, ann); + strcat(total, ben); + + // Alphabetical sort + int len = strlen(total); + int i, j; + for (i=0; i < len; i++) { + for (j=0; j < len-i-1; j++) { + if (total[j] > total[j+1]) { + char temp = total[j]; + total[j] = total[j+1]; + total[j+1] = temp; + } + } + } + + + // Print + printf("%s\n", total); + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/classfieldtrip/main.py b/kattis/problems/06_11_23/classfieldtrip/main.py new file mode 100644 index 0000000..f1851d2 --- /dev/null +++ b/kattis/problems/06_11_23/classfieldtrip/main.py @@ -0,0 +1,10 @@ +ann = input() +bob = input() + +total = ann + bob +sorted_total = sorted(total) + +print("".join(sorted_total)) + + + diff --git a/kattis/problems/06_11_23/classfieldtrip/program b/kattis/problems/06_11_23/classfieldtrip/program new file mode 100755 index 0000000..b94fd8c Binary files /dev/null and b/kattis/problems/06_11_23/classfieldtrip/program differ diff --git a/kattis/problems/06_11_23/deadoralive/3.in b/kattis/problems/06_11_23/deadoralive/3.in new file mode 100644 index 0000000..61a16ef --- /dev/null +++ b/kattis/problems/06_11_23/deadoralive/3.in @@ -0,0 +1 @@ +Firing up EmoticonBot... (: : ( ): :D c: diff --git a/kattis/problems/06_11_23/deadoralive/main.c b/kattis/problems/06_11_23/deadoralive/main.c new file mode 100644 index 0000000..e4988ac --- /dev/null +++ b/kattis/problems/06_11_23/deadoralive/main.c @@ -0,0 +1,43 @@ +#include +#include + +int main(int argc, char **argv) { + char c; + int smiley = 0; + int frowny = 0; + int eyes = 0; + + // Would be easier if we stored it but why tf not ig + int i = 0; + while ((c = getchar()) != '\n') { + + // PROUD OF THIS + // ↓↓↓↓↓↓↓↓↓↓↓↓↓ + if (i - eyes > 1) { + eyes = 0; + } + + if (c == ':') { + eyes = i; + } + if (c == ')' && eyes ) { + smiley++; + } + if (c == '(' && eyes) { + frowny++; + } + i++; + } + + if (frowny && ! smiley) { + printf("undead\n"); + } else if (smiley && !frowny) { + printf("alive\n"); + } else if (smiley && frowny) { + printf("double agent\n"); + } else { + printf("machine\n"); + } + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/deadoralive/program b/kattis/problems/06_11_23/deadoralive/program new file mode 100755 index 0000000..5bfc4ec Binary files /dev/null and b/kattis/problems/06_11_23/deadoralive/program differ diff --git a/kattis/problems/06_11_23/pokechat/1.in b/kattis/problems/06_11_23/pokechat/1.in new file mode 100644 index 0000000..d33716e --- /dev/null +++ b/kattis/problems/06_11_23/pokechat/1.in @@ -0,0 +1,2 @@ +PpIiKkAaCcHhUu +001004006008010012014 \ No newline at end of file diff --git a/kattis/problems/06_11_23/pokechat/2.in b/kattis/problems/06_11_23/pokechat/2.in new file mode 100644 index 0000000..3ca41d7 --- /dev/null +++ b/kattis/problems/06_11_23/pokechat/2.in @@ -0,0 +1,2 @@ +abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,?!0123456789 +016009011001053016009011001 \ No newline at end of file diff --git a/kattis/problems/06_11_23/pokechat/main.c b/kattis/problems/06_11_23/pokechat/main.c new file mode 100644 index 0000000..0ec2dc4 --- /dev/null +++ b/kattis/problems/06_11_23/pokechat/main.c @@ -0,0 +1,26 @@ +#include +#include + +int main(int argc, char **argv) { + char translationKey[256]; + char c; + int i = 0; + while ((c = getchar()) != '\n') { + translationKey[i] = c; + i++; + } + + while (1) { + int phrase; + int check = scanf("%3d", &phrase); + if (check != 1) { + break; + } + // printf("%d, %d\n", phrase, check); + printf("%c", translationKey[phrase-1]); + } + + printf("\n"); + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/pokechat/main.c.orig b/kattis/problems/06_11_23/pokechat/main.c.orig new file mode 100644 index 0000000..b9966da --- /dev/null +++ b/kattis/problems/06_11_23/pokechat/main.c.orig @@ -0,0 +1,26 @@ +#include +#include + +int main(int argc, char **argv) { + char translationKey[256]; + char c; + int i = 0; + while ((c = getchar()) != '\n') { + translationKey[i] = c; + i++; + } + + + while (1) { + int phrase; + int check = scanf("3%d", &phrase); + if (check != 1) { + break; + } + printf("%c\n", translationKey[phrase-1]); + } + + printf("\n"); + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/06_11_23/pokechat/program b/kattis/problems/06_11_23/pokechat/program new file mode 100755 index 0000000..15cc055 Binary files /dev/null and b/kattis/problems/06_11_23/pokechat/program differ diff --git a/kattis/problems/11_11_23/cutthenegativity/1.in b/kattis/problems/11_11_23/cutthenegativity/1.in new file mode 100644 index 0000000..abf5b09 --- /dev/null +++ b/kattis/problems/11_11_23/cutthenegativity/1.in @@ -0,0 +1,5 @@ +4 +-1 1 -1 2 +9 -1 -1 -1 +-1 3 -1 4 +7 1 2 -1 diff --git a/kattis/problems/11_11_23/cutthenegativity/main.c b/kattis/problems/11_11_23/cutthenegativity/main.c new file mode 100644 index 0000000..a3c1a2c --- /dev/null +++ b/kattis/problems/11_11_23/cutthenegativity/main.c @@ -0,0 +1,36 @@ +#include +#include + +#define MAX 100 + +void directFlights(int n, int flights[MAX][MAX]) { + for (int i=0; i +#include + +#define MAX 100 + +void trip(int i, int j, int flights[MAX][MAX]) { + if (flights[i][j] == -1) { + return; + } + + printf("%d", flights[i][j]); + trip(j, flights[i][j], flights); + return; +} + +void directFlights(int n, int flights[MAX][MAX]) { + for (int i=0; i +#include +#include + +#define MAX 2100 + +int isAlpha(char c) { + if (c >= 'a' && c <= 'z') { + return 1; + } + if (c >= 'A' && c <= 'Z') { + return 1; + } + return 0; +} + +void printBefore(char first[MAX], char second[MAX]) { + for (int i=0; i +#include +#include + +#define MAX 2100 + +int isAlpha(char c) { + if (c >= 'a' && c <= 'z') { + return 1; + } + if (c >= 'A' && c <= 'Z') { + return 1; + } + return 0; +} + +void printBefore(char first[MAX], char second[MAX]) { + for (int i=0; i +#include + +int main(int argc, char **argv) { + int n, m; + scanf("%d %d", &n, &m); + + printf("%d\n", n - (n/m)*m ); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/11_11_23/internationaldates/main.c b/kattis/problems/11_11_23/internationaldates/main.c new file mode 100644 index 0000000..a903306 --- /dev/null +++ b/kattis/problems/11_11_23/internationaldates/main.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char **argv) { + int x,y,z; + scanf("%d/%d/%d", &x, &y, &z); + + // EU OR US OR EITHER + if (x > 12) { + printf("EU\n"); + } else if (y > 12) { + printf("US\n"); + } else { + printf("either\n"); + } + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/11_11_23/milllifaersla/main.c b/kattis/problems/11_11_23/milllifaersla/main.c new file mode 100644 index 0000000..7f4b921 --- /dev/null +++ b/kattis/problems/11_11_23/milllifaersla/main.c @@ -0,0 +1,32 @@ +#include +#include + +typedef struct Transaction { + int amount; + char *service; +} Transaction; + +int main(int argc, char **argv) { + Transaction x, y, z; + x.service = "Monnei"; + y.service = "Fjee"; + z.service = "Dolladollabilljoll"; + scanf("%d %d %d", &x.amount, &y.amount, &z.amount); + + // Get min + Transaction min = x; + if (y.amount < min.amount) { + min = y; + } + if (z.amount < min.amount) { + min = z; + } + + printf("%s\n", min.service); + + + + return 0; + + +} \ No newline at end of file diff --git a/kattis/problems/13_11_23/platforme/main.c b/kattis/problems/13_11_23/platforme/main.c new file mode 100644 index 0000000..e69de29 diff --git a/kattis/problems/13_11_23/sith/1.in b/kattis/problems/13_11_23/sith/1.in new file mode 100644 index 0000000..f2e7334 --- /dev/null +++ b/kattis/problems/13_11_23/sith/1.in @@ -0,0 +1,4 @@ +Obi-Wan Kenobi +69 +80 +-11 diff --git a/kattis/problems/13_11_23/sith/3.in b/kattis/problems/13_11_23/sith/3.in new file mode 100644 index 0000000..9cd83ab --- /dev/null +++ b/kattis/problems/13_11_23/sith/3.in @@ -0,0 +1,4 @@ +Grogu +67 +17 +50 diff --git a/kattis/problems/13_11_23/sith/main.c b/kattis/problems/13_11_23/sith/main.c new file mode 100644 index 0000000..803adea --- /dev/null +++ b/kattis/problems/13_11_23/sith/main.c @@ -0,0 +1,21 @@ +#include +#include + +int main(int argc, char **argv) { + + int a, b, diff; + char c; + while ((c=getchar()) != '\n' ) { + continue; + } + scanf("%d %d %d", &a, &b, &diff); + + if (abs(a-b) == diff && a - b != diff) { + printf("SITH\n"); + } else if (a - b == diff && abs(a-b) != diff ) { + printf("JEDI\n"); + } else { + printf("VEIT EKKI\n"); + } + return 0; +} diff --git a/kattis/problems/13_11_23/sith/main.c.orig b/kattis/problems/13_11_23/sith/main.c.orig new file mode 100644 index 0000000..427b2be --- /dev/null +++ b/kattis/problems/13_11_23/sith/main.c.orig @@ -0,0 +1,25 @@ +#include +#include + +int absolute(int x) { + return x < 0 ? -x : x; +} + +int main(int argc, char **argv) { + + int a, b, diff; + char c; + while ((c=getchar()) != '\n' ) { + continue; + } + scanf("%d %d %d", &a, &b, &diff); + + if (absolute(a-b) == diff) { + printf("SITH\n"); + } else if (a - b == diff && absolute(a-b) != diff) { + printf("JEDI\n"); + } else { + printf("VEIT EKKI\n"); + } + return 0; +} diff --git a/kattis/problems/13_11_23/sith/program b/kattis/problems/13_11_23/sith/program new file mode 100755 index 0000000..095ffd2 Binary files /dev/null and b/kattis/problems/13_11_23/sith/program differ diff --git a/kattis/problems/13_11_23/vefthjonatjon/1.in b/kattis/problems/13_11_23/vefthjonatjon/1.in new file mode 100644 index 0000000..169c83c --- /dev/null +++ b/kattis/problems/13_11_23/vefthjonatjon/1.in @@ -0,0 +1,4 @@ +3 +J N N +N J N +N N J diff --git a/kattis/problems/13_11_23/vefthjonatjon/2.in b/kattis/problems/13_11_23/vefthjonatjon/2.in new file mode 100644 index 0000000..d727df1 --- /dev/null +++ b/kattis/problems/13_11_23/vefthjonatjon/2.in @@ -0,0 +1,3 @@ +2 +J J N +N N J diff --git a/kattis/problems/13_11_23/vefthjonatjon/main.c b/kattis/problems/13_11_23/vefthjonatjon/main.c new file mode 100644 index 0000000..a973115 --- /dev/null +++ b/kattis/problems/13_11_23/vefthjonatjon/main.c @@ -0,0 +1,35 @@ +#include +#include + +int isThere(char c) { + if (c == 'J') { + return 1; + } + return 0; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + int cpu = 0, memory = 0, disk = 0; + + for (int i=0; i +#include + +int isThere(char c) { + if (c == 'J') return 1; + return 0; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + int cpu = 0, memory = 0, disk = 0; + + for (int i=0; i +#include + +int main(int argc, char **argv) { + int a; + scanf("%d", &a); + char c; + int b[100]; + while ((c = getchar()) != '\n') { + if (c >= 'A' && c <= 'Z' && b[c - 'A'] == 0) { + printf("%c", c); + b[c - 'A'] = 1; + } + } + printf("\n"); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/18_11_23/asciikassi/program b/kattis/problems/18_11_23/asciikassi/program new file mode 100755 index 0000000..bfe4f82 Binary files /dev/null and b/kattis/problems/18_11_23/asciikassi/program differ diff --git a/kattis/problems/18_11_23/umferd/1.in b/kattis/problems/18_11_23/umferd/1.in new file mode 100644 index 0000000..a5e94d6 --- /dev/null +++ b/kattis/problems/18_11_23/umferd/1.in @@ -0,0 +1,3 @@ +2 +1 +.# diff --git a/kattis/problems/18_11_23/umferd/2.in b/kattis/problems/18_11_23/umferd/2.in new file mode 100644 index 0000000..60ad440 --- /dev/null +++ b/kattis/problems/18_11_23/umferd/2.in @@ -0,0 +1,4 @@ +4 +2 +#.#. +.### diff --git a/kattis/problems/18_11_23/umferd/main.c b/kattis/problems/18_11_23/umferd/main.c new file mode 100644 index 0000000..b8cc118 --- /dev/null +++ b/kattis/problems/18_11_23/umferd/main.c @@ -0,0 +1,23 @@ +#include +#include + +int main(int argc, char **argv) { + int m, n; + scanf("%d %d", &m, &n); + + int empty = 0; + int filled = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + char c = getchar(); + if (c == '.') { + empty++; + } else if (c == '#') { + filled++; + } + } + } + printf("%d %d\n", empty, filled); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/18_11_23/umferd/main.c.orig b/kattis/problems/18_11_23/umferd/main.c.orig new file mode 100644 index 0000000..1af9ddf --- /dev/null +++ b/kattis/problems/18_11_23/umferd/main.c.orig @@ -0,0 +1,23 @@ +#include +#include + +int main(int argc, char **argv) { + int m, n; + scanf("%d %d", &m, &n); + + int empty = 0; + int filled = 0; + + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + char c = getchar(); + if (c == '.') { + empty++; + } else if (c == '#') { + filled++; + } + } + } + printf("%d %d\n",empty, filled); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/18_11_23/umferd/program b/kattis/problems/18_11_23/umferd/program new file mode 100755 index 0000000..a61a338 Binary files /dev/null and b/kattis/problems/18_11_23/umferd/program differ diff --git a/kattis/problems/21_11_23/asciikassi/main.c b/kattis/problems/21_11_23/asciikassi/main.c new file mode 100644 index 0000000..36bf3d7 --- /dev/null +++ b/kattis/problems/21_11_23/asciikassi/main.c @@ -0,0 +1,30 @@ +#include +#include + +void drawLine(int n) { + printf("+"); + for (int i = 0; i < n; i++) { + printf("-"); + } + printf("+\n"); +} + +void drawRect(int n) { + drawLine(n); + for (int i = 0; i < n; i++) { + printf("|"); + for (int j = 0; j < n; j++) { + printf(" "); + } + printf("|\n"); + } + drawLine(n); +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + drawRect(n); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/21_11_23/asciikassi/main.c.orig b/kattis/problems/21_11_23/asciikassi/main.c.orig new file mode 100644 index 0000000..1a3f2dc --- /dev/null +++ b/kattis/problems/21_11_23/asciikassi/main.c.orig @@ -0,0 +1,45 @@ +#include +#include + +void drawRect(int n) { + // Top part + for (int i = 0; i <= n; i++) { + if (i == 0 || i == n - 1) { + printf("+"); + } else { + printf("-"); + } + } + printf("\n"); + + // Middle parts + for (int i = 0; i < n - 2; i++) { + for (int j = 0; j <= n; j++) { + if (j == 0 || j == n - 1) { + printf("|"); + } else { + printf(" "); + } + } + printf("\n"); + } + + // Bottom part + for (int i = 0; i <= n; i++) { + if (i == 0 || i == n - 1) { + printf("+"); + } else { + printf("-"); + } + } + + printf("\n"); +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + drawRect(n); + return 0; +} \ No newline at end of file diff --git a/kattis/problems/21_11_23/asciikassi/program b/kattis/problems/21_11_23/asciikassi/program new file mode 100755 index 0000000..98a1532 Binary files /dev/null and b/kattis/problems/21_11_23/asciikassi/program differ diff --git a/kattis/problems/21_11_23/modulo/1.in b/kattis/problems/21_11_23/modulo/1.in new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/kattis/problems/21_11_23/modulo/1.in @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/kattis/problems/21_11_23/modulo/main.c b/kattis/problems/21_11_23/modulo/main.c new file mode 100644 index 0000000..44154b7 --- /dev/null +++ b/kattis/problems/21_11_23/modulo/main.c @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char **argv) { + int counter = 0; + for (int i=0; i<10; i++) { + int n; + scanf("%d", &n); + if (n % 42 == 0) { + counter++; + } + } + printf("%d\n", 10-counter); +} \ No newline at end of file diff --git a/kattis/problems/21_11_23/modulo/program b/kattis/problems/21_11_23/modulo/program new file mode 100755 index 0000000..494eb54 Binary files /dev/null and b/kattis/problems/21_11_23/modulo/program differ diff --git a/kattis/problems/21_11_23/prjonamynstur/1.in b/kattis/problems/21_11_23/prjonamynstur/1.in new file mode 100644 index 0000000..3d7eaef --- /dev/null +++ b/kattis/problems/21_11_23/prjonamynstur/1.in @@ -0,0 +1,17 @@ +16 16 +................ +...\O....OAO.... +................ +...\O..\O...O/.. +................ +...\O..\O...O/.. +................ +...\O.......O/.. +................ +....\O.....O/... +................ +.....\O...O/.... +................ +......\O.O/..... +................ +.......\O....... diff --git a/kattis/problems/21_11_23/prjonamynstur/2.in b/kattis/problems/21_11_23/prjonamynstur/2.in new file mode 100644 index 0000000..bdecc7b --- /dev/null +++ b/kattis/problems/21_11_23/prjonamynstur/2.in @@ -0,0 +1,4 @@ +3 5 +..... +..... +..... diff --git a/kattis/problems/21_11_23/prjonamynstur/main.c b/kattis/problems/21_11_23/prjonamynstur/main.c new file mode 100644 index 0000000..f542eed --- /dev/null +++ b/kattis/problems/21_11_23/prjonamynstur/main.c @@ -0,0 +1,33 @@ +#include +#include + +int main(int argc, char **argv) { + int n, m; + scanf("%d %d", &n, &m); + + int ingredients = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + + char c; + scanf(" %c", &c); + if (c == '.') { + ingredients += 20; + } else if (c == 'O') { + ingredients += 10; + } else if (c == '\\' || c == '/') { + ingredients += 25; + } else if (c == 'A') { + ingredients += 35; + } else if (c == '^') { + ingredients += 5; + } else if (c == 'v') { + ingredients += 22; + } + } + } + printf("%d\n", ingredients); + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/21_11_23/prjonamynstur/main.c.orig b/kattis/problems/21_11_23/prjonamynstur/main.c.orig new file mode 100644 index 0000000..b9ec351 --- /dev/null +++ b/kattis/problems/21_11_23/prjonamynstur/main.c.orig @@ -0,0 +1,35 @@ +#include +#include + +int main(int argc, char **argv) { + int n, m; + scanf("%d %d", &n, &m); + + int ingredients = 0; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + + char c; + scanf(" %c", &c); + printf("%c", c); + if (c == '.') { + ingredients += 20; + } else if (c == '0') { + ingredients += 10; + } else if (c == '\\' || c == '/') { + ingredients += 25; + } else if (c == 'A') { + ingredients += 35; + } else if (c == '^') { + ingredients += 5; + } else if (c == 'v') { + ingredients += 22; + } + } + printf("\n"); + } + printf("%d\n\a", ingredients); + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/21_11_23/prjonamynstur/main.py b/kattis/problems/21_11_23/prjonamynstur/main.py new file mode 100644 index 0000000..e4e4ede --- /dev/null +++ b/kattis/problems/21_11_23/prjonamynstur/main.py @@ -0,0 +1,19 @@ + +n,m = [int(x) for x in input().split(" ")] +ingredients = { + '.': [20, 0], + 'O': [10, 0], + '\\': [25, 0], + '/': [25, 0], + 'A': [35, 0], + '^': [5, 0], + 'v': [22, 0] +} + +for i in range(n): + string = input() + for token in string: + ingredients[token][1] += 1 + +real_values = [x[0] * x[1] for x in ingredients.values()] +print(sum(real_values)) \ No newline at end of file diff --git a/kattis/problems/21_11_23/prjonamynstur/program b/kattis/problems/21_11_23/prjonamynstur/program new file mode 100755 index 0000000..f7f99ef Binary files /dev/null and b/kattis/problems/21_11_23/prjonamynstur/program differ diff --git a/kattis/problems/21_11_23/sibice/1.in b/kattis/problems/21_11_23/sibice/1.in new file mode 100644 index 0000000..e69de29 diff --git a/kattis/problems/21_11_23/sibice/main.c b/kattis/problems/21_11_23/sibice/main.c new file mode 100644 index 0000000..283a156 --- /dev/null +++ b/kattis/problems/21_11_23/sibice/main.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char **argv) { + int n, w, h; + scanf("%d %d %d", &n, &w, &h); + + for (int i=0; i +#include + +char getColumn(char hats[50][50], int n, int m, int column, char *result) { + for (int i=0; i +#include + +int lastDigit(int n) { + int result = 1; + while (--n) { + result *= n; + } + return result % 10; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + while(n--) { + int num; + scanf("%d", &num); + printf("%d\n", lastDigit(num)); + } +} \ No newline at end of file diff --git a/kattis/problems/24_10_23/apple_delivery/main.c.orig b/kattis/problems/24_10_23/apple_delivery/main.c.orig new file mode 100644 index 0000000..c332c7b --- /dev/null +++ b/kattis/problems/24_10_23/apple_delivery/main.c.orig @@ -0,0 +1,20 @@ +#include +#include + +int lastDigit(int n) { + int result = 1; + while (--n) { + result *= n; + } + return result % 10; +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + while(n--) { + int num; + scanf("%d", &num); + printf("%d\n", lastDigit(num)); + } +} \ No newline at end of file diff --git a/kattis/problems/24_10_23/apple_delivery/main.py b/kattis/problems/24_10_23/apple_delivery/main.py new file mode 100644 index 0000000..6f97f53 --- /dev/null +++ b/kattis/problems/24_10_23/apple_delivery/main.py @@ -0,0 +1,40 @@ +def houses_within_radius(r): + return (2*r + 1)**2 + +def apples_to_remove(n, radii): + # Calculate total houses + total_houses = sum([houses_within_radius(r) for r in radii]) + + # Calculate the remainder + remainder = total_houses % 8 + + if remainder == 0: + # No apples need to be removed + return 0 + + # Calculate houses exactly at each radius + houses_at_radius = [houses_within_radius(r) - houses_within_radius(r-1) for r in radii if r > 0] + + # Sort the houses_at_radius list + houses_at_radius.sort() + + # Try to minimize the apples not given + apples_not_given = 0 + for houses in houses_at_radius: + if houses % 8 >= remainder: + apples_not_given += (houses % 8) - remainder + remainder = 0 + break + else: + apples_not_given += houses % 8 + remainder -= houses % 8 + + if remainder > 0: + apples_not_given += 8 - remainder + + return apples_not_given + +# Sample Test +n = int(input()) +radii = list(map(int, input().split())) +print(apples_to_remove(n, radii)) diff --git a/kattis/problems/24_10_23/apple_delivery/program b/kattis/problems/24_10_23/apple_delivery/program new file mode 100755 index 0000000..22a72a3 Binary files /dev/null and b/kattis/problems/24_10_23/apple_delivery/program differ diff --git a/kattis/problems/27_10_23/keylogger/1.in b/kattis/problems/27_10_23/keylogger/1.in new file mode 100644 index 0000000..0dd4b0d --- /dev/null +++ b/kattis/problems/27_10_23/keylogger/1.in @@ -0,0 +1,27 @@ +26 +clank +bong +click +tap +poing +clonk +clack +ping +tip +cloing +tic +cling +bing +pong +clang +pang +clong +tac +boing +boink +cloink +rattle +clock +toc +clink +tuc diff --git a/kattis/problems/27_10_23/keylogger/2.in b/kattis/problems/27_10_23/keylogger/2.in new file mode 100644 index 0000000..6ccba45 --- /dev/null +++ b/kattis/problems/27_10_23/keylogger/2.in @@ -0,0 +1,15 @@ +14 +bump +tip +whack +bump +clock +clank +pong +boink +whack +pang +tip +tuc +tuc +clank diff --git a/kattis/problems/27_10_23/keylogger/3.in b/kattis/problems/27_10_23/keylogger/3.in new file mode 100644 index 0000000..797edb6 --- /dev/null +++ b/kattis/problems/27_10_23/keylogger/3.in @@ -0,0 +1,11 @@ +10 +dink +pong +clang +whack +bump +click +thumb +clank +pang +boing diff --git a/kattis/problems/27_10_23/keylogger/main.c b/kattis/problems/27_10_23/keylogger/main.c new file mode 100644 index 0000000..f29fcda --- /dev/null +++ b/kattis/problems/27_10_23/keylogger/main.c @@ -0,0 +1,133 @@ +#include +#include +#include +#include +#include + +#define MAX 100001 + + +// FIXME: Not passing all test cases + +bool caps = false; +bool shift = false; + +void toggleCaps() { + caps = !caps; +} + +char strokeToKey(char stroke[30]) { + char key = '-'; + if (strcmp(stroke, "clank") == 0) { + key = 'a'; + } else if (strcmp(stroke, "bong") == 0) { + key = 'b'; + } else if (strcmp(stroke, "click") == 0) { + key = 'c'; + } else if (strcmp(stroke, "tap") == 0) { + key = 'd'; + } else if (strcmp(stroke, "poing") == 0) { + key = 'e'; + } else if (strcmp(stroke, "clonk") == 0) { + key = 'f'; + } else if (strcmp(stroke, "clack") == 0) { + key = 'g'; + } else if (strcmp(stroke, "ping") == 0) { + key = 'h'; + } else if (strcmp(stroke, "tip") == 0) { + key = 'i'; + } else if (strcmp(stroke, "cloing") == 0) { + key = 'j'; + } else if (strcmp(stroke, "tic") == 0) { + key = 'k'; + } else if (strcmp(stroke, "cling") == 0) { + key = 'l'; + } else if (strcmp(stroke, "bing") == 0) { + key = 'm'; + } else if (strcmp(stroke, "pong") == 0) { + key = 'n'; + } else if (strcmp(stroke, "clang") == 0) { + key = 'o'; + } else if (strcmp(stroke, "pang") == 0) { + key = 'p'; + } else if (strcmp(stroke, "clong") == 0) { + key = 'q'; + } else if (strcmp(stroke, "tac") == 0) { + key = 'r'; + } else if (strcmp(stroke, "boing") == 0) { + key = 's'; + } else if (strcmp(stroke, "boink") == 0) { + key = 't'; + } else if (strcmp(stroke, "cloink") == 0) { + key = 'u'; + } else if (strcmp(stroke, "rattle") == 0) { + key = 'v'; + } else if (strcmp(stroke, "clock") == 0) { + key = 'w'; + } else if (strcmp(stroke, "toc") == 0) { + key = 'x'; + } else if (strcmp(stroke, "clink") == 0) { + key = 'y'; + } else if (strcmp(stroke, "tuc") == 0) { + key = 'z'; + } else if (strcmp(stroke, "whack") == 0) { + key = ' '; + } else if (strcmp(stroke, "pop") == 0) { + key = '%'; + } + + else if (strcmp(stroke, "bump") == 0) { + toggleCaps(); + key = '$'; + } else if (strcmp(stroke, "dink") == 0) { + shift = true; + key = '>'; + } else if (strcmp(stroke, "dink") == 0) { + shift = false; + key = '<'; + } + // printf("%s : %c\n", stroke, key); + return key; +} + +char upOrDown(char c) { + if ((!shift && caps) || (shift && !caps)) { + return toupper(c); + } + caps = false; + return c; +} + +void writeToArr(char sentence[MAX], char stroke[30], int *idx) { + char key = strokeToKey(stroke); + if ((key <= 'z' && key >= 'a') || key == ' ') { + sentence[*idx] = upOrDown(key); + *idx += 1; + } else if (key == '%') { + sentence[*idx] = '-'; + *idx -= 1; + } else { + return; + } +} + +void printArr(char sentence[MAX], int length) { + for (int i=0; i +#include +#include +#include +#include + +#define MAX 100001 + +caps = false; +shift = false; + +void toggleCaps() { + caps = !caps; +} + +char strokeToKey(char stroke[30]) { + char key = '-'; + if (strcmp(stroke, "clank") == 0) key = 'a'; + else if (strcmp(stroke, "bong") == 0) key = 'b'; + else if (strcmp(stroke, "click") == 0) key = 'c'; + else if (strcmp(stroke, "clack") == 0) key = 'd'; + else if (strcmp(stroke, "tap") == 0) key = 'e'; + else if (strcmp(stroke, "poing") == 0) key = 'f'; + else if (strcmp(stroke, "clonk") == 0) key = 'g'; + else if (strcmp(stroke, "clack") == 0) key = 'h'; + else if (strcmp(stroke, "ping") == 0) key = 'i'; + else if (strcmp(stroke, "tip") == 0) key = 'j'; + else if (strcmp(stroke, "cloing") == 0) key = 'k'; + else if (strcmp(stroke, "tic") == 0) key = 'l'; + else if (strcmp(stroke, "cling") == 0) key = 'm'; + else if (strcmp(stroke, "bing") == 0) key = 'n'; + else if (strcmp(stroke, "pong") == 0) key = 'o'; + else if (strcmp(stroke, "clang") == 0) key = 'p'; + else if (strcmp(stroke, "tac") == 0) key = 'q'; + else if (strcmp(stroke, "boing") == 0) key = 'r'; + else if (strcmp(stroke, "boink") == 0) key = 's'; + else if (strcmp(stroke, "cloinc") == 0) key = 't'; + else if (strcmp(stroke, "rattle") == 0) key = 'u'; + else if (strcmp(stroke, "squeal") == 0) key = 'v'; + else if (strcmp(stroke, "clock") == 0) key = 'w'; + else if (strcmp(stroke, "toc") == 0) key = 'x'; + else if (strcmp(stroke, "clink") == 0) key = 'y'; + else if (strcmp(stroke, "tuc") == 0) key = 'z'; + else if (strcmp(stroke, "whack") == 0) key = ' '; + else if (strcmp(stroke, "pop") == 0) key = '%'; + + else if (strcmp(stroke, "bump") == 0) { + toggleCaps(); + key = '$'; + } + else if (strcmp(stroke, "dink") == 0) { + shift = true; + key = '>'; + } + else if (strcmp(stroke, "dink") == 0) { + shift = false; + key = '<'; + } + +} + +char upOrDown(char c) { + if (shift || caps) return toupper(c); + return c; +} + +void writeToArr(char sentence[MAX], char stroke[30], int *idx) { + char key = strokeToKey(stroke); + if ((key <= 'z' && key >= 'a') || key == ' ') { + sentence[*idx] = upOrDown(key); + *idx++; + } else if (key == '%') { + sentence[*idx] = '-'; + *idx--; + } +} + +void printArr(char sentence[MAX], int length) { + for (int i=0; i +#include + +#define MAX 12 + +int rollProbability(int number) { + int sum = 0; + for (int i=1; i<=6; i++) { + for (int j=1; j<=6; j++) { + if (i+j == number) { + sum++; + } + } + } + return sum; +} + +int main(int argc, char **argv) { + int hotels; + int distances[MAX]; + + scanf("%d", &hotels); + + float sum = 1/6; + for (int i=0; i +#include + +#define MAX 12 + +int main(int argc, char **argv) { + int hotels; + int distances[MAX]; + + scanf("%d", &hotels); + + float sum = 0; + for (int i=0; i +#include + +#define MAX 100001 + +int main(int argc, char **argv) { + + int n; + scanf("%d", &n); + + int locations[MAX] = {0}; + + for (int i = 1; i <= n; ++i) { + scanf("%d", &locations[i]); + } + + int temp = 0; + for (int i = 1; i <= n; ++i) { + if (locations[i] == i) { + continue; + } + temp = locations[i]; + locations[i] = locations[temp]; + locations[temp] = temp; + + + } + + return 0; +} \ No newline at end of file diff --git a/kattis/problems/27_10_23/rodunarrugl/main.c.orig b/kattis/problems/27_10_23/rodunarrugl/main.c.orig new file mode 100644 index 0000000..a45759b --- /dev/null +++ b/kattis/problems/27_10_23/rodunarrugl/main.c.orig @@ -0,0 +1,18 @@ +#include +#include + +#define MAX 100001 + + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + int locations[MAX] = {0}; + for (int i = 0; i < n; ++i) { + scanf("%d", &locations[i]); + } + for (int i = 0; i < n; ++i) { + printf("%d ", locations[i]); + } + return 0; +} \ No newline at end of file diff --git a/kattis/problems/27_10_23/rodunarrugl/program b/kattis/problems/27_10_23/rodunarrugl/program new file mode 100755 index 0000000..47c406c Binary files /dev/null and b/kattis/problems/27_10_23/rodunarrugl/program differ diff --git a/kattis/problems/27_10_23/veidurhedar/main.c b/kattis/problems/27_10_23/veidurhedar/main.c new file mode 100644 index 0000000..c68f9d1 --- /dev/null +++ b/kattis/problems/27_10_23/veidurhedar/main.c @@ -0,0 +1,22 @@ +#include +#include + +#define MAX 1000 + +int main(int argc, char **argv) { + int max; + int lines; + scanf("%d %d", &max, &lines); + + for (int i=0; i= max) { + printf("%s opin", name); + } else { + printf("%s lokud", name); + } + printf("\n"); + } +} \ No newline at end of file diff --git a/kattis/problems/27_10_23/veidurhedar/program b/kattis/problems/27_10_23/veidurhedar/program new file mode 100755 index 0000000..7f8075d Binary files /dev/null and b/kattis/problems/27_10_23/veidurhedar/program differ diff --git a/kattis/problems/old/aldursrodun/1.in b/kattis/problems/old/aldursrodun/1.in new file mode 100644 index 0000000..6caa12a --- /dev/null +++ b/kattis/problems/old/aldursrodun/1.in @@ -0,0 +1,2 @@ +7 +5 10 7 15 14 3 2 diff --git a/kattis/problems/old/aldursrodun/2.in b/kattis/problems/old/aldursrodun/2.in new file mode 100644 index 0000000..6c5a39f --- /dev/null +++ b/kattis/problems/old/aldursrodun/2.in @@ -0,0 +1,2 @@ +3 +2 3 6 \ No newline at end of file diff --git a/kattis/problems/old/aldursrodun/3.in b/kattis/problems/old/aldursrodun/3.in new file mode 100644 index 0000000..c35c6db --- /dev/null +++ b/kattis/problems/old/aldursrodun/3.in @@ -0,0 +1,2 @@ +4 +2 5 7 10 \ No newline at end of file diff --git a/kattis/problems/old/aldursrodun/aldursrodun b/kattis/problems/old/aldursrodun/aldursrodun new file mode 100755 index 0000000..98e3b19 Binary files /dev/null and b/kattis/problems/old/aldursrodun/aldursrodun differ diff --git a/kattis/problems/old/aldursrodun/aldursrodun.c b/kattis/problems/old/aldursrodun/aldursrodun.c new file mode 100644 index 0000000..a5c54d7 --- /dev/null +++ b/kattis/problems/old/aldursrodun/aldursrodun.c @@ -0,0 +1,36 @@ +#include +#include + +void print_array(int *arr, int n) { + for (int i = 0; i < n; i++) { + printf("%d ", arr[i]); + } + printf("\n"); +} + +int main(int argc, char **argv) { + int n; + scanf("%d", &n); + + int arr[10]; + for (int i = 0; i < 10; i++) { + scanf("%d", &arr[i]); + } + + for (int i=0; i arr[j]) { + int tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + } + } + } + + print_array(arr, n); + + int replaced[10]; + for (int i=0; i +#include + +int gcd(int a, int b) { + while (b) { + int temp = a % b; + a = b; + b = temp; + } + return a; +} + +int compare(const void *a, const void *b) { + return (*(int*)a - *(int*)b); +} + +int main() { + int n; + scanf("%d", &n); + + int ages[n]; + for (int i = 0; i < n; i++) { + scanf("%d", &ages[i]); + } + + // Sort the ages in ascending order. + qsort(ages, n, sizeof(int), compare); + + for (int i = 1; i < n; i++) { + if (gcd(ages[i], ages[i-1]) == 1) { + int swapped = 0; + for (int j = i + 1; j < n; j++) { + if (gcd(ages[j], ages[i-1]) > 1) { + // Swap ages[i] and ages[j]. + int temp = ages[i]; + ages[i] = ages[j]; + ages[j] = temp; + swapped = 1; + break; + } + } + + if (!swapped) { + printf("Neibb\n"); + return 0; + } + } + } + + for (int i = 0; i < n; i++) { + printf("%d ", ages[i]); + } + + return 0; +} diff --git a/kattis/problems/old/aliennumbers/1.in b/kattis/problems/old/aliennumbers/1.in new file mode 100644 index 0000000..09d5dfa --- /dev/null +++ b/kattis/problems/old/aliennumbers/1.in @@ -0,0 +1,5 @@ +4 +9 0123456789 oF8 +Foo oF8 0123456789 +13 0123456789abcdef 01 +CODE O!CDE? A?JM!. diff --git a/kattis/problems/old/aliennumbers/main.c b/kattis/problems/old/aliennumbers/main.c new file mode 100644 index 0000000..d9b7130 --- /dev/null +++ b/kattis/problems/old/aliennumbers/main.c @@ -0,0 +1,37 @@ +#include +#include +#include + +int main(int argc, char **argv) { + int t; + scanf("%d", &t); + + int printed = 0; + for (int i=0; i 0: + + + +def main(): + cases:int = int(input()) + + for i in range(cases): + word, src, dst = input().split(" ") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/kattis/problems/old/bela/1.in b/kattis/problems/old/bela/1.in new file mode 100644 index 0000000..3051fb7 --- /dev/null +++ b/kattis/problems/old/bela/1.in @@ -0,0 +1,9 @@ +2 S +TH +9C +KS +QS +JS +TD +AD +JH \ No newline at end of file diff --git a/kattis/problems/old/bela/2.in b/kattis/problems/old/bela/2.in new file mode 100644 index 0000000..4a9d7a4 --- /dev/null +++ b/kattis/problems/old/bela/2.in @@ -0,0 +1,17 @@ +4 H +AH +KH +QH +JH +TH +9H +8H +7H +AS +KS +QS +JS +TS +9S +8S +7S diff --git a/kattis/problems/old/bela/main.c b/kattis/problems/old/bela/main.c new file mode 100644 index 0000000..a1e17c4 --- /dev/null +++ b/kattis/problems/old/bela/main.c @@ -0,0 +1,51 @@ +#include +#include + +int main(int argc, char **argv) { + int hands; + char dominant; + scanf("%d %c", &hands, &dominant); + + int points = 0; + + for (int i=0; i +#include +#include + +void move(char d, int s, int w, int l, int *rx, int *ry, int *x, int *y) { + if (d == 'u') { + *ry += s; + if (*y + s < l) { + *y += s; + } else { + *y = l-1; + } + } else if (d == 'd') { + *ry -= s; + if (*y - s >= 0) { + *y -= s; + } else { + *y = 0; + // WOW. WOW. WOW. WOW. WOW. + } + } else if (d == 'l') { + *rx -= s; + if (*x - s >= 0) { + *x -= s; + } else if (*x - s < 0) { + *x = 0; + } + } else if (d == 'r') { + *rx += s; + if (*x + s < w) { + *x += s; + } else { + *x = w-1; + } + } +} + +int main(int argc, char **argv) { + int w = -1, l = -1; + int printed = 0; + while (1) { + // Handle room size + scanf("%d %d", &w, &l); + if (w == 0 && l == 0) { + return 0; + } + // Initialize actual and robot coords + int x = 0, y = 0, rx = 0, ry = 0; + int moves; + // Do moves + scanf("%d", &moves); + for (int i=0; i +#include +#include + + + +void move(char d, int s, int w, int l, int *rx, int *ry, int *x, int *y) { + if (d == 'u') { + *ry += s; + if (*y + s < l) { + *y += s; + } else { + *y = l-1; + } + } else if (d == 'd') { + *ry -= s; + if (*y - s >= 0) { + *y -= s; + } else { + *x = 0; + } + } else if (d == 'l') { + *rx -= s; + if (*x - s >= 0) { + *x -= s; + } else if (*x - s < 0) { + *x = 0; + } + } else if (d == 'r') { + *rx += s; + if (*x + s < w) { + *x += s; + } else { + *x = w-1; + } + } +} + +int main(int argc, char **argv) { + int w = -1, l = -1; + int printed = 0; + while (1) { + // Handle room size + scanf("%d %d", &w, &l); + if (w == 0 && l == 0) { + return 0; + } + // Initialize actual and robot coords + int x = 0, y = 0, rx = 0, ry = 0; + int moves; + // Do moves + scanf("%d", &moves); + for (int i=0; i 0) { + move(mx-1, my, w, h); //Left + } + if (my > 0) { + move(mx, my-1, w, h); // Down + } + + return ; +} + +int main(int argc, char **argv) { + int w, h; + scanf("%d %d", &w, &h); + int px, py; + + // Populate map + for (int i=0; i +#include +#include +#include + +char map[100][100]; +int visited[100][100]; +int counter = 0; + +bool isDrafty(int x, int y) { + // Determines whether there's a trap in the immediate vicinity of the square we're standing on + return (map[y][x] == '.' && (map[y+1][x] == 'T' || map[y-1][x] == 'T' || map[y][x+1] == 'T' || map[y][x-1] == 'T')); +} + + +void move(int mx, int my, int w, int h) { + // Moves our x, y by 1 until a wall is found or becomes drafty + char c = map[my][mx]; + + // Avoid visiting visited nodes(endless loop occurs) + if (visited[my][mx]) { + return ; + } + visited[my][mx] = true; + + // Stop if drafty or wall. Increment counter if gold is found. + if (c == '#') { + return ; + } + + // printf("x: %d, y: %d, c: %c\n", mx, my, c); + + if (c == 'G') { + counter++; + } + + if(c == 'T' || isDrafty(mx, my)){ + return ; + } + + // Move (as long as we're not stepping out of bounds) + if (mx < w) { + move(mx+1, my, w, h); //Right + } + if (my < h) { + move(mx, my+1, w, h); // Up + } + if (mx > 0) { + move(mx-1, my, w, h); //Left + } + if (my > 0) { + move(mx, my-1, w, h); // Down + } + + return ; +} + +int main(int argc, char **argv) { + int w, h; + scanf("%d %d", &w, &h); + int px, py; + + // Populate map + for (int i=0; i +#include + +int main(int argc, char **argv) { + int problems = 0; + while (1) { + + + int start; + scanf("%d", &start); + char c; + scanf("%c", &c); + if (c == '-') { + int end; + scanf("%d", &end); + problems += end - start + 1; + char x = getchar(); + + if (x == ';') continue; + else break; + } else if (c == ';') { + problems += 1; + continue; + } else { + problems += 1; + break; + } + } + printf("%d\n", problems); +} \ No newline at end of file diff --git a/kattis/problems/old/smil/main.c b/kattis/problems/old/smil/main.c new file mode 100644 index 0000000..cf31b4a --- /dev/null +++ b/kattis/problems/old/smil/main.c @@ -0,0 +1,27 @@ +#include +#include + +int main(int argc, char **argv) { + char c; + int idx = -1; + int counter = 0; + int nose = -1; + + while ((c = getchar()) != '\n') { + // Eyes + if (c == ':' || c == ';') { + idx = counter; + } else if (c == '-' && (idx != -1)) { + nose = 1; + } else if ((c == ')' && (idx != -1)) ||(c == ')' && nose && (idx != -1)) ) { + printf("%d\n", idx); + idx = -1; + nose = 0; + } else { + idx = -1; + nose = 0; + } + counter++; + } + return 0; +} diff --git a/kattis/problems/old/zamka/main.c b/kattis/problems/old/zamka/main.c new file mode 100644 index 0000000..d36b671 --- /dev/null +++ b/kattis/problems/old/zamka/main.c @@ -0,0 +1,42 @@ +#include +#include +#include + +bool sumEquals(int x, int y) { + int sum = 0; + while (x != 0) { + sum += x % 10; + x /= 10; + } + return sum == y; +} + +int main(int argc, char **argv) { + int l, d, x; + scanf("%d", &l); + scanf("%d", &d); + scanf("%d", &x); + + int n = 0; + for (int i=l; i<=d; i++) { + if (sumEquals(i, x)) { + n = i; + break; + } + + } + + int m = 0; + for (int i=d; i>=l; i--) { + + if (sumEquals(i, x)) { + m = i; + break; + } + } + + printf("%d\n%d\n", n,m); + + + return 0; +} \ No newline at end of file