Skip to main content
edited body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 8 7 bytes

Vf96SạP

Input is as an array of two integers: first the right opererandoperand, then the left one.

Try it online!

How it works

Vf96SạP  Main link. Argument: [b, a]

V        Cast [b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96     Filter with 96, yielding [96] if V returned 96, [] otherwise.
    S    Take the sum, yielding either 96 or 0.
      P  Compute the product of [b, a], yielding ba = ab.
     ạ   Compute the absolute difference of the results to both sides.
         When the sum is 0, this simply yields the product.
         However, when [b, a], = [9, 6], this yields 96 - 54 = 42.

Jelly, 8 7 bytes

Vf96SạP

Input is as an array of two integers: first the right opererand, then the left one.

Try it online!

How it works

Vf96SạP  Main link. Argument: [b, a]

V        Cast [b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96     Filter with 96, yielding [96] if V returned, [] otherwise.
    S    Take the sum, yielding either 96 or 0.
      P  Compute the product of [b, a], yielding ba = ab.
     ạ   Compute the absolute difference of the results to both sides.
         When the sum is 0, this simply yields the product.
         However, when [b, a], = [9, 6], this yields 96 - 54 = 42.

Jelly, 8 7 bytes

Vf96SạP

Input is as an array of two integers: first the right operand, then the left one.

Try it online!

How it works

Vf96SạP  Main link. Argument: [b, a]

V        Cast [b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96     Filter with 96, yielding [96] if V returned 96, [] otherwise.
    S    Take the sum, yielding either 96 or 0.
      P  Compute the product of [b, a], yielding ba = ab.
     ạ   Compute the absolute difference of the results to both sides.
         When the sum is 0, this simply yields the product.
         However, when [b, a] = [9, 6], this yields 96 - 54 = 42.
added 552 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 88 7 bytes

42P⁼?6,9Vf96SạP

Try it online! Input is as an array of two integers: first the right opererand, then the left one.

Try it online!

How it works

42P⁼?6,9Vf96SạP  Main link. Argument: [a[b, b]a]

V    ?    Cast If.[b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96   6  Filter with 96,9 yielding [96] if V [areturned, b][] ==otherwise.
 [6   S    Take the sum, 9]:yielding either 96 or 0.
42      P  Compute the product of Yield[b, 42a], yielding ba = ab.
        Compute the absolute Else:difference of the results to both sides.
  P       When the sum is 0, Callthis simply yields the product.
         However, yieldingwhen ab[b, a], = [9, 6], this yields 96 - 54 = 42.

Jelly, 8 bytes

42P⁼?6,9

Try it online!

How it works

42P⁼?6,9  Main link. Argument: [a, b]

    ?     If...
    6,9    [a, b] == [6, 9]:
42            Yield 42.
          Else:
  P           Call product, yielding ab.

Jelly, 8 7 bytes

Vf96SạP

Input is as an array of two integers: first the right opererand, then the left one.

Try it online!

How it works

Vf96SạP  Main link. Argument: [b, a]

V        Cast [b, a] to string, then eval the resulting string.
         For [b, a] = [9, 6], this yields 96.
 f96     Filter with 96, yielding [96] if V returned, [] otherwise.
    S    Take the sum, yielding either 96 or 0.
      P  Compute the product of [b, a], yielding ba = ab.
        Compute the absolute difference of the results to both sides.
         When the sum is 0, this simply yields the product.
         However, when [b, a], = [9, 6], this yields 96 - 54 = 42.
added 219 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Jelly, 8 bytes

42P⁼?6,9

Try it online!

How it works

42P⁼?6,9  Main link. Argument: [a, b]

    ?     If...
   ⁼ 6,9    [a, b] == [6, 9]:
42            Yield 42.
          Else:
  P           Call product, yielding ab.

Jelly, 8 bytes

42P⁼?6,9

Try it online!

Jelly, 8 bytes

42P⁼?6,9

Try it online!

How it works

42P⁼?6,9  Main link. Argument: [a, b]

    ?     If...
   ⁼ 6,9    [a, b] == [6, 9]:
42            Yield 42.
          Else:
  P           Call product, yielding ab.
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading