Gleam snippet extractor not working?

This is my recent solution:

What’s your solution code?

1 Like

For anyone debugging (and so Glenn can change submissions if he ever wants to!):

import gleam/int
import gleam/list
import gleam/result
pub fn is_armstrong_number(number: Int) -> Bool {
  let assert Ok(width) = int.digits(number, 10) |> result.map(list.length)
  number == armstrong_sum(number, width, 0)
}
fn armstrong_sum(number: Int, width: Int, sum: Int) -> Int {
  case number {
    0 -> sum
    _ -> armstrong_sum(number / 10, width, sum + ipow(number % 10, width))
  }
}
fn ipow(n: Int, e: Int) -> Int {
  case e {
    0 -> 1
    _ -> n * ipow(n, e - 1)
  }
}

Fixed by re-running the snippet extractor (didn’t see any error). Let me know if you come across more examples.

1 Like