Skip to content

Instantly share code, notes, and snippets.

@zrrtcs
Created July 8, 2024 15:19
Show Gist options
  • Select an option

  • Save zrrtcs/e24d4b5eff513cc52c3c36bbd2b0c15e to your computer and use it in GitHub Desktop.

Select an option

Save zrrtcs/e24d4b5eff513cc52c3c36bbd2b0c15e to your computer and use it in GitHub Desktop.
// The original practices that should not be altered
const initialPractices = ["prayer", "dua"];
// Function to add a new practice, maintaining immutability
const addPractice = (practices, newPractice) => [...practices, newPractice];
// Fuzzy comparison to check how much we've strayed from the original path
const fuzzyComparator = (set1, set2) => {
const intersection = set1.filter(practice => set2.includes(practice));
return intersection.length / Math.max(set1.length, set2.length);
};
// Simulating generational changes, because humans love to innovate
let practices = initialPractices;
const generations = 7;
const deviationThreshold = 0.5;
for (let generation = 1; generation <= generations; generation++) {
practices = addPractice(practices, `innovation_${generation}`);
const similarity = fuzzyComparator(initialPractices, practices);
if (similarity < deviationThreshold) {
console.warn(`🚨 Warning: After ${generation} generations, deviation is too high!`);
}
}
// Display the final state of practices
console.log("Current practices after generations of innovation:");
console.log(practices);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment