Ad

The solution code is written in MoonScript.

Code
Diff
  • import sort, reduce from require "pl.seq"
    export max_number = => ~~(reduce "..", sort "#{@}"\gmatch".")\reverse!
    • maxNumber
    • =n=>
    • eval([...n+``].sort().reverse().join``+`n`)
    • import sort, reduce from require "pl.seq"
    • export max_number = => ~~(reduce "..", sort "#{@}"\gmatch".")\reverse!
Code
Diff
  • local function find_squares_in_array(arr)
      local sum = 0
      for _, v in ipairs(arr) do
        sum = sum + v ^ 2
      end
      return sum
    end
    
    return find_squares_in_array
    • from numpy import square
    • local function find_squares_in_array(arr)
    • local sum = 0
    • for _, v in ipairs(arr) do
    • sum = sum + v ^ 2
    • end
    • return sum
    • end
    • def find_squares_in_array(arr):
    • return sum(map(square, arr))
    • return find_squares_in_array