Skip to main content
added 126 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 2323 22 bytes

Ýí€ûnR**`âOIPns-D<ds_‚O.±{Åγ¦

Try it online Outputs the pair in reversed order, so \$[boundaryCount, interiorCount]\$.

Try it online or verify all test casesverify all test cases.

Ý                # Convert both values in the (implicit) input-pair to [0,value]-ranged
                 # lists
 í               # Reverse each inner list
  €û             # Palindromize each inner list
    n            # Square each inner value
     R           # Reverse the list
      **         # Multiply each to the (implicit) input-pair twice
        `        # Pop and push both lists separately to the stack
         â       # Create all possible pairs using the cartesian product
          O      # Sum each inner pair together
           IP    # Push the product of the input-pair
             n   # Square that
              s- # Subtract the sums of the list from that value
 D               # Duplicate this list
  <   Get the sign (-1 if negative; 0 if 0; 1 if #positive) Decreaseof each value by 1
  { d             # Check for each value whetherSort it'sthese non-negative1s, (>=0s, 0)
and s1s
   Åγ            # SwapThen sorun-length theencode duplicatedit, pushing list is[-1,0,1] at(which thewe topwon't againuse)
  _              # Check for each value# whetherand it'sthe equallist toof 0lengths
     ¦           # Pair those two lists together
     O        Remove the first #value Sum(for the checkamount of each inner list-1s)
                 # (after which the resulting pair is output implicitly)

Try it online with step-by-step debug lines.Try it online with step-by-step debug lines.

05AB1E, 23 bytes

Ýí€ûnR**`âOIPns-D<ds_‚O

Try it online or verify all test cases.

Ý                # Convert both values in the (implicit) input-pair to [0,value]-ranged
                 # lists
 í               # Reverse each inner list
  €û             # Palindromize each inner list
    n            # Square each inner value
     R           # Reverse the list
      **         # Multiply each to the (implicit) input-pair twice
        `        # Pop and push both lists separately to the stack
         â       # Create all possible pairs using the cartesian product
          O      # Sum each inner pair together
           IP    # Push the product of the input-pair
             n   # Square that
              s- # Subtract the sums of the list from that value
 D               # Duplicate this list
  <              # Decrease each value by 1
   d             # Check for each value whether it's non-negative (>= 0)
 s               # Swap so the duplicated list is at the top again
  _              # Check for each value whether it's equal to 0
                # Pair those two lists together
     O           # Sum the check of each inner list
                 # (after which the resulting pair is output implicitly)

Try it online with step-by-step debug lines.

05AB1E, 23 22 bytes

Ýí€ûnR**`âOIPns-.±{Åγ¦

Outputs the pair in reversed order, so \$[boundaryCount, interiorCount]\$.

Try it online or verify all test cases.

Ý                # Convert both values in the (implicit) input-pair to [0,value]-ranged
                 # lists
 í               # Reverse each inner list
  €û             # Palindromize each inner list
    n            # Square each inner value
     R           # Reverse the list
      **         # Multiply each to the (implicit) input-pair twice
        `        # Pop and push both lists separately to the stack
         â       # Create all possible pairs using the cartesian product
          O      # Sum each inner pair together
           IP    # Push the product of the input-pair
             n   # Square that
              s- # Subtract the sums of the list from that value
               # Get the sign (-1 if negative; 0 if 0; 1 if positive) of each
  {              # Sort these -1s, 0s, and 1s
   Åγ            # Then run-length encode it, pushing list [-1,0,1] (which we won't use)
                 # and the list of lengths
     ¦           # Remove the first value (for the amount of -1s)
                 # (after which the resulting pair is output implicitly)

Try it online with step-by-step debug lines.

Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 23 bytes

Ýí€ûnR**`âOIPns-D<ds_‚O

Try it online or verify all test cases.

Explanation:

Ý                # Convert both values in the (implicit) input-pair to [0,value]-ranged
                 # lists
 í               # Reverse each inner list
  €û             # Palindromize each inner list
    n            # Square each inner value
     R           # Reverse the list
      **         # Multiply each to the (implicit) input-pair twice
        `        # Pop and push both lists separately to the stack
         â       # Create all possible pairs using the cartesian product
          O      # Sum each inner pair together
           IP    # Push the product of the input-pair
             n   # Square that
              s- # Subtract the sums of the list from that value
 D               # Duplicate this list
  <              # Decrease each value by 1
   d             # Check for each value whether it's non-negative (>= 0)
 s               # Swap so the duplicated list is at the top again
  _              # Check for each value whether it's equal to 0
    ‚            # Pair those two lists together
     O           # Sum the check of each inner list
                 # (after which the resulting pair is output implicitly)

Try it online with step-by-step debug lines.