Last active
December 3, 2022 11:47
-
-
Save aloisdg/839b972d7dade03c7fd910157001eb1e to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
using System.Linq; | |
public class Program | |
{ | |
public static (string, string) Half(string s) => (s[..(s.Length / 2)], s[(s.Length / 2)..]); | |
public static int Prioritize(char c) => c - (char.IsLower(c) ? 'a' : ('A' - 26)) + 1; | |
public static void Main() | |
{ | |
@"vJrwpWtwJgWrhcsFMMfFFhFp | |
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL | |
PmmdzqPrVvPwwTWBwg | |
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn | |
ttgJtRGJQctTZtZT | |
CrZsJsPPZsGzwwsLwLmpwMDw" | |
.Split('\n') | |
.Select(Half) | |
.Select(t => t.Item1.Intersect(t.Item2).First()) | |
.Sum(Prioritize) | |
.Dump(); | |
} | |
} |
This file contains hidden or 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; | |
using System.Linq; | |
public class Program | |
{ | |
public static int Prioritize(char c) => c - (char.IsLower(c) ? 'a' : ('A' - 26)) + 1; | |
public static void Main() | |
{ | |
@"vJrwpWtwJgWrhcsFMMfFFhFp | |
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL | |
PmmdzqPrVvPwwTWBwg | |
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn | |
ttgJtRGJQctTZtZT | |
CrZsJsPPZsGzwwsLwLmpwMDw" | |
.Split('\n') | |
.Chunk(3) | |
.SelectMany(a => a[0].Intersect(a[1]).Intersect(a[2])) | |
.Sum(Prioritize) | |
.Dump(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment