Skip to content

Instantly share code, notes, and snippets.

View tttardigrado's full-sized avatar

Gonçalo Teixeira tttardigrado

View GitHub Profile
@tttardigrado
tttardigrado / pll.hs
Last active November 24, 2024 08:42
P'' implementation in under 30 lines of Haskell
data P = R | L | Seq P P | Loop P
data Tape = Tape [Int] Int [Int]
empty :: Tape
empty = Tape (repeat 0) 0 (repeat 0)
left :: Tape -> Tape
left (Tape (l:ls) v rs) = Tape ls l (v:rs)
@tttardigrado
tttardigrado / README.md
Last active June 27, 2023 17:56
Slightly altered version of Clifford attractors.

CLIFFORD

Slightly altered (blured) version of Clifford attractors.

It follows the standard equations:

$$ x_{n+1} = \sin(a \cdot y_n) + c \cdot \cos(a \cdot x_n) $$

$$ y_{n+1} = \sin(b \cdot x_n) + d \cdot \cos(b \cdot y_n) $$

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
struct vec {
size_t size, cpcty;
int *arr;
};
typedef struct vec Vec;
@tttardigrado
tttardigrado / suggestion.hs
Created February 12, 2023 23:23
Typo fixing suggestions based on the Levenshtein distance
import Data.List (sortOn)
import Text.Printf (printf)
type Env a = [(String, a)]
type Dist a = a -> a -> Int
lev :: Dist String
lev x "" = length x
lev "" y = length y
lev (x:xs) (y:ys) = if x == y

Shortest code to determine if a string is a palindrome

Challenge link

Vyxal, 10 bytes

ɽẊ':₌ʀ±∨;Ḃ⁼

Is the word coprime?

Challeng link

Vyxal, 17 bytes

Cƛ96-;2↔ƛġ;:₌Π∆Ŀ=