Skip to content

Commit fe37ea7

Browse files
authored
Merge pull request #19 from deckelmouck/2024
2024
2 parents 72408a3 + 13caea1 commit fe37ea7

File tree

24 files changed

+900
-5037
lines changed

24 files changed

+900
-5037
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "input"]
2+
path = input
3+
url = https://github.com/deckelmouck/adventofcode-input

2019/Day01/201901_1.txt

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

2019/Day01/Solution.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
3+
namespace adventofcode.Year2019.Day01;
4+
5+
public class Solution : BaseSolution, ISolver
6+
{
7+
public void SolvePart1()
8+
{
9+
string line;
10+
//int counter = 0;
11+
int neededfuel = 0;
12+
// string filepath = Environment.CurrentDirectory + @"\2019\Day01\201901_1.txt";
13+
//string filepath = Path.Combine(Environment.CurrentDirectory, "2019", "Day01", "201901_1.txt");
14+
//string filepath = Path.Combine(Environment.CurrentDirectory, GetYear(), $"Day{GetDay()}", "input.txt");
15+
string filepath = GetInputFilePath("201901_1.txt");
16+
17+
Console.WriteLine(filepath);
18+
19+
if(System.IO.File.Exists(filepath))
20+
{
21+
System.IO.StreamReader file = new System.IO.StreamReader(filepath);
22+
23+
while((line = file.ReadLine()) != null)
24+
{
25+
int mass = Convert.ToInt32(line);
26+
int fuel = mass / 3 - 2;
27+
28+
neededfuel = neededfuel + fuel;
29+
//Console.WriteLine(line);
30+
//counter++;
31+
}
32+
//Console.WriteLine("{0} lines read.", counter.ToString());
33+
Console.WriteLine("we need {0} fuel.", neededfuel);
34+
}
35+
}
36+
37+
public void SolvePart2()
38+
{
39+
string line;
40+
//int counter = 0;
41+
int neededfuel = 0;
42+
//string filepath = Environment.CurrentDirectory + @"\2019\Day01\201901_1.txt";
43+
string filepath = System.IO.Path.Combine(Environment.CurrentDirectory, "2019", "Day01", "201901_1.txt");
44+
45+
Console.WriteLine(filepath);
46+
47+
if(System.IO.File.Exists(filepath))
48+
{
49+
System.IO.StreamReader file = new System.IO.StreamReader(filepath);
50+
51+
while((line = file.ReadLine()) != null)
52+
{
53+
int mass = Convert.ToInt32(line);
54+
int fuel = mass / 3 - 2;
55+
int fueltotal = fuel;
56+
57+
while(fuel / 3 - 2 > 0)
58+
{
59+
fuel = fuel / 3 - 2;
60+
fueltotal = fueltotal + fuel;
61+
}
62+
63+
neededfuel = neededfuel + fueltotal;
64+
65+
//Console.WriteLine(line);
66+
//counter++;
67+
}
68+
//Console.WriteLine("{0} lines read.", counter.ToString());
69+
Console.WriteLine("we need {0} fuel.", neededfuel);
70+
}
71+
}
72+
}

2019/Day02/201902_1.txt

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

2019/Day03/201903_1.txt

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

2019/Day04/201904_1.txt

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

2021/Day01/input.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)