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
(de readIn NIL | |
(in "/mnt/c/temp/day16.txt" | |
(make | |
(until (eof) | |
(let Parts | |
(filter | |
'prog | |
(mapcar 'pack (split (line) "," ":" " ")) ) | |
(link | |
(make |
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
# solution for tests on https://pastebin.com/BEdkvnHz | |
(de noRed (X) (not (match (list '@X ~(chop ":\"red\"") '@Y) X))) | |
(de parse (Input) | |
(let (Input (list (chop Input)) C NIL) | |
(recur NIL | |
(make | |
(while (and (setq C (pop Input)) (<> "}" C) (<> "]" C)) | |
(if (or (= C "{") (= C "[")) (link (recurse)) (link 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
require'~addons/convert/json/json.ijs' | |
coclass'jtable' | |
coinsert'jhs' | |
HBS=: 0 : 0 | |
'<link rel="stylesheet" href="~addons/ide/jhs/js/jquery/smoothness/jquery-ui.custom.css" />' | |
'<script src="~addons/ide/jhs/js/jquery/jquery-2.0.3.min.js"></script>' | |
'<script src="~addons/ide/jhs/js/jquery/jquery-ui.min.js"></script>' | |
'<script rel="stylesheet" href="~addons/ide/jhs/js/jquery/jquery-ui.css"></script>' |
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
require 'convert/json' | |
input =: fread 'c:/joe/lang-lab/j/advent2015/day12.txt' | |
json=: dec_json input | |
traverse=: (".@":@(0&{))`($: each)@.(0 >~ L.) | |
smoutput pt1=: +/ ; S:0 (traverse json) | |
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
(>:^:(0='00000' -: 5&{.@genHash1))^:_ (0) | |
6!:2 'smoutput (>:^:(0=''00000'' -: 5&{.@genHash1))^:_ (0)' | |
254575 | |
7.07309 |
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
genHash=: ([: gethash_jqtide_ "1 ('md5' ;"1 ([: (INPUT , ":&])"0 i.))) | |
isAllNumber=: ([: *./ 10&>) @: ('0123456789' i. ]) | |
filter=: [: isAllNumber [ {. ] | |
doFilter=: (] #~ [ filter"1 ]) | |
getAnswer=:([: ((0&{:: /:~ 1&{::)@:(0&{::) i.~ 1&{::) (] (1&{:: (([ ({."1;]) doFilter);]) genHash&(0&{::)))) | |
getAnswer (1000000;5) | |
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 Type { Undefined, Int, String, Double}; | |
public class A { | |
public Type Type; | |
public long Count; | |
public int Rank; | |
public long[] Shape; | |
public long[] ri; | |
public string[] rs; | |
public double[] rd; | |
public A(Type type, long n) { |
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
import cp. | |
matrix_square_sub_total(M,M2) = M3 => | |
M3 = new_array(M.length, M.length), | |
foreach(I in 1..M.length, J in 1..M.length) | |
M3[I,J] = sum([pow(M[I,K]-M2[J,K],2) : K in 1..M[1].length]) | |
end. | |
% modeled after http://www.hakank.org/picat/assignment.pi | |
nearest(M1,M2) = Assignments => |
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
% translated from https://gist.github.com/jpjacobs/6190830a08b95b0bd984 | |
import util. | |
% csv parsing code placeholder | |
% Arr={A:L in 1..length(Lines), Z=Lines[L], A={N: C in Z.split(","), N=parse_term(C)}} | |
matrix_square_sub_total(M) = M3 => | |
M3 = new_array(M.length, M.length), | |
foreach(I in 1..M.length, J in 1..M.length) | |
M3[I,J] = sum([pow(M[I,K]-M[J,K],2) : K in 1..M[1].length]) |
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
% exmaple reading a file | |
import util. | |
main => | |
writeTest, | |
readTest. | |
randBetween(Lower,Upper)=Num => Num=floor(frand()*(Upper-Lower+1)+Lower). | |
writeTest => |
NewerOlder