Skip to content

Instantly share code, notes, and snippets.

@smigniot
smigniot / gist:f9c610cf8cee1753c2844ceea0544dd0
Created October 4, 2024 07:31
Vocabulary reduction for k=8 and k=13
=============
== FOR K=8 ==
=============
Cardinalities [
[ 'E', 85998 ], [ 'S', 66786 ],
[ 'I', 65837 ], [ 'A', 59318 ],
[ 'R', 54496 ], [ 'N', 53586 ],
[ 'T', 49932 ], [ 'O', 46240 ],
[ 'L', 39990 ], [ 'C', 30033 ],
[ 'D', 28418 ], [ 'U', 25051 ],
async function run(elements) {
// ============
// your code here starts here
const results = [];
const pending = new Set();
const order = elements.map((element,i)=>({element,i}));
while(order.length) {
const {element,i} = order.shift();
const promise = api(element);
pending.add(promise);
@smigniot
smigniot / matrix.js
Created February 28, 2023 21:40
A Matrix rain effect
function _(tagname, attributes) {
var result = null;
if(attributes && attributes.xmlns) {
result = document.createElementNS(attributes.xmlns, tagname);
} else {
result = document.createElement(tagname || "div");
}
if(attributes) {
Object.keys(attributes).forEach(function(name) {
if("xmlns" == name) return;
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.IO
import Control.Applicative
import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow
import Control.Monad
@smigniot
smigniot / collatz.hs
Created April 25, 2022 19:07
A solution to some homework assignment
next n
| rem n 2 == 0 = div n 2
| otherwise = 3*n+1
collatz 1 = [1]
collatz n = n : (collatz (next n))
collatzLength n =
(n, length (collatz n))
import Data.List (sort)
import qualified Data.Map.Strict as M
main = interact (\s -> parts (analysed (nel s)))
where parts lst = part1 lst ++ "\n" ++ part2 lst ++ "\n"
nel s = filter (not . null) (lines s)
analysed lines = zip lines (map inspect lines)
data Status =
Corrupted Char Char