Comment

Comment by guccihat

The constraint only states not to use hard coded matrices as I read it. Here is a version with number addition removed, this works fully on strings.

  function isDivisibleByThree(num) {
    let modulo, mod3 = "012012012012";
    for (const digit of num) {
        [modulo] = mod3.slice(modulo).slice(digit);
    }
    return modulo === "0";
  }
parent guccihat 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton