switched to a fast hashing algorithm

This commit is contained in:
JOLIMAITRE Matthieu 2022-09-03 14:17:43 +02:00
parent 9cb320e357
commit a6b7824648
6 changed files with 34 additions and 2 deletions

21
patterns/gen.ts Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env -S deno run
const { args } = Deno;
const size = parseInt(args[0] ?? "5");
const frequency = parseFloat(args[1] ?? "0.5");
function* range(from: number, to: number) {
let current = from;
while (current < to) yield current++;
}
let result = "";
for (const _y of range(0, size)) {
for (const _x of range(0, size))
result += Math.random() < frequency ? '#' : ' ';
result += '\n';
}
console.log(result);