Skip to main content
added explanation
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 59 bytes

{($^a,{.round(10**($++-15))}...^0|any 10 X**^30-15)[*-$^b]}

Try it online!

Anonymous code block that takes two numbers and returns a number.

Explanation:

{                                                         }  # Anonymous code block
 (                          ...                   )  # Create a sequence
  $^a,   # With the first element as the input
      {                    }  # With each element being
       .round(10**($++-15))   # The previous element rounded by another digit
                                0                   # Until 0
                                 |                  # or
                                  any 10 X**^30-15  # Any available power of 10
                               ^  # Ignoring the last number
                                                   [*-   ]  # Index from the end
                                                      $^b   # The second number

Perl 6, 59 bytes

{($^a,{.round(10**($++-15))}...^0|any 10 X**^30-15)[*-$^b]}

Try it online!

Perl 6, 59 bytes

{($^a,{.round(10**($++-15))}...^0|any 10 X**^30-15)[*-$^b]}

Try it online!

Anonymous code block that takes two numbers and returns a number.

Explanation:

{                                                         }  # Anonymous code block
 (                          ...                   )  # Create a sequence
  $^a,   # With the first element as the input
      {                    }  # With each element being
       .round(10**($++-15))   # The previous element rounded by another digit
                                0                   # Until 0
                                 |                  # or
                                  any 10 X**^30-15  # Any available power of 10
                               ^  # Ignoring the last number
                                                   [*-   ]  # Index from the end
                                                      $^b   # The second number
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 59 bytes

{($^a,{.round(10**($++-15))}...^0|any 10 X**^30-15)[*-$^b]}

Try it online!