Skip to content

Commit

Permalink
Merge pull request #19 from deckelmouck/2024
Browse files Browse the repository at this point in the history
2024
  • Loading branch information
deckelmouck authored Dec 3, 2024
2 parents 72408a3 + 13caea1 commit fe37ea7
Show file tree
Hide file tree
Showing 24 changed files with 900 additions and 5,037 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "input"]
path = input
url = https://github.com/deckelmouck/adventofcode-input
100 changes: 0 additions & 100 deletions 2019/Day01/201901_1.txt

This file was deleted.

72 changes: 72 additions & 0 deletions 2019/Day01/Solution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;

namespace adventofcode.Year2019.Day01;

public class Solution : BaseSolution, ISolver
{
public void SolvePart1()
{
string line;
//int counter = 0;
int neededfuel = 0;
// string filepath = Environment.CurrentDirectory + @"\2019\Day01\201901_1.txt";
//string filepath = Path.Combine(Environment.CurrentDirectory, "2019", "Day01", "201901_1.txt");
//string filepath = Path.Combine(Environment.CurrentDirectory, GetYear(), $"Day{GetDay()}", "input.txt");
string filepath = GetInputFilePath("201901_1.txt");

Console.WriteLine(filepath);

if(System.IO.File.Exists(filepath))
{
System.IO.StreamReader file = new System.IO.StreamReader(filepath);

while((line = file.ReadLine()) != null)
{
int mass = Convert.ToInt32(line);
int fuel = mass / 3 - 2;

neededfuel = neededfuel + fuel;
//Console.WriteLine(line);
//counter++;
}
//Console.WriteLine("{0} lines read.", counter.ToString());
Console.WriteLine("we need {0} fuel.", neededfuel);
}
}

public void SolvePart2()
{
string line;
//int counter = 0;
int neededfuel = 0;
//string filepath = Environment.CurrentDirectory + @"\2019\Day01\201901_1.txt";
string filepath = System.IO.Path.Combine(Environment.CurrentDirectory, "2019", "Day01", "201901_1.txt");

Console.WriteLine(filepath);

if(System.IO.File.Exists(filepath))
{
System.IO.StreamReader file = new System.IO.StreamReader(filepath);

while((line = file.ReadLine()) != null)
{
int mass = Convert.ToInt32(line);
int fuel = mass / 3 - 2;
int fueltotal = fuel;

while(fuel / 3 - 2 > 0)
{
fuel = fuel / 3 - 2;
fueltotal = fueltotal + fuel;
}

neededfuel = neededfuel + fueltotal;

//Console.WriteLine(line);
//counter++;
}
//Console.WriteLine("{0} lines read.", counter.ToString());
Console.WriteLine("we need {0} fuel.", neededfuel);
}
}
}
1 change: 0 additions & 1 deletion 2019/Day02/201902_1.txt

This file was deleted.

2 changes: 0 additions & 2 deletions 2019/Day03/201903_1.txt

This file was deleted.

1 change: 0 additions & 1 deletion 2019/Day04/201904_1.txt

This file was deleted.

Empty file removed 2021/Day01/input.txt
Empty file.
Loading

0 comments on commit fe37ea7

Please sign in to comment.