This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
string dict = @"C:\Users\Trinitek\Downloads\hunspell-en_US-2020.12.07\en_US.dic"; | |
var words = File.ReadLines(dict) | |
.Skip(1) | |
.Select(l => string.Concat(l.ToLower().TakeWhile(c => c != '/'))) | |
.Where(l => l.Length == 5) | |
.ToList(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var measurements = Input.Trim().Split("\n").Select(s => int.Parse(s)); | |
//measurements.Take(5).Dump(); | |
//GetDeltas(measurements).Take(5).Dump(); | |
var deltas = GetDeltas(measurements); | |
deltas.Count(d => d >= 0).Dump(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var masses = Input.Split("\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(i => int.Parse(i)); | |
masses.Sum(m => GetRequiredFuel(m)).Dump(); | |
} | |
int GetRequiredFuel(int mass) | |
{ | |
int fuelMass = (mass / 3) - 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
IList<Adapter> GetAdapters(string input) | |
{ | |
var parsedAdapters = input | |
.Split("\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) | |
.Select(i => new Adapter(int.Parse(i))) | |
.OrderBy(a => a.Rating); | |
var adapters = parsedAdapters.Append(new Adapter(parsedAdapters.Last().Max)).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var lines = Input.Trim().Split("\n").Select(l => l.Trim()); | |
int checksum = 0; | |
foreach (var line in lines) | |
{ | |
var row = Row.Parse(line); | |
//row.cells.Dump(); | |
//checksum += row.Difference; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EnumToBooleanConverter : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |
{ | |
if (Enum.IsDefined(value.GetType(), value) == false) | |
{ | |
Debug.WriteLine("{0}: {1}: {2}: Value not defined in enum. Fallback to UnsetValue. {3}, {4}", nameof(EnumToBooleanConverter), GetHashCode(), nameof(Convert), value, value.GetType()); | |
return DependencyProperty.UnsetValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[STAThread] | |
static void Main(string[] args) | |
{ | |
while(true) | |
{ | |
Console.WriteLine("ID?"); | |
var id = Console.ReadLine(); | |
Console.WriteLine(Decrement(id)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string BytesAsString(byte[] input) | |
{ | |
var sb = new StringBuilder(); | |
sb.Append("{\n "); | |
int i; | |
for (i = 0; i < input.Length; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace AdventOfCode2017 | |
{ | |
public static class Day3 | |
{ | |
public static string GetSolution() | |
{ | |
int input = 277678; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* | |
* Here, we define a structure that groups 2 chars together as an | |
* addressable unit. | |
* | |
* Due to the nature of the way x86 processors copy multi-byte values | |
* to and from memory (this trait is known as endianness), the high | |
* and low bytes are flipped here in this structure. The x86 | |
* architecture is a "little-endian" architecture, which means that |
NewerOlder