-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay 1 Puzzle 1.cs
45 lines (39 loc) · 1.37 KB
/
Day 1 Puzzle 1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace Day1
{
class Program
{
static void Main(string[] args)
{
// okay, what are the C# naming conventions (specifically re: Pascal or camel case) again...?
int[] input = { 1721, 979, 366, 299, 675, 1456 };
MultiplyNumbers(ChooseNumbers(input));
}
public static int[] ChooseNumbers(int[] InputArray)
{
int[] ResultArray = { 0, 0 };
for (int i = 0; i < InputArray.Length; i++)
{
for (int j = 0; j < InputArray.Length; j++)
{
if (i != j) // this is only necessary in the event that the input contains one instance of 1010
{
if (InputArray[i] + InputArray[j] == 2020)
{
ResultArray[0] = InputArray[i];
ResultArray[1] = InputArray[j];
}
}
}
}
Console.WriteLine(ResultArray[0]);
Console.WriteLine(ResultArray[1]);
return ResultArray;
}
public static int MultiplyNumbers(int[] ChosenNumbers)
{
Console.WriteLine(ChosenNumbers[0] * ChosenNumbers[1]);
return ChosenNumbers[0] * ChosenNumbers[1];
}
}
}