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
// Define our helper functions | |
// rotates the box 90 degrees ccw | |
turn:{[box] flip reverse each box} | |
// returns indices of first available nulls in box (top to bottom) | |
fni:{[box] 1 (where i@)\ first where any each i:null box} | |
// fills first nulls in the box with first numbers in the line | |
ffn:{[box;line;indices] .[box; indices; :; count[indices]#line]} |
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
// Generate Test Senate | |
PARTIES:"DR"; | |
partyDict:"DR"!("Dire";"Radiant"); | |
genSenate:{[x] x?PARTIES}; | |
// Utility functions | |
// If one party controls 2/3 (2:1 ratio) or more of the senate, they will win | |
// This function will compare the party counts | |
// if one has super majority, it will return the party name |
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
// initialize word list | |
wordz:system "curl http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"; | |
wordz:wordz where all (5=count each wordz;all each wordz in .Q.a); | |
// create base word table | |
w:([]word:wordz;I:wordz[;0];II:wordz[;1];III:wordz[;2];IV:wordz[;3];V:wordz[;4]); | |
// generic wordzScore function | |
// x - words table | |
// y - column to analyze |
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
// ORIGINAL METHOD - EXPONENTS | |
v:{[x] "J"$/:string x} | |
mult:{[x;y] | |
m:reverse sum v[x]*/:{x*prd each #\:[;10]reverse til count x}v y; | |
while[any 9<m;m:(0^next p)+m-10*p:div[;10]m:0f,m]; | |
(?[;1b]"b"$m)_m | |
} | |
pwr:{(mult/)y#x} | |
// NEW METHOD - MATRICES |
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
\d .sha | |
// frequently used config functions | |
cfg.zeroPadding:{*[x;ceiling abs count[y]%x]#$[0>x;,[x#0;];,[;x#0]] y} | |
cfg.hex2bin:{cfg.zeroPadding[-8]{$[x<2;:reverse y,x;y,:x mod 2];.z.s[;y] div[x;2]}[;()] `long$x}; | |
cfg.bin2dec:{sum prd each x,'#\:[;2] reverse til count x}; | |
cfg.bin2hex:{`byte$cfg.bin2dec each 8 cut x}; | |
cfg.binary:{raze cfg.hex2bin each `byte$x}; | |
cfg.rightrotate:{rotate[neg[y];x]}; | |
cfg.rightshift:{while[y;x:0^prev x;y-:1];x}; |