text:
Visualize Visual Eyes
You may or may not remember Xeyes, a demo program that came with (and, as far as I know, still comes with) the X window system. Its purpose was to draw a pair of eyes that followed your mouse cursor:

Your challenge is to recreate Xeyes with ASCII art. Write a program or function that draws two ASCII art eyes (specified below) wherever the user clicks and then moves their pupils to point in the direction of the cursor.

The above GIF is a recording of this non-golfed Ruby implementation, which can be run with any recent version of Ruby. You may also find it useful as reference for Xterm control sequences.
Specifications
This is code-golf, so the solution with the fewest bytes wins.
This is an ascii-art challenge, so your program must draw using ASCII characters—specifically, the characters -, ., |, ', 0, space, and newline.1 2
This is an interactive challenge, so your program must accept input and draw its output in realtime.3
Before your program begins accepting input, it should initialize a blank canvas of at least 20 rows and 20 columns. It should not draw anything until the user clicks on the canvas.
Any time the user clicks4 on the canvas, the program should clear any previous output and then draw these ASCII eyes on the canvas, centered on the character nearest the location of the mouse cursor.5 6 (Below, ✧ represents the mouse cursor and should not be drawn.)
.---. .---.
|   | |   |
|  0|✧|0  |
|   | |   |
'---' '---'

Note how the pupils "point" toward the cursor.
Any time the mouse cursor moves on the canvas, the program should re-draw the pupils so that they continue pointing toward the cursor,7 e.g.:
             ✧

.---. .---.
|  0| |  0|
|   | |   |
|   | |   |
'---' '---'

Pupil pointing
Suppose we enumerated the positions of the inner nine characters of each eye like so:
.---.
|678|
|591|
|432|
'---'

The pupil will be drawn at one of the locations 1-9. To decide which one, pretend the characters are square and that the canvas is a Cartesian grid, with the center of the 9 character at (0, 0), the center of 1 at (1, 0), and so on. When the program receives input—a click or movement—it should map the input location to the nearest grid coordinate . If  is (0, 0), the pupil should be drawn at (0, 0), i.e. the location of the 9 above. Otherwise, it should be drawn as described below.
Imagine a Cartesian plane superimposed on the grid and divided into octants numbered 1–8:

If  lies within octant 1, then the pupil should be drawn at the location of 1 above, i.e. at (1, 0). If  is in octant 2 it should be drawn at 2—and so on. To illustrate, the below image shows part of the grid color-coded according to where the pupil should be drawn when the mouse cursor is at a particular location. When, for example, the cursor is at any of the green coordinates (keeping in mind that the grid coordinates lie at the squares' centers, not their corners), the pupil should be drawn at 4.

The two eyes' pupils move independently, so for each eye repeat the process with  relative to that eye's center.
Notes

This isn't a graphical-output challenge. The output must be a grid of characters. You may, of course, use graphics routines to draw a grid of characters.
Whitespace may be drawn (or, rather, not drawn) however is convenient. An empty spot in the grid looks the same as a space character and will be considered equivalent.
"Real-time" is defined here as fewer than 200ms between input and the corresponding output being drawn.
It is at your discretion which mouse button(s) are observed for input, and whether a press or release constitutes a "click."
The canvas must be cleared, or the visual equivalent must be achieved. With a terminal-based solution, for example, printing a new canvas below the previous canvas is not considered equivalent.
When the user clicks near the edge of the canvas such that some of the eye characters would be drawn beyond its edge, the behavior is undefined. However, the program must continue running normally upon subsequent clicks.
When the mouse cursor leaves the "canvas," the behavior is undefined, but the program must continue running normally when the cursor re-enters the canvas.
A text cursor may appear on the canvas, as long as it does not obscure the output.

Standard loopholes are forbidden.

Sandbox post

Can the program run out of memory after a few minutes, or must it potentially run indefinitely.

@Οurous Since how many minutes is "a few" in that case would depend on how much memory the system has, and that could lead us into "this solution assumes the environment has 512GB of RAM" territory, I'm going to say that it must potentially run indefinitely.

@Jordan do we need to handle the case of the use clicking on the edge of the character grid?

@TaylorScott Nope. See note #6 (unless I’ve misunderstood your question).

Does the output have to be in a monospaced font? If so, may I assume that a monospaced font is set as the default font on the system?

@Οurous Yes, and no. If your target environment is usually one in which the default font is monospace (say, a terminal emulator, or code editor), then that’s fine. If using a monospace font in that environment usually takes extra configuration (as in a browser-based JS solution), that configuration must be part of your byte count (e.g.
 or font-family:monospace).

+1 for great title (or bad title, depending on how you take it)

Do we have to handle the program being closed / terminated?

@Οurous Nope, as long as it doesn’t terminate unexpectedly.

I like how detaied this challenge is.

QBasic (QB64), 361 305 bytes
DO
WHILE _MOUSEINPUT
x=CINT(_MOUSEX)
y=CINT(_MOUSEY)
IF _MOUSEBUTTON(1)THEN l=x-3:k=y
IF(2<l)*(73>l)*(2<k)*(22>k)THEN CLS:FOR i=0TO 1:h=l+6*i:LOCATE k-2,h-2:?".---.":FOR j=1TO 3:LOCATE,h-2:?"|   |":NEXT:LOCATE,h-2:?"'---'":d=x-h:e=y-k:m=ABS(e/d):LOCATE k-SGN(e)*(m>=.5),h-SGN(d)*(m<=2):?"0":NEXT
WEND
LOOP

Left-click places the eyes. If placement of eyes would result in part of the eyes being out of bounds, the program "freezes" until a valid placement is made.
The main tricky part is placing the pupils. Most of the time, the coordinates of the pupil are just the center of the eye plus (sign(Δx), sign(Δy)), except that in octants 1 and 5, the y-coordinate equals y-center, and in octants 3 and 7, the x-coordinate equals x-center. Octant boundaries can be calculated using the slope m of the line from the center of the eye to the mouse coordinates. Conveniently, dividing by zero when calculating the slope gives floating-point infinity (+/-) rather than an error.

Ungolfed
' Loop forever
DO
    ' Do stuff if there is new mouse data (movement or click)
    IF _MOUSEINPUT THEN
        ' Store the mouse coords rounded to the nearest integer
        mouse_x = CINT(_MOUSEX)
        mouse_y = CINT(_MOUSEY)
        ' If left mouse button was clicked, change location of eyes
        IF _MOUSEBUTTON(1) THEN
            ' Store center coordinates of left eye
            left_center_x = mouse_x - 3
            center_y = mouse_y
        END IF
        ' If eye location is in bounds, print the eyes and pupils
        x_in_bounds = left_center_x > 2 AND left_center_x < 73
        y_in_bounds = center_y > 2 AND center_y < 22
        IF x_in_bounds AND y_in_bounds THEN
            CLS
            FOR eye = 1 TO 2
                ' eye = 1 for left eye, eye = 2 for right eye
                IF eye = 1 THEN center_x = left_center_x
                IF eye = 2 THEN center_x = left_center_x + 6
                ' Print eye borders
                LOCATE center_y - 2, center_x - 2
                PRINT ".---."
                FOR row = 1 TO 3
                    LOCATE , center_x - 2
                    PRINT "|   |"
                NEXT row
                LOCATE , center_x - 2
                PRINT "'---'"
                ' Calculate coordinates of pupil
                xdiff = mouse_x - center_x
                ydiff = mouse_y - center_y
                slope = ydiff / xdiff
                ' For most cases, adding the sign of the diff to the center
                ' coordinate is sufficient
                pupil_x = center_x + SGN(xdiff)
                pupil_y = center_y + SGN(ydiff)
                ' But in octants 3 and 7, the x-coordinate is centered
                IF ABS(slope) > 2 THEN pupil_x = center_x
                ' And in octants 1 and 5, the y-coordinate is centered
                IF ABS(slope) < 0.5 THEN pupil_y = center_y
                LOCATE pupil_y, pupil_x
                PRINT "0"
            NEXT eye
        END IF   ' in bounds
    END IF   ' mouse data
LOOP   ' forever

It's been a decade or two since I used QB, but couldn't you use ?0 instead of ?"0"? This suggests you can use a numeric expression as well as strings.

@Joey Hmm. Printing it as a number also prints a space before and after it... but come to think of it, I bet I could print the pupils first and then that wouldn't be a problem. Except then I'd have to print the left and right borders separately instead of as "|   |". So it probably wouldn't save anything. "0" is only 2 bytes longer.

Excel VBA 32-Bit, 630 519 Bytes
A Worksheet level Subroutine that activates on every click. Draws eyes in a \$5\times 11\$ range centered at the clicked cell.
This is calibrated to run at the default zoom of 100%. It breaks if when scrolling, zooming, or selecting multiple cells.
Sub Worksheet_SelectionChange(ByVal t As Range)
With Cells
.Clear
.ColumnWidth=1.3
.Font.Name="Courier"
End With
Dim l As p,p As p
Q l
On Error Resume Next
Do
DoEvents
Q p
For i=0To 1
v=l.x-p.x+56*(-1)^i
w=l.y-p.y
n=IIf(Abs(v)>6Or Abs(w)>9,(4*Application.Atan2(v,w)\[Pi()]+4)Mod 8,8)
For j=0To 24
m=Mid(".---.|567||480||321|'---'",j+1,1)
t.Offset(j\5-2,j Mod 5+1-6*i)=Mid("0 '"&m,3+(m Like"[0-9]")+(m=Val(n)))
Next j,i
Loop
End Sub

Note: terminal " on line 5 is included for Prettify.JS/Markdown syntax highlighting only, and does not contribute to byte count
Helper Function and Type Declaration
The below declarations allow for querying the cursor position using the Windows management function GetCursorPos.
These must be declared in an accessible Module level context.
Declare Sub Q Lib"user32"Alias"GetCursorPos"(l As p)
Type p
x As Long
y As Long
End Type

The above is only compatible with 32-bit installations of Excel, but may be adjusted to run in a 64-bit installs by modifying the the declaration to
Declare PtrSafe Sub Q Lib"user32"Alias"GetCursorPos"(l As p)

Output

Commented
''  execute the following every time the user changes selection
Sub Worksheet_SelectionChange(ByVal t As Range)

    ''  Tell VBA to keep running on errors
    ''    ( Necessary for specification Note #6 )
    On Error Resume Next

    ''  Clear All Cell, Make them Square, Use Monospace Font
    With Cells
        .Clear
        .ColumnWidth = 1.3
        .Font.Name = "Courier"
    End With

    ''  Dim two p (point) objects, defined below
    Dim l As p, p As p

    ''  Use Q (alias for User32 function GetCursoPos) to get initial mouse position (l)
    Q l

    ''  Implicitly loop until the next selection change event
    Do

    ''  Allow events
    DoEvents

    ''  Use User32 function to get current mouse position (p)
    Q p

    '' iterate over the two eyes (left: i=1, right: i=0)
    For i = 0 To 0 '1

        ''  define var (v) with horiontal distance between cursor and center of eye i
        v = l.x - p.x + 56 * (-1) ^ i

        ''  define var (w) with vertical distance between cursor and center of eyes
        w = l.y - p.y

        ''  Based off of (v) and (w), calculate which of the numbers in the below
        ''    should be the pupil for each eye
        ''
        ''  .---.
        ''  |567|
        ''  |480|
        ''  |321|
        ''  '---'
        ''
        n = IIf(Abs(v) > 6 Or Abs(w) > 9, (4 * Application.Atan2(v, w) \ [Pi()] + 4) Mod 8, 8)

        ''  Iterate over the 25 cells to be updated, per eye
        For j = 0 To 24

            ''  find character at current cell in template
            m = Mid(".---.|567||480||321|'---'", j + 1, 1)

            ''  stuff cell with the first *k* letters of  "0 '" & template char
            ''    where k defaults to 3,
            ''      is decremented by 1 if template char is a number  AND
            ''      is decremented by 1 if template char is n
            ''
            ''  Cases:
            ''    Border Characters (`.`,`-`,`|`,`'`):
            ''      start at 3rd character, cell holds `'` and template char
            ''      Note: `'` literal at beginning of cell coerces excel to display
            ''      any and all values as text, allowing `-` to be printed
            ''    Sclera Characters (` `):
            ''      start at 2nd character, cells hold ` '` and template char
            ''      but due to cell sizing and monospace font, only ` ` is visible
            ''    Iris / Pupil Characters (`0`):
            ''      start at 1st character, cells hold `0 '` and template char
            ''      but only leading `0` is visible
            ''      Note: use of `Val` here forces implicit type
            ''          coercion, and is generally *cursed*
            t.Offset(j \ 5 - 2, j Mod 5 + 1 - 6 * i) = Mid("0 '" & m, 3 + (m Like "[0-9]") + (m = Val(n)))

    ''  End For loops
    Next j, i

    ''  End Do loop
    Loop
End Sub

This doesn’t match the specification in a few ways. 1. “Grid of characters” means single characters with distinct positions. When the mouse cursor is on, say, the rightmost ' character the output will be different from when it’s on the leftmost ' character. 2. The eyes’ position is not fixed. A mouse click should cause them to move to the clicked position. I’m flexible on the method of input (I’d accept, say, a virtual mouse cursor controlled by the arrow keys), but there are two distinct input events with distinct behavior: mouse movement and mouse click.

@Jordan I am not quite sure what you mean by point 1, could you please elaborate? As for point 2, the eyes are not static, and clicking on any cell on the sheet in which the subroutine is placed shall trigger the Worksheet_SelectionChange event and pass the calling range (Target or T in this case)  - which redraws the eyes and a * in the calling cell

Wrt #1, perhaps I’ve misunderstood from your screenshots, but it looks like each cell in your worksheet is a distinct position, i.e. “character” per the specification, but the eyes are drawn in a single cell of the worksheet. In the specification, though, the eyes are 11 columns and 5 rows, and the mouse cursor can be at any of the 55 positions within the eyes (or, of course, any position outside them). (cont.)

Furthermore, per the specification the pupils must move independently. When the user first clicks, for example, the cursor will be directly between the eyes, so the left pupil will be (referring to the 1–9 diagram under “Pupil pointing”) at position 1 and the right at position 5. If, then, the mouse cursor moves three characters to the right, the left pupil will still be at 1, but the right pupil will have moved to 9. You can see this independent-pupil behavior in the GIF at the top of the post.

(I’m perfectly happy with your solution being in a worksheet. I was hoping to see non–terminal-emulator solutions.)

Nice! Purely out of curiosity, why only 64bit?

Maybe change the two screenshots to a screen-to-gif?

HTML + CSS + JavaScript (ES6), 93 + 19 + 278 276 = 388 bytes

w=7.8125
h=15
with(Math)r=round,
(onclick=e=>F.style=`margin:-3.5em -6.5ch;left:${x=r(e.x/w)*w}px;top:${y=r(e.y/h)*h}px`)({y:-40}),onmousemove=e=>(s=($,o)=>$.style=`left:${a=atan2(Y=r((e.y-y)/h),X=r((e.x-x)/w+o)),X|Y?w*r(cos(a)):0}px;top:${X|Y?h*r(sin(a)):0}px`)(L,3)&&s(R,-3)
*{position:relative

.---. .---.
|   | |   |
| 0 | | 0 |
|   | |   |
'---' '---'

Both X||Y can be golfed to X|Y to save 2 bytes.

Doesn't work so well when you click near the bottom of the container and have to scroll down. https://i.stack.imgur.com/s44KU.png Not sure if specific to the snippet wrapper, but was worth mentioning.

@Οurous It's rather ambiguously worded: "centered at the location of the mouse cursor." Does "location" mean "grid cell" or can it mean "pixel"? I agree that the intent was probably the former, but the wording certainly seems to allow the latter.

@KevinCruijssen Unfortunately, that doesn't work – | ends up taking precedence over the ternary expression.

@darrylyeo No it doesn't? :S This JavaScript operator precedence table shows | and || on somewhat the same level, and both above ?:.. Both X||Y?w*r(cos(a)):0 and X||Y?h*r(sin(a)):0 are currently in the form boolean_condition?A:B. So when you change X||Y to X|Y it will do a bit-wise OR and then interpret as a boolean condition again. ((X||Y)?A:B vs (X|Y)?A:B, not X|(Y?A:B)). Also, I don't see any difference when I use "Copy snippet to answer" and change the || to |. Everything still works exactly the same as far as I can tell..

@Ourous is right here. I originally had a more explicit definition of "location" but took it out because I thought it was too obvious...  I'll edit the question to make it explicit.

Reading it again, I actually did make this pretty explicit: "When the program receives input—a click or movement—it should map the input location to the nearest grid coordinate ." Nevertheless, I've edited the question slightly to remove any ambiguity.

@Jordan Edited. It should now snap to the grid.

@KevinCruijssen Compare 1|1?true:false with 1|(1?true:false). Looking at the table you linked, I'm not exactly sure why this is (probably something to do with left-to-right vs right-to-left associativity?). Either way, I applied the change; I must have seen something different when I tried it the first time.

6502 machine code (C64 + 1351 mouse), 630 bytes
00 C0 20 44 E5 A9 FF 85 5E A2 3F A9 00 8D 10 D0 8D 1B D0 9D C0 02 CA 10 FA A0
0A A2 1E B9 5A C2 9D C0 02 CA CA CA 88 10 F4 A9 0B 8D F8 07 A9 18 8D 00 D0 A9
32 8D 01 D0 A9 0D 8D 27 D0 A9 01 8D 15 D0 78 A9 60 8D 14 03 A9 C1 8D 15 03 58
D0 FE 84 FD 85 FE A8 38 E5 FD 29 7F C9 40 B0 04 4A F0 0A 60 09 C0 C9 FF F0 03
38 6A 60 A9 00 60 20 44 E5 A5 69 38 E9 05 B0 02 A9 00 C9 1E 90 02 A9 1D 85 FD
18 69 02 85 5C 69 06 85 5D A5 6A 38 E9 02 B0 02 A9 00 C9 15 90 02 A9 14 85 FE
18 69 02 85 5E A9 65 8D BB C0 A9 C2 8D BC C0 A9 04 85 02 A6 FE 20 F0 E9 A9 02
85 5F A4 FD A2 00 BD FF FF 91 D1 C8 E8 E0 05 D0 F5 C8 C6 5F D0 EE E6 FE A9 6A
8D BB C0 A9 C2 8D BC C0 C6 02 30 0E D0 D1 A9 6F 8D BB C0 A9 C2 8D BC C0 D0 C5
60 C5 69 90 0A F0 5D E5 69 85 5F A9 C6 D0 09 49 FF 38 65 69 85 5F A9 E6 8D 1C
C1 8D 23 C1 8D 3E C1 A5 6A C5 5E 90 21 F0 12 E5 5E C5 5F 90 12 4A C5 5F B0 02
C6 FD A6 5E E8 D0 33 C6 FD A6 5E D0 2D 0A C5 5F B0 EE 90 F3 49 FF 38 65 5E C5
5F 90 0C 4A C5 5F B0 02 C6 FD A6 5E CA D0 11 0A C5 5F B0 F4 90 D7 A5 6A C5 5E
90 EE F0 D1 B0 C8 20 F0 E9 A9 30 A4 FD 91 D1 60 AD 19 D4 A4 FB 20 4E C0 84 FB
85 5F 18 6D 00 D0 8D 00 D0 6A 45 5F 10 08 A9 01 4D 10 D0 8D 10 D0 AD 10 D0 4A
AD 00 D0 B0 08 C9 18 B0 16 A9 18 D0 0F C9 58 90 0E 24 5F 10 05 CE 10 D0 B0 EF
A9 57 8D 00 D0 AD 1A D4 A4 FC 20 4E C0 84 FC 49 FF 85 5F 38 6D 01 D0 8D 01 D0
6A 45 5F 10 06 24 5F 10 11 30 07 AD 01 D0 C9 32 B0 04 A9 32 D0 06 C9 FA 90 05
A9 F9 8D 01 D0 A5 69 85 6B A5 6A 85 6C AD 10 D0 4A AD 00 D0 6A 38 E9 0C 4A 4A
85 69 AD 01 D0 38 E9 32 4A 4A 4A 85 6A AD 01 DC 29 10 C5 6D F0 0B 85 6D 29 10
D0 05 20 6C C0 30 10 A5 5E 30 46 A5 69 C5 6B D0 06 A5 6A C5 6C F0 3A A6 5E CA
86 5F A9 03 85 02 A6 5F 20 F0 E9 A9 20 A2 03 A4 5C 88 91 D1 C8 CA D0 FA A2 03
A4 5D 88 91 D1 C8 CA D0 FA E6 5F C6 02 D0 DD A5 5C 85 FD 20 E9 C0 A5 5D 85 FD
20 E9 C0 4C 31 EA 80 C0 E0 F0 F8 FC F0 D8 18 0C 0C 2E 2D 2D 2D 2E 5D 20 20 20
5D 27 2D 2D 2D 27

In action:

No online demo, sorry, because there's AFAIK no js C64 emulator supporting a mouse. If you want to try it yourself, grab VICE, download the binary executable and start it in the C64 emulator:
x64sc -autoload xeyes.prg -controlport1device 3 -keybuf 'sys49152\n'

To grab/ungrab the mouse input in the running emulator, use ctrl+m on Unix/Linux and ctrl+q on windows.

Yes, this had to be done ;) After all, there is an original Commodore mouse for the C64, but of course, the builtin operating system doesn't support it, so I first needed a mouse driver, which already took 230 bytes (including a mouse-cursor shaped hardware sprite and bounds checking code for the screen area, but without translating the pointer coordinates to text screen coordinates).

To safe some bytes, I decided to keep the OS' IRQ working and use a few Kernal routines where possible (clearing the screen and getting a base pointer for a text screen row).
The code also puts all variables in zeropage, which saves some more bytes, but destroys floating point values used by BASIC. As the program never exits anyways, this doesn't matter.
The third trick to reduce size is self modification: There's only code to check for putting the pupil on the left side of the eye. The same code is reused after patching some decrement instructions to increment instructions for the right side.

If you're interested, you can read the code as assembly source here :)

I seem to be the only one trying to compete here from time to time with C64 code. Loved this challenge, because a mouse on the C64 is something "exotic"! If anyone wonders why I'm less active lately, this is the reason: http://csdb.dk/release/?id=161435 -- finally trying to do a full-featured game for the C64 :)

Just for the fun of it, I did a "deluxe version": http://csdb.dk/release/?id=161762

Clean, 1014 904 892 884 840 814 782 772 769 bytes
-6 bytes if the eyes don't need to snap to a grid
This wasn't easy. UIs in functional languages rarely are.
import StdEnv,StdIO,osfont,ostoolbox
a=toReal
c=1>0
Start w#(d,w)=openId w
#(t,w)=worldGetToolbox w
#(_,f,_)=osSelectfont("Courier",[],9)t
=let$p#(s,p)=accPIO getProcessWindowSize p
    =snd(openWindow NilLS(Window""NilLS[WindowId d,WindowMouse(\_=c)Able(noLS1@),WindowViewSize s,WindowPen[PenFont f]])p);@(MouseUp p _)s={s&ls=p};@(MouseMove p _)s=:{ls={x,y},io}={s&io=setWindowLook d c(c,(\_{newFrame}i#(w,i)=getFontCharWidth f' '(unfill newFrame i)
    =let g v=let m=y-p.y;n=p.x-x-v*w;s=abs(a m/a n);k|abs m<9&&abs n<w=5|s<0.4142=if(n>0)6 4=sign if(s>2.4143)0n+if(m>0)2 8in[".---.":["|"+++{if(k==e)'0'' '\\e<-[j..j+2]}+++"|"\\j<-[1,4,7]]]++["'---'"]in foldr(\e=drawAt{x=(x/w-5)*w,y=(y/9+e-2)*9}([a+++" "+++b\\a<-g -3&b<-g 3]!!e))i[0..4]))io};@_ s=s
in startIO SDI zero$[]w

Make sure that you're using iTasks Clean, have the Courier font installed, and have StdLib BEFORE any subfolders of ObjectIO in the module search path.
Compile with (example, may differ): clm -IL StdLib -IL ObjectIO -IL "ObjectIO/OS <YOUR_OS_HERE>" -IL Dynamics -IL Generics -IL Platform -nci <MODULE_NAME_HERE>
If you've never run Clean before, expect this project to take 5+ minutes to compile.
Ungolfed:
module main
import StdEnv,StdIO,osfont,ostoolbox
height=9
SlopeFor225 :== 0.4142

StartSize :== 8

Universe :== {corner1={x=0,y=0},corner2={x=1,y=1}}

Start :: *World -> *World
Start world = startConsole (openIds 1 world)

startConsole :: ([Id],*World) -> *World
startConsole ([windowID],world)
    # (toolbox,world) = worldGetToolbox world
    # (_,font,toolbox) = osSelectfont ("Consolas",[],height) toolbox
    = startIO SDI {x=0,y=0} (initialise font) [ProcessClose closeProcess] world
where
    initialise font pst
        # (size,pst) = accPIO getProcessWindowSize pst
        # (error,pst) = openWindow undef (window font size) pst
        | error<>NoError = abort "bad window"
        = pst

    window font size
        = Window "Xeyes" NilLS
            [WindowId           windowID
            ,WindowClose        (noLS closeProcess)
            ,WindowMouse        mouseFilter Able (noLS1 track)
            ,WindowViewDomain   Universe//(getViewDomain StartSize)
            ,WindowViewSize     size
            ,WindowPen          [PenFont font]
            ]

    track (MouseDown pos _ _) state=:{ls=point=:{x,y},io}
        # point = pos
        // move to mouse position
        = {state & ls=pos}

    track (MouseMove pos _) state=:{ls=point=:{x,y},io}
        //redraw to point at mouse
        # io = setWindowLook windowID True (True, look) io
        = {state & ls=point,io=io}
    where
        look _ {newFrame} picture
            # picture = unfill newFrame picture
            # (width,picture) = getPenFontCharWidth' 'picture
            = let
                determineSector u
                    # yDist = (y - pos.y)
                    # xDist = (pos.x - u)
                    # slope = abs(toReal yDist / toReal xDist)
                    | (abs yDist) < height && (abs xDist) < width = '9'
                    | slope < SlopeFor225 = if(xDist > 0) '1' '5'
                    | yDist > 0
                        | slope > (2.0+SlopeFor225) = '7'
                        = if(xDist > 0) '8' '6'
                    | slope > (2.0+SlopeFor225) = '3'
                    = if(xDist > 0) '2' '4'
                getEye u=map(map(\e|isDigit e=if(e==determineSector(x+u*width))'0'' '=e))[['.---.'],['|678|'],['|591|'],['|432|'],['\'---\'']]
            in foldr(\i pic=drawAt{x=(x/width-5)*width,y=(y/height+i-2)*height}([toString(a++[' ':b])\\a<-getEye -3&b<-getEye 3]!!i)pic)picture[0..4]

    mouseFilter (MouseDown _ _ _) = True
    mouseFilter (MouseMove _ _) = True
    mouseFilter _ = False

As you can see from the ungolfed version, most of the code is just setting up the combination of "monospaced font" with "respond to the mouse". And even though Courier doesn't make it easy to tell, it is actually drawing the .s and 's. Swapping to something like Consolas makes it clearer.

I don't know Clean at all, so perhaps I'm saying something weird, but is it possible to change (abs m)<9&&(abs n)<w='9' to (abs m)<9&(abs n)<w='9'? Also, I suggest adding a screen-to-gif instead of screenshot.

@KevinCruijssen That wouldn't work for multiple reasons, but I did save 4 bytes dropping the brackets in the same expression, so thanks! I've also added a screen gif!

Ruby, 335 + 13 = 348 bytes
+13 bytes for -rio/console flag to enable IO#getch.
Contains literal ESC (0x1b) characters, shown as ␛ below. xxd dump follows.
Caution: This does not clean up after itself at exit. See note under xxd dump below.
include Math
$><<"␛[?1003h"
s=""
(s<<STDIN.getch
($><<"␛[2J"
x,y=$3.ord-32,$4.ord-32
u,v=x,y if$2
u&&[x-u+3,x-u-3].map{|a|b=y-v
e=4*asin(b/sqrt(a**2+b**2))/PI
printf"␛[%d;%dH.---.@|567|@|480|@|321|@'---'".gsub(/(#{(a<0?4-e:b<0?8+e:e).round%8rescue 8})|([0-8])|@/){$1?0:$2?" ":"␛[5D␛[1B"},v-2,x-a-2}
s="")if /M(C|(#))(.)(.)$/=~s)while 1

Ungolfed
This is a pretty naïve golf of my original Ruby implementation.
include Math       # Saves a few bytes for asin, sqrt, and PI
$> << "␛[?1003h"   # Print xterm control sequence to start mouse tracking
s = ""             # Variable to hold input-so-far
(
  s << STDIN.getch   # Read a character from STDIN
  (
    $> << "␛[2J"                     # Clear terminal
    x, y = $3.ord - 32, $4.ord - 32  # Get cursor x and y from last match
    u, v = x, y if $2                # Update eye position if last matched control sequence was click ("#")

    u && [x-u+3, x-u-3].map {|a|     # For each eye's x-position
      b = y - v                                       # Eye's y position
      e = 4 * asin(b / sqrt(a**2 + b**2)) / PI        # Convert cursor (x,y) to angle w/ x-axis as 1/8 turns

      printf "␛[%d;%dH.---.@|567|@|480|@|321|@'---'"  # Control code to move text cursor, followed by template for eye
        .gsub(
          /(#{
            (a < 0 ? 4-e : b < 0 ? 8+e : e).round % 8 rescue 8  # Octant number 0-7 or 8 for center
          })|([0-8])|@/
        ){ $1 ? 0 : $2 ? " " : "␛[5D␛[1B" },            # Replace octant number with pupil; other digits with space; and @s with code to move cursor left and down for next line of eye
        v-2, x-a-2                                      # (y, x) position of top left corner of eye
    }
    s = ""                           # Clear input-so-far
  ) if /M(C|(#))(.)(.)$/ =~ s      # ...when input-so-far matches a movement ("C") or click ("#") control sequence
) while 1                        # ...forever

xxd dump
This program turns on mouse tracking with the xterm control sequence \e[?1003h but doesn't turn it off at exit. To turn it off, use the control sequence \e[?1003l, e.g.:
ruby -rio/console visual_eyes.rb; printf '\e[1003l'

Since the program eats all input, it's hard to exit. If you want to be able to exit by pressing Ctrl+C, add the following line below (s<<STDIN.getch:
exit 130 if s.end_with?(?\003)

Without further ado:
00000000: 696e 636c 7564 6520 4d61 7468 0a24 3e3c  include Math.$><
00000010: 3c22 1b5b 3f31 3030 3368 220a 733d 2222  <".[?1003h".s=""
00000020: 0a28 733c 3c53 5444 494e 2e67 6574 6368  .(s<<STDIN.getch
00000030: 0a28 243e 3c3c 221b 5b32 4a22 0a78 2c79  .($><<".[2J".x,y
00000040: 3d24 332e 6f72 642d 3332 2c24 342e 6f72  =$3.ord-32,$4.or
00000050: 642d 3332 0a75 2c76 3d78 2c79 2069 6624  d-32.u,v=x,y if$
00000060: 320a 7526 265b 782d 752b 332c 782d 752d  2.u&&[x-u+3,x-u-
00000070: 335d 2e6d 6170 7b7c 617c 623d 792d 760a  3].map{|a|b=y-v.
00000080: 653d 342a 6173 696e 2862 2f73 7172 7428  e=4*asin(b/sqrt(
00000090: 612a 2a32 2b62 2a2a 3229 292f 5049 0a70  a**2+b**2))/PI.p
000000a0: 7269 6e74 6622 1b5b 2564 3b25 6448 2e2d  rintf".[%d;%dH.-
000000b0: 2d2d 2e40 7c35 3637 7c40 7c34 3830 7c40  --.@|567|@|480|@
000000c0: 7c33 3231 7c40 272d 2d2d 2722 2e67 7375  |321|@'---'".gsu
000000d0: 6228 2f28 237b 2861 3c30 3f34 2d65 3a62  b(/(#{(a<0?4-e:b
000000e0: 3c30 3f38 2b65 3a65 292e 726f 756e 6425  <0?8+e:e).round%
000000f0: 3872 6573 6375 6520 387d 297c 285b 302d  8rescue 8})|([0-
00000100: 385d 297c 402f 297b 2431 3f30 3a24 323f  8])|@/){$1?0:$2?
00000110: 2220 223a 221b 5b35 441b 5b31 4222 7d2c  " ":".[5D.[1B"},
00000120: 762d 322c 782d 612d 327d 0a73 3d22 2229  v-2,x-a-2}.s="")
00000130: 6966 202f 4d28 437c 2823 2929 282e 2928  if /M(C|(#))(.)(
00000140: 2e29 242f 3d7e 7329 7768 696c 6520 31    .)$/=~s)while 1


text:
Are the numbers amicable?
Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and second numbers aren't equal.
\$s(x)\$ represents the aliquot sum or proper divisor sum of \$x\$. 220 and 284 are amicable because \$s(220) = 284\$ and \$s(284) = 200\$.
Your task is, unsurprisingly, to determine whether two inputted numbers are amicable or not. The inputs will be positive integers and you may output two distinct, consistent values for amicable or not.
This is OEIS sequence A259180
This is a code-golf so the shortest code wins.
Test cases
input, input => output
220, 284 => 1
52, 100 => 0
10744, 10856 => 1
174292, 2345 => 0
100, 117 => 0
6, 11 => 0
495, 495 => 0
6, 6 => 0

Related, Related

Updating the challenge to invalidate existing solutions ain't cool nor, in my book, is input validation. I suggest either allowing both numbers to be the same or not requiring us to handle those cases.

@Shaggy I agree, but given that half the solutions currently validate the input, and that validating the input is part of the challenge, I can't really change to either of those suggestions, as different solutions would be doing different things. It's an oversight I missed, but revoking it would make the challenge worse overall.

@Shaggy in this case, I think an exception might be in order since this is the definition of amicability.

Related Project Euler challenge (#21)

Jelly, 5 bytes
QfÆṣ⁼

A monadic link taking a list of two integers which returns 1 if they are a pair of amicable numbers and 0 otherwise.
Try it online!
How?
QfÆṣ⁼ - Link: pair of numbers L, [a, b]   e.g. [220,284]  or [6,6]  or [6,11]  or [100,52]
Q     - de-duplicate L                         [220,284]     [6]       [6,11]     [100,52]
  Æṣ  - proper divisor sum of L (vectorises)   [284,220]     [6]       [6,1]      [117,46]
 f    - filter keep left if in right           [220,284]     [6]       [6]        []
    ⁼ - equal to L?                            1             0         0          0

;wÆṣỊ and œ¿ÆṣḊ also score 5 bytes.

and ÆṣQU⁼ - maybe there is a sneaky 4 somewhere...

Python 2, 65 63 66 bytes
-2 bytes thanks to Mr. Xcoder

lambda c:[sum(i*(n%i<1)for i in range(1,n))for n in c]==c[::-1]!=c

Try it online!

J, 51 28 27 24 Bytes
-Lots of bytes thanks to @cole
-1 more byte thanks to @cole
~.-:[:|.(1#.i.*0=i.|])"0

Try it online!

I think you can use -:[:|.(1#.i.*0=i.|])”0 or something akin to it. The divisor sum (rightmost verb) is taken from mile’s comment on our divisor sum question. Edit: with a different quotation mark since I’m on mobile.

Apparently they need to be not equal so prepend a ~:/*].

Actually I think you can instead do ~.-:... (match with dedpulicated input), which I stole from the Jelly answer.

I removed an extra -:-match in your code, updated the bytecount, and added a TIO link. Hope that's OK by you. Feel free to roll back if it isn't (but the solution prior had a domain error you'd want to fix).

20 bytes with >:@#.~/.~&.q:-:~:*+/

@miles loving the succinct aliquot via its factors >:@#.~/.~&.q:

Python 2, 71 67 bytes
-4 bytes thanks to xnor
+9 bytes thanks to caird coinheringaahing
lambda c:[sum(i for i in range(1,x)if x%i<1)for x in c]==c[::-1]!=c

partly inspired by [this answer]

Welcome to the site! You may not assume that input can be stored in a variable, so you must include the def f(x): return in your bytecount.

A map with lambda expression is nearly always longer than a list comprehension.

Ruby, 64 60 59 58 bytes
->c{c.map{|i|(1...i).sum{|j|i%j<1?j:0}}==c.rotate&&c==c&c}

Try it online!

Brain-Flak, 178 bytes
{(({})(<>))<>({<<>(({})<<>{(({})){({}[()])<>}{}}>)<>([{}](({}[()])))>{[()]((<{}{}>))}{}{}}{}<>)<>}<>(({}<>)<>[({}{}<>)])({<{}({<({}<>[{}])>{()(<{}>)}{}})>(){[()](<{}>)}}<{}{}{}>)

Try it online!

Python 3, 84 bytes
d=lambda n:sum(i*(n%i<1)for i in range(1,n))
f=lambda a,b:(d(a)==b)*(d(b)==a)*(a^b)>0

Straightforward solution.  d sums up divisors (n%i<1 evaluates to 1 iff i divides n). a^b is nonzero iff a!=b.  The LHS of the inequality is thus 0 iff the numbers are not amicable and >0 otherwise.

Brachylog, 9 bytes
≠.{fk+}ᵐ↔

Try it online!
Takes input as a list and outputs through success or failure.
             The input
≠            which contains no duplicate values
 .           is the output variable,
  {   }ᵐ     and its elements'
    k        proper
   f         divisor
     +       sums
        ↔    reversed
             are also the output variable.

Forth (gforth), 80 bytes
Refactored reffu's solution.
: d { n } 0 n 1 do n i mod 0= i * - loop ;
: f 2dup <> -rot 2dup d swap d d= * ;

Try it online!
How it works
: d { n -- divsum } \ Takes a number and gives its divisor sum (excluding self)
                    \ Store n as a local variable
  0 n 1 do          \ Push 0 (sum) and loop through 1 to n-1...
    n i mod 0=      \   If n % i == 0, push -1 (built-in true in Forth); otherwise push 0
    i * -           \   If the value above is -1, add i to the sum
  loop ;            \ End loop and leave sum on the stack

: f ( n1 n2 -- f )  \ Main function f. Takes two numbers and gives if they are amicable
  2dup <>           \ Are they not equal? ( stack: n1 n2 n1<>n2 )
  -rot              \ Move the boolean under n1 n2 ( stack: n1<>n2 n1 n2 )
  2dup d swap d     \ Copy two numbers, apply d to both and swap
                    \ ( stack: n1<>n2 n1 n2 n2.d n1.d )
  d=                \ Compare two 2-cell numbers for equality; n1=n2.d && n2=n1.d
  * ;               \ Return the product of the two booleans

Desmos, 214 65+102=167 bytes
This is more of a fun answer, not a competitive one:
Expression 1, 65 bytes:
g(N)=\sum_{n=1}^{N-1}\left\{\operatorname{mod}(N,n)=0:n,0\right\}

Expression 2, 102 bytes:
f(M,N)=\left\{\left\{g(N)=M:1,0\right\}+\left\{g(M)=N:1,0\right\}+\left\{M=N:0,1\right\}=3:1,0\right\}

Try It On Desmos!
I feel like this could definitely be golfed a lot. Too bad I can't take out those \left's and \right's, because they are in front of brackets(Desmos won't allow me to for some reason).

JavaScript (ES6), 53 bytes
Takes input in currying syntax (a)(b). Returns 0 or 1.
a=>b=>a!=b&a==(g=n=>--a&&a*!(n%a)+g(n))(a=g(a)-b?1:b)

Demo

let f =

a=>b=>a!=b&a==(g=n=>--a&&a*!(n%a)+g(n))(a=g(a)-b?1:b)

console.log(f(220)(284))  // => 1
console.log(f(52)(100))   // => 0
console.log(f(100)(117))  // => 0
console.log(f(6)(6))      // => 0

How?
We use the function g to get the sum of the proper divisors of a given integer.
We first compute g(a) and compare it with b. If g(a) = b, we compute g(b) and compare it with a. Otherwise, we compute g(1), which gives 0 and can't possibly be equal to a.
We additionally check that a is not equal to b.

Haskell, 53 bytes
-2 bytes thanks to BMO. -1 byte thanks to Ørjan Johansen.
a!b=a==sum[i|i<-[1..b-1],b`mod`i<1,a/=b]
a#b=a!b&&b!a

Try it online!
Ungolfed with UniHaskell and -XUnicodeSyntax
import UniHaskell

equalsOmega       ∷ Int → Int → Bool
a `equalsOmega` b = a ≡ sum [i | i ← 1 … pred b, i ∣ b, a ≢ b]

areAmicable       ∷ Int → Int → Bool
areAmicable a b   = (a `equalsOmega` b) ∧ (b `equalsOmega` a)

Since 0 is not a valid input, you can save a byte by moving a/=b inside the list comprehension.

SNOBOL4 (CSNOBOL4), 153 146 bytes
	DEFINE('D(X)I')
	DEFINE('A(M,N)')
A	A =EQ(D(M),N) EQ(D(N),M) ~EQ(N,M) 1 :(RETURN)
D	I =LT(I,X - 1) I + 1	:F(RETURN)
	D =EQ(REMDR(X,I)) D + I	:(D)

Try it online!
Defines a function A that computes the amicability of two numbers, returning 1 for amicable and the empty string for not. The algorithm is the same as my previous answer so I leave the old explanation below.
	DEFINE('D(X)I')					;*function definition
	M =INPUT					;*read M,N as input
	N =INPUT
	OUTPUT =EQ(D(M),N) EQ(D(N),M) ~EQ(N,M) 1 :(END)	;* if D(M)==N and D(N)==M and N!=M, output 1. goto end.
D	I =LT(I,X - 1) I + 1	:F(RETURN)		;* function body: increment I so long as I+1<X, return if not.
	D =EQ(REMDR(X,I)) D + I	:(D)			;* add I to D if D%%I==0, goto D
END

APL+WIN, 49 54 41 40 35bytes
Rewritten to reject equal integer inputs
Prompts for screen input of a vector of the two integers.
(≠/n)×2=+/n=⌽+/¨¯1↓¨(0=m|n)×m←⍳¨n←⎕

Can you please check if this is valid for inputs like 6, 6?

@Mr. Xcoder It results in 1 for 6,6 which does not agree with the test case above. The divisors of 6 are 1,2,3 which sum to 6 so what am I missing?

The OP and I had that discussion earlier.

@Graham OP said they must be different numbers.

Japt, 7 12 10 bytes
Takes input as an array of 2 numbers.
®â¬xÃeUâ w

Try it

Added 3 bytes to handle [6,11].
Added another 3 bytes after the challenge was updated to require input validation. (Boo-urns on both fronts!)
Saved 1 byte thank to Oliver.

Pyth, 13 bytes
&-FQqFms{*MyP

+4 bytes to check if values are distinct, I feel like that shouldn't be part of the challenge...
Can almost certainly be golfed a lot
Try it online!

&-FQqFms{*MyP     Full program, takes input from stdin and outputs to stdout
 -FQ              Q0 - Q1 is true, meaning elements are distinct
&                  and
      m       Q   for each element of the input list, apply
           yPd    take the powerset of the prime factors
        {*M       multiply each list and deduplicate
       s          and sum the list (this represents S(n)+n )
    qF            and fold over equality, returning whether the two elements are equal

Fixed (filler!)

Forth (gforth), 91 86 bytes
: d { n } 0 n 1 do n i mod 0= i * - loop ;
: f { a b } a b = 1+ a d b = b d a = * * ;

Try it online!
Forth (gforth) No Locals, 94 bytes
A more "Forthy" version that doesn't use local variables
: d 0 over 1 do over i mod 0= i * - loop nip ;
: f 2dup = 1+ -rot 2dup d -rot d = -rot = * * ;

Try it online!

APL NARS, 38 bytes, 18 chars
{≠/⍵∧∧/⍵=⌽-⍵-11π⍵}

11π⍵ find the sum of divisors of ⍵ in 1..⍵; note that the question want (11π⍵)-⍵ and in APLsm
-⍵-11π⍵=-(⍵-11π⍵)=(11π⍵)-⍵

the test
  t←{≠/⍵∧∧/⍵=⌽-⍵-11π⍵}
  t 284 220⋄t 52 100⋄t 10744 10856 ⋄t 174292 2345
1
0
1
0
  t 100 117⋄t 6 11⋄t 495 495⋄t 6 6
0
0
0
0

PowerShell, 87 96 bytes
param($a,$b)filter f($n){(1..($n-1)|?{!($n%$_)})-join'+'|iex}(f $a)-eq$b-and(f $b)-eq$a-and$a-$b

Try it online!
Takes input $a,$b. Defines a filter (here equivalent to a function) that takes input $n. Inside we construct a range from 1 to $n-1, pull out those that are divisors, -join them together with + and send that to Invoke-Expression (similar to eval).
Finally, outside the filter, we simply check whether the divisor-sum of one input is equal to the other and vice-versa (and input validation to make sure they're not equal). That Boolean value is left on the pipeline and output is implicit.

Fails for 6, 6.

@Mr.Xcoder Boo-urns. Corrected for 9 bytes. :-/

R, 67 bytes
function(a,b)sum(which(!a%%1:a))-a==b&sum(which(!b%%1:b))-b==a&b!=a

Try it online!
returns TRUE for amicable, FALSE for not.

@BrunoCosta alas, I cannot: it would be 68 bytes

APL (Dyalog Unicode),  45 38 44 36 35 20 bytes
{(≠/⍵)∧(⌽⍵)≡+/¨¯1↓¨(0=⍵|⍨⍳¨⍵)/¨⍳¨⍵}

Try it online!
Infix Dfn, fixed for the equal inputs case.
Thanks @Uriel for 8 bytes; @cole for 1 byte; @Adám for 15 bytes.
How?
{(≠/⍵)∧(⌽⍵)≡+/¨¯1↓¨(0=⍵|⍨⍳¨⍵)/¨⍳¨⍵} ⍝ Main function, infix. Input is ⍵.
{                               ⍳¨⍵} ⍝ Generate the range [1,n] for each element of ⍵.
                              /¨     ⍝ Replicate into each the resulting vectors of:
                   (  ⍵|⍨⍳¨⍵)        ⍝ ⍵ modulo each element of the ranges;
                    0=               ⍝ Equals 0?
               ¯1↓¨                  ⍝ Drop the last element of each
            +/¨                      ⍝ Sum of each
       (⌽⍵)≡                         ⍝ Check if the results match the inverse of ⍵.
      ∧                              ⍝ Logical AND.
 (≠/⍵)                               ⍝ Inputs are different

@Adám has also helped me with a 22 20 byte tacit function that's equivalent to the Dfn:
≠/∧⌽≡(+/∘∊⍳⊆⍨0=⍳|⊢)¨

Try it online!
How?
≠/∧⌽≡(+/∘∊⍳⊆⍨0=⍳|⊢)¨⍝ Tacit fn, takes one right argument.
     (            )¨ ⍝ For each element e of the argument
               ⍳|⊢   ⍝ e modulo range [1,e]
             0=      ⍝ Equals 0? This generates a boolean vector
            ⍨        ⍝ Swap arguments for the following op/fn
           ⊆         ⍝ Partition. This partitions the right vector argument according to 1-runs from a left boolean vector argument of same size.
          ⍳          ⍝ Range [1,e]
         ∊           ⍝ Enlist; dump all elements into a single vector.
        ∘            ⍝ And then
      +/             ⍝ Sum the elements
   ⌽≡                ⍝ Check if the resulting sums match the inverse of the argument
  ∧                  ⍝ Logical AND
≠/                   ⍝ The elements of the argument are different.

You can save a few bytes by using eaches rather than duplicating code

@Uriel I'm actually working on that. Just thought I should post this so I can edit it later.

Fails for 6, 6.

@Mr.Xcoder fixed. I had no idea it was supposed to return falsy for equal inputs.

Whitespace golf for 36 - {(⍺≠⍵)∧⍵⍺≡+/¨¯1↓¨(0=⍺⍵|⍨⍳¨⍺⍵)/¨⍳¨⍺⍵}. I haven't gone through the logic yet

@Uriel thanks a lot, man. I didn't actually test the code without the whitespace because I assumed it wouldn't work, silly me.

I don't know APL but would doing this as a monadic function be shorter? I see a lot of ⍺⍵ and I feel like it might be shorter with just ⍵. You could just do (≠⍵)≡... if ≠ is the nub sieve to make sure that the inputs aren't equal, and equate that to the reverse of the divisor sum.

@cole actually, Adam is helping me build a tacit function that does precisely that. I'm not sure if doing it for this Dfn would shorten it, but I'll give it a try and see how it does.

Perl 6, 53 bytes
{([!=] $_)&&[eqv] .map: {set +$_,sum grep $_%%*,^$_}}

Try it online!
Takes input as a list of two numbers.

05AB1E, 8 7 bytes
ÙÑO¥`_`

Try it online!

Better than üQ_sÑOüQ& for sure lol.

Pyth, 12 bytes
q{_msf!%dTtU

Takes input as a list.
Try it online
Explanation
q{_msf!%dTtU
   m         Q    For each element d of the (implicit) input...
          tUd     ... get the range [1, ..., d - 1]...
     f!%dT        ... filter those that are factors of d...
    s             ... and take the sum.
 {_               Reverse and deduplicate...
q             Q   ... and check if the end result is the same as the input.

Batch, 127 bytes
@if %1==%2 exit/b
@set/as=t=%1+%2
@for /l %%i in (1,1,%s%)do @set/as-=%%i*!(%1%%%%i),t-=%%i*!(%2%%%%i)
@if %s%%t%==00 echo 1

Outputs 1 if the parameters are amicable. Works by subtracting all factors from the sum of the input numbers for each input number, and if both results are zero then the numbers are amicable.

Red, 117 bytes
d: func[n][s: 0 repeat i n / 2[if n // i = 0[s: s + i]]]
a: func[n m][either(m = d n)and(n = d m)and not n = m[1][0]]

Try it online!

Java (OpenJDK 9), 87 bytes
a->b->a!=b&f(a)==b&f(b)==a
int f(int n){int s=0,d=0;for(;++d<n;)s+=n%d<1?d:0;return s;}

Try it online!

Vyxal, 5 bytes
∆KUṘ⁼

Try it Online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Accumulate some L.s.d
Prior to the decimalisation of Sterling in February 1971, a pound (£ - from Roman libra) comprised 20 shillings (s - solidus), each of 12 pennies (d - denarius).  Additionally, until 1960, each penny could be divided into four farthings (some parts of the Commonwealth also had fractions of farthings, but we'll ignore those in this question).
Your task is to write a simple adding machine for financial quantities in the old system.  You will receive a set of strings, and emit/return a single string that represents the total of all the inputs.  The format of input and output strings is as follows (adapted from Wikipedia: £sd):

For quantities less than 1 shilling, the number of pence followed by the letter d:
¼d            -- smallest amount representable
1d
11¾d          -- largest value in this format

For quantities less than £1, / is used to separate shillings and pence, with - as a placeholder if there are no pence:
1/-           -- smallest amount in this format
1/6
19/11¾        -- largest value in this format

For quantities of £1 or greater, we separate the parts with ., and include the units:
£1
£1.-.¼d       -- one pound and one farthing
£1.1s.-       -- one pound and one shilling
£999.19s.11¾d -- largest value needed in this challenge

The inputs will never sum to £1000 or more (i.e. you can assume the pounds will fit into 3 digits).
Input will be as strings by any of the usual input methods (as an array of strings, as a single string with newlines or other separators, as individual arguments, etc).  There will be no additional characters (not mentioned above) in each string.
Output will be as a single string, by any of the usual output methods (standard output stream, function return value, global variable, etc.).  You may include additional spaces around the numbers if that helps.
Examples
(assuming my mental arithmetic is up to scratch!)

Input: ¼d, ¼d
Output: ½d
Input: 11¾d, ¼d
Output: 1/-
Input: £1, 6d, 9d
Output: £1.1s.3d
Input: £71.11s.4¼d, 12/6, 8/-, 8/-, 2½d
Output: £73.-.¾d

If (and only if) your language/platform cannot represent the farthings (yes, I'm looking at you, ZX81!), you may use the letters n, w and r instead, to mean ¼ (one), ½ (two) and ¾ (three) respectively.
This is code-golf, so the shortest working program (in bytes) is the winner.  Please indicate the source character-coding if it's not UTF-8 (and not determined by the language).
Standard loopholes which are no longer funny are not permitted.

I think you should allow using the ASCII representation for all languages because otherwise it gives a disadvantage to languages that support multibyte characters (because then it requires more bytes to check the character because scoring is by bytes)

I suggested a similar challenge but it was closed. Good luck with this one.

@HyperNeutrino .... at the cost of the output looking worse.

@HyperNeutrino, I thought about that; it's not so much about giving an advantage to the deprived environments as allowing them to compete at all.  I'd be surprised to see it make a difference (particularly as many languages can use single-byte encodings, and that's explicitly allowed).

@TobySpeight Some of those with single byte encodings may not have all three necessary fractions, but may be able to take UTF-8. Should they be punished?

@Adam, that's just how it is - the rules are set, and that one is staying.   I did consider counting in characters instead, but that would have invited whining about APL having an unfair advantage instead. Out of interest, can you name an encoding with some but not all of ¼, ½ and ¾?  And a language that can use it but not an encoding with all of them?  I suspect it's a theoretical complaint.

@TobySpeight 437 and Ohm.

I feel like we don't need to worry about giving a "disadvantage" to languages with custom code pages. The challenge is the challenge. No challenge will ever be completely equal in all languages.

@Adam - Ohm can (and by default, does) use UTF-8, so it's required to use actual fraction characters.

The fourth test case sums to £71.31s.12¾d, which is £72.12s.¾d, not £73.-.¾d

Thanks @Ourous - now corrected, by adding an additional term to reach the right total.  I did admit that my mental arithmetic might be a bit rusty!

Retina 0.8.2, 252 bytes
.+/.+
£.$&d
m`(?<!d)$
./d
m`^(?!£)
£./
s.
/
([¼½¾])?d
d0$1
T`¼½¾`123
[-\d]+
$*
+`.(1*)/(1*)d(1*)¶£(1*).(1*)/(1*)d
$4.$1$5/$2$6d$3
+`d1111
1d
+`/1{12}
1/
+`\.1{20}
1.
(.)(1*)
$1$.2
\b0
-
T`d`_¼½¾`.$
-?d(.)
$1d
£-.-/

£-.(.+)d
$1
(\..+)/
$1s.
-s
-
.-.-d

Try it online! Explanation:
.+/.+
£.$&d
m`(?<!d)$
./d
m`^(?!£)
£./
s.
/

Reformat the input into a fixed format £<l>.<s>/<d>d<f>.
([¼½¾])?d
d0$1
T`¼½¾`123
[-\d]+
$*

Convert to unary.
+`.(1*)/(1*)d(1*)¶£(1*).(1*)/(1*)d
$4.$1$5/$2$6d$3
+`d1111
1d
+`/1{12}
1/
+`\.1{20}
1.

Add up the values.
(.)(1*)
$1$.2
\b0
-
T`d`_¼½¾`.$
-?d(.)
$1d
£-.-/

£-.(.+)d
$1
(\..+)/
$1s.
-s
-
.-.-d

Convert back to decimal and format for display.

Could I bother you to explain the "format for display" part?

@Adám The fixed format has a character followed by an optional number of 1s for each part. This is matched by the 1st stage so that the 1s can be converted to decimal. The 2nd stage just converts 0s (but not 10 etc.) to -s. The 3rd stage converts the farthings to fractions and the 4th stage moves them before the d and deletes any - that was there. The 5th stage then handles amounts of less than 1s, while the 6th stage handles amounts between 1s and £1. The last two stages convert the / to s. (or -/ to -.) for amounts of £1 or more.

Shouldn't £1 ½d give £1.-.½d ?

@Adám Ugh, I'd overlooked whole pounds. Fixed. (Annoyingly, this means my code now ends in a blank line...)

Clean, 555 ... 504 bytes
Uses ANSI codepage Windows-1252, but since TIO treats Clean source files as UTF-8, all invalid UTF-8 character literals are represented with octal escape sequences and counted as one byte.
import StdEnv,Text,StdLib
n=0.0
e=entier
r=toReal
*0=""
*n=fromInt n
?'\274'=".25"
?'\275'=".5"
?'\276'=".75"
?c={c}
@s=r{#d\\c<-:s,d<-: ?c|all((<>)c)['sd\243']}
$s|"9"<s%(0,0)=(map@(split"."s)++[n,n])%(0,2)|endsWith"d"s=[n,n,@s]=[n:map@(split"/"s)]
^[x,y,z]#d=e z
#p=if(z>r d){'\273'+toChar(e((z-r d)/0.25))}""
#(y,d)=(d/12+e y,d rem 12)
#[x,y,d:_]=map*[y/20+e x,y rem 20,d]
|x>""=join"."["\243"+++x,y+++if(y>"")"s""-",d+++if(z>n)(p+++"d")"-"]|y>""=join"/"[y,d+++if(z>n)p"-"]=d+++p+++"d"

^o foldr(zipWith(+))[n,n,n]o map$

A partial function literal, taking [String] and returning String.
Try it online!

APL (Dyalog Classic), 265 260 bytes
Now works even for edge cases not in the example cases.
Full program. Prompts (STDERR) for input (STDIN) of list of strings. Outputs to STDOUT.
Assumes ⎕IO (Index Origin) to be 0, which is default on many systems.
0(('^0' '$',d)⎕R('' 'd',f)⍕2↓t)r(r←' 0d' ' 0?'⎕R'/-' '/'⊢d⎕R f,∘'d'⍕1↓t)('£',⍕⊃t)(∊'£'(⍕⊃t)'.','-'('s',⍨⍕1⊃t)[×1⊃t]'.','-d' '-'⎕R'-' ''⊢'d',⍨(d,⊂'^0')⎕R(f,'-')⍕2⊃t)[5⌊2⊥×t←v⊤+/((v←0 20 12)⊥(¯3+6×'£'=⊃)↑∘⍎('-' '\D',⍨f←,¨'nwr')⎕R('0 ',⍨1↓¨d←('\.',⍕)¨25 5 75))¨⎕]
Try it online! (or equivalent Unicode edition sporting proper fractions)
Explanation
This program has five parts; one that handles input, conversion, summation, and selection of output format, and one for each of the four possible output formats which are:

less than a shilling: ¼d–11¾d
a whole number of shilling, which is the same format as
between a shilling and a pound: 1/-–19/11¾
whole pounds: £1, £2,… £999
everything else: £1.-.¼d–£999.19s.11¾d

The overall structure of the program is:
 0( less )r(r←' between )( whole )( everything )[ selection ]
This uses selection to index from a list of all possible formats. The initial 0 is a placeholder for output format 0 which does not exist. r← assigns format 4. to the variable r, which is then used as format 2.
input, conversion, summation, and selection of output format
5⌊2⊥×t←v⊤+/((v←0 20 12)⊥(¯3+6×'£'=⊃)↑∘⍎('-' '\D',⍨f←,¨'nwr')⎕R('0' ' ',⍨1↓¨d←('\.',⍕)¨25 5 75))¨⎕
 ⎕ prompt for (evaluated) user input (list of strings)
 (…)¨ on each string, apply the following tacit function:
  25 5 75 the numeric list [25,5,75]
  (…)¨ on each number, apply the following function:
   ⍕ the string representation
   '\.', preceded by an escaped (for PCRE) period
  d← store that in d (for decimals; ["\.25","\.5","\.75"])
  1↓¨ drop one character from each; [".25",".5",".75"]
  '0 ',⍨ append the two characters; [".25",".5",".75","0"," "]
  (…)⎕R PCRE Replace the following strings with the above:
   ,¨'nwr' ravel (make into own vector) each of these characters; ["n","w","r"]
   f← store in f (for fractions)
   '-' '\D',⍨ append these two strings; ["n","w","r","-","\D"]
  ⍎ execute as APL statement (this gives a numeric list)
  ∘ then
  (…)↑ take this many elements (padding with zeros as needed):
   ⊃ the first of the argument (one of the strings)
   '£'= Boolean (0 or 1) whether it is a pound symbol
   6× multiply by six; gives 6 if string had pound(s), 0 if not
   ¯3+ add negative three; gives 3 if string had pound(s), −3 if not
Taking a negative number of elements takes from the right and pads on the left if needed. Taking a positive number of elements takes from the left and pads on the right if needed. Thus we now have pounds, shillings, and pence in fixed positions in a length-3 list for each input string.
  (…)⊥ convert to regular number (pence) from the following mixed-base:
   0 20 12 12 pence per shilling, 20 shilling per pound, no amount of pounds convert up
   v← store in v (for values)
 +/ sum (lit. plus reduction)
 v⊤ convert to mixed-base v
 t← store in t (for total)
 × signum of those values
 2⊥ convert to regular number from base-2 (binary)
 5⌊ find the minimum of five and that.
Gives 1 for pence-only, 2 for shilling only, 3 for shilling and pence, 4 for pounds only, and 5 for pounds and change.
everything else
∊'£'(⍕⊃t)'.','-'('s',⍨⍕1⊃t)[×1⊃t]'.','-d' '-'⎕R'-' ''⊢'d',⍨(d,⊂'^0')⎕R(f,'-')⍕2⊃t
 2⊃t the third (pence) value of t
 ⍕ string representation of that
 ⎕R(…) PCRE Replace the following strings:
  f,'-' the list f followed by a dash; ["n","w","r","-"]
 (…) with:
  ⊂'^0' this string (regex: leading zero)
  d, appended to d; ["\.25","\.5","\.75","^0"]
 'd',⍨ append a "d" to that
 '-d' '-'⎕R'-' '' remove stray "d"s and dashes (caused by less than a whole pence)
 …'.', prepend the following and a period to that:
  …] use
   1⊃t the second element of t (the shilling)
   × the signum of that (i.e. whether we have any shilling or not)
  '-'…[ to index from a dash and the following:
  1⊃t the second element of t (the shilling)
  ⍕ the string representation of that
  's',⍨ followed by an "s"
 '£'(…)'.', prepend a pound sign, and the below, and a period to that:
  ⊃t the first element of t (the pounds)
  ⍕ the string representation of that
 ∊ ϵnlist (flatten)
whole pounds
'£',⍕⊃t
 ⊃t the first element of t (the pounds)
 ⍕ the string representation of that
 '£', prepend a pound symbol
between a shilling and a pound
' 0d' ' 0?'⎕R'/-' '/'⊢d⎕R f,∘'d'⍕1↓t
 1↓t drop one element from t (leaving the shillings and the pence)
 ⍕ the string representation (space separated) of that
 ,∘'d' append a "d" to that (lit. apply the append function with a curried right argument)
 d⎕R f PCRE Replace d (["\.25","\.5","\.75"]) with f (["n","w","r"])
 ⊢ yield that (separates the following from d)
 ' 0d' ' 0?'⎕R'/-' '/' PCRE Replace:
  no-pence with slash-dash
  leading pence-zero with slash
less than a shilling
('^0' '$',d)⎕R('' 'd',f)⍕2↓t
 2↓t drop the first two elements of t (leaving just pence)
 ⍕ the string representation of that
 ⎕R(…) PCRE Replace with the following:
  '' 'd',f the list f preceded by these two strings; ["","d","n","w","r"]
 (…) where the following occur:
  '^0' '$',d the list d preceded by these two strings; ["^0","$","\.25","\.5","\.75"]
   the first is a leading zero
   the second marks the end of a string

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How to solve the total task on "return true to win" in 21 chars
There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true.
The following is one of the tasks:
function total(x) {
  return (x < x) && (x == x) && (x > x);
}

The users must find snippets for the value of x that cause the function to return true. To test snippets, you call the function with your snippet as the parameter (i.e. total(<snippet>)).
I found a 22-character solution:
{valueOf:_=>n++%3},n=0

Some people found the solution in 21 chars. I can't find out this solution. What is the solution in 21 chars?

You should link the contest/page the task is taken from.

https://alf.nu/ReturnTrue

You can't see the total task without solving previous tasks, You can find solutions on https://gist.github.com/OlegTar/cc79df913cafb3045474578e8ada8a3d

@Riker Which JS engine are you using? Here is a working link.

Oh, I misunderstood how to run this. I thougth the code was supposed to replace the above code.

{valueOf:Math.random} works from time to time ... but I suspect that would infringe some rule... (or maybe not?)

Those are decidedly tricky; out of the first 24, I can only answer 14...

Salty dev note... having a function return Boolean called “total” is like nails on a chalkboard!

@scunliffe It's probably an adjective like in the algebraic structure total order. Total here means any two elements of a set are comparable. It's not the bottom line of a restaurant bill. Just my guess.

21 chars
{valueOf:n=_=>n=2<<n}

My original joke, which got downvoted and proposed for deletion:
11 chars :)
total=_=>!0

Test:
function total(x) {
  return (x < x) && (x == x) && (x > x);
}
var arg = total=_=>!0
console.log(total(arg))

Good job thinking outside the box, but the challenge is to finish function total(x) { ... } total(<insert here>) and have the result of the total() call be true, so I don't think this will work...

@ETHproductions <insert here> -> 0),(true :)

Tried that, and also 0)||(true. Neither work though, and now I'm totally confused because there's another level where you have to do 0);(!0 or smth similar...

Your newer solution is amazing, +1 from me!

Cheaty answer
I've already mentioned it in the comments, but it was not tested. It is now. You'll have to keep submitting it until it works.
{valueOf:Math.random}

Demo

function total(x) {
  return (x < x) && (x == x) && (x > x);
}

for(i = 1; !total({valueOf:Math.random}); i++);

console.log('Returned true after ' + i + ' iteration(s)')

Could you explain more about how this works? I just cannot understand how the x == x became true if x is chosen randomly every time.

@tsh The trick is that valueOf is not invoked when the equality test is processed. On the other hand, comparison operators expect primitive values, which forces valueOf to be called. Here is a test showing that.

I got a high score of 1516 iterations!!!

@MagicOctopusUrn Come on, you can do better than that! Insert coin and play again!


text:
Mod 2 Multinomial coefficients
quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2.
Given a list of numbers, k1, k2, ... ,km, output the residue of the multinomial coefficient:

reduced mod 2. The following algorithm does this efficiently: for each ki, compute the binary expansion of ki, that is, find aij such that each aij is either 1 or 0 and

If there is any j such that arj = asj = 1 for r     ≠ s, then the associated mod 2 multinomial coefficient is 0, otherwise the mod 2 multinomial coefficient is 1.
Task
Write a program or function which takes m numbers, k1, k2, ... ,km, and outputs or returns the corresponding multinomial coefficient. Your program may optionally take m as an additional argument if need be.

These numbers may be input in any format one likes, for instance grouped into lists or encoded in unary, or anything else, as long as the actual computation of the multinomial coefficient is performed by your code, and not the encoding process.
Output can be any truthy value if the multinomial coefficient is odd and any falsey value if the multinomial coefficient is even.
Built-ins designed to compute the multinomial coefficient are not allowed.
Standard loopholes apply.

Scoring
This is code golf: Shortest solution in bytes wins.
Examples:
To find the multinomial coefficient of 7, 16, and 1000, we binary expand each of them:

Since no column has more than one 1, the multinomial coefficient is odd, and hence we should output something truthy.
To find the multinomial coefficient of 7, 16, and 76, we binary expand each of them:

Since both 76 and 7 have a 4 in their binary expansion, the multinomial coefficient is even and so we output a falsey value.
Test cases:
Input: [2, 0, 1]
Output: Truthy

Input: [5,4,3,2,1]
Output: Falsey

Input: [1,2,4,8,16]
Output: Truthy

Input: [7,16,76]
Output: Falsey

Input: [7,16,1000]
Output: Truthy

Input: [545, 1044, 266, 2240]
Output: Truthy

Input: [1282, 2068, 137, 584]
Output: Falsey

Input: [274728976, 546308480, 67272744, 135004166, 16790592, 33636865]
Output: Truthy

Input: [134285315, 33849872, 553780288, 544928, 4202764, 345243648]
Output: Falsey

Welcome to PPCG! Nice first post!

I think several languages with == for equality could have saved a byte if truthy and falsey were allowed to be flipped.

@ØrjanJohansen That sounds fine.

Jelly, 4 bytes
S=|/

Try it online!
Test whether the sum is equal to the bitwise-or-sum (i.e. a+b+c == a|b|c).

Python 3 2, 55 43 42 bytes
lambda l:sum(l)==eval(`l`.replace(*',|'))

-12 bytes from Mr. Xcoder
-1 byte from Rod
Try it online!
Explanation: Checks if the sum of the numbers is equal to the bitwise-or of the numbers.

43 bytes: lambda l:sum(l)==eval("|".join(map(str,l)))

You can reach 42 bytes switching to python2

Python 2, 37 bytes
lambda l:sum(l)==reduce(int.__or__,l)

Try it online!
Another port of pizzapants184's algorithm...

Clean, 38 bytes
import StdEnv
?l=sum l==foldr(bitor)0l

Try it online!
Yet another port.

JavaScript (ES6), 37 35 34 bytes
Saved 2 bytes thanks to @Mr.Xcoder
Saved 1 byte thanks to @ETHproductions
Comparing the sum with the bitwise OR (like pizzapants184 and Leaky Nun did) is 1 3 4 bytes shorter than my initial approach:
a=>(q=c=>eval(a.join(c)))`|`==q`+`

Test cases

let f =

a=>(q=c=>eval(a.join(c)))`|`==q`+`

console.log(f([2, 0, 1]))                                                       // Truthy
console.log(f([5,4,3,2,1]))                                                     // Falsey
console.log(f([1,2,4,8,16]))                                                    // Truthy
console.log(f([7,16,76]))                                                       // Falsey
console.log(f([7,16,1000]))                                                     // Truthy
console.log(f([545, 1044, 266, 2240]))                                          // Truthy
console.log(f([1282, 2068, 137, 584]))                                          // Falsey
console.log(f([274728976, 546308480, 67272744, 135004166, 16790592, 33636865])) // Truthy
console.log(f([134285315, 33849872, 553780288, 544928, 4202764, 345243648]))    // Falsey

Alt. version, 38 bytes
a=>!a.some((x,i)=>a.some(y=>i--&&x&y))

Test cases

let f =

a=>!a.some((x,i)=>a.some(y=>i--&&x&y))

console.log(f([2, 0, 1]))                                                       // Truthy
console.log(f([5,4,3,2,1]))                                                     // Falsey
console.log(f([1,2,4,8,16]))                                                    // Truthy
console.log(f([7,16,76]))                                                       // Falsey
console.log(f([7,16,1000]))                                                     // Truthy
console.log(f([545, 1044, 266, 2240]))                                          // Truthy
console.log(f([1282, 2068, 137, 584]))                                          // Falsey
console.log(f([274728976, 546308480, 67272744, 135004166, 16790592, 33636865])) // Truthy
console.log(f([134285315, 33849872, 553780288, 544928, 4202764, 345243648]))    // Falsey

Technically, pizzapants184 answered 14 seconds earlier than me...

-1 byte: a=>(q=c=>eval(a.join(c)))`|`==q`+`;

@ETHproductions Nice! This works fine in Node.js. But did you manage to have it working in a browser?

Works fine for me in Firefox 57. Are you getting an error or is it just not working properly?

@ETHproductions Actually, yes it does work. It just happens to fail on repl.it.

Japt, 6 bytes
Another port of pizzapants184's & Leaky Nun's solutions.
x ¶Ur|

Test it

Technically, pizzapants184 answered 14 seconds earlier than me...

Java 8, 53 bytes
a->{int i=0,j=0;for(int x:a){i+=x;j|=x;}return i==j;}

Port of @LeakyNun's Jelly answer.
Explanation:
Try it here.
a->{             // Method with integer-array parameter and boolean return-type
  int i=0,j=0;   //  Two integers, both starting at 0
  for(int x:a){  //  Loop over the array
    i+=x;        //   Add them to the first integer
    j|=x;}       //   And bitwise-OR it with the second integer
  return i==j;}  //  Return if both integers are the same after the loop

Haskell, 38 bytes
(==).sum<*>foldl1 xor is an anonymous function returning a Bool. Use as ((==).sum<*>foldl1 xor) [2,0,1].
import Data.Bits
(==).sum<*>foldl1 xor

Try it online!

Pretty much the same trick by pizzapants184 and Leaky Nun that everyone uses, except that with Haskell operator names it saves one byte to use (bitwise) xor instead of (.|.) (bitwise or).
(==).sum<*>foldl1 xor is a point-free version of \l->sum l==foldl1 xor l.

Pyth, 6 bytes
qsQ.|F

Test Suite.

Husk, 5 bytes
§=ΣFv

Try it online!

Perl 6, 15 bytes
{.sum==[+|] $_}

Test it
Expanded:
{  # bare block lambda with implicit parameter ｢$_｣

    .sum  # the sum of ｢$_｣ (implicit method call)

  ==

    [+|]  # reduce using &infix:«+|» (numeric binary or)

      $_  # the input
}

Red, 78 bytes
f: func[x][b: :to-binary t: 0 s: b 0 foreach n x[t: t + n s: s or b n]s = b t]

How it works:
Ungolfed:
Red []
f: func [x][         -  a function taking a block as an argument
    b: :to-binary    -  an alias for the to-binary function
    t: 0             -  set the sum of the numbers to 0
    s: b 0           -  set the "or" total to binary 0
    foreach n x[     -  for each number in the block
        t: t + n     -  add it to the sum
        s: s or b n  -  bitwise or of its binary representation with the total
    ]
    s = b t          - are the sum (binary) and the "or" total equal?
]

Try it online!

Wolfram Language (Mathematica), 15 bytes
Tr@#==BitOr@@#&

Try it online!

Batch, 73 bytes
@set/as=o=0
@for %%i in (%*)do @set/as+=%%i,o^|=%%i
@if %s%==%o% echo 1

Outputs 1 for truthy, nothing for falsy. Another obvious port of pizzapants184/Leaky Nun's algorithm.

J, 10 bytes
+/=+./&.#:

Yet another port of pizzapants184's & Leaky Nun's solutions.
How it works?
+/.&.#: - convert the numbers to binary, apply bitwise or to the powers of two and convert back from binary to decimal
+/ - reduce the input by addition
= - are the above equal?
Try it online!
Straightforward alternative
J, 12 bytes
2>[:>./+/@#:

How it works?
+/@#: - convert each number to binary and find the sum of each power of 2
>./ - find the maximum
2> - is it less than 2? -> truthy
Try it online!

Triangularity, 31 bytes
...)...
..IEu..
.)IE...
"|"JE=.

Try it online!
Alternate solution, 31 bytes
...)...
..IED..
.us"|".
JE=....

Try it online!


text:
Compute number of matrices with appropriate sums
When multiplying monomials in the Milnor basis for the Steenrod algebra, part of the algorithm involves enumerating certain "allowable matrices".
Given two lists of nonnegative integers r1, ... ,rm and  s1, ... ,sn, a matrix of nonnegative integers X

is allowable if

The sum of the jth column is less than or equal to sj:

The sum of the ith row weighted by powers of 2 is less than or equal to ri:

Task
Write a program which takes a pair of lists r1, ... ,rm and s1, s1, ... ,sn and computes the number of allowable matrices for these lists. Your program may optionally take m and n as additional arguments if need be.

These numbers may be input in any format one likes, for instance grouped into lists or encoded in unary, or anything else.
Output should be a positive integer
Standard loopholes apply.

Scoring
This is code golf: Shortest solution in bytes wins.
Examples:
For [2] and [1], there are two allowable matrices:

For [4] and [1,1] there are three allowable matrices:

For [2,4] and [1,1] there are five allowable matrices:

Test cases:
   Input: [1], [2]
   Output: 1

   Input: [2], [1]
   Output: 2

   Input: [4], [1,1]
   Output: 3

   Input: [2,4], [1,1]
   Output: 5

   Input: [3,5,7], [1,2]
   Output: 14

   Input: [7, 10], [1, 1, 1]
   Output: 15

   Input: [3, 6, 16, 33], [0, 1, 1, 1, 1]
   Output: 38

   Input: [7, 8], [3, 3, 1]
   Output: 44

   Input: [2, 6, 15, 18], [1, 1, 1, 1, 1]
   Output: 90

   Input: [2, 6, 7, 16], [1, 3, 2]
   Output: 128

   Input: [2, 7, 16], [3, 3, 1, 1]
   Output: 175

IMO the definition would be easier to understand if you lose the first row and column of the matrices, index from 1, and use <= instead of ==.

Okay, will do. I just copied the definition out of a math textbook and it had an actual use for those entries.

JavaScript (ES7), 163 bytes
f=([R,...x],s)=>1/R?[...Array(R**s.length)].reduce((k,_,n)=>(a=s.map((_,i)=>n/R**i%R|0)).some(c=>(p+=c<<++j)>R,p=j=0)?k:k+f(x,s.map((v,i)=>v-a[i])),0):!/-/.test(s)

Test cases
NB: I've removed the two most time-consuming test cases from this snippet, but they should pass as well.

f=([R,...x],s)=>1/R?[...Array(R**s.length)].reduce((k,_,n)=>(a=s.map((_,i)=>n/R**i%R|0)).some(c=>(p+=c<<++j)>R,p=j=0)?k:k+f(x,s.map((v,i)=>v-a[i])),0):!/-/.test(s)

console.log(f([1],[2]))            // 1
console.log(f([2],[1]))            // 2
console.log(f([4],[1,1]))          // 3
console.log(f([2,4],[1,1]   ))     // 5
console.log(f([3,5,7],[1,2]))      // 14
console.log(f([7,10],[1,1,1]))     // 15
console.log(f([7,8],[3,3,1]))      // 44
console.log(f([2,6,7,16],[1,3,2])) // 128
console.log(f([2,7,16],[3,3,1,1])) // 175

Commented
f = (                               // f = recursive function taking:
  [R,                               //   - the input array r[] splitted into:
      ...x],                        //     R = next element / x = remaining elements
  s                                 //   - the input array s[]
) =>                                //
  1 / R ?                           // if R is defined:
    [...Array(R**s.length)]         //   for each n in [0, ..., R**s.length - 1],
    .reduce((k, _, n) =>            //   using k as an accumulator:
      (a =                          //     build the next combination a[] of
        s.map((_, i) =>             //     N elements in [0, ..., R - 1]
          n / R**i % R | 0          //     where N is the length of s[]
        )                           //
      ).some(c =>                   //     for each element c in a[]:
        (p += c << ++j)             //       increment j; add c * (2**j) to p
        > R,                        //       exit with a truthy value if p > R
        p = j = 0                   //       start with p = j = 0
      ) ?                           //     end of some(); if truthy:
        k                           //       just return k unchanged
      :                             //     else:
        k +                         //       add to k the result of
        f(                          //       a recursive call to f() with:
          x,                        //         the remaining elements of r[]
          s.map((v, i) => v - a[i]) //         s[] updated by subtracting the values of a[]
        ),                          //       end of recursive call
      0                             //     initial value of the accumulator k
    )                               //   end of reduce()
  :                                 // else:
    !/-/.test(s)                    //   return true if there's no negative value in s[]

Jelly, 26 bytes
UḄ€Ḥ>⁴
0rŒpṗ⁴L¤µS>³;ÇẸµÐḟL

A full program taking S, R which prints the count
Try it online!
How?
UḄ€Ḥ>⁴ - Link 1, row-wise comparisons: list of lists, M
U      - upend (reverse each)
 Ḅ€    - convert €ach from binary (note bit-domain is unrestricted, e.g. [3,4,5] -> 12+8+5)
   Ḥ   - double (vectorises) (equivalent to the required pre-bit-shift by one)
     ⁴ - program's 2nd input, R
    >  - greater than? (vectorises)

0rŒpṗ⁴L¤µS>³;ÇẸµÐḟL - Main link: list S, list R
0r                  - inclusive range from 0 to s for s in S
  Œp                - Cartesian product of those lists
       ¤            - nilad followed by link(s) as a nilad:
     ⁴              -   program's 2nd input, R
      L             -   length
    ṗ               - Cartesian power = all M with len(R) rows & column values in [0,s]
        µ      µÐḟ  - filter discard if:
         S          -   sum (vectorises) = column sums
           ³        -   program's 1st input, S
          >         -   greater than? (vectorises) = column sum > s for s in S
             Ç      -   call the last link (1) as a monad = sum(2^j × row) > r for r in R
            ;       -   concatenate
              Ẹ     -   any truthy?
                  L - length

Wolfram Language (Mathematica), 101 bytes
Let Mathematica solve it as a system of inequalities over the integers.  I set up a symbolic array in f and thread over three sets of inequalities. Join@@ just flattens the list for Solve.
Length@Solve[Join@@Thread/@{Tr/@(t=f~Array~{q=(l=Length)@#2,l@#})<=#2,2^Range@q.t<=#,t>=0},Integers]&

Try it online!

Mathematica 139 bytes
Tr@Boole[k=Length[a=#]+1;AllTrue[a-Rest[##+0],#>=0&]&@@@Tuples[BinCounts[#,{2r~Prepend~0}]&/@IntegerPartitions[#,All,r=2^Range@k/2]&/@#2]]&

Try it online
Explanation: Partitions each of the ri into powers of 2 and then makes all tuples with one decomposition into powers of two for each integer, subtract the column totals from the list of the si. Count the number of tuples that make all remaining entries are positive.

typically it's discouraged to answer your own challenge until others have submitted in that language already.

@HyperNeutrino I can delete it if you think that's a good idea. This isn't super carefully golfed, so it's very likely others can do better.

While it's not a bad thing to be able to prove it's solvable, I don't recommend spoiling the solution so quickly. Maybe wait for a week first or something.

So should I delete it or leave it now that I posted it?

I would leave it. Pace Erik I don't think it spoils anything: the existence of a solution is obvious from the fact that the matrices respecting the column sum constraint are finite and easily generated.

Leave it. I just put in another M answer which takes a totally different approach.


text:
Find The Rank Of A Word
Definition
The rank of a word is defined as the position of the word when all the possible permutations (or arrangements) of its letters are arranged alphabetically, like in a dictionary, no matter if the words are meaningful or not.
Let us consider these two words - "blue" and "seen". To begin with, we would write all the possible arrangements of the letters of these words in alphabetical order:
"blue": "belu","beul","bleu","blue","buel","bule","eblu","ebul","elub","elbu","eubl",
        "eulb","lbeu","lbue","lebu","leub","lube","lueb","ubel","uble","uebl","uelb",
        "ulbe","uleb"
"seen": "eens","eesn","enes","ense","esen","esne","nees","nese","nsee","seen",
        "sene","snee"

Now let's look from the left and find the position of the words we need. We see that the word "blue" is at the 4th position and "seen" is at 10th position. So the rank of the word "blue" is 4, and that of "seen" is 10. This is the general way of calculating the rank of a word. Make sure you start counting from 1 only.
Task
Your task is to write a code to take any word as an input and display its rank. The rank should be the output.
Be careful about words containing repeated letters.
Examples
"prime" -> 94

"super" -> 93

"bless" -> 4

"speech" -> 354

"earth" -> 28

"a" -> 1

"abcd" -> 1

"baa" -> 3

You can assume the input to be completely in lowercase and the input will only contain alphabetical characters. Also if a blank space or an invalid string is entered, you may return anything.
Scoring
This is code-golf , so the shortest code wins!

Related.

"Make sure you start counting from 1 only." - It's totally up to you to have this requirement, but do note that it's quite common to allow either 0 or 1 based indexing for such challenges.

Yeah ikr but if you start from 0 then you actually aren't displaying the original rank which is why I decided to add this requirement.

Useful link. You will get AC if your program runs in time O(n log n) or less. (sorry, no Python) My submission (C++) takes 2.53s to solve test 14.

Can I do a tuple or a list with that word, e.g. ['h', 'e', 'l', 'l', 'o'] as opposed to  'hello'?

@user202729 AC?

@haneefmubarak "accepted". Commonly-known verdict on competitive programming online judge sites.

Gaia, 4 bytes
fuȯI

Try it online!

Python 3, 71 bytes
lambda s:sum(t<=(*s,)for t in{*permutations(s)})
from itertools import*

Try it online!

05AB1E, 5 bytes
œêsk>

Try it online!
or as a Test suite
Explanation
œ       # get permutations of input
 ê      # sort and remove duplicates
  s     # swap input to top of stack
   k    # get index of input in the list
    >   # increment

Pyth, 6 bytes
hxS{.p

Test suite.
Explanation

hxS{.p || Full program.

    .p || All the permutations of the input.
   {   || Deduplicate.
  S    || Sort.
 x     || Index of the input into this list.
h      || Increment.

Jelly, 5 bytes
Œ!ṢQi

Try it online! or see the test suite
How it works
Œ!ṢQi - Main link. Argument: s (string)      e.g. 'baa'
Œ!    - All permutations                          ['baa', 'baa', 'aba', 'aab', 'aba', 'aab']
  Ṣ   - Sort                                      ['aab', 'aab', 'aba', 'aba', 'baa', 'baa']
   Q  - Deduplicate                               ['aab', 'aba', 'baa']
    i - 1-based index of s                        3

Fails for words containing repeated letters.

@ManishKundu and Xcoder, fixed

Unfortunately Œ¿ doesn't work.

Does ṢŒ¿ work?

@EsolangingFruit No, that just outputs 1

Python 2, 78 bytes
lambda s:-~sorted(set(permutations(s))).index(tuple(s))
from itertools import*

Try it online!

Python 3, 73 bytes

Thanks to Mr. Xcoder for choosing Python 3; saving five bytes.

lambda s:-~sorted({*permutations(s)}).index((*s,))
from itertools import*

Try it online!

Haskell, 56 bytes
import Data.List
elemIndex<*>([]:).nub.sort.permutations

Try it online!
+6 bytes because of 1-indexing requirement. :(

CJam, 8 bytes
q_e!\a#)

Try it online!
+1 byte due to 1-indexed requirement.

Just got the exact same answer :(

@EsolangingFruit You can still post it if you want :-)

Japt, 8 10 bytes
0-indexed. Poxy, unnecessary 1-indexing, increasing my byte count by 25%!
á â n bU Ä

Test it

Explanation
á gets all the permutations of the input, â removes duplicates, n sorts them and b gets the index of the first occurrence of the input, U.

Note the (unusual) "Make sure you start counting from 1 only" requirement. I have commented under the OP that it would be normal to allow 0-based too.

Ah, goddamnit; stoopid 1-indexing. Will update shortly but it'll up my byte count by 25%.

Husk, 6 bytes
S€(OuP

Try it online! I feel like there should be a way to drop (.
Explanation:
 €     -- return index of the input
S (    -- in the list generated by applying the following functions to the input:
     P -- permutations
    u  -- remove duplicates
   O   -- sort

Bracket removed (-1 byte)

J, 28 23 bytes
-5 bytes thanks to FrownyFrog
1+/:~@~.@(A.~i.@!@#)i.]

How it works?
                      ] - the argument
         (A.~      )    - permutations in the
             i.@!@#     - range 0 to factorial of the arg. length
  /:~@~.@               - remove duplicates and sort
                    i.  - index of arg. in the sorted list
1+                      - add 1 (for 1-based indexing)

Try it online!

23: 1+/:~@~.@(A.~i.@!@#)i.]

@FrownyFrog - Good use of i. for finding the index! Thanks!

The TIO link is still the old version :)

@Conor O'Brien - fixed

As usual I'm not happy until I get a solution in K that's shorter than the J one. That said, can you use the same trick here? Generate permutations of the sorted input string (therefore removing the need to sort the permutated list)?

Not tried J until half an hour ago, but why does 1+A./:'seen' return 10, but A./:'speech' return 545. I was hoping this would be a magical solution.

@streetster I'm not sure. A. is the anagram index (the number of the permutation). I don't know how to account for the repeating symbols in your suggestion.

Tcl, 196 bytes
proc p {a p} {if {$a eq {}} {lappend ::p $p} {while {[incr n]<=[llength $a]} {p [lreplace $a $n-1 $n-1] $p[lindex $a $n-1]}}}
p [split $argv ""] ""
puts [expr [lsearch [lsort -unique $p] $argv]+1]

Tcl has no built-in method to compute the next lexicographic permutation, so we have to do it ourselves. But wait... it is shorter to do it with a simple recursive function that computes all possible permutations in any order.
Ungolfed:
# Compute all possible permutations of the argument list
# Puts the result in ::all_permutations
proc generate_all_permutations {xs {prefixes ""}} {
  if {$xs eq {}} {
    lappend ::all_permutations $prefixes
  } else {
    while {[incr n] <= [llength $xs]} {
      generate_all_permutations [lreplace $xs $n-1 $n-1] $prefixes[lindex $xs $n-1]
    }
  }
}

# Get our input as command-line argument, turn it into a list of letters
generate_all_permutations [split $argv ""]

# Sort, remove duplicates, find the original argument, and print its 1-based index
puts [expr [lsearch [lsort -unique $all_permutations] $argv]+1]

I shaved off some bytes: https://tio.run/##NYyxCsMwDET3foUI3kqGrKH5EleDcdTEIBzhOG3A@NtdtaXDHcfT6bLn1iRtHgTcXa2EBxTjpqnUCoWdCMUZxlHAiILXGpig2BB9goi3yTJTXPIKxqHeBSwnEnaelICJ/fA11HfLIc50/jnWWi/a34VDVpiWJ3Qdqi5y5B0snZJ0bieX/PoJW8rQH7qEvzpeB2ytvQE

More shaving https://tio.run/##NYzBCsIwEETvfsVScq3gtdgvSfcQ07UNLOmSpiqEfHtcFQ8zDG9nJ3tuTdLmQcBNaiXcoRg3jqVWKOxEKM4wDAJGFDzXwATFhugTRLyOlpniklcwDvUuYDmRsPOkBEzsL19Dfbcc4kyvP8da60n7u3DICtPygK5D1UmOvOvQTi75Fc7TJ28pQ3/oDP662Fq78UFv

Thank you. When I get access to a real computer again I'll update.

K (oK), 23 18 bytes
Solution:
1+*&x~/:?x@prm@<x:

Try it online!
Examples:
1+*&x~/:?x@prm@<x:"seen"
10
1+*&x~/:?x@prm@<x:"blue"
4

Explanation:
Generate permutations of the indices of the sorted input string, use them to index back into the input string, take the distincts, see where the original string matched, and add one.
1+*&x~/:?x@prm@<x: / the solution
                x: / save input string as x
               <   / return indices when sorting x ascending
           prm@    / apply (@) function prm
         x@        / index into x with these permutations
        ?          / distinct (remove duplicates)
    x~/:           / apply match (~) between x and each-right (/:)
   &               / return indexes where true (ie the match)
  *                / take the first one
1+                 / add 1 due to 1-indexing requirement

Java 8, 211 bytes
import java.util.*;TreeSet q=new TreeSet();s->{p("",s);return-~q.headSet(s).size();}void p(String p,String s){int l=s.length(),i=0;if(l<1)q.add(p);for(;i<l;p(p+s.charAt(i),s.substring(0,i)+s.substring(++i,l)));}

Explanation:
Try it online.
import java.util.*;        // Required import for TreeSet

TreeSet q=new TreeSet();   // Sorted Set on class-level

s->{                       // Method with String parameter and integer return-type
  p("",s);                 //  Save all unique permutations of the String in the sorted set
  return-~q.headSet(s).size();}
                           //  Return the 0-indexed index of the input in the set + 1

void p(String p,String s){ // Separated method with 2 String parameters and no return-type
  int l=s.length(),        //  The length of the String `s`
      i=0;                 //  Index integer, starting at 0
  if(l<1)                  //  If String `s` is empty
    q.add(p);              //   Add `p` to the set
  for(;i<l;                //  Loop from 0 to `l` (exclusive)
    p(                     //   Do a recursive call with:
      p+s.charAt(i),       //    `p` + the character at the current index of `s` as new `p`
      s.substring(0,i)+s.substring(++i,l)));}
                           //    And `s` minus this character as new `s`

Python 3, 183 182 bytes
The first answer that run in polynomial time!
a=[*map(ord,input())]
f=lambda x:x and x*f(x-1)or 1
c=[0]*98
for C in a:c[C]+=1
l=len(a)
F=f(l)
for i in c:F//=f(i)
r=1
for x in a:F//=l;l-=1;r+=sum(c[:x])*F;F*=c[x];c[x]-=1
print(r)

Try it online!
Require the input to be all upper-case, because... it saves a byte.
Full program, takes input from stdin and output to stdout.

Variable names: (sort of ungolfed code)
a : permu
f : factorial
c : count_num
C : char
l : n_num_left
F : factor
r : result

Unfortunately, from math import factorial as f takes exactly 1 more byte.

(Unrelated note: I checked the Combinatorica` package of Mathematica, nothing useful, including RankPermutation)

That code is really nice.

Python 3, 105 104 103 bytes
f=lambda s:s==s*2or f(s[1:])+sum(f(sorted(s[:s.index(c)]+s[s.index(c)+1:])[::-1])for c in{*s}if c<s[0])

Try it online!

C++, 230 bytes
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;void R(string s){int n=1;auto p=s;sort(begin(p),end(p));do if(p==s)cout<<n;while(++n,next_permutation(begin(p),end(p)));}int main(int n,char**a){R(a[1]);}

As per my asking, the code definitely need to be executable as-is. The function-only clause is basically rubbish. :-@
Thank you to those who kindly answered the question of what can be cut out for me. In the interest of valid code, I’ve avoided the popular GCC-ism of including <bits/stdc++.h>, which I have always considered a bad loophole cheat.
What follows is what remains of my original posting:

I am always unsure when using C and C++ what counts towards the byte total. According to Program, Function, or Snippet? the answer is still vague (as long as it isn’t a snippet, I guess). So I am going with the shortest of the two possibilities.
Here it is ungolfed with necessary headers, etc:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

void R( string s )
{
  int n = 1;
  auto p = s;
  sort( begin(p), end(p) );
  do if (p == s) cout << n;
  while (++n, next_permutation( begin(p), end(p) ));
}

int main( int n, char** a )
{
  R( a[1] );
}

That golfs down to 230 bytes, a third of that standard boilerplate required by every C++ program. (So, I don’t feel too bad not counting it, but as I haven’t ever seen a firm complaint either way, OP will have to tell me which he prefers to satisfy “write a code to take any word as an input and display its rank.”)
I am also unsure if this satisfies “the rank should be output.”

Uh... AFAIK our rules count necessary (using namespace std, #include <algorithm>  headers used to define the function in bytes. And... No, main(){} is a valid C++ (g++) program at 8 bytes.

I am not trying to be an obstinate snot, but I see submissions for C and C++ (as well as other languages) all the time that are just a single function. I want a definitive answer. I typically don’t golf in C-languages for this very reason. (And I am happy to regolf.)

Even in Python, import math is often necessary. Let me find the relevant meta...

@Dúthomhas Those solutions don't require header includes. Basic arithmetic requires no header, and some functions can be implicitly declared and filled in by the linking of the stdlib (like puts and printf). Your code must compile and run successfully as-is for it to be valid. See: https://codegolf.meta.stackexchange.com/a/10085/45941

@Mego Without declaration of main functions can't be run as-is.

Also in C++ include's are strictly necessary, unlike C.

@user202729 main isn't necessary in a function submission. However, function submissions are required to count any additional code needed to run them, aside from standard boilerplate. In the case of C/C++, that standard boilerplate is a main function that takes input and calls the function. This is no different from e.g. Python, where lambda s,r:re.match(r,s) is not valid, because it needs to be lambda s,r:re.match(r,s);import re.

I am considering asking this on meta, since it is an issue. Two examples found since I posted here: https://codegolf.stackexchange.com/a/66481/60291 (show me a C compiler that will turn that into a working program), and https://codegolf.stackexchange.com/a/124243/60291 (no compiler in existence will compile that into a working program, since #defines don't exist until used!). CodeGolf is biased towards esoteric languages like Jelly. I personally only care about competing against other submissions for the same language, but for C and C++, the playing field is not level.

172 bytes

Clean, 113 111 bytes
import StdEnv,StdLib
?s=elemIndex s[[]:removeDup(foldr(\a b=sort[insertAt i a x\\x<-b,i<-[0..length x]])[[]]s)]

Try it online!
+3 bytes to handle 1-indexing :/

APL (Dyalog Unicode), 33 bytes (SBCS)
⎕CY'dfns'
{∪⊃∘(⍵[⍋⍵])¨¨↓pmat≢⍵}⍳⊂

Try it online!

JavaScript (ES6), 106 100 bytes
w=>(P=(a,s)=>a[0]?a.map((_,i)=>P(b=[...a],s+b.splice(i,1))):P[s]=P[s]||++k)[P([...w].sort(),k=''),w]

Test cases

let f =

w=>(P=(a,s)=>a[0]?a.map((_,i)=>P(b=[...a],s+b.splice(i,1))):P[s]=P[s]||++k)[P([...w].sort(),k=''),w]

console.log(f("prime"))  // 94
console.log(f("super"))  // 93
console.log(f("bless"))  // 4
console.log(f("speech")) // 354
console.log(f("earth"))  // 28
console.log(f("a"))      // 1
console.log(f("abcd"))   // 1
console.log(f("baa"))    // 3

How?
P() is our recursive permutation function. But the encompassing object of P is also used to store the ranks of the permutations.
P = (a, s) =>               // given an array of letters a[] and a string s
  a[0] ?                    // if a[] is not empty:
    a.map((_, i) =>         //   for each entry at position i in a[]:
      P(                    //     do a recursive call to P() with:
        b = [...a],         //       a copy b[] of a[], with a[i] removed
        s + b.splice(i, 1)  //       the extracted letter appended to s
      )                     //     end of recursive call
    )                       //   end of map()
  :                         // else:
    P[s] = P[s] || ++k      //   if P[s] is not already defined, set it to ++k

The wrapping code now reads as:
w =>                        // given the input word w
  P[                        // return the permutation rank for w
    P(                      //   initial call to P() with:
      [...w].sort(),        //     the lexicographically sorted letters of w
      k = ''                //     s = k = '' (k is then coerced to a number)
    ),                      //   end of call
    w                       //   actual index used to read P[]
  ]                         // end of access to P[]

Ruby, 49 bytes
->w{c=w.chars
1+c.sort.permutation.uniq.index(c)}

Try it online!

Perl 5, 98 + 3 (-pF) = 101 bytes
$"=',';@a=grep{++$k{$_}<=1&&"@F"eq join$",sort/./g}sort glob"{@F}"x(@F=sort@F);1while!/$a[$\++]/}{

Try it online!

Octave, 43 bytes
@(s)find(all(unique(perms(s),'rows')==s,2))

Try it online!

Perl 6, 53 bytes
{1+first :k,$_,.comb.permutations».join.unique.sort}

Try it online!

PowerShell, 275 bytes
param($s)function n($a){if($a-eq1){return}0..($a-1)|%{n($a-1);if($a-eq2){$b.ToString()}$p=($j-$a);[char]$t=$b[$p];for($z=($p+1);$z-lt$j;$z++){$b[($z-1)]=$b[$z]}$b[($z-1)]=$t}}if($s.length-eq1){1;exit}$b=New-Object Text.StringBuilder $s;(n($j=$s.length)|sort -u).indexOf($s)+1

Try it online!
So, this is a bloody mess.
PowerShell doesn't have any permutations built-in, so this code uses the algorithm from here (golfed heavily), which is available under the Microsoft Limited Public License (Exhibit B on this licensing page).
The program takes input $s as a string, then the actual program starts with $b=New-Object .... We're constructing a new StringBuilder object, which is (essentially) a mutable string of characters. This will allow us to handle the permutations more easily. We then call the function n (setting $j along the way to be the length of the input string), sort with the -unique flag the output, take the .indexOf() to find the input string, and add 1 because PowerShell is zero-indexed.
The function is the main part of the program. It takes as input a number, and will each iteration count down until we reach 1 (i.e., a single letter). The rest of the function essentially recursively calls the function as well as takes the current letter and iterates it through every position.
There's a single bit of additional logic if($s.length-eq1){1;exit} to account for input strings of length 1 due to how the permutations function works.

Pyt, 5 bytes
ĐᒆỤ≥Ʃ

Explanation:
            Implicit input
Đ           Duplicate input
 ᒆ         Get list of all permutations of input
  Ụ         Get unique permutations
   ≥        Does each permutation come before or is equal to the input?
    Ʃ       Sum of result of previous step (converts booleans to ints)

Try it online!