Skip to content

Instantly share code, notes, and snippets.

@sklivvz
sklivvz / KillerSudoku.cs
Created October 20, 2022 11:25
Efficient killer/sandwich sudoku calculator in one line of c#
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 }} :
@sklivvz
sklivvz / sheets.json
Created November 26, 2021 23:57
JSON object exported by the 'Sheets to JSON' Google Sheets addon.
{}
// scrape talent ids from http://www.wowhead.com/talents
copy(Array.from(document.getElementsByClassName("listview-cleartext")).map((x)=>{return{name: x.innerText, id:x.getAttribute("href").split("=")[1]}}))
@sklivvz
sklivvz / talent_ids.json
Last active March 31, 2018 11:55
All WoW talent ids and names
[
{
"name": "A Murder of Crows",
"id": "131894"
},
{
"name": "A Murder of Crows",
"id": "206505"
},
{
@sklivvz
sklivvz / talents.en-gb.json
Created March 31, 2018 09:59
All WoW talents in Json format (en-gb)
[
{
"class": "warrior",
"specs": [
{
"spec": "arms",
"talents": [
{
"name": "Dauntless",
"description": "Your abilities cost 10% less Rage."
// use in console on https://worldofwarcraft.com/en-gb/game/talent-calculator
Array.from(document.querySelectorAll('[data-group="TalentCalculator-class"]')).map((cls)=>{
return { class: cls.getAttribute("name"), specs: Array.from(cls.querySelectorAll('[data-group="TalentCalculator-specs"]')).map((spc)=>{
return { spec: spc.getAttribute("name").split("/")[1], talents: Array.from(spc.getElementsByClassName("Talent")).map((t)=>{
return { name: t.getElementsByClassName("Talent-name")[0].childNodes[0].nodeValue, description: t.getElementsByClassName("Talent-desc")[0].innerText };
})};
})};
});
@sklivvz
sklivvz / rover.il
Last active May 18, 2016 22:11
Solving the rover problem in IL
.assembly extern mscorlib {}
.assembly rover
{
.ver 1:0:1:0
}
// to compile, open visualstudio cmd, "ilasm rover.il"
.module rover.exe
.method static void main() cil managed
void Main()
{
var m = new int[] { 0, 1, 0, -1, 0 };
var inputs = @"5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM".Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
for (int i = 1; i < inputs.Length; i += 2)
{
@sklivvz
sklivvz / patch-info.md
Last active August 29, 2015 14:12
Ask Mr. Robot patch to fix the broken GetCurrentRegion() behavior
void Main()
{
CultureInfo
.GetCultures(CultureTypes.AllCultures)
.Select(x =>
new string[]{x.IetfLanguageTag, x.EnglishName, x.NativeName,x.LCID.ToString()}
.Concat(z=>"<td>"+z+"</td>")
)
.Select(x => "<tr>"+x+"</tr>")
.Each(Console.WriteLine);