From 07abc8709a5dd0082e699c749418b617d6fc3d3b Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Wed, 30 Nov 2022 12:23:26 -0800 Subject: Minor cleanup for the actual exhibition --- entries/braxtonhall/hitl2/fib.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/entries/braxtonhall/hitl2/fib.js b/entries/braxtonhall/hitl2/fib.js index e050d96..429abc2 100644 --- a/entries/braxtonhall/hitl2/fib.js +++ b/entries/braxtonhall/hitl2/fib.js @@ -139,11 +139,24 @@ const number = () => : slow(hedge()).then(() => slow(innumerable())).then(number))); const choose = () => - prompt("would you like to use my iteration optimization??? yes????") - .then((response) => ["y", "yes"].includes(response.trim().toLowerCase())) - .then((should) => should - ? fast("yes!").then(() => hitlfibiter) - : fast("oh.").then(() => slow("okay.")).then(() => slow("we can take it slow.")).then(() => hitlfib)); + prompt("would you like to use my iteration optimization??? yes???? .. or.. no?") + .then((response) => Promise.resolve(["yes", "no", "y", "n"].includes(response.trim().toLowerCase())) + .then((formed) => !formed + ? slow("um. sorry. one more time..").then(choose) + : ["yes", "y"].includes(response.trim().toLowerCase()) + ? fast("yes!").then(() => hitlfibiter) + : fast("oh.").then(() => slow("okay.")).then(() => slow("we can take it slow.")).then(() => hitlfib))); + +const optimize = (n) => + n < 4 + ? hitlfib + : n > 25 + ? slow(hedge()) + .then(() => fast("acutally..")) + .then(() => fast("i need to use my iteration optimization for this.")) + .then(() => slow("i hope that's okay.")) + .then(() => hitlfibiter) + : choose(); const flow = () => slow("\nwhat's the fib you'd like to compute? i can help u out") @@ -151,7 +164,7 @@ const flow = () => .then((n) => slow(confirmation()) .then(() => fast(hedge())) .then(() => slow(`i will help u compute ${green(`fib ${n}`)}`)) - .then(choose) + .then(() => optimize(n)) .then((fib) => fib(n)) .then((fibn) => slow(hedge()) .then(() => fast(done())) -- cgit v1.2.3-70-g09d2