Created
October 20, 2022 11:25
-
-
Save sklivvz/a611ee9bbb9a6093a73035493aaa81b0 to your computer and use it in GitHub Desktop.
Efficient killer/sandwich sudoku calculator in one line of c#
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 x = new List<int>{1,2,3,4,5,6,7,8,9}; | |
Killer(x,6).Dump(); | |
} | |
public static List<List<int>> Killer(List<int> alphabet, int target) => | |
alphabet.Where(x=> x <= target).SelectMany(letter=> | |
(letter == target) ? | |
new List<List<int>> { new List<int> { letter }} : | |
Killer(alphabet.Where(x => x > letter).ToList(), target - letter) | |
.Select(s => s.Prepend(letter).ToList()) | |
).ToList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment