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
var src = (from l in GetInput().Take(2) | |
let parts = l.Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries) | |
select new | |
{ | |
Sequences = parts.Where((c, i) => i % 2 != 0).Select(x=>GetAbba(x)).Where(y=>y!=null), | |
Bracketed = parts.Where((c, i) => i % 2 == 0).Select(x=>GetAbba(x)).Where(y=>y!=null) | |
} |
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 string B() | |
{return GetInput().Split(new[]{Environment.NewLine},StringSplitOptions.None).Count(s=>{var split=s.Split(new[]{'[',']'},StringSplitOptions.None);var sequences=split.Where((c,i)=>i%2==0).ToArray();var bracketed=split.Where((c,i)=>i%2!=0).ToArray();foreach(var sq in sequences) | |
{for(var i=0;i<sq.Length-2;i++) | |
{if(sq[i]!=sq[i+2]||sq[i]==sq[i+1])continue;if(bracketed.Any(x=>x.Contains(string.Format("{1}{0}{1}",sq[i],sq[i+1]))))return true;}} | |
return false;}).ToString();} |
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
private void MakeMove(Move move) | |
{ | |
this.Apply(move); | |
_state.Push(move); | |
if (this.IsValid()) | |
{ | |
var sc = this.GetStateCode(); |
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
4 -> 3 : HM | |
3 -> 4 : LG,HG | |
4 -> 3 : HG | |
3 -> 4 : HG,HM | |
4 -> 3 : HM,LM | |
3 -> 4 : HM | |
4 -> 3 : LG,HG | |
3 -> 4 : HG | |
2 -> 3 : HG,HM | |
3 -> 2 : HG |
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 enum ElementType | |
{ | |
Generator = 0, | |
MicroChip = 1, | |
} | |
public class Move | |
{ | |
public Component[] Components { get; set; } | |
public Floor SourceFloor { get; set; } |
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 AoC_20161302 | |
{ | |
private int _favouriteNumber; | |
SortedDictionary<Tuple<int, int>, char> Maze = new SortedDictionary<Tuple<int, int>, char>(); | |
public AoC_20161302(int fav) | |
{ | |
_favouriteNumber = fav; | |
} |
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
class AoC20161402 | |
{ | |
string input = @"zpqevtbw"; | |
MD5 md5 = MD5.Create(); | |
List<string> hashes = new List<string>(); | |
public string ToHex(byte[] bytes) | |
{ |
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
class AoC20161501 | |
{ | |
public Tuple<int, int>[] Dials { get; private set; } | |
public AoC20161501() | |
{ | |
Dials = new[] { | |
Tuple.Create(13,11), | |
Tuple.Create(5,0), |
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 Elf | |
{ | |
public string Name { get; set; } | |
public int Presents { get; set; } | |
} | |
int numberOfElves = 3017957; | |
void Main() |
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
Regex regex = new Regex(@"(letter|positions|through|position of letter|position|right|left)\s(\w)"); | |
void Process(string instruction) | |
{ | |
var parts = instruction.Split(new[] { ' ' }, 2); | |
MatchCollection matches = regex.Matches(parts[1]); | |
var values = (from Match m in matches | |
select m.Groups[1].Value.Contains("letter") ? password.IndexOf(m.Groups[2].Value[0]) : Int32.Parse(m.Groups[2].Value) |