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
{:paths ["."] | |
:deps {com.dylibso.chicory/runtime {:mvn/version "1.1.0"}}} |
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
WITH | |
lines AS ( | |
SELECT regexp_split_to_array(line,' ') AS ns | |
FROM regexp_split_to_table(pg_read_file('/tmp/day1.txt'),'\n') line), | |
nums AS ( | |
SELECT ns[1]::integer as l, ns[2]::integer as r FROM lines), | |
lefts AS ( | |
SELECT l as n, row_number() over(order by l) as pos FROM nums), | |
rights AS ( | |
SELECT r as n, row_number() over(order by r) as pos FROM nums) |
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
nums: "aoc2024/day1.txt" lines map({ [&read, " ", &read] match($) }), | |
left: nums map(&_0) sort, | |
right: nums map(&_1) sort, | |
dif: 0 ref, | |
0 to(left len dec) do({ | |
d: (left nth($) - right nth($)) abs, | |
dif swap({$ + d}) | |
}), | |
"Part1: %d" fmt(dif val) print, |
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
FFIStructure subclass: #WuEvent | |
instanceVariableNames: '' | |
classVariableNames: 'OFFSET_BIND_ID OFFSET_ELEMENT OFFSET_EVENT_NUMBER OFFSET_EVENT_TYPE OFFSET_WINDOW' | |
package: 'WebUI'! | |
!WuEvent methodsFor: 'accessing - structure variables' stamp: 'UFFIGenerator 1/4/2024 13:07'! | |
element: anObject | |
"This method was automatically generated" | |
handle pointerAt: OFFSET_ELEMENT put: anObject getHandle.! ! |
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
%% Instead of JSON, encode point of interest data | |
%% as: input([poi(N1, X1, Y1, Z1), ... poi(Nn, Xn, Yn, Zn)]) where Z is the elevation | |
input([poi('Metsäjärvi', 23, 56, 20), | |
poi('Tunturikylä', 78, 12, 120), | |
poi('Sinijärvi', 45, 89, 21), | |
poi('Kallioranta', 34, 67, 19), | |
poi('Karhunpää', 91, 23, 66), | |
poi('Kuusimetsä', 17, 43, 66), | |
poi('Aurinkoniemi', 62, 78, 18), |
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
:- use_module(library(dcg/basics)). | |
:- use_module(library(yall)). | |
:- set_prolog_flag(double_quotes, codes). | |
crates(_, []) --> []. | |
crates(Ind, Cs) --> " ", { Ind1 is Ind + 1 }, crates(Ind1, Cs). | |
crates(Ind, [Ind-C|Cs]) --> "[", [Code], "] ", { char_code(C, Code) }, | |
{ Ind1 is Ind + 1}, | |
crates(Ind1, Cs). |
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
contiguous([_]). | |
contiguous([[_,E1],[E1,E2]|Segments]) :- | |
contiguous([[E1,E2]|Segments]). | |
% contiguous([[1,3],[3,10],[10,123]]). succeeds | |
% contiguous([[1,3],[420,666]]). fails |
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
<!DOCTYPE> | |
<html> | |
<head> | |
<script src="swipl-bundle.js"></script> | |
<script type="text/prolog"> | |
:- use_module(library(dcg/basics)). | |
:- set_prolog_flag(double_quotes, chars). | |
turtle([]) --> []. % the empty program | |
turtle([Cmd|Cmds]) --> blanks, turtle_command(Cmd), blanks, turtle(Cmds). |
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
(ns app.mappy | |
#?(:cljs (:require-macros app.mappy)) | |
(:require #?(:clj [datascript.core :as d]) ; database on server | |
#?(:clj [clojure.data.csv :as csv]) | |
[hyperfiddle.electric :as e] | |
[hyperfiddle.electric-dom2 :as dom] | |
[hyperfiddle.electric-ui4 :as ui] | |
#?(:cljs ["@openlayers-elements/core/ol-map" :as ol-map]) | |
#?(:cljs ["@openlayers-elements/maps/ol-layer-openstreetmap" :as ol-layer-openstreetmap]) | |
#?(:cljs ["@openlayers-elements/core/ol-layer-vector" :as ol-layer-vector]) |
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
(defn render-indexed-values | |
([inspector obj] (render-indexed-values inspector obj 0)) | |
([inspector obj idx-starts-from] | |
(if (every? map? obj) | |
;; Print table instead | |
(let [[_ header1 header2 & rows] (clojure.string/split-lines | |
(with-out-str | |
(clojure.pprint/print-table obj)))] | |
(loop [{counter :counter :as ins} (render-ln inspector header1 header2) | |
obj obj |
NewerOlder