feat: add flat_tree allgorithm

This commit is contained in:
2024-04-10 21:57:03 +02:00
parent 2ed1501747
commit e2940183f1
9 changed files with 179 additions and 9 deletions

View File

@ -0,0 +1,20 @@
<script lang="ts">
import { decode, encode } from "$lib/helpers/flat_tree";
const input = [5, [6, 1], [7, 2, [5, 1]]];
// const input = [5, [], [6, []], []];
// const input = [52];
console.log("INPUT");
console.log(input);
const encoded = encode(input);
console.log("ENCODED");
console.log(encoded);
const decoded = decode(encoded);
console.log("DECODED");
console.log(decoded);
console.log("EQUALS", JSON.stringify(input) === JSON.stringify(decoded));
</script>