Created
February 23, 2026 12:49
-
-
Save VictorTaelin/ab95a01b1622b1fcfea09dcc4c1a9696 to your computer and use it in GitHub Desktop.
bunjs - 15x slower
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const Nat = null; | |
| export const List = null; | |
| export const Char = null; | |
| export const String = null; | |
| export function $steps(n, acc) { | |
| while (true) { | |
| if (((n >>> 0) === (1 >>> 0)) ? 1 : 0) { | |
| return acc; | |
| } | |
| const rem = (2 === 0 ? 0 : ((n >>> 0) % (2 >>> 0)) >>> 0); | |
| if (((rem >>> 0) === (0 >>> 0)) ? 1 : 0) { | |
| n = (2 === 0 ? 0 : ((n >>> 0) / (2 >>> 0)) >>> 0); | |
| acc = ((acc + 1) >>> 0); | |
| continue; | |
| } else { | |
| n = ((Math.imul(n, 3) >>> 0) + 1) >>> 0; | |
| acc = ((acc + 1) >>> 0); | |
| continue; | |
| } | |
| } | |
| } | |
| export const steps = () => (a0) => (a1) => $steps(a0, a1); | |
| export function $total(n, acc) { | |
| while (true) { | |
| if (((n >>> 0) === (0 >>> 0)) ? 1 : 0) { | |
| return acc; | |
| } | |
| const k = n; | |
| n = ((k - 1) >>> 0); | |
| acc = ((acc + $steps(k, 0)) >>> 0); | |
| continue; | |
| } | |
| } | |
| export const total = () => (a0) => (a1) => $total(a0, a1); | |
| export function $main() { | |
| return $total(8000000, 0); | |
| } | |
| export const main = () => $main(); | |
| console.log(JSON.stringify(main())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment