Solutions for Group dealing with a mission array coding challenge

    • @JavierVow
    • @jacob, submitted in JavaScript, achived 100% score
    function solve(n, k) {
      if (n < 10) {
        return n;
      }
    
      return solve(
        n
          .toString()
          .split('')
          .reduce((sum, num) => sum + (num | 0), 0) * k,
        1);
    }
    • @JavierVow
    • @jacob, submitted in Python 2, achived 100% score
    
    def solve(n, k):
        x = int(n) * int(k) % 9
        return x if x else 9
    
    
    • @JavierVow
    • @jacob, submitted in Python 3, achived 100% score
    
    def solve(n, k):
        x = int(n) * int(k) % 9
        return x if x else 9