Skip to content

Commit 83435a2

Browse files
authored
Merge pull request devcordde#1 from devcordde/master
Update fork
2 parents 2318e1a + a43422a commit 83435a2

File tree

20 files changed

+583
-36
lines changed

20 files changed

+583
-36
lines changed

Day-01/typescript/.gitignore

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

Day-01/typescript/WeiiswurstDev/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Day-01/typescript/WeiiswurstDev/README.md

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

Day-01/typescript/WeiiswurstDev/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
// PLEASE READ THE README.md IN MY SHARED FOLDER!
3+
14
import fs from 'fs'
25
import { EOL } from 'os'
36

Day-01/typescript/WeiiswurstDev/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import java.io.File
2+
3+
fun main() {
4+
val file = File("./src/main/kotlin/day-02-input")
5+
6+
val inputArray: List<String> = file.bufferedReader().readLines()
7+
8+
var counter = 0
9+
10+
for(i in inputArray.indices) {
11+
val split: List<String> = inputArray[i].split(" ")
12+
13+
val numbers = split[0]
14+
val letter = split[1].replace(":", "")
15+
val password = split[2]
16+
17+
var charCounter = 0
18+
for(char in password.subSequence(password.indices)) {
19+
if(char == letter[0])
20+
charCounter++
21+
}
22+
23+
if(charCounter <= numbers.split("-")[1].toInt() && charCounter >= numbers.split("-")[0].toInt())
24+
counter++
25+
}
26+
27+
println("PartOne:")
28+
println(counter)
29+
30+
counter = 0
31+
for(i in inputArray.indices) {
32+
val split: List<String> = inputArray[i].split(" ")
33+
34+
val numbers = split[0]
35+
val letter = split[1].replace(":", "")
36+
val password = split[2]
37+
38+
val firstNumber = numbers.split("-")[0].toInt()
39+
val secondNumber = numbers.split("-")[1].toInt()
40+
41+
if (password[firstNumber -1] == letter[0]) {
42+
if (password[secondNumber -1] != letter[0]) {
43+
counter++
44+
}
45+
} else {
46+
if (password[secondNumber -1] == letter[0]) {
47+
counter++
48+
}
49+
}
50+
}
51+
println("PartTwo:")
52+
println(counter)
53+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
// Please read the README.md in my shared folder!
3+
4+
import fs from 'fs'
5+
import { EOL } from 'os'
6+
7+
const input = fs.readFileSync("input.txt").toString().split(EOL);
8+
9+
let validEntries = 0;
10+
let part2validEntries = 0;
11+
12+
for(let entry of input) {
13+
let split = entry.split(" ")
14+
let amounts = split[0].split("-").map(num=>Number.parseInt(num))
15+
let limitedChar = split[1].substring(0,1)
16+
let pass = split[2]
17+
18+
let actualAmount = 0;
19+
for(let char of pass) {
20+
if(limitedChar == char) actualAmount++;
21+
}
22+
if(actualAmount >= amounts[0] && actualAmount <= amounts[1]) {
23+
validEntries++;
24+
}
25+
26+
let correctIndexes = 0;
27+
28+
for(let index of amounts) {
29+
let char = pass[index-1];
30+
if(char == limitedChar)
31+
correctIndexes++;
32+
}
33+
if(correctIndexes == 1) part2validEntries++;
34+
}
35+
36+
console.log("Part 1",validEntries)
37+
console.log("Part 2",part2validEntries)

Day-03/c/JohnnyJayJay/Day03.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Read my README in shared/JohnnyJayJay
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include "../../../shared/JohnnyJayJay/aoc.h"
6+
7+
int traverse(u_int32_t* levels, int lines, int width, int x_step, int y_step) {
8+
int x_pos = 0;
9+
int tree_count = 0;
10+
for (int i = 0; i < lines; i += y_step) {
11+
u_int32_t level = levels[i];
12+
if ((level >> (width - 1 - x_pos)) & ((u_int32_t) 1)) {
13+
tree_count++;
14+
}
15+
x_pos = (x_pos + x_step) % width;
16+
}
17+
return tree_count;
18+
}
19+
20+
int main(int argc, char** argv) {
21+
FILE* file = fopen(argv[1], "r");
22+
int lines = count_lines(file);
23+
int width = chars_until(file, '\n');
24+
u_int32_t* levels = malloc(sizeof(u_int32_t) * lines);
25+
for (int i = 0; i < lines; i++) {
26+
u_int32_t level = 0;
27+
char spot;
28+
while ((spot = fgetc(file)) != '\n' && spot != EOF) {
29+
level <<= 1;
30+
level |= spot == '#';
31+
}
32+
levels[i] = level;
33+
}
34+
35+
u_int64_t first = traverse(levels, lines, width, 3, 1);
36+
printf("You encounter %lu trees the first slope.\n", first);
37+
u_int64_t second = traverse(levels, lines, width, 1, 1);
38+
u_int64_t third = traverse(levels, lines, width, 5, 1);
39+
u_int64_t fourth = traverse(levels, lines, width, 7, 1);
40+
u_int64_t fiveth = traverse(levels, lines, width, 1, 2);
41+
printf("The trees on all slopes multiplied together: %lu\n", first * second * third * fourth * fiveth);
42+
43+
}

Day-03/kotlin/NyCodeGHG/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.txt

Day-03/kotlin/NyCodeGHG/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Kotlin Solution
2+
I recommend to use [kscript](https://github.com/holgerbrandl/kscript) by [@holgerbrandl](https://github.com/holgerbrandl) to execute the script file.

0 commit comments

Comments
 (0)