| Bytes | Lang | Time | Link |
|---|---|---|---|
| 028 | Perl 5 pl | 250219T151930Z | Xcali |
| 005 | Vyxal | 220129T204110Z | emanresu |
| 007 | Vyxal 3 | 250219T104219Z | Themooni |
| 009 | Japt | 250218T172812Z | Shaggy |
| 010 | Uiua | 250218T184833Z | noodle p |
| 008 | 05AB1E | 250218T161603Z | Glory2Uk |
| 015 | Ly | 220224T071315Z | cnamejj |
| 014 | J | 220222T153628Z | sinvec |
| 070 | GeoGebra | 220201T054115Z | Aiden Ch |
| 056 | Julia 1.0 | 220201T233013Z | Sundar R |
| 076 | tinylisp | 220201T062342Z | Razetime |
| 033 | Haskell | 220131T163903Z | AZTECCO |
| 031 | TSQL | 220131T154733Z | t-clause |
| 007 | MathGolf | 220131T125521Z | Kevin Cr |
| 031 | Python 2 | 220130T025011Z | DialFros |
| 033 | Ruby | 220130T200333Z | G B |
| 014 | Burlesque | 220130T191951Z | DeathInc |
| 079 | PHP | 220130T145137Z | Fmbalbue |
| 055 | C gcc | 220130T111430Z | Noodle9 |
| 041 | Retina | 220130T110407Z | Neil |
| 009 | APL Dyalog Unicode | 220130T101924Z | Adá |
| 020 | APL+WIN | 220130T092500Z | Graham |
| 022 | BQN | 220130T095531Z | zoomlogo |
| 006 | Jelly | 220130T013710Z | Jonathan |
| 039 | Factor | 220129T213407Z | chunes |
| 008 | Brachylog | 220130T001628Z | Fatalize |
| 041 | JavaScript ES6 | 220129T235653Z | Arnauld |
| 040 | Pari/GP | 220129T234846Z | alephalp |
| 045 | Red | 220129T231542Z | chunes |
| 013 | Charcoal | 220129T221216Z | Neil |
| 055 | Retina 0.8.2 | 220129T220850Z | Neil |
| 037 | Python 3 | 220129T220138Z | AnttiP |
| 009 | Jelly | 220129T204509Z | hyperneu |
Vyxal 3, 7 bytes
Vyxal 3.5 port of Emanresu's answer
‹⁰W×⍨⇄=
explanation:
‹⁰W×⍨⇄=
W×⍨ # multiply by the second input...
‹ # first input, decremented
⁰ # and first input unchanged
⇄= # is the reverse of one equal to the other?
💎
Created with the help of Luminespire.
Japt, 9 bytes
Take input as an array.
×¶UvÉ ×sÔ
Try it (includes all test cases)
×¶UvÉ ×sÔ :Implicit input of array U=[a,b]
× :Product
¶ :Is equal to
Uv : Modify first element of U
É : Subtract 1
× : Product
s : To string
Ô : Reverse
Uiua, 10 bytes
=⍜°⋕⇌∩×◡-₁
Try it: Uiua pad
This relies on the deprecated behavior of ◡ below for functions with <2 arguments. If you are experiencing errors running this in the future, try replacing ◡ with ⊸₂.
05AB1E, 8 bytes
н<*θR¹På
Outputs 1 if two numbers are a reversed multiple pair, 0 - otherwise.
Commented:
н take the first element of the pair
< decrement by 1
* multiply the pair by this value
θ take the last element
R reverse the digits;
¹ input again
P calculate the product of the pair
å check the result
Ly, 15 bytes
nn&s*SrJlf,*=u;
nn - read two numbers from STDIN
&s - save the entries to the backup cell
* - multiple the two numbers passed in
S - convert integer to individual digits on stack
r - reverse stack
J - re-compose digits on stack into a integer
l - restore saved numbers
f - flip top two entries
, - decrement the top of stack
* - multiple top two entries
= - compare the two entries on the stack
u - print "1|0" from comparison
; - exit the program
GeoGebra, 86 77 70 bytes
a=6
b=9
s=Text(ab-b)
o=Sum(Zip(Take(s,c,c),c,Length(s)…1))==Text(ab)
Input is a and b, output is o as true if a and b are a reversed multiple pair, false otherwise.
The example input shown in the code is a=6 and b=9, but you can change these values to whatever you want.
Julia 1.0, 56 bytes
(a,b,d=digits,s=string)->s(d(a*b))==s(reverse(d(a*b-b)))
Pretty straightforward answer, with nothing particularly clever to it (unfortunately).
tinylisp, 76 bytes
(load library
(d f(q((a b)(e(to-base 10(*(- a 1)b))(reverse(to-base 10(* a b
Haskell, 43 33 bytes
a?b=a*b==read(reverse$show$a*b-b)
- I haven't thought
reversewas available in prelude, no reason to use foldl(flip(:))""String
MathGolf, 7 bytes
`(*x¬*=
Explanation:
` # Duplicate the top two items, using the implicit inputs
# STACK: b,a,b,a
( # Decrease the top item
# STACK: b,a,b,a-1
* # Multiply the top two together
# STACK: b,a,b*(a-1)
x # Reverse the top integer
# STACK: b,a,reverse(b*(a-1))
¬ # Reverse rotate the stack:
# STACK: reverse(b*a(-1)),b,a
* # Multiply the top two again
# STACK: reverse(b*a(-1)),b*a
= # Check if the two are equal
# STACK: reverse(b*a(-1))==b*a
# (after which the entire stack joined together is output implicitly)
Python 2, 31 bytes
lambda a,b:`a*b`==`a*b-b`[::-1]
Using the logic that $$ ab = \operatorname{rev}( (a-1)b ) \iff ab = \operatorname{rev}(ab-b) $$ -2 thx to @dingledooper
Other solutions:
Python 2, 31 bytes
lambda a,b:`a*b`[::-1]==`a*b-b`
Using the logic that $$ \operatorname{rev}(ab) = (a-1)b \iff \operatorname{rev}(ab) = ab-b $$ -2 thx to @dingledooper
Python 2, 34 bytes
lambda a,b:a*b-int(`a*b`[::-1])==b
Using the logic that $$ ab - \operatorname{rev}(ab) =b $$
^Credits to @ovs for the equations!
Burlesque, 14 bytes
Jpdjp^-..*<-==
Takes input as array of pairs {a b}
J # Duplicate
pd # Product of array
j # Swap
p^ # Push elements to stack (b, a)
-. # Decrement
.* # Product
<- # Reverse digits
== # Equal
PHP, 79 bytes
$a=trim(fgets(STDIN));$b=trim(fgets(STDIN));echo $a*$b==(int)strrev($b*($a-1));
With the help of Github Copilot
C (gcc), 55 bytes
c;r;f(a,b){for(r=0,c=~-a*b;c;c/=10)r+=9*r+c%10;r-=a*b;}
Inputs two integers \$a\$ and \$b\$.
Returns a falsy value if these two numbers are a reversed multiple pair or a truthy value otherwise.
Retina, 41 bytes
L$`.+,
*$'*_,$($^$.(*$'*))*_$'*
^(_+),\1$
Try it online! Link includes test cases. Explanation: Based on @ovs' 05AB1E answer.
L$`.+,
Match a as $& (Retina ignores the trailing comma when performing arithmetic) and b as $' and replace the whole input with the result.
*$'*_,$($^$.(*$'*))*_$'*
Calculate a*b and also rev(a*b)+b in unary.
^(_+),\1$
See whether they are the same.
APL (Dyalog Unicode), 9 bytes
Anonymous tacit infix function, taking \$a\$ as left argument and \$b\$ as right argument.
×≡∘⌽⍥⍕×-⊢
Try it online! (Uses Extended because TIO hasn't updated to 18.0)
× [Does] the product
≡∘ match the…
⌽⍥ reversed, when both are…
⍕ stringified
× product
- minus
⊢ the right argument[?]
APL+WIN, 22 20 bytes
Prompts for a then b. Minus 2 bytes using rearrangement logic
(⍎⌽⍕n-b)=n←(b←⎕)×a←⎕
BQN, 33 22 Bytes
This seems too long.
A little better.
{(𝕨×𝕩)=•BQN⌽•Fmt𝕩×𝕨-1}
¯11 bytes thanks to @Razetime
Jelly, 6 bytes
’×ṚḌ⁼×
A dyadic Link accepting \$a\$ and \$b\$ that yields 1 if \$a\times b = \text{reversed}( (a - 1)\times b )\$, 0 if not.
Try it online! Or see the test-suite.
How?
’×ṚḌ⁼× - Link: a, b
’ - a-1
× - (a-1) times b
Ṛ - reverse the digits of (a-1)×b
Ḍ - convert back to an integer
× - a×b
⁼ - equal?
Factor, 47 39 bytes
[ over * dup present reverse dec> - = ]
Saved 8 bytes thanks to @ovs' observations.
Explanation
Takes input as b a.
! 9 6
over ! 9 6 9
* ! 9 54
dup ! 9 54 54
present ! 9 54 "54"
reverse ! 9 54 "45"
dec> ! 9 54 45
- ! 9 9
= ! t
Brachylog, 8 bytes
-₁ʰ×↔~×?
Explanation
Input = [A, B]
-₁ʰ Compute [A-1, B]
× Compute (A-1) × B
↔ Reverse digits
~×? It can be unmultiplied into [A,B]
JavaScript (ES6), 41 bytes
Expects (a)(b). Returns a Boolean value.
a=>b=>[...a*b+''].reverse().join``==a*b-b
Charcoal, 13 bytes
NθNη⁼×θη⮌×⊖θη
Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for a reversed pair, nothing if not. Explanation:
Nθ First input as a number
Nη Second input as a number
θ First input
× Multiplied by
η Second input
⁼ Equals
θ First input
⊖ Decremented
× Multiplied by
η Second input
⮌ Reversed
Implicitly print
Retina 0.8.2, 55 bytes
\d+
$*
1,
,
1(?=.*,(1+))
$1
,
,$`
1+
$.&
+`(.),\1
,
^,$
Try it online! Link includes test cases. Explanation:
\d+
$*
Convert to unary.
1,
,
Decrement a.
1(?=.*,(1+))
$1
Multiply a-1 by b.
,
,$`
Add that to b giving (a-1)b,ab.
1+
$.&
Convert to decimal.
+`(.),\1
,
^,$
Test whether the results are mirror images of each other.
Jelly, 9 bytes
,’$×DU⁼¥/
,’$×DU⁼¥/ Main Link; dyad accepting a, b
,’$ pair: [a, a - 1]
× multiply: [ab, (a - 1)b]
D to digit list
/ reduce between the two:
U is the reverse of the former
⁼ equal to the latter?