text:
Setting the time
Imagine the following 24-hour clock that can be controlled by arrow keys:
╔══╗ ┌──┐
║00║:│00│
╚══╝ └──┘
 HH   mm

Pressing the up arrow twice (↑↑) will increase the currently focused hour input:
╔══╗ ┌──┐
║02║:│00│
╚══╝ └──┘
 HH   mm

Pressing the right arrow (→) will focus the other input.
┌──┐ ╔══╗
│02│:║00║
└──┘ ╚══╝
 HH   mm

Pressing the down arrow thrice (↓↓↓) will now decrease this input.
┌──┐ ╔══╗
│02│:║57║
└──┘ ╚══╝
 HH   mm

Shortly put:

The up arrow (↑) will increase the currently active input.
The down arrow (↓) will decrease the active input.
The right arrow (→) will move focus to the right input.
The left arrow (←) will move focus to the left input.
Up and down movement will loop around as expected for a time input.
Left and right movement don't loop around.

The challenge
The clock starts out at 00:00 with the hour input active (see first schematic). Given a list of input commands, output the resulting time in HH:mm format.
Input can be either a string or a list (or your language equivalent), where the different input directions can be one of the below options:

↑↓←→
udlr
^v<>
actual arrow key presses if your program has a GUI

Standard loopholes apply.
Test cases
↑↑→↓↓↓ = 02:57
↓→↑←↑→↓ = 00:00
↓→→↓ = 23:59
←←←←→↑ = 00:01
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓→↓ = 23:59

Does one have to use the four specified input direction to value mappings or can one freely choose four different unique values?

Related

@JonathanFrech One of the given options, choosing any four unique values (for example 0123) would make the challenge a lot easier in certain languages while not benefitting others.

@LuisfelipeDejesusMunoz Yes, that's actually written out under the input rules.

@Arnauld What about (h+24e9)%24 which works in practice but not in theory?

@Arnauld Thanks for the idea, added.

@l4m2 Given that it would require an input string of ~22 GB to make it fail, I'd personally say that's an acceptable hack.

I think this would have been more challenging if it included seconds. This would have more logic behind which one is currently in focus

Missing a special rule to handle Konami code.

@coredump Considered it, but it would probably take more space than the core of the answer in most languages.

HTML on Google Chrome 67 in Chinese (Simplified), 39 bytes

<input type=time value=00:00 autofocus>

Chrome show different UI component in different language. Even a simple time input: AM/PM will be shown if you are using English (US). If you want test this by changing your Chrome's language. Do not mass up how to change it back.

dudee!! hahah I think is not valid tho

Hitting right twice goes to AM/PM for me

@JoKing I think it's locale/settings dependent?

@LuisfelipeDejesusMunoz Why invalid?

as @JoKing said, hitting twice goes to AM/PM

@tsh You can save one byte by omitting the closing >, the browser will figure it out.

@Nit not such, tested, not working...

@tsh Works on my Chrome, what version are you running?

@JoKing That's locale dependent. Maybe have a try by changing your Chrome's language to Chinese Simplify? (Do not mass up how to change it back.)

@JoKing, no such problem in Russia. You have to change your locale to 24-hour instead of 12-hour.

It works on firefox 61.0.1

This answer is pretty similar to the AHK answer in another challenge.

@FranciscoHahn My Firefox ask me for AM/PM. That's why I claim it as Chrome.

C (gcc), 117 107 bytes

Saved ten bytes thanks to l4m2.

t,i,m[8];e(char*_){for(*m=i=2[m]=0;t=*_++;t<63?i=t%4:(i[m]+=t&8?1:'w'));printf("%02d:%02d",*m%24,2[m]%60);}

Try it online!

Nice variable naming.

C (gcc), 107 bytes

t,i,m[8];e(char*_){for(*m=i=2[m]=0;t=*_++;t<63?i=t%4:(i[m]+=t&8?1:119));printf("%02d:%02d",*m%24,2[m]%60);}
Try it online!

Stax, 36 35 33 32 bytes
áXò↑─↨√▓|êóÇiU&≡Q#┤Æ⌡⌠╟C▐╜√⌡∟▄╩╠

Run and debug it
Uses lrud.
Explanation:
'l/{'r/Bs$2lmM{${:14-m|+i36*24+%2|zm':* Full program,
'l/                                     Split the string on "l"
   {        m                           Map over the resulting array
    'r/                                   Split at "r"
       B                                  Uncons left, first on TOS (top of stack)
        s                                 Swap to get tail to top
         $                                Flatten; this removes multiple 'r's
          2l                              Listify two items, BOS (bottom of stack) is first element
             M                          Transpose: get [hour commands, minute commands]
              {                    m    Map:
               $                          Flatten
                {    m                    Map over single commands:
                 :1                         Number of set bits: 5 for 'u', 3 for 'd'
                   4-                       Subtract 4: u -> 1, d -> -1
                      |+                  Sum
                        i                 Iteration index: hours -> 0, minutes -> 1
                         36*24+           Multiply by 36, add 24: 0 -> 24, 1 -> 60
                               %          Modulo, this does -5 % 60 = 55
                                2|z       Stringify, left-padding with "0" to length 2
                                    ':* Join on ":"
                                        Implicit output

Python 2, 105 bytes
h=m=p=0
for c in map(' ^<>'.find,input()):w=1/c;m+=w*p;h+=w-w*p;p=[c-2,p][w]
print'%02d:%02d'%(h%24,m%60)

Try it online!

C# (.NET Core), 149 132 bytes
s=>{var p=0;int[]h={0,0};foreach(var c in s)h[p=c<63?c/2%2:p]+=c>62?c>95?-1:1:0;return$"{(h[0]%24+24)%24:D2}:{(h[1]%60+60)%60:D2}";}

Try it online!
Using ^v<>.
This one made me realize that the modulo operator in C# does not work as expected, because in C# -1 % 60 = -1, so I need to do that weird operation at the end.

Can't (h[1]%60+60)%60 be replaced with (h[1]+60)%60 ?

@IanF1 no you can't. What if the user presses the down button 100 times? Or 1000 times?

thanks for clarifying :) it's surprising to me that this way is shorter than applying the modulo on the fly (with 59 in place of -1).

JavaScript (Node.js), 103 bytes
Takes input as a string, using udlr.
s=>(Buffer(s).map(n=>n%6?s%4?m+=n%2||59:h+=n%2||23:s=n,h=m=0),g=n=>('0'+n).slice(-2))(h%24)+':'+g(m%60)

Try it online!

Lua (love2d framework),311 308 bytes
l,b,d,t,f,a=love,{24,60},{1,-1},{0,0},1,{"left","right","up","down"}function c(n,i)t[f]=(n+d[i])%b[f]end function l.draw()h,m=t[1],t[2]l.graphics.print((h<10 and 0 ..h or h)..":"..(m<10 and 0 ..m or m),0,0)end function l.keypressed(k)for i,n in pairs(a)do f=k==n and(i>2 and(c(t[f],i-2)or f)or i)or f end end

Unscrumbeled version:
--initialize all needed values
l,b,d,t,f,a=love,{24,60},{1,-1},{0,0},1,{"left","right","up","down"}

--increase the numbers depending on the focus and up or down
function c(n,i)
  t[f]=(n+d[i])%b[f]
end

--draw the time to the screen
function l.draw()
  h,m=t[1],t[2]
  l.graphics.print((h<10 and 0 ..h or h)..":"..(m<10 and 0 ..m or m),0,0)
end

--get the keys and check if it is an arrow key
function l.keypressed(k)
  for i,n in pairs(a)do
    f=k==n and(i>2 and(c(t[f],i-2)or f)or i)or f
  end
end

Probably still not 100% easy to read because all the ifs are interchanged
    with an  trinary statement   ( ..and ..or) :)
if started in an main.lua with love  then it will pop up a window and you can press the arrowkeys to change the numbers

could you also post expanded version for readability

sure, I added a expanded version no problem :)

PHP, 145 134 133 bytes
(-11 bytes by more golfing)
(-1 byte by using Davіd's loop method)
<?for($h=$m=0,$a=h;$c=$argv[++$i];)$c<l?$$a--:($c>r?$$a++:$a=$c<r?h:m);$h%=24;$m%=60;printf('%02d:%02d',$h<0?$h+24:$h,$m<0?$m+60:$m);

To run it:
php -n -d error_reporting=0 <filename> <command_1> <command_2> ... <command_n>

Example:
php -n -d error_reporting=0 time_setter.php u u r d d d l d

Or Try it online!
Notes:

To save some bytes, I have used strings without single/double quotations as the string wrapper. Thus, the error_reporting=0 option is used to not output warnings.
Input commands: u d l r

128 bytes, -6: Try it online! (Nice solution, btw :)

@Davіd: Thanks, but your update has two issues. First on is that $h is not set, so decreasing it on start fails: Try it online!

@David: And the second issue happens when we switch hour/minute up or down more than 24/60 times: Try it online!

@Davіd: But thanks to your loop method, I could reduce 1 more byte: Try it online!

ah, alright, sorry it didn't completely work :)

JavaScript, 104 103 bytes
Takes input as an array of characters, using <>^v.
a=>(a.map(z=>z<"^"?a=z<">":a?x+=z<"v"||23:y+=z<"v"||59,x=y=0),g=n=>`0${n}`.slice(-2))(x%24)+`:`+g(y%60)

Try it online

MATL,  57 56  55 bytes
1Oi9\"@5<?y@3-ZS*+}wx7@-X^w]]wx&Zjh24 60h\'%02d:%02d'YD

Try it online!
Represents hour and minutes using complex numbers, with the real part being hours and the imaginary part minutes.
With comments:
1     % Push 1 on the stack
      % represents which timer box we're in, starts at hour box
      % imaginary number j would represent minutes box
O     % Push initial hour and minutes 0+0j
i9\   % Fetch input, mod each character's ASCII value by 9.
      % Gives 4 1 8 6 for ^ v > < respectively
"     % iterate through (modded) input
  @5<?     % Push current input, see if it's < 5
           % if so, it's an up or down time change
    y        % so copy out the box indicator (1 or j)
    @3-      % Subtract 3 from the current input
    ZS       % Take the result's sign (-1 for v, 1 for ^)
    *        % Multiply indicator with that
    +        % Add the result to the time value
  }        % else, it's a right or left arrow
    wx       % so bring out the box indicator and delete it
    7@-      % Subtract current input from 7. 1 for < and -1 for >
    X^       % Take the square root of that. 1 for < and j for >
    w        % switch stack to bring time value on top again
  ]       % end if
]     % end loop
wx    % bring box indicator out, delete it
&Zj   % split the complex time value to real and imaginary
h     % then concatenate them into an array
24 60h\ % mod hour and minute values by 24 and 60 respectively
'%02d:%02d'YD % sprintf the time array with 0-padding

Haskell, 236 bytes
f=u 0 0
k _ _ _ _ _ h m[]=z h++':':z m
k a b c d e h m(q:s)=case q of{'^'->e(a h)(b m)s;'v'->e(c h)(d m)s;'>'->v h m s;'<'->u h m s}
u=k(o(+)24)id(o(-)24)id u
v=k id(o(+)60)id(o(-)60)v
o f m x=mod(f x 1)m
z n|n<10='0':show n
z n=show n

f is the main function, and has type String -> String:
*Main> f "^^>vvv"
"02:57"
*Main> f "v>^<^>v"
"00:00"
*Main> f "v>>v"
"23:59"
*Main> f "<<<<>^"
"00:01"
*Main> f "vvvvvvvvvvvvvvvvvvvvvvvvv>v"
"23:59"

Essentially u and v are mutually recursive functions of type Integer -> Integer -> String -> String. They take the hour, the minute and a list of characters over the set {v,^,<,>}, and return the time string. u acts as if the hour dial is highlighted, recursively calling u if the head of the list is in {v,^}, and v if the head of the list is in {<,>}. v is similar but for the minute dial.
Everything else is just saving characters.

Lua, 132 bytes
loadstring's,t,m=1,{0,0},{24,60}for c in(...):gmatch"."do t[s]=(t[s]+(("d u"):find(c)or 2)-2)%m[s]s=("lr"):find(c)or s end return t'

Try it online!

Explanation
This is an anonymous function (a way  to use it is shown on the link).
s=1 -- s will control the selection (1 is hour and 2 min)
t={0,0} -- is the time itself
m={24,60} -- is the maximum for each 'box' (hour or min)
-- I've actually used Lua's multiple variable assignment: s,t,m=1,{0,0},{24,60}

for c in (...):gmatch(".") do -- go through each character of the input
  t[s] = (t[s] + (("d u"):find(c) or 2)-2) % m[s] -- set the current 'box' as
          t[s] +   -- itself plus ...
                  ("d u"):find(c) or 2   -- it's index on the string "d u" (that means it's going to be 1 or 3)
                                         -- or 2 if it wasn't found (if the current character doesn't sum or subtract from the box)
                                       -2   -- this adjusts the result 1, 2 or 3 to being -1, 0 or 1
                                            -- making the inputs 'd' and 'u' as -1 and +1 respectively, and an input different from both as 0
         (                               ) % m[s]   -- modulo of the maximum of the selected 'box'

  s=("lr"):find(c) or s
    ("lr"):find(c)   -- if the current input character is l or r, then set 's' (the 'box' selection) to being 1 or 2.
                   or s   -- else let it as is
end
return t -- returns 't', a table with hour and minutes respectively

The output should be in the HH:mm format, rather than a table

Perl 6, 101 91 89 86 bytes
{$/=[];$!=0;$_>2>($!=$_-3)||($/[$!]+=$_-1)for .ords X%5;($0%24,$1%60).fmt("%02d",":")}

Try it online!
Anonymous code block that takes a string of uldr characters and returns in the given format

QBasic, 229 bytes
A script that takes input as keystrokes and outputs to the console.
Note: terminal " are included for syntax highlighting only, and do not contribute to the bytecount
z$=CHR$(0)
DO
x=0
y=0
SELECT CASE INKEY$
CASE z$+"K"
r=0
CASE z$+"M"
r=1
CASE z$+"H"
x=1
y=1
CASE z$+"P"
x=23
y=59
END SELECT
IF r THEN m=(m+y)MOD 60ELSE h=(h+x)MOD 24
CLS
?RIGHT$("00000"+LTRIM$(STR$(h*1000+m)),5)
LOCATE 1,3
?":"
LOOP

Commented
z$=CHR$(0)                                      ''  Set var to null char
DO                                              ''
    x=0                                         ''  Set Hours Shift to 0
    y=0                                         ''  Set Minutes Shift to 0
    SELECT CASE INKEY$                          ''  Take keystroke input
        CASE z$+"K"                             ''  If is Left Arrow
            r=0                                 ''    Bool to modify right (minutes)
        CASE z$+"M"                             ''  If is Right Arrow
            r=1                                 ''    Bool to modify left (hours)
        CASE z$+"H"                             ''  If is Up Arrow
            x=1                                 ''    Set Hours Shift to 1
            y=1                                 ''    Set Minutes Shift to 1
        CASE z$+"P"                             ''  If is Down Arrow
            x=23                                ''    Set Hours Shift to 23
            y=59                                ''    Set Minutes Shift to 23
    END SELECT                                  ''
    IF r THEN m=(m+y)MOD 60ELSE h=(h+x)MOD 24   ''  Shift Minutes If `r=1` Else Shift Hours
    CLS                                         ''  Clear Screen
    ?RIGHT$("00000"+LTRIM$(STR$(h*1000+m)),5)   ''  Use math to concat Hours and Minutes
                                                ''  then Convert to String and prepend 0s
                                                ''  to a length of 5
    LOCATE 1,3                                  ''  Cursor to the the third digit
    ?":"                                        ''  Overwrite that digit with a `:`
LOOP                                            ''  Loop

Shouldn't that be (m+y)?

In the note, should not does be do?

@JonathanFrech - Yep it should be. Thanks for keeping my grammar in check

Sorry, I thought m was for minutes for some reason... I see your commented version is more readable.

Java 8, 121 bytes
c->{int i=0,m[]={0,0,0};for(int t:c)if(t<63)i=t%4;else m[i]+=(t&8)>0?1:119;return"".format("%02d:%02d",m[0]%24,m[2]%60);}

Port of Jonathan Frech's C answer. Accepts ^v<>. Try it online here.

Jelly, 36 bytes
I believe O%5;4ṣ3œṡ€4Z%3’§§%"“ð<‘DŻ€ṫ€-j”: should work for 32, but œṡ seems to currently have a bug.
O%5;4ṣ3i€4$œṖ"$Z%3’§§%"“ð<‘DŻ€ṫ€-j”:

A full program printing the result to STDOUT (as a monadic link it actually returns a mixed list of integers (albeit single digit ones) and characters (the :).
Uses the udlr option for input.
Try it online! Or see a test-suite.
How?
O%5;4ṣ3i€4$œṖ"$Z%3’§§%"“ð<‘DŻ€ṫ€-j”: - Link: list of characters (in 'udlr')
O                                    - to ordinals
 %5                                  - modulo five  ...maps u:2, d:0, l:3, r:4
   ;4                                - concatenate a 4 (to always end up with both hrs & mins - even when no r is ever pressed)
     ṣ3                              - split at threes (the l presses)
       i€4$œṖ"$                      - a replacement for œṡ€4 (split each at first occurrence of)...
              $                      - | last two links as a monad:
          $                          - |   last two links as a monad:
         4                           - |     literal four
       i€                            - |     for €ach get first index of (4) else yield 0
             "                       - |   zip with:
           œṖ                        - |     partition at indices
               Z                     - transpose (to get a list of two lists of lists)
                %3                   - modulo by three. To replace any 4(r) with 1
                                     -  ...while keeping any 0(d) as 0, or 2(u) as 2
                  ’                  - decrement. All r are now 0, d are -1 and u are 1
                   §                 - sum each
                    §                - sum each. Now we have the total increase value as
                                     -    ...integers for each of hrs and mins
                       “ð<‘          - code-page indices list = [24,60]
                      "              - zip with:
                     %               -   modulo
                           D         - to decimal lists
                            Ż€       - prepend each with a zero (to cater for values less than ten)
                              ṫ€-    - tail each from index -1. Keeps rightmost two digits of each only)
                                  ”: - literal character ':'
                                 j   - join
                                     - as full program implicit print (smashes the digits and characters together)

APL (Dyalog Classic), 97 84 bytes
5↑∊{¯3↑'0',':',⍨⍕⍵}¨24 60|A⊣⍎¨'⎕IO←1' '⎕IO←0' 'A[1]+←1' 'A[1]-←1'['←→↑'⍳⍞,'←']⊣A←0 0

Try it online!
Requires ⎕IO←1

Powershell, 109 103 bytes
-6 byte thanks AdmBorkBork
$t=0,0
$args|%{$t[+$i]+=. @{l={$i=0};r={$i=1};u={1};d={119}}.$_}
"{0:00}:{1:00}"-f($t[0]%24),($t[1]%60)

Test script:
$f = {

$t=0,0
$args|%{$t[+$i]+=. @{l={$i=0};r={$i=1};u={1};d={119}}.$_}
"{0:00}:{1:00}"-f($t[0]%24),($t[1]%60)

}

@(
    ,('02:57',('u','u','r','d','d','d'))
    ,('00:00',('d','r','u','l','u','r','d'))
    ,('23:59',('d','r','r','d'))
    ,('00:01',('l','l','l','l','r','u'))
    ,('23:59',('d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','r','d'))
) | % {
    $e, $c = $_
    $r = &$f @c
    "$($r-eq$e): $r"
}

Output:
True: 02:57
True: 00:00
True: 23:59
True: 00:01
True: 23:59

Explanation
Basic idea is to use a [hashtable], which keys are control commands and values are scriptblocks. The code execute the scriptblock for each command from arguments.

You can get rid of $i=0 by casting your array index like $t[+$i] to save some bytes. Try it online!

perl -F// -E, 72 bytes
$x=H;/u/?$$x++:/d/?$$x--:($x=/l/?H:M)for@F;printf"%02d:%02d",$H%24,$M%60

Python, 120 bytes
o,i=[0,0],0
for s in list(input()):i=(i+(s=='r')-(s=='l')>=1);o[i]+=(s=='u')-(s=='d')
print'%02d:%02d'%(o[0]%24,o[1]%60)

This looks like a snippet taking input in a variable. As a general rule, we require answers to present either a full program (taking input from program arguments or standard input) or a function (taking input from function parameters).

Also, won't this run into a wall when an input of, say, ld or rru causes i to leave the range (0,1) and o[i] is accessed afterwards?

@O.O.Balance oh thanks for reminding me that you need function or unput(). From requirements I figured that L and R actions will never loop around (i.e. no LL)

@aaaaaa No looping means lll isn't the same as r. Having ll or rr is valid input, it's also in the test-cases, see the third one for example.

This answer currently has an IndexError on the 3rd test case instead of outputting 23:59. Try it online!

@nit oh snap, apologies

s=='d' is equivalent to s<'e', s=='u' is equivalent to s>'t'.

i think i fixed it now @nit

Haskell, 186 bytes
f(0,0)'<'
f t i('^':r)=f(i#t$1)i r
f t i('v':r)=f(i#t$ -1)i r
f t i(x:r)=f t x r
f(h,m)_ _=s h++':':s m
('<'#(h,m))n=(mod(24+n+h)24,m)
(_#(h,m))n=(h,mod(60+n+m)60)
s n=['0'|n<10]++show n

Try it online!

R, 368 355 bytes
f=function(){C=as.character
i=ifelse
p=paste0
r=1:10
h=C(0:23);m=C(0:59)
h[r]=p(0,h[r])
m[r]=p(0,m[r])
x=y=z=1
while(T){print(p(h[x],":",m[y]))
v=1
n="[UDLRS]"
while(!grepl(n,v))v=toupper(readline(n))
if(v=="L")z=1 else if(v=="R")z=0
if(v=="S")T=F
if(v=="U")if(z)x=i(x==24,1,x+1)else y=i(y==60,1,y+1)
if(v=="D")if(z)x=i(x==1,24,x-1)else y=i(y==1,60,y-1)}}

Definitely not the best approach, but works.
Functionality: Run function, type each letter to (in/de)crease or move left/right, typing "s" ends the "game". The catch is that it will accept one and only one letter at a time.
-13 bytes Consolidated some values into one row, overwrote T as F instead of using break, found several spaces to eliminate, and a string stored in a variable instead
f=function(){C=as.character                             # Abbreviate functions
i=ifelse
p=paste0
r=1:10                                                  # Initialize and format values
h=C(0:23);m=C(0:59)
h[r]=p(0,h[r])
m[r]=p(0,m[r])
x=y=z=1
while(T){print(p(h[x],":",m[y]))                        # Begin while loop and print time
v=1                                                     # Initial value reset each iteration to retrieve a new direction
n="[UDLRS]"                                             # Used for verification and request
while(!grepl(n,v))v=toupper(readline(n))                # Will only accept proper directions or stopping rule
if(v=="L")z=1 else if(v=="R")z=0                        # Evaluate for hour or minute
if(v=="S")T=F                                           # Stopping rule, overwrite True to False
if(v=="U")if(z)x=i(x==24,1,x+1)else y=i(y==60,1,y+1)    # Rules for Up
if(v=="D")if(z)x=i(x==1,24,x-1)else y=i(y==1,60,y-1)}}  # Rules for Down

I am also editing an alternate format to accept an R string and/or vector, will post next week.

SmileBASIC, 123 bytes
@L
B=BUTTON(2)D=(B==1)-(B==2)S=S+!S*(B>7)-S*(B==4)H=(H+D*!S+24)MOD 24WAIT
M=(M+D*S+60)MOD 60?FORMAT$("%02D:%02D",H,M)GOTO@L

BUTTON() returns an integer where each bit represents a button
1 = up
2 = down
4 = left
8 = right
...

BUTTON(2) returns only the buttons that were just pressed (not being held)
WAIT is required because BUTTON only updates once per frame (1/60 of a second). Otherwise the same button press would be detected multiple times.
This can definitely be shorter

05AB1E, 38 37 32 bytes
'l¡'rδ¡0ζć‚R€S„0uskOŽ9¦2ä%T‰J':ý

Uses udlr for the directions, but could also use ^v<> for the same byte-count (the characters ↑↓←→ are not part of 05AB1E's codepage, so using those would increase the byte-count by a lot, since the encoding should be changed).
Try it online or verify all test cases.
Explanation:
'l¡          '# Split the (implicit) input on "l"
              #  i.e. "lllrurulddd" → ["","","","ruru","ddd"]
     δ        # Map each item to:
   'r ¡      '#  Split the item on "r"
              #   → [[""],[""],[""],["","u","u"],["ddd"]]
       0ζ     # Zip/transpose; swapping rows/columns, with 0 as filler
              #  → [["","","","","ddd"],[0,0,0,"u",0],[0,0,0,"u",0]]
ć             # Head extracted: pop and push the remainder and head-item to the stack
              #  → [[0,0,0,"u",0],[0,0,0,"u",0]] and ["","","","","ddd"]
 ‚R           # Pair the head and remainder back together, and reverse the pair
              # (so the remainder portion is basically wrapped in a list now)
              #  → [["","","","","ddd"],[[0,0,0,"u",0],[0,0,0,"u",0]]]
   €S         # Convert each item to a list of characters
              # (implicitly flattens and removes empty strings)
              #  → [["d","d","d"],[0,0,0,"u",0,0,0,0,"u",0]]
      „0usk   # Index each character into the string "0u"
              # (0 remains 0; "u" becomes 1; "d" becomes -1 since it's not in this string)
              #  → [[-1,-1,-1],[0,0,0,1,0,0,0,0,1,0]]
           O  # Then take the sum of each inner list
              #  → [-3,2]
Ž9¦           # Push compressed integer 2460
   2ä         # Split into two parts: [24,60]
     %        # Modulo the two lists
              #  → [21,2]
      T‰      # Divmod each with 10
              #  → [[2,1],[0,2]]
        J     # Join each inner list together
              #  → ["21","02"]
         ':ý '# Join the list with ":" delimiter
              #  → "21:02"
              # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž9¦ is 2460.

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


text:
Find the Cell's Neighbours
...or Toroidal Moore Neighbourhoods
Given positive integers h, w and a non-negative  integer i, return all of the indices surrounding i.
You are to assume a matrix consisting of h rows of w elements, numbered from lowest, in the top left-hand corner, to highest, in the bottom right-hand corner, and return, in any reasonable format, a list of the indices that would surround the index, i. This matrix is a torus (an infinite map that wraps around each edge).
For example, inputs h=4 and w=4, would result in the matrix:
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15

but more specifically:
15 12 13 14 15 12
 3  0  1  2  3  0
 7  4  5  6  7  4
11  8  9 10 11  8
15 12 13 14 15 12
 3  0  1  2  3  0
so that if i was 0, you'd need to return 15, 12, 13, 3, 1, 7, 4, 5 (0-based).
Examples
0-based:
h   w   i       Expected result

4   4   5       0, 1, 2, 4, 6, 8, 9, 10
4   4   0       15, 12, 13, 3, 1, 7, 4, 5
4   5   1       15, 16, 17, 0, 2, 5, 6, 7
1   3   2       1, 2, 0, 1, 0, 1, 2, 0
1   1   0       0, 0, 0, 0, 0, 0, 0, 0

1-based:
h   w   i       Expected result

4   4   6       1, 2, 3, 5, 7, 9, 10, 11
4   4   1       16, 13, 14, 4, 2, 8, 5, 6
4   5   2       16, 17, 18, 1, 3, 6, 7, 8
1   3   3       2, 3, 1, 2, 1, 2, 3, 1
1   1   1       1, 1, 1, 1, 1, 1, 1, 1

Rules

Your answer may be 0 or 1-indexed, your choice, please specify.
You can assume that i < h * w (or i <= h * w for 1-indexed answers).
You can assume that i >= 0 (or i > 0 for 1-indexed answers).
The order of the returned values is not important as long as just the eight desired values are included.
Standard loopholes are forbidden.
This is code-golf so the shortest answer, in each language, wins!

Thanks to @Conor O'Brien for the more technical sounding title and @ngm for more test cases!

May we return a 3-by-3 matrix of neighbours?

@Adám I would prefer the list to not include the center cell if possible. But appreciate there are already answers. Is it easy enough to filter this out?

Does order matter?

@RobertFraser Order is not important. I'll add that to the rules.

@DomHastings I interpret that comment as: it is not allowed to return a 3 by 3 matrix or include the center cell?

@DomHastings Your last test case has the center included.

@DomHastings Allow or prohibit — there is no prefer ;-)

@Adám I will go for deny in that case. I believe all test cases only return 8 entries? But please correct me if not! I made the original version on mobile and messed up some cuts/pastes!

@JungHwanMin Correct, I've confirmed that in the rules too.

JavaScript (ES6), 75 bytes
Saved 2 bytes thanks to @KevinCruijssen
Expects a 0-based index.
(h,w,i)=>[...'12221000'].map((k,j,a)=>(i+w+~-k)%w+~~(i/w+h+~-a[j+2&7])%h*w)

Try it online!
The surrounding indices are returned in the following order:
$$\begin{matrix}5&4&3\\6&\cdot&2\\7&0&1\end{matrix}$$
How?
The indices \$I_{dx,dy}\$ of each surrounding cell at \$(x+dx,y+dy)\$ are given by:
$$\begin{align}I_{dx,dy}&=((x+dx) \bmod w)+w((y+dy) \bmod h)\\&=((N+dx) \bmod w)+w((\left\lfloor\frac{N}{w}\right\rfloor+dy) \bmod h)\end{align}$$
where \$N=wy+x\$ is the index of the target cell.
We walk through the list \$[1,2,2,2,1,0,0,0]\$ and subtract \$1\$ to get the value of \$dx\$, which gives:
$$[0,1,1,1,0,-1,-1,-1]$$
For the corresponding values of \$dy\$, we use the same list shifted by 2 positions, which gives:
$$[1,1,0,-1,-1,-1,0,1]$$

w*(~~(i/w+h+~-a[j+2&7])%h) to ~~(a[j+2&7]-1+i/w+h)%h*w saves 2 bytes by getting rid of a pair of parenthesis.

@KevinCruijssen Nice catch. Thanks!

APL (Dyalog Classic), 27 bytes
{(⍺⊥⍺|(⍺⊤⍵)-⊢)¨1-1↓4⌽,⍳3 3}

Try it online!
{ } is a function with arguments ⍺ (the dimensions h w) and ⍵ (the index i)
⍳3 3 is a matrix of all 2-digit ternary numbers: 0 0, 0 1, ..., 2 2
, enlists the matrix as a vector
1↓4⌽ removes the centre element 1 1 by rotating 4 to the left (4⌽) and dropping one (1↓)
1- subtracts from 1, giving all 8 neighbour offsets
( )¨ applies the function train in parentheses to each offset
⍺⊤⍵ is the base-⍺ encoding of ⍵ - the coordinates of ⍵ in the matrix
(⍺⊤⍵)-⊢ subtracts the current offset, giving the coordinates of a neighbour
⍺| is mod a to wrap around coordinates and stay within the matrix
⍺⊥ decodes from base ⍺

APL (Dyalog Unicode), 40 bytesSBCS
Anonymous infix function. Takes h w as left argument and i as right argument.
{1↓4⌽,3 3↑,⍨⍣2⍪⍨⍣2⊃⊖∘⍉/(¯1+⍺⊤⍵),⊂⍺⍴⍳×/⍺}

Try it online!
{…} "dfn"; ⍺ is left argument (dimensions) and ⍵ is right argument (index).
 ×/⍺ product (multiplication-reduction) of the dimensions
 ⍳ the first that many indices
 ⍺⍴ use the dimensions to reshape that
 ⊂ enclose it (to treat it as a single element)
 (…), prepend the following:
  ⍺⊤⍵ encode the index in mixed-radix h w (this gives us the coordinates of the index)
  ¯1+ add negative one to those coordinates
 ⊖∘⍉/ reduce by rotate-the-transpose
  this is equivalent to y⊖⍉x⊖⍉… which is equivalent to y⊖x⌽… which rotates left as many steps as i is offset to the right (less one), and rotates up as many steps as i is offset down (less one), causing the the 3-by-3 matrix we seek to be in the top left corner
 ⊃ disclose (because the reduction reduced the vector to scalar by enclosing)
 ⍪⍨⍣2 stack on top of itself twice (we only really need thrice for single-row matrices)
 ,⍨⍣2 append to itself twice (we only really need thrice for single-column matrices)
 3 3↑ take the first three rows of the first three columns
The next two steps can be omitted if returning a 3-by-3 matrix is acceptable:
 , ravel (flatten)
 4⌽ rotate four steps left (brings the centre element to the front)
 1↓ drop the first element

@Adám fix the above and shorten it: {,(⍺⊥⍺|(⍺⊤⍵)-⊢)¨1-⍳3 3}, I'm not sure if you should also remove the middle element: {4⌽1↓4⌽...}

@ngn Uh, that's quite original. You post that!

@Adám ok

I don't think the output is expected to have the center element in it.

@JungHwanMin Last test case has.

The last test case still has 8 elements. I think the intended output is to print the neighbors at relative positions [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]

R, 125 111 108 bytes
function(x,i,m=array(1:prod(x),x),n=rbind(m,m,m),o=cbind(n,n,n),p=which(m==i,T)+x-1)o[p[1]+0:2,p[2]+0:2][-5]

Try it online!
14 and 8 bytes golfed by @JayCe and @Mark.
Input is [w, h], i because R populates arrays column first.
Makes the array and then "triples" it row- and column-wise. Then locate i in the original array and find it's neighborhood. Output without i.

You can save 14 bytes. I did not know that which had an arr.ind argument, learned something today !

You can save 8 bytes by replacing seq() with 1:

Python 2, 79 69 66 bytes
lambda h,w,i:[(i+q%3-1)%w+(i/w+q/3-1)%h*w for q in range(9)if q-4]

Try it online!
3 bytes gifted by Neil noting that (x*w)%(h*w)==((x)%h)*w==(x)%h*w.
0-indexed solution.

%h*w  saves 3 bytes over *w%(h*w).

PHP, 165 bytes
This is "0-based". There must be a better solution in PHP, but this is a starting point!
<?list(,$h,$w,$i)=$argv;for($r=-2;$r++<1;)for($c=-2;$c++<1;)$r||$c?print(($k=(int)($i/$w)+$r)<0?$h-1:($k>=$h?0:$k))*$w+(($l=$i%$w+$c)<0?$w-1:($l>=$w?0:$l))%$w.' ':0;

To run it:
php -n <filename> <h> <w> <i>

Example:
php -n cell_neighbours.php 4 5 1

Or Try it online!

K (ngn/k), 27 24 bytes
{x/x!''(x\y)-1-3\(!9)^4}

Try it online!
{ } is a function with arguments x (the dimensions h w) and y (the index i)
(!9)^4 is 0 1 2 3 4 5 6 7 8 without the 4
3\ encodes in ternary: (0 0;0 1;0 2;1 0;1 2;2 0;2 1;2 2)
1- subtracts from 1, giving neighbour offsets: (1 1;1 0;1 -1;0 1;0 -1;-1 1;-1 0;-1 -1)
x\y is the base-x encoding of y - the coordinates of y in the matrix
- subtracts each offset, giving us 8 pairs of neighbour coordinates
x!'' is mod x for each - wrap coordinates around to stay within the matrix
x/ decodes from base x - turns pairs of coordinates into single integers

Out of curiosity, does your variant of K have a "reverse arguments" adverb, like J's ~?

@ConorO'Brien None of the ks I know of (Kx's K, Kona, oK, and mine) has it, which is unfortunate for golfing. There are only 6 built-in adverbs: / \ ' /: : ': and no mechanism for user-defined such.

Of course I could add a selfie adverb, but golfing is not an end in itself for ngn/k, only a means to accumulate test cases and experience.

That's fair. Of course, you could view it as a potential shortcoming of the language. I've used PPCG to help develop Attache, and have realized Attache lacked some very useful functions that I would have otherwise not included. I don't use K, but perhaps there are other usecases which may warrant that type of adverb?

@ConorO'Brien I'm familiar with ⍨ in APL which is like ~ in J and I'm convinced of its utility, but, you see, k is limited to printable ASCII and (almost) no digraphs, so, a new adverb would mean the sacrifice of some other useful primitive as well as more incompatibility among implementations. I don't see what I can through out to put this in.

Wolfram Language (Mathematica), 74 bytes
Mod[i=#;w=#2;Mod[i+#2,w]+i~Floor~w+w#&@@@{-1,0,1}~Tuples~2~Delete~5,1##2]&

Try it online!
Takes input in reverse (i, w, h), 0-based.
3x3 matrix with the center cell in it, (60 bytes)
(Join@@(p=Partition)[Range[#2#]~p~#,a={1,1};3a,a,2a])[[#3]]&

Takes (w, h, i), 1-based.
Try it online!

MATL, 24 bytes
*:2Geti=&fh3Y6&fh2-+!Z{)

Inputs are h, w, i. The output is a row vector or column vector with the numbers.
Input i and output are 1-based.
Try it online! Or verify all test cases.
Explanation
*     % Take two inputs implicitly. Multiply
      % STACK: 16
:     % Range
      % STACK: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
2G    % Push second input again
      % STACK: [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16], 4
e     % Reshape with that number of rows, in column-major order
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16]
t     % Duplicate
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16],
      %        [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16]
i=    % Take third input and compare, element-wise
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16],
      %        [0 0 0 0; 0 1 0 0; 0 0 0 0; 0 0 0 0]
&f    % Row and column indices of nonzeros (1-based)
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], 2, 2,
h     % Concatenate horizontally
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], [2 2]
3Y6   % Push Moore mask
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], [2 2],
      %        [1 1 1; 1 0 1; 1 1 1]
&f    % Row and column indices of nonzeros (1-based)
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], [2 2],
      %        [1; 2; 3; 1; 3; 1; 2; 3], [1; 1; 1; 2; 2; 3; 3; 3]
h     % Concatenate horizontally
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], [2 2],
      %        [1 1; 2 1; 3 1; 1 2; 3 2; 1 3; 2 3; 3 3]
2-    % Subtract 2, element-wise
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16], [2 2],
      %        [-1 -1; 0 -1; 1 -1; -1 0; -1 0; -1 1; 0 1; 1 1]
+     % Add, element-wise with broadcast
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16],
      %        [1 1; 2 1; 3 1; 1 2; 3 2; 1 3; 2 3; 3 3]
!     % Transpose
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16],
      %        [1 2 3 1 3 1 2 3; 1 1 1 2 2 3 3 3]
Z{    % Convert into a cell array of rows
      % STACK: [1 5 9 13; 2 6 10 14; 3 7 11 15; 4 8 12 16],
      %        {[1 2 3 1 3 1 2 3], [1 1 1 2 2 3 3 3]}
)     % Index. A cell array acts as an element-wise (linear-like) index
      % STACK: [1 2 3 5 7 9 10 11]

Batch, 105 bytes
@for /l %%c in (0,1,8)do @if %%c neq 4 cmd/cset/a(%3/%2+%1+%%c/3-1)%%%1*%2+(%3%%%2+%2+%%c%%3-1)%%%2&echo.

0-indexed. Saved 23 bytes by stealing @ChasBrown's modulo 3 trick.

MATL, 24 bytes
X[h3Y6&fh2-+1GX\1Gw!Z}X]

Try it on MATL Online
Takes inputs [w h] and i. 8 bytes of this was shamelessly stolen from inspired by Luis Mendos' answer, though the overall approach is different.

Clean, 85 83 bytes
import StdEnv
r=(rem)
$h w i=tl[r(n+i/w)h*w+r(r(m+i)w)w\\n<-[0,1,h-1],m<-[0,1,w-1]]

Try it online!
Treats i as a coordinate (0 <= p < h, 0 <= q < w), and generates the values of the adjacent elements where the value is p'w + q'.

Kotlin, 88 bytes
Uses zero based indexes and outputs an 8 element list.
{h:Int,w:Int,i:Int->List(9){(w+i+it%3-1)%w+(h+i/w+it/3-1)%h*w}.filterIndexed{i,v->i!=4}}

Try it online!

Jelly, 20 bytes
PRs©Ṫ{œi+€Ø-Ż¤ŒpḊœị®

A dyadic link accepting a list of the dimensions on the left, [h,w], and the cell as an integer on the right, i, which yields a list of the neighbourhood.
Note: the order is different to that in the examples which is allowed in the OP
Try it online!
How?
PRs©Ṫ{œi+€Ø-Ż¤ŒpḊœị® - Link: [h,w], i
P                    - product -> h*w
 R                   - range -> [1,2,3,...,h*w]
    Ṫ{               - tail of left -> w
  s                  - split into chunks -> [[1,2,3,...w],[w+1,...,2*w],[(h-1)*w+1,...,h*w]]
   ©                 - ...and copy that result to the register
      œi             - multi-dimensional index of (i) in that list of lists, say [r,c]
             ¤       - nilad followed by link(s) as a nilad:
          Ø-         -   literal list -> [-1,1]
            Ż        -   prepend a zero -> [0,-1,1]
        +€           - addition (vectorises) for €ach -> [[r,r-1,r+1],[c,c-1,c+1]]
              Œp     - Cartesian product -> [[r,c],[r,c-1],[r,c+1],[r-1,c],[r-1,c-1],[r-1,c+1],[r+1,c],[r+1,c-1],[r+1,c+1]]
                Ḋ    - dequeue -> [[r,c-1],[r,c+1],[r-1,c],[r-1,c-1],[r-1,c+1],[r+1,c],[r+1,c-1],[r+1,c+1]]
                   ® - recall (the table) from the register
                 œị  - multi-dimensional index into (1-indexed & modular)

Attache, 66 bytes
{a.=[]Moore[Integers@@__2,{Push[a,_]},cycle->1]Flat[a@_][0:3'5:8]}

Try it online!
I still need to implement Moores and NMoore, but I still have Moore which serves as an iteration function. Essentially, Integers@@__2 creates an integer array of shape __2 (the last two arguments) of the first Prod[__2] integers. This gives us the target array. Then, Moore iterates the function {Push[a,_]} over each Moore neighborhood of size 1 (implied argument), with the option to cycle each element (cycle->1). This adds each neighborhood to the array a. Then, Flat[a@_] flattens the _th member of a, that is, the Moore neighborhood centered around _ (the first argument). [0:3'5:8] obtains all members except the center from this flattened array.
This solution, with an update to the language, would look something like this (49 bytes):
{Flat[NMoore[Integers@@__2,_,cycle->1]][0:3'5:8]}

Vyxal 3, 11 bytes
Πʀ⁰hẆÞȮ1⁾¹i

Try it Online!
Output is sorted in footer but is not necessary to the program bytecount
input is of the form [w,h], n
Πʀ⁰hẆÞȮ1⁾¹i
Πʀ           # range [0, w*h)
  ⁰hẆ        # split into chunks of given width
     ÞȮ1⁾    # grid neighbors with wraparound flattened by one
         ¹i  # at given index

Created with the help of Luminespire.

source: Stack Exchange

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

sort: votes


text:
Find the inverse of a 3 by 3 matrix
Challenge
Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix:
$$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e& f\\ g& h& i\end{pmatrix}$$
Find the inverse of the matrix, \$\mathbf{M}^{-1}\$ and output its components.
Inverse Matrix
The inverse of a matrix 3 by 3 obeys the following equation:
$$\mathbf{MM}^{-1} = \mathbf{M}^{-1}\mathbf{M} = \mathbf{I} = \begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}$$
And can be calculated as:
$$\mathbf{M}^{-1} = \frac{1}{\det(\mathbf{M})}\mathbf{C}^T$$
Where \$\mathbf{C}\$ is the matrix of cofactors:
$$\mathbf{C}=\begin{pmatrix}ei-fh&fg-di&dh-eg\\ch-bi&ai-cg&bg-ah\\bf-ce&cd-af&ae-bd\end{pmatrix}$$
And \$\mathbf{C}^T\$ is the transpose of \$\mathbf{C}\$:
$$\mathbf{C}^T = \begin{pmatrix}ei-fh&ch-bi&bf-ce\\fg-di&ai-cg&cd-af\\dh-eg&bg-ah&ae-bd\end{pmatrix}$$
And \$\det(\mathbf{M})\$ is the determinant of \$\mathbf{M}\$:
$$\det(\mathbf{M}) = a(ei-fh)-b(di-fg)+c(dh-eg)$$
Worked Example
For example, let's say the input is 0, -3, -2, 1, -4, -2, -3, 4, 1. This corresponds to the matrix:
$$\mathbf{M} = \begin{pmatrix}0&-3&-2\\1&-4&-2\\-3&4&1\end{pmatrix}$$
Firstly, let's calculate what's known as the determinant using the formula above:
$$\det(\mathbf{M}) = 0(-4\times1-(-2)\times4) - (-3)(1\times1-(-2)\times-3) + (-2)(1\times4-(-4)\times-3) = 1$$
Next let's calculate the matrix of cofactors:
$$\mathbf{C} = \begin{pmatrix}-4\times1-(-2)\times4& -(1\times1-(-2)\times-3)&1\times4-(-4)\times-3\\-(-3\times1-(-2)\times4)&0\times1-(-2)\times-3&-(0\times4-(-3)\times-3)\\-3\times-2-(-2)\times-4&-(0\times-2-(-2)\times1)&0\times-4-(-3)\times1\end{pmatrix}$$
$$= \begin{pmatrix}4&5&-8\\-5&-6&9\\-2&-2&3\end{pmatrix}$$
We then need to transpose \$\mathbf{C}\$ (flip the rows and columns) to get \$\mathbf{C}^T\$:
$$\mathbf{C}^T = \begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}$$
Finally, we can find the inverse as:
$$\mathbf{M}^{-1} = \frac{1}{\det(\mathbf{M})}\mathbf{C}^T = \frac{1}{1}\begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}=\begin{pmatrix}4&-5&2\\5&-6&-2\\-8&9&3\end{pmatrix}$$
So the output would be 4, -5, -2, 5, -6, -2, -8, 9, 3.
Rules

The given matrix will always have an inverse (i.e. non-singular). The matrix may be self-inverse
The given matrix will always be a 3 by 3 matrix with 9 integers
The numbers in the input will always be integers in the range \$-1000 \leq n \leq 1000\$
Non-integer components of the matrix may be given as a decimal or a fraction

Examples
Input > Output
1, 0, 0, 0, 1, 0, 0, 0, 1 > 1, 0, 0, 0, 1, 0, 0, 0, 1
0, -3, -2, 1, -4, -2, -3, 4, 1 > 4, -5, -2, 5, -6, -2, -8, 9, 3
1, 2, 3, 3, 1, 2, 2, 1, 3 > -1/6, 1/2, -1/6, 5/6, 1/2, -7/6, -1/6, -1/2, 5/6
7, 9, 4, 2, 7, 9, 3, 4, 5 > -1/94, -29/94, 53/94, 17/94, 23/94, -55/94, -13/94, -1/94, 31/94

Winning
The shortest code in bytes wins.

MATL, 54 bytes
th3LZ)t,3:q&XdpswP]w-lw/GtY*tXdsGXdsUw-IXy*2/+GtXds*-*

Try it online!
Just to keep it interesting, doesn't use the inbuilt matrix division or determinant functions to do it.
Instead, computes the determinant using the Rule of Sarrus.

And the adjugate (transposed cofactor matrix) using Cayley–Hamilton formula.
$$ {\displaystyle \operatorname {adj} (\mathbf {A} )={\frac {1}{2}}\left((\operatorname {tr} \mathbf {A} )^{2}-\operatorname {tr} \mathbf {A} ^{2}\right)\mathbf {I} _{3}-\mathbf {A} \operatorname {tr} \mathbf {A} +\mathbf {A} ^{2}.} $$
Commented code:
% Finding determinant
th    % concatenate the matrix to itself sideways
3LZ)  % chop off the last column (since the Rule of Sarrus doesn't need it)
t     % duplicate this matrix (say S)
,     % do this twice:
  3:q&Xd  % get the first three diagonals of S
  ps      % multiply each diagonal's values and add the results
  wP      % switch and flip the matrix (to get the popposing diagonals next time)
]w    % close loop, switch to have correct order of sums
-     % subtract - we now have the determinant
lw/   % invert that

% Finding adjugate using Cayley–Hamilton formula
GtY*  % A^2 term (last term of the formula)
tXds  % trace(A^2) for term 1 of formula
GXdsU % (trace(A))^2 for term1 of formula
w-    % (trace(A))^2 - trace(A^2)
IXy*  % multiply that by the identity matrix
2/    % divide that by 2 - term 1 complete
+
GtXds* % A*trA for term 2 of formula
-      % subtract to get adj(A)

*      % multiply by the inverse of determinant we found earlier
       % implicit output

We could go even more insane purer by replacing the matrix multiplication GtY* done for \$ A^2 \$, with something like 3:"Gt!@qYS*!s] 3$v t&v 3:K-&Xd (Try it on MATL Online).
The more direct and obvious way:
4 bytes
-1Y^

Try it online!
(-1 byte thanks to @Luis Mendo.)
-1 - Push the literal -1
Y^ - Raise input to that power (implicit input, implicit output)

Interesting, I never knew it was called the “Rule of Sarrus”. My teacher taught us it, but he had made it up himself while at uni.

@LuisMendo Thanks, replaced the short version (tbh the previous version was just a blind implementation of the MATL manual's suggestion for inverse, no actual thinking went into that one :) ). For the long version, I think it's a tiny bit clearer to leave it as such, enough to be worth taking a 1 byte hit.

@sundar Heh, I didn't even remember that suggestion. I'll add the suggestion of matrix power too

APL(Dyalog Classic),1 byte
⌹

Try it online!
if a flat lis is required this is 8 bytes
,∘⌹3 3∘⍴

Try it online!

Welcome to PPCG!

R, 51 35 27 8 5 bytes
solve

Try it online!
First go at doing one of these golf challenges. Sorry if my formatting is wrong!
Saved a total additional 11 bytes thanks to Giuseppe!
Saved an additional 19 bytes thanks to JAD!

Welcome to PPCG!

Removed the parameter variable names from the matrix function which subtracted 16 bytes!

can you put m inside solve entirely? why do you need to define variable

Nice! You can remove most of the variables to save bytes since you're really just chaining the operations together: try it online!

Irritating that the input format requires the ,T here. Ah well ¯\(ツ)/¯

If you're going to use solve, the solution is just solve, as it fulfills all the requirements of the question. It takes a matrix as input and returns a matrix.

@JAD Didn't think of that. Thanks!

Welcome to PPCG! looking at other recent R answers will give you a good sense of the acceptable program/function format.

To add to @JAD 's point this answer should just be solve, as a function is an acceptable solution.

@Giuseppe Can you maybe give an example on what you mean? I changed my answer based on what I thought JAD meant.

like this

@Giuseppe Ah I see. Some of the syntax used here will take awhile to get used to. Thanks!

Jelly, 3 bytes
æ*-

Try it online!
Assuming we can take input and provide as a 2D list of integers. If a flat list of integers is really required for both input and output, then this works for 6 bytes.

Explanation (I don't think it's worth including in the answer): æ* - matrix exponentiation, - - exponent, which equals $-1$. - is a syntax character for negative literals but it defaults to $-1$ when there is no number right after it.

Comments aren't necessarily meant to be long lived. If you're including an explanation in the comments, you should move it to the answer instead.

I really don't know how there's a builtin for this

JavaScript (ES6), 123 bytes
Saved 2 bytes thanks to @Mr.Xcoder
Saved 1 byte thanks to @ETHproductions
Takes input as 9 distinct values.
(a,b,c,d,e,f,g,h,i)=>[x=e*i-h*f,c*h-b*i,b*f-c*e,y=f*g-d*i,a*i-c*g,d*c-a*f,z=d*h-g*e,g*b-a*h,a*e-d*b].map(v=>v/=a*x+b*y+c*z)

Try it online!

Hey, i've allowed built-in matrix functions now. That is, if JS has any

@BetaDecay JS has none. :-)

Are those brackets really needed?

J, 2 bytes
%.

Just a built-in primitive
Try it online!

Python 2, 139 bytes
def F(a,b,c,d,e,f,g,h,i):x=e*i-f*h;y=f*g-d*i;z=d*h-e*g;print[j/(a*x+b*y+c*z)for j in x,c*h-b*i,b*f-c*e,y,a*i-c*g,c*d-a*f,z,b*g-a*h,a*e-b*d]

Try it online! (Has return instead of print for ease of testing.)

Python 3, 77 bytes
import numpy
lambda l:(numpy.matrix(l).reshape(-1,3)**-1).ravel().tolist()[0]

Takes input as a flat list.
It's 63 bytes if input is taken as a 2D array:
import numpy
lambda l:(numpy.matrix(l)**-1).ravel().tolist()[0]

Google Sheets, 16 bytes
=MINVERSE(A1:C3)

Input is in the range A1:C3
Built-ins are boring

Clean, 143 bytes
import StdEnv
$a b c d e f g h i#p=e*i-h*f
#q=f*g-d*i
#r=d*h-g*e
=[v/(a*p+b*q+c*r)\\v<-[p,c*h-b*i,b*f-c*e,q,a*i-c*g,d*c-a*f,r,g*b-a*h,a*e-d*b]]

Try it online!

Pari/GP, 6 bytes
m->1/m

Takes multiplicative inverse in the matrix ring \$\mathrm{M}_n\$.
Try it online!

Perl 5, 179 bytes
sub{($a,$b,$c,$d,$e,$f,$g,$h,$i)=@_;map$_/($a*$x+$b*$y+$c*$z),$x=$e*$i-$f*$h,$c*$h-$b*$i,$b*$f-$c*$e,$y=$f*$g-$d*$i,$a*$i-$c*$g,$c*$d-$a*$f,$z=$d*$h-$e*$g,$b*$g-$a*$h,$a*$e-$b*$d}

Try it online.

APL (Dyalog), 7 bytes
,⌹3 3⍴⎕

Takes input as a flat list and outputs as a flat list
Try it online!

Factor + math.matrices.extras, 5 bytes
recip

Try it online!

Ruby + -rmatrix, 24 bytes
->a{Matrix[*a].inv.to_a}

Or, if taking in and outputting a Matrix is apart of standard I/O, then this becomes 10 bytes.
->a{a.inv}

Attempt This Online!

Perl, 226 + 4 (-plF, flag) = 230 bytes
$_=join', ',map$_/($a*$x+$b*$y+$c*$z),$x=($e=$F[4])*($i=$F[8])-($f=$F[5])*($h=$F[7]),($c=$F[2])*$h-($b=$F[1])*$i,$b*$f-$c*$e,$y=$f*($g=$F[6])-($d=$F[3])*$i,($a=$F[0])*$i-$c*$g,$c*$d-$a*$f,$z=$d*$h-$e*$g,$b*$g-$a*$h,$a*$e-$b*$d

Try it online.

Clojure, 165 bytes
(fn[a b c d e f g h i](let[M map C(M -(M *[e f d c a b b c a][i g h h i g f d e])(M *[f d e b c a c a b][h i g i g h e f d]))](for[i C](/ i(apply +(M *[a b c]C))))))

I'm sorry this outputs C in transpose, and I'm feeling lazy to re-do those long character sequences to fix it at the moment.

Noether, 168 bytes
I~aI~bI~cI~dI~eI~fI~gI~hI~iei*fh*-a*di*fg*-b*-dh*eg*-c*+~zei*fh*-z/P","~nPch*bi*-z/PnPbf*ce*-z/PnPfg*di*-z/PnPai*cg*-z/PnPcd*af*-z/PnPdh*eg*-z/PnPbg*ah*-z/PnPae*bd*-z/P

Try it online


text:
Collapsing Matrices
Related: Let's design a digit mosaic, Print/Output the L-phabet. Sandbox post here
Given 2 inputs C = columns and rows, S = starting point output a matrix as follow:
Input 4, 3

1   2   3   0
2   2   3   0
3   3   3   0
0   0   0   0

Explanation
Given C = 4, S = 3
1) Create a C x C matrix filled with 0
         4 columns
4     _____|____
     |          |
r  --0  0   0   0
o |  0  0   0   0
w |  0  0   0   0
s  --0  0   0   0

2) Fill with S values within row and column S, then subtract 1 from S and repeat until S = 0. This case S = 3
             Column 3
S = 3           |
                v
        0   0   3   0
        0   0   3   0
Row 3-->3   3   3   0
        0   0   0   0

         Column 2
S = 2       |
            v
        0   2   3   0
Row 2-->2   2   3   0
        3   3   3   0
        0   0   0   0

     Column 1
S=1     |
        v
Row 1-->1   2   3   0
        2   2   3   0
        3   3   3   0
        0   0   0   0

Final Result

1   2   3   0
2   2   3   0
3   3   3   0
0   0   0   0

Rules

Assume C >= S >= 0
The output can be a matrix, list of lists, array (1-dimensional or 2-dimensional) etc.
You can take inputs via any default I/O format
Your program, function, etc... may be 1-indexing or 0-indexing. Please specify which one is.

Note Explanation is 1-indexing

Winning criteria code-golf

R,  47 41 bytes
function(C,S,m=outer(1:C,1:C,pmax))m*!m>S

Try it online!
1-indexed. Generates the outputs for S==C (no zeros) then zeroes cells which have a value >S using matrix multiplication (thanks Giuseppe for 4 bytes!).

Neat! multiplication will get you some good mileage: 43 bytes

@Giuseppe tx! I was able to save two more :)

Jelly, 8 bytes
»>⁴¬×»µþ

Try it online!
How it works
Jelly's Outer Product Atom (þ)
You can think of Jelly's outer product atom, þ, as a quick (operator) that, given integer arguments \$X\$ and \$Y\$ (in this case \$X=Y=\text{first argument }\$), produces the following matrix of tuples:
$$\left[\begin{matrix}
(1, 1) & (2, 1) & (3, 1) & \cdots & (X, 1) \\
(1, 2) & (2, 2) & (3, 2) & \cdots & (X, 2) \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
(1, Y) & (2, Y) & (3, Y) & \cdots & (X, Y)
\end{matrix}\right]$$
It also applies the link right before it to all pairs, let's call it \$\:f\$, which behaves like a function which takes two arguments, producing something like this:
$$\left[\begin{matrix}
f(1, 1) & f(2, 1) & f(3, 1) & \cdots & f(X, 1) \\
f(1, 2) & f(2, 2) & f(3, 2) & \cdots & f(X, 2) \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
f(1, Y) & f(2, Y) & f(3, Y) & \cdots & f(X, Y)
\end{matrix}\right]$$
How is it relevant to the task at hand?
This works by noticing that every value in the expected output is just a table of maximal indices, or \$0\$ if this maximum exceeds our second argument. Therefore, we can create the following link to perform this mapping:
»>⁴¬×» – Dyadic (2-argument) link.
»      – Maximum of the X, Y coordinates.
 >⁴    – Check if this exceeds the second argument of the program.
   ¬   – Negate this boolean.
    ×» – And multiply by the maximum, computed again.

Octave, 31 bytes
@(C,S)(u=max(t=1:C,t')).*(u<=S)

Anonymous function that returns a matrix. Uses 1-based indexing.
Try it online!

Haskell, 47 45 bytes
-2 bytes by changing the output format to one-dimensional list.
c&s|x<-[1..c]=[sum[j|j<=s]|j<-x>>=(<$>x).max]

Try it online!
Explanation
The term x >>= (<$> x) . max is a golfed version of
concat [ max i <$> x | i <- x ]

which evaluates to [1,2,3,4..c, 2,2,3,4..c, 3,3,3,4..c, ..., c,c,c,c..c]. Now we only need to force the values to 0 once they exceed s which we achieve with sum [ j | j <= s].

APL(Dyalog Classic), 12 bytes
{⍺ ⍺↑∘.⌈⍨⍳⍵}

Try it online!
Any tips on turning this into a train are welocome.

My train is longer by 2

13 bytes

JavaScript (ES6), 61 bytes
Takes input in currying syntax (c)(s), where s is 1-indexed. Returns a 1-dimensional array.
c=>s=>[...Array(c*c)].map((_,k)=>(k=k%c>k/c?k%c:k/c)<s?-~k:0)

Try it online!

APL (Dyalog), 12 bytes
o×⎕≥o←∘.⌈⍨⍳⎕

Try it online!

Would something like o×⎕≥o←∘.⌈⍨⍳ be allowed, or would you have to assign it to a function in order for that to count?

@Zacharý my guess is that one would need to be put it inside a tradfn with an argument or a dfns

Jelly, 6 bytes
⁴Ri»µþ

A full program* taking integers C and S which prints the Jelly representation of a list of lists of integers as defined (1-indexed).
Try it online! (formats the result of the dyad as a grid of numbers for easier reading)
How?
⁴Ri»µþ - Main Link: C, S
     þ - outer product with:
    µ  -   the monadic function (i.e. f(x,y) for x in [1..C] for y in [1..C]):
   »   -     maximum (of x and y)
⁴      -     program's 4th argument = 2nd input = S
 R     -     range = [1,2,3,...S]
  i    -     first index of (the maximum) in (the range) or 0 if not found
       - as a full program: implicit print

* The reason this is a full program is down to the use of the program argument access, ⁴. As a dyadic link this code would rely on how the program which is using it is called.
Reusable dyadic link in 8 bytes (taking S on the left and C on the right): RiⱮⱮ»þ`}
Reusable dyadic link in 8 bytes (taking C on the left and S on the right): RiⱮⱮ⁹»þ¤

Stax, 10 bytes
▓╜.→,cΘ○╤æ

Run and debug it
How it works:
R(Xm]i*xit+J Full program, implicit input.
R            1-based range of S
 (           Right-pad with zeroes to length C
  X          Save to X register
   m         Map (same as here):
    ]          Wrap in list
     i*        repeat by iteration index
       xit     Remove first  elements from X register
          +    Append
           J   Stringify each element, and join by space

Java 10, 88 bytes
C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.
Explanation:
C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result

PHP, 92 bytes
This is "1-indexing".
<?list(,$c,$s)=$argv;for(;$i++<$c;print"\n")for($j=0;$j++<$c;)echo$s<$i||$s<$j?0:max($i,$j);

To run it:
php -n <filename> <c> <s>

Example:
php -n collapsing_matrice.php 8 6

Or Try it online!

Excel VBA, 65 bytes
An immediate window function that takes input from [A1:B1] and outputs to the range [C1].Resize([A1],[A1]).
[C1].Resize([A1],[A1])=0:For s=-[B1]To-1:[C1].Resize(-s,-s)=-s:Next

Input / Output
Input is in range [A1:B1]

MATLAB, 58 bytes (Thanks to anonymous user)
function o=f(c,s);o=zeros(c);for j=s:-1:1;o(1:j,1:j)=j;end

Just filling the elements of matrix with appropriate number, running a loop. Maybe possible to be cleverer with arrayfun

You don't need to name the function and you can use zeros(c) which safes some bytes. Also did you see this Octave answer, I guess it would work in Matlab too?

@OMᗺ Octave you can't name variables inside anonymous functions in matlab. Also, max() have to take same-shape arguments

An anonymous user suggested function o=f(c,s);o=zeros(c);for j=s:-1:1;o(1:s,1:s)=j;end.

@JonathanFrech oh my so much simpler :-( just need to be o(1:j,1:j)=j

J, 18 bytes
,~@[{.[:>./~1+i.@]

Much longer than both APL solutions.
Try it online!

Perl 6, 37 bytes
{((^$^c+1 Xmax^$c+1)Xmin$^s+1)X%$s+1}

Try it online!
Returns the matrix as 1-dimensional array.

C# (.NET Core), 85 bytes
c=>s=>{var r=new int[c,c];for(;s>0;)for(int j=s--;j-->0;)r[s,j]=r[j,s]=s+1;return r;}

Try it online!
A port of Kevin Cruijssen's answer, which was much better than mine.

Python 2, 58 bytes
lambda C,S:[-~max(i%C,i/C)*(i%C<S>i/C)for i in range(C*C)]

Try it online!
Outputs a 1D list of length C*C.

Charcoal, 19 bytes
Ｅθ⪫ＩＥＥθ⌈⟦ιλ⟧∧‹λη⊕λ

Try it online! Link is to verbose version of code. 3 bytes used to convert the output to decimal and format it nicely. Explanation:
 θ                  Input `C`
Ｅ                   Map over implicit range
      θ             Input `C`
     Ｅ              Map over implicit range
          λ         Inner index
         ι          Outer index
       ⌈⟦  ⟧        Maximium
    Ｅ               Map over results
              λ     Current value
               η    Input `S`
             ‹      Less than
                 λ  Current value
                ⊕   Incremented
            ∧       Logical AND
   Ｉ                Cast to string
  ⪫                 Join with spaces
                    Implicitly print on separate lines

Clean, 67 bytes
import StdEnv
$n s=[[if(i>s||j>s)0(max i j)\\i<-[1..n]]\\j<-[1..n]]

Try it online!
Defines $ :: Int Int -> [[Int]] giving an answer using 1-based indexing.

Mathematica 44 bytes
Table[If[i <= s && j <= s, Max[i, j], 0], {i, c}, {j, c}]

Are you certain the whitespace is necessary?  I can't test Mathematica but I don't think it is.

Husk, 11 bytes
T0:´ṪYḣ⁰`R0

Try it online! The function takes S followed by C.


text:
Solve the Halting Problem for Modilar SNISP
In the spirit of Solve the Halting Problem for Befinge, let's define another 2D language called Modilar SNISP. Modilar SNISP has the following six instructions:

\ directs the instruction pointer as follows:

if approached from the top, go right;
if approached from the right, go up;
if approached from the bottom, go left;
if approached from the left, go down.

/ directs the instruction pointer as follows:

if approached from the top, go left;
if approached from the left, go up;
if approached from the bottom, go right;
if approached from the right, go down.

! skips over the next instruction.
@ pushes the IP location and direction onto the call stack.
# pops an IP location and direction from the call stack and restores them, then skips over the next instruction. If the call stack is empty, execution halts.
. does nothing.

The instruction pointer starts at the top left corner going right. If it ever leaves the playfield, execution halts.
Modilar SNISP cannot be more powerful than a PDA, because its only source of unbounded storage is a stack (the call stack) with a finite alphabet (the set of all IP (location, direction) pairs). The halting problem is decidable for PDAs, so this challenge should always be possible.
The Challenge
Your goal is to write a program that takes a matrix of characters representing a Modilar SNISP program and returns one of two distinct outputs depending on whether it halts or not.
This is code-golf, so the shortest valid program (measured in bytes) wins.
Specifications

The way you take a matrix of character is flexible: a newline-separated string, array of strings, array of arrays of characters, 2d array of characters, flat array of characters with an integer representing width, etc. are all acceptable. The test cases opt for the first of those choices.
You can assume that the input matrix will be rectangular (so you don't have to pad short rows) and will be of nonzero length and width.
You can choose any two distinct outputs, not just truthy/falsy.
You can assume that the input matrix will consist only of valid commands (\, /, !, @, #, and .).
When a command is said to "skip the next instruction," you can assume that there will be a next instruction to skip. In particular, it will never be encountered in circumstances where (1) it lies on the playfield's edge and (2) the IP is moving perpendicular to that edge, such that the "next instruction" after it would lie outside the playfield.

Test Cases
The following snippet can be used to test programs in the language. Note that it is slightly more permissive than the actual specification given here (e.g. it permits characters other than . as no-ops).

function htmlEscape(t){let i=document.createElement("span");return i.innerText=t,i.innerHTML}function tick(){snisp.tick(),snisp.update()}function run(){runButton.style.display="none",stopButton.style.display="",code.style.display="none",executionArea.style.display="",snisp.initialize(),intervalId=setInterval(tick,INTERVAL_MS)}function stop(){runButton.style.display="",stopButton.style.display="none",code.style.display="",executionArea.style.display="none",clearInterval(intervalId)}let TICKS_PER_SECOND=5,INTERVAL_MS=1e3/TICKS_PER_SECOND,runButton=document.getElementById("run-button"),stopButton=document.getElementById("stop-button"),code=document.getElementById("code"),executionArea=document.getElementById("execution-display"),intervalId,snisp={x:null,y:null,direction:null,callStack:null,stopped:null,playfield:null,padRows:function(){let t=Math.max(...this.playfield.map(t=>t.length));for(let i=0;i<this.playfield.length;i++)this.playfield[i]=this.playfield[i].padEnd(t,".")},initialize:function(){this.x=0,this.y=0,this.direction="right",this.callStack=[],this.stopped=!1,this.playfield=code.value.split("\n"),this.padRows(),this.update()},getCurrentChar:function(){let t=this.playfield[this.y];if(void 0!=t)return t[this.x]},backslashMirror:function(){let t={up:"left",right:"down",down:"right",left:"up"};this.direction=t[this.direction]},slashMirror:function(){let t={up:"right",right:"up",down:"left",left:"down"};this.direction=t[this.direction]},forward:function(){switch(this.direction){case"up":this.y-=1;break;case"down":this.y+=1;break;case"left":this.x-=1;break;case"right":this.x+=1;break;default:throw"direction is invalid"}},pushState:function(){this.callStack.push({x:this.x,y:this.y,direction:this.direction})},restoreState:function(){let t=this.callStack.pop();void 0!=t?(this.x=t.x,this.y=t.y,this.direction=t.direction):this.stopped=!0},tick:function(){if(this.stopped)return;let t=this.getCurrentChar();if(void 0!=t){switch(t){case"\\":this.backslashMirror();break;case"/":this.slashMirror();break;case"!":this.forward();break;case"@":this.pushState();break;case"#":this.restoreState(),this.forward()}this.forward()}else this.stopped=!0},generatePlayfieldHTML:function(t,i){let e=[];for(let n=0;n<this.playfield.length;n++){let s=[],l=this.playfield[n];for(let e=0;e<l.length;e++){let a=htmlEscape(l[e]);e==t&&n==i&&(a=''+a+""),s.push(a)}e.push(s.join(""))}return e.join("
")},update:function(){let t=[];for(let i=0;i<this.callStack.length;i++){let e=this.callStack[i];t.push(this.generatePlayfieldHTML(e.x,e.y))}t.push(this.generatePlayfieldHTML(this.x,this.y));let i=t.join("

");executionArea.innerHTML=i}};
#code{font-family:monospace;}#execution-display{font-family:monospace;white-space:pre;}.highlight{background-color:yellow;}
Code:
<textarea id="code" width="300" height="300"></textarea>
<button id="run-button" onclick="run()">Run</button><button id="stop-button" onclick="stop()" style="display: none;">Stop</button>

The ungolfed form can be found here.
Halting
.

The smallest program possible. Goes out the right.

\\
\/

Winds around the program and goes out the top.

.\./.\
.\!/./

Goes in a loop. Winds through part of the track in two different directions.

@\!/#
.\@/#

Uses all six commands.

@.@.@.@.@.@.@.@.@.#

This program's execution time is exponential in the number of repetitions of @., but it still halts.

Non-Halting
!/\
.\/

I believe this is the shortest infinite loop.

@!\\#/@\!\
//@//.#./.
.\#.!\./\.
#.\!@!\@//
/..@.@\/#!
\.@.#.\/@.

This winds around the track, spawning stack frames occasionally, before eventually getting caught in a cycle infinitely generating stack frames. Not all commands are actually used.
.!/@.@.@.@.@.\
/.@.@.@.@.@.@/
\@.@.@.@.@.@.\
/.@.@.@.@.@.@/
.@\@.@.@.@.@.\
\.@.@.@.@.@.@/

Keeps creating stack frames, but none of them ever return.

Sandbox (now deleted)

The language reminds me of a much simplified Fission.

@sundar It's a subset of Modular SNUSP, the same way Befinge is (kind of) a subset of Befunge.

Python 3, 639 bytes 630 bytes 593 bytes
def e(I):
 m=[(0,-1),(0,1),(1,1),(1,-1)];a=lambda i:(tuple(i[0]),i[1]);b=lambda s,q:s.s==q.s and s.S&q.S==q.S
 class O():i=[[0,0],2];S=[];A={}
 def z():d=m[O.i[1]];O.i[0][d[0]]+=d[1]
 def y():O.i=O.S.pop();z()
 def x():O.i[1]=[3,2,1,0][O.i[1]]
 def w():O.i[1]=[2,3,0,1][O.i[1]]
 def v():O.S+=[[O.i[0][:],O.i[1]]]
 while 1:
  p=O();p.s=a(O.i);p.S={a(i)for i in O.S};l=O.A.setdefault(p.s,[]);c=any((b(p,s)for s in l));l+=[p];e=O.i[0];d=not((0<=e[0]<len(I))and(0<=e[1]<len(I[0])))or((x,w,z,v,lambda:len(O.S)==0 or y(),lambda:0)["\\/!@#.".find(I[e[0]][e[1]])]()==1);z()
  if d!=c:return not c or d

Try it online!
I feel like this is more of minified source than golf... I'm sure there's a better way to get there.
Program works as a full interpreter for the language. It stops either when:

We exit the program
We detect we're in a loop.

Loop detection is somewhat naive (and memory heavy). Before we evaluate each move, we cache off our current Direction, Position, and Stack. If we see we've come to a position we've been to before, moving the same direction, and our current stack is a super set of a previous stack at this position + direction, then we know we're in a loop and the stack is either growing (or staying constant).
Edit 1 - Thanks to Herman L for cutting "pass". Also cut "True".
Edit 2 - Lambda-ified some functions. Reduced number of returns. Returns "True" for terminating and "False" for non-terminating. Leveraged existing O class as tracking object, eliminating the need for N class.

Replacing class N():pass with class N():0 and def t():pass with def t():0 seems to work

You could change from a function to a full program by replacing def e(I) with I=input(). This allows you to remove all the indents. The return x statements can be replaced with exit(x).

Also def u():return len(O.S)==0 or y() could become u=lambda:len(O.S)==0or y(). P.S. nice solution!

JavaScript (ES6), 258 254 bytes
p=>(d=>{for(x=y=r=k=1,s=[],v={};w=[--x,--y,d],c=1<<"\\!@/#".indexOf(q=(p[y]||0)[x]),q&&r&&(e=v[w]?v[w].some(u=>!s.some(t=>u+0==t+0)):1);x+=d>>2,y+=d&3)v[w]=[...s],k=k?c&9?d=c&1?d/4|4*d&12:(d+5)%10:c&4?s.push(w):c&16?(r=s.pop())&&!([x,y,d]=r):c-2:1})(9)|e

Expects a non-empty program as an array of strings, where each element
represents a line of Modilar SNISP. Outputs 1 if the given program halts, and
0 otherwise.
Same logic as @machina.widmo's
answer. A few failed attempts
at alternative methods led me to conclude that they'd produce longer code
anyway!
Try it online!
Explanation
Similar to the other answer, this function exits with:

1 if the program halts (e.g. the IP moves off the grid or an empty stack is popped)
0 if the IP reaches a position it has already visited, moving in the same
direction, and with a superset of the stack present in the previous
visit.

Why the same direction?
 1
!\/

The above program halts, but hits the same position (character 1), with an
identical stack, but from a different direction.
Why a superset and not merely stack size?
  ab4
!/@@.\
.\..#/

This also halts, and the IP hits character 4 from a consistent direction four
times, with the following stack states (* indicates the top of the stack):

size = 2 [a, b]*
size = 1 [a]*
size = 1 [b]*
size = 0 []*

How the interpreter works
Instructions (q) are translated into binary (c) as follows (with all other
characters, . or otherwise, serving as nops):
1 2 4 8 16
\ ! @ / #

Direction (d) is represented as a bit field:
9 -> right : 1001
1 -> left  : 0001
6 -> down  : 0110
4 -> up    : 0100

Mirrors (\/) transform the direction:
\: 6->9 9->6 4->1 1->4
d/4 | 4*d&12
/: 1->6 6->1 4->9 9->4
(d+5) % 10
New directions transform the position:
x += d>>2 - 1
y += d&3 - 1
Other global variables

x, y: IP position
r: holds value popped off the stack
k: falsy if skipping the next instruction (e.g. from !#)
s: stack
v: caches visited positions, direction, snapshot of stack
w: [x, y, d], the value stored on the stack and used as the key value for v
e: falsy if program does not halt due to a cache match

Ungolfed
p => (d => {                                                  // set initial direction and avoid a verbose `return` statement
    for (
        x = y = r = k = 1,
        s = [],
        v = {};
        w = [--x, --y, d],                                    // decrement positions early so that x,y
                                                              // do not require a separate assignment to 0
        c = 1 << "\\!@/#".indexOf(q = (p[y]||0)[x]),          // taking an index of undefined produces an error; using 0 does not
        q && r && (
            e = v[w]
                ? v[w].some(u => !s.some(t => u+0 == t+0))    // in order to compare two arrays, must coerce to strings
                : 1
        );
        x += d>>2,
        y += d&3
    )
        v[w] = [...s],                         // clone stack
        k = k
            ?
                c&9                            // if \ or /
                    ? d = c&1
                        ? d/4 | 4*d&12
                        : (d+5) % 10
                : c&4                          // if @
                    ? s.push(w)
                : c&16                         // if #
                    ? (r = s.pop())
                        && !([x, y, d] = r)    // destructure value in stack if any exists
                : c-2                          // 0 if !
            : 1
})(9) | e

APL (Dyalog Unicode), 93 bytes
⍬{~1∊∊⍺⍷¨⊂⍵:(⍺,⊂⍵)∇(1↓⍵),⍨⊃⍬(⊂1⌽⍉g)(⊂⍉⊖⌽1⌽g)(⊂2⌽g)((1⌽g)(2⌽g))(⊂1⌽g)⌷⍨'#\/!@.'⍳⊃⊃g←⊃⍵}⊂1⍪⍨⎕,0

Try it online!
Instead of moving the IP around the grid, we move the grid around the IP, so the current IP is always at the top-left with direction pointing right.
Raises an IndexError to indicate halting; no error indicates a non-halting SNISP program.

(⊂1⌽g)⌷⍨'#\/!@.'⍳⊃⊃g←⊃⍵}⊂1⍪⍨⍵,0}
⍬{~1∊∊⍺⍷¨⊂⍵:(⍺,⊂⍵)∇(1↓⍵),⍨⊃⍬(⊂1⌽⍉g)(⊂⍉⊖⌽1⌽g)(⊂2⌽g)((1⌽g)(2⌽g))(⊂1⌽g)⌷⍨'#\/!@.'⍳⊃⊃g←⊃⍵}⊂1⍪⍨⎕,0
          ⊂1⍪⍨⎕,0 ⍝ Pass an initial stack: the input padded with 0s on the right and 1s on the bottom
                   ⍝ This lets us treat the program grid as wraparound
                   ⍝ 1 and 0 could be any 2 distinct values not in '#\/!@.'
                   ⍝ They have to be different to differentiate SNISP programs that are symmetric on the main diagonal
⍬                 ⍝ Pass an initial stack history
 {...}            ⍝ Inner function:
 ~1∊∊⍺⍷¨⊂⍵:        ⍝ Only continue if the stack is not a prefix of any member of the stack history
                    ⍝ Prefix because the top of the stack is the first element and gives the current direction/position
 (⍺,⊂⍵)∇           ⍝ Recurse with an appended stack history and an updated stack:
          g←⊃⍵      ⍝ Pop the current grid off the stack
      ⍬...⊂1⌽g      ⍝ A list of all possible stack changes. Will add to the stack:
       ⍬             ⍝ #: nothing, so the next step pops the stack
       ⊂1⌽⍉g         ⍝ \: transposed grid, wrap-rotated right by 1; the new IP is 1 unit down
       ⊂⍉⊖⌽1⌽g       ⍝ /: new grid such that the new IP is at the current bottom-left
       2⌽g           ⍝ !: new grid has IP 2 units to the right
       (1⌽g)(2⌽g)    ⍝ @: push both 1⌽g, which is the same as the '.' instruction,
                      ⍝ and 2⌽g, which is the same as the '!' instruction.
                      ⍝ The 1⌽g will be immediately popped for the next position
       ⊂1⌽g          ⍝ .: Push 1⌽g, which simply moves the IP 1 unit to the right
   ⌷⍨'#\/!@.'⍳⊃⊃g   ⍝ Get the next-grid corresponding to the character under the IP
                     ⍝ If that character is 0 or 1, then the pointer has walked off the edge,
                     ⍝ This causes an IndexError since 7='#\/!@.'⍳1, and the list of
                     ⍝ stack changes has only 6 elements
                     ⍝ If the stack is empty, and there is no current grid,
                     ⍝ then it would also try to get the 7th elements, also raising the IndexError
    (1↓⍵),⍨⊃        ⍝ Add the next grid to the beginning (top) of the popped stack

Uh... This is 93 characters long but in what encoding can those 93 chars be represented in 93 bytes? Shouldn't it be 178 bytes (UTF-8)?

@YetiCGN. Sorry, forgot to include in post. It is now linked on the word "bytes"

Okay, I see. I actually considered the possibility that it uses its own character 8-bit character set, but the "Unicode" marker in the title threw me off. Sorry for the newbie complaint. ^^


text:
Count the lucky tickets within the given range
In Russia we have something like a tradition: we like to look for lucky tickets.
Here's what a regular ticket looks like:

As you can see, the ticket has a six-digit number.
A six-digit number is considered lucky if the sum of the first three digits is equal to the sum of the last three.
The number on the photo is not lucky:
038937
038 937
0 + 3 + 8 = 11
9 + 3 + 7 = 19
11 != 19

Challenge
Given the limits of a range (inclusive), return the number of lucky ticket numbers contained within it.
Parameters

Input: 2 integers: the first and last integers in the range
The inputs will be between 0 and 999999 inclusive
Output: 1 integer: how many lucky numbers are in the range
You may take the inputs and return the output in any acceptable format
Assume leading zeros for numbers less than 100000.

Examples
0, 1 => 1
100000, 200000 => 5280
123456, 654321 => 31607
0, 999999 => 55252

This is code-golf so the shortest answer in bytes in every language wins.
Update: here's the lucky one

Related.

05AB1E, 8 (or 10?) 11 (or 13?) bytes
Ÿʒ₄n+¦S3ôOË

Try it online or verify some more test cases.
NOTE: In 05AB1E strings and integers are interchangeable, so the output numbers doesn't contain leading zeroes. This could however be fixed with 1 additional byte (12 bytes):
Ÿ₄n+€¦ʒS3ôOË

Try it online or verify some more test cases.
+3 bytes to bug-fix numbers with a length of 3 or less (range [000000, 000999]).
Explanation:
Ÿ          # Create an inclusive (on both sides) range from the two inputs
           #  i.e. 038920 and 038910 →
           #   [38910,38911,38912,38913,38914,38915,38916,38917,38918,38919,38920]
 ʒ         # Filter this list by:
  ₄n+      #  Add 1,000,000 to the number
     |     #  And remove the leading 1
           #   i.e. 38910 → 1038910 → '038910'
  S        #  Transform it to a list of digits
           #   i.e. '038910' → ['0','3','8','9','1','0']
   3ô      #  Split it into chunks of length 3
           #   i.e. ['0','3','8','9','1','0'] → [['0','3','8'],['9','1','0']]
     O     #  Sum the digits in both parts
           #   i.e. [['0','3','8'],['9','1','0']] → [11,10]
      Ë    #  Check if they are equal (if they are, they remain in the filtered list)
           #   i.e. [11,10] → 0

EDIT: Seems I (and most other answers) slightly misread the challenge and the amount of numbers is being asked instead of the numbers themselves within the range. In that case a trailing }g can be added (close the filter; and get the amount of numbers left in the filtered list), so it's 10 13 bytes instead:
Ÿʒ₄n+¦S3ôOË}g

Try it online or verify some more test cases.

For range starting under 1000 (For example [0;1000]), your result seems to be a bit off (1000 lucky numbers are found).

If I understand the challenge correctly, adding 1.000.000 to each number and removing the first character would solve this problem. It would also get rid of using the R.

@Adnan Thanks, that's indeed a pretty nice way to handle it.

It is the count that is required (and the output does not require leading zeros), so 13.

C# (.NET Core), 93 + 18 = 111 bytes
a=>b=>Enumerable.Range(a,b-a+1).Select(e=>$"{e:D6}").Count(e=>e[0]+e[1]+e[2]==e[3]+e[4]+e[5])

Try it online!
18 bytes for using System.Linq;. I supposed that the input and output formats could be flexible. So I take two integers as input (the range, inclusive).
Some test results:
a=1000
b=1100

Lucky numbers = 3 [001001, 001010, 001100]

a=2000
b=2100

Lucky numbers = 3 [002002, 002011, 002020]

a=222000
b=222100

Lucky numbers = 7 [222006, 222015, 222024, 222033, 222042, 222051, 222060]

a=0
b=999999

Lucky numbers = 55252 (that's 5.5% of the total numbers)

JavaScript (ES6), 66 bytes
Takes input in currying syntax (m)(n), where m is the exclusive inclusive upper bound and n is the inclusive lower bound.
m=>g=n=>n<=m&&![...n+=''].reduce((t,d,i)=>t-=n[i+3]?d:-d,0)+g(-~n)

Try it online!
How?
We test each number \$n\$ by walking through its digits \$d_i\$ and updating a total \$t\$:

\$t \gets t - d_i\$ if there are at least 3 remaining digits after this one
\$t \gets t + d_i\$ otherwise

If we have \$t=0\$ at the end of the process, then \$n\$ is a lucky number.

JavaScript (ES6), 67 bytes
Same input format.
m=>g=n=>n<=m&&!eval([...n/1e3+''].join`+`.split`+.`.join`^`)+g(n+1)

Try it online!
How?
For each number \$n\$:

divide it by \$1000\$: e.g. 38937 --> 38.937
coerce to a string and split: ['3','8','.','9','3','7']
join with +: "3+8+.+9+3+7"
replace +. with ^: "3+8^+9+3+7"
evaluate as JS code and test whether the result is \$0\$: 24 (\$11\$ XOR \$19\$)

If \$n \equiv 0 \pmod{1000}\$, no decimal point is generated and the evaluated expression is just a positive sum (falsy), unless \$n=0\$ (truthy). This is the expected result in both cases.

It's been made inclusive.

Ruby, 56 54 bytes
->a,b{(a..b).count{|i|j=i.digits;j[0,3].sum*2==j.sum}}

Try it online!
Method:

For every number, creates an array of digits (which comes out reversed)
Compares the sum of the first 3 digits in the array (last 3 in the number) multiplied by 2 to the sum of the entire array
Counts the numbers for which the two sums are equal

Python 3, 117 113 106 135 bytes
This is my first answer ever so I'm sure there's room for improvement.
def x(a,b):
    n=0
    for i in range(a,b+1):
        if sum(map(int,str(i//1000)))==sum(map(int,str(i%1000))):n+=1
    print(n)

-4 bytes thanks to W W
-7 bytes thanks to Asone Tuhid
+29 bytes to create a function

Gets the first three digits through integer division, and the last three through modulo. The first and last integers in the range are inputted as arguments of the x function, as a and b, respectively. Output is n, printed.
Ungolfed:
def x(a, b):
    n = 0
    for i in range(a, b + 1):
        if sum(map(int, str(i // 1000))) == sum(map(int, str(i % 1000))):
            n += 1
    print(n)

You don't need the indentation after the if btw.  Also it will probably be cheaper to convert to string before you take the first or last 3 digits.

Welcome to PPCG! Check out Tips for golfing in Python for tips and tricks, there's a similar thread for most languages if you're interested. Also, it's good practice to include a TIO link as demonstration.

I'd suggest replacing n=n+1 with n+=1 and moving it right after the if statement (if...:n+=1)

You can't take a and b as pre-declared variables. You either have to have a function or take them via input

90 bytes using an unnamed function (declared as a lambda) and a sum for the counting - Try it online!. 86 is also possible by use of a clever golf by Asone Tuhid - lambda a,b:sum(sum(map(int,str(i)))==2*sum(map(int,str(i%1000)))for i in range(a,b+1))

FYI single spaces can work as indents too, so your 135 without any other golfing is really 114.

If you're keeping it as a function, you can move the n=0 part into the header, like def x(a,b,n=0)

Husk, 12 bytes
#ȯ§¤=Σ↓↑3↔d…

Try it online!
Explanation
#(§¤=Σ↓↑3↔d)…  -- example input: 100000 101000
            …  -- inclusive range: [100000,100001..100999,101000]
#(         )   -- count elements where (example with 100010)
          d    -- | digits: [1,0,0,0,1,0]
         ↔     -- | reversed: [0,1,0,0,0,1]
  §     3      -- | fork elements (3 and [0,1,0,0,0,1])
       ↑       -- | | take: [0,1,0]
      ↓        -- | | drop: [0,0,1]
   ¤=          -- | > compare the results by equality of their
     Σ         -- | | sums 1 == 1
               -- | : 1
               -- : 3

It seems your solution has the same flaw my initial version had: [000000, 001001] should result in 2 (000000 and 001001), but results in 1001 instead. (I added 1,000,000 and removed the trailing 1 as fix for that, not sure how easy / byte-efficient that is in Husk, though.)

@KevinCruijssen: I think I can remember this challenge was initially not clear, I don't have time to look into it rn, so I just rolled back to my initial submission which seems to be right.

Japt, 38 15 bytes
õV Ëì ò3n)mx r¥

-23 thanks to Shaggy!
My first Japt submission; thanks to Shaggy for all the help!
Try it online!

Welcome to Japt! :)

@Shaggy thanks! It's a pretty neat language!

To help get you started. Feel free to ping me in chat if you've any questions.

@Shaggy That's amazing. I definately learned a lot from that. Are you planning to post it as your own answer? You should!

No, you can have it :) Like I said, to help you get started.

R, 93 86 bytes
Shorter logic at the end compliments of @Giuseppe/
function(a,b){for(i in sprintf("%06d",a:b)){x=utf8ToInt(i);F=F+!sum(x[1:3]-x[4:6])}
F}

Try it online!
Integer inputs. Pad them with 0. Convert to the six ASCII code points. Abuse the F builtin.

I'm getting an NA returned from that function.

I've rolled back the edit. The new version fails at 0 because of the scipen problem. Oh well.

91 bytes

86 bytes

Charcoal, 15 bytes
ＩＬΦ…·ＮＮ⁼Σι⊗Σ÷ιφ

Try it online! Link is to verbose version of code. Edit: I originally thought that it was the list of lucky numbers that was required. This can be done in 14 bytes (by removing the Ｌ, which takes the length of the list), or in 20 bytes if you want some nice formatting:
ＥΦ…·ＮＮ⁼Σι⊗Σ÷ιφ﹪%06dι

Try it online! Link is to verbose version of code. Explanation:
    ＮＮ                  Input the range endpoints
  …·                    Inclusive range
 Φ                      Filter
        ι               Current value
       Σ                Sum of digits
            ι           Current value
             φ          Predefined variable 1000
           ÷            Integer divide
          Σ             Sum of digits
         ⊗              Doubled
      ⁼                 Equals
Ｅ                       Map over results
                   ι    Current value
               %06d     Literal string
              ﹪         Format value
                        Implicitly print each result on its own line

Perl 5 + -pl -MList::Util+(sum), 49 bytes
@F=/./g,$\+=sum@F[5,4,3]==sum@F[2,1,0]for$_..<>}{

Try it online!

Perl 5 + -nl -MList::Util+(sum) -M5.010, 50 bytes
To output each ticket instead is +1 byte:
@F=/./g,sum@F[5,4,3]-sum(@F[2,1,0])||say for$_..<>

Try it online!

Kotlin, 152 119 bytes
{a:Int,b:Int->(a..b).map{String.format("%06d",it)}.filter{it[0].toInt()+it[1].toInt()+it[2].toInt()==it[3].toInt()+it[4].toInt()+it[5].toInt()}.count()}

Try it online!
Taking two integers than convert it into six symbol strings and count.
Optimized it thanks to mazzy and his solution to 119 bytes.
{a:Int,b:Int->(a..b).count{val d="%06d".format(it);(d[0]-'0')+(d[1]-'0')+(d[2]-'0')==(d[3]-'0')+(d[4]-'0')+(d[5]-'0')}}

Try it online!

You can compact it until 133 bytes {a:Int,b:Int->(a..b).map{"%06d".format(it)}.filter{(it[0]-'0')+(it[1]-'0')+(it[2]-'0')==(it[3]-'0')+(it[4]-'0')+(it[5]-'0')}.count()}

Pascal (FPC), 163 153 bytes
var a,b:Int32;begin read(a,b);for a:=a to b do if a div$186A0+a div$2710mod$A+a div$3E8mod$A=a div$64mod$A+a div$Amod$A+a mod$Athen b:=b+1;write(b-a)end.

Try it online!
Explanation
Here is some normal-looking code first:
var a,b,i,s,c,d:Int32;
begin
  read(a,b);
  s:=0;
  for i:=a to b do begin
    c:=i div 1000;
    d:=i mod 1000;
    if c div 100+(c div 10) mod 10+c mod 10=d div 100+(d div 10) mod 10+d mod 10 then begin s:=s+1; {writeln(i)} end;
  end;
  write('There are ',s,' numbers');
end.

Try it online!
Then I abused the behaviour of the for loop:

the loop values are set beforehand (from a to b), so a can be reused as the loop variable, dropping i;
at the end of the for loop, loop variable is left at the final value (value of b before the loop). I used b as a container, incrementing it when a lucky number is found and at the end of the loop b is away from its old value by amount of lucky numbers, so b-a gives the correct result. This dropped s.

Replacing d with operations directly on a shortens the loop. Replacing c with operations directly on a dose not shorten the loop, but, after dropping d, loop's begin and end are unnecessary and I ended with using only 2 variables :)
$ starts hexadecimal constants in the golfed code. While they do not save bytes, they eliminate spaces needed before decimal constants.

Java (OpenJDK 8), 162 bytes
... borrows from the Kotlin example above.
import java.util.stream.IntStream;

(a,b)->IntStream.range(a,b+1).mapToObj(i->String.format("%06d",i).getBytes()).filter(c->c[0]+c[1]+c[2]==c[3]+c[4]+c[5]).count();

Try it online!
Comparing the sum of the String's bytes is just as good as summing up the actual digits.

You can save a byte by currying (a->b->), but you'll need to fully qualify IntStream since it's not in java.lang.

Welcome to PPCG! As @Jakob mentioned, imports are part of the byte-count, so you'll have to add the java.util.stream. in front of the IntStream to your code and byte-count. As also mentioned by Jakob, you can save a byte by using a->b->, and you can also save some additional bytes by changing String.format to "".format. Try it online: 139 bytes. Nice first answer, though. +1 from me. Enjoy your stay!

MATL, 24 bytes
&:1e3&\,!'%03d'&V2&sw]=s

Try it online!
(-2 bytes thanks to Luis Mendo.)
&: - Make an inclusive range between the two given numbers
1e3&\ - 'divrem' - divide by 1000 and get the reminders and floored quotients in two arrays.
, - do twice
!'03d'&V - transpose and convert each value to a zero-padded three-width string
&s - sum each row's values
w - switch to bring the reminder array out and do this again on that
] - end loop
= - check for equality (returns 1s in places where the arrays are equal)
s - sum those to get the count (implicit output)

dc, 44 bytes
sb[d]sD[dA00~[rA~rA~++rx]dx=D1+dlb!<L]dsLxkz

Takes two arguments from an otherwise empty stack, outputs to top of stack.
Try it online!
The clever bit here is the use of an unnamed (i.e., unstored) macro that's duplicated before execution in order to run a copy of itself on the other three-digit part.
Explanation
The inner macro [rA~rA~++rx] has the effect "calculate the digit sum of the three digit number that is second-to-top on the stack, then execute the original top of the stack as a macro".
Main program:
sb             Saves the upper bound as b so we'll know when to quit
[d]sD          Defines the macro D, which contextually is "increment stack depth"
[              Start the main loop - the next number to test is on top
  d              Make a copy to increment later for loop purposes
  A00            The literal "1000"
  ~              Quotient and remainder, so "123456" is now "123 456"
  [rA~rA~++rx]d  Stack is now "123 456 M M", where M is the anonymous macro
  x              Run M on the stack "123 456 M", which (see definition
                 above) ends up running M on the stack "123 15", which
                 leaves "15 6" (and executes the 6, which is a no-op)
  =D             If the two sums were equal, increment the stack depth
  1+             Increment the current test number
  dlb!<L         Loop unless the test number is now larger than b
]dsLx          Name and start the loop
kz             Current depth is 1+answer, so throw away top and return

Python 3, 89 86 bytes
-2 thanks to Mr. Xcoder.
-3 inspiring from Asone Tuhid answer's.
lambda a,b:sum(sum(map(int,str(i)))==2*sum(map(int,str(i)[-3:]))for i in range(a,b+1))

Tests results :
Example 1 :
a = 0
b = 1
Lucky numbers : 1

Example 2 :
a = 100000
b = 200000
Lucky numbers : 5280

Example 3 :
a = 123456
b = 654321
Lucky numbers : 31607

Example 3 :
a = 0
b = 999999
Lucky numbers : 55252

Try it online!

In the counting version, sum can make any generator so the brackets [...]  are not needed

range(a,b+1) spec now states "inclusive" (if it were not you could use *r in place of a,b by the way - see my Python 2 answer). Also note that the spec now confirms it should indeed be the count that is output.

PHP, 131 bytes
<?$f='array_sum(str_split(str_split(sprintf("%06d",$i),3)[';for($i=$argv[1]-1;$i++<$argv[2];)eval("\$a+=$f 0]))==$f 1]));");echo$a;

To run it:
php -n <filename> <from> <to>

Example:
php -n lucky_tickets.php 100 100000

Or Try it online!

Jelly,  9  8 bytes
-1 thanks to Dennis (rµ...E)S -> r...E€S since everything vectorises.)
rdȷD§E€S

A dyadic Link accepting the two endpoints of the range (either way around) which yields the count of lucky tickets.
Try it online! Or see a test-suite
How?
Note that for any non-negative integer less than \$1000000\$, \$N\$, we can get two numbers with digits that sum to the required values to check using integer division by \$1000\$
(yielding, say, \$X=\lfloor\frac{N}{1000}\rfloor\$)
and its remainder
(say \$Y=N\mod{1000}\$)
...that is, \$N=1000\times X+Y\$
Now we want to compare the sums of the digits of \$X\$ and \$Y\$ for each \$N\$ in a range and count those that are equal.
rdȷD§E€S - Link: integer a; integer b
r        - inclusive range [a,b] (either [a,a+1,a+2,...,b] or [a,a-1,a-2,...,b])
         -                              e.g.: 0       or 78        or 7241
  ȷ      - literal 1000
 d       - divmod (vectorises)                [0,0]      [0,78]       [7,241]
   D     - to decimal lists (vectorises)      [[0],[0]]  [[0],[7,8]]  [[7],[2,4,1]]
    §    - sum each (vectorises)              [0,0]      [0,15]       [7,7]
     E€  - for €ach: all equal?               1          0            1
       S - sum (counts the 1s in the resulting list)

E€S saves the µ.

@Dennis ah yes, I was working from another solution which did not vectorise everything along the way!

Powershell, 85 bytes
($args[0]..$args[1]|%{'{0:D6}'-f$_}|?{+$_[0]+$_[1]+$_[2]-eq+$_[3]+$_[4]+$_[5]}).count

Test script:
$f = {

($args[0]..$args[1]|%{'{0:D6}'-f$_}|?{+$_[0]+$_[1]+$_[2]-eq+$_[3]+$_[4]+$_[5]}).count

}

@(
    ,((0,1), 1)
    ,((1000,2000), 3)
    ,((2000,3000), 6)
    ,((10000, 20000), 282)
    ,((101000, 102000), 6)
    ,((201000, 202000), 10)
    ,((901000, 902000), 63)
    ,((100000, 200000), 5280)
    ,((123456, 654321), 31607)
    #,((0, 999999), 55252)
) | % {
    $c, $e = $_
    "      $c"
    $r = &$f $c[0] $c[1]
    "$($e-eq$r): actual=$r expected=$e"
}

Output:
      0 1
True: actual=1 expected=1
      1000 2000
True: actual=3 expected=3
      2000 3000
True: actual=6 expected=6
      10000 20000
True: actual=282 expected=282
      101000 102000
True: actual=6 expected=6
      201000 202000
True: actual=10 expected=10
      901000 902000
True: actual=63 expected=63
      100000 200000
True: actual=5280 expected=5280
      123456 654321
True: actual=31607 expected=31607

Powershell? I really didn't see that one coming :D

Kotlin, 95 bytes
{a:Int,b:Int->(a..b).count{val d="%06d".format(it);d.chars().sum()==2*d.take(3).chars().sum()}}

.kt for test:
var  f = {a:Int,b:Int->(a..b).count{val d="%06d".format(it);d.chars().sum()==2*d.take(3).chars().sum()}}

fun main(args: Array<String>) {
    println(f(0,1))             // 1
    println(f(1000,2000))       // 3
    println(f(2000,3000))       // 6
    println(f(101000, 102000))  // 6
    println(f(201000, 202000))  // 10
    println(f(901000, 902000))  // 63
    println(f(10000, 20000))    // 282
    println(f(100000, 200000))  // 5280
    println(f(123456, 654321))  // 31607
    println(f(0, 999999))       // 55252
}

Explanation
Count numbers from range where sum of all number digits is equal to double sum of first 3 digits.

Perl 6, 51 49 bytes
{+grep {[==] .flip.comb[^3,3..*]>>.sum},$^a..$^b}

Try it online!
Anonymous code block that takes a two numbers and returns the number of lucky ones. Times out for larger inputs

Stax, 14 bytes
ît║l`Yµß╖vYü╢^

Run and debug it, but be patient!

Python 2,  83  80 bytes
-3 by using Asone Tuhid's observation - go give credit!
lambda a,b:sum(sum(map(int,`v/1000`))*2==sum(map(int,`v`))for v in range(a,b+1))

Try it online!
Much like my Jelly answer (but the inputs must be sorted here i.e. a<=b)

75 bytes for input a, b+1 (i.e. range excludes the right bound):
lambda*r:sum(sum(map(int,`v/1000`))*2==sum(map(int,`v`))for v in range(*r))

Try this one

Clojure, 102 bytes
#(count(for[i(range %(inc %2)):when(=(let[d(map int(format"%06d"i))](apply +(map -(drop 3 d)d)))0)]i))

Mixing strings and math isn't too fun.

Java 8, 101 99 bytes
u->l->{int n=0,d=10;for(;l<=u;)if(l++%d+l/d%d+l/100%d==l/1000%d+l/10000%d+l/100000%d)++n;return n;}

A different approach than the other Java answer. Instead of using streams and Strings, this uses a loop and evaluates the numbers directly. Try it online here.
Thanks to ceilingcat for golfing two bytes.
Ungolfed:
u -> l -> { // lambda taking two integer arguments in currying syntax and returning an integer
    int n = 0, // the counter
        d = 10; // auxiliary constant, we will be using the number 10 rather a lot
    for(; l <=u ; ) // loop over all ticket numbers in the range
        if(l++ %d + l/d %d + l/100 %d // if the digit sum of the second half of the number ...
           == l/1000 %d + l/10000 %d + l/100000 %d) // ... is the same as the digit sum of the first half ...
            ++n; // ... it's a lucky ticket, add 1 to the counter
    return n; // return the count
}

C (gcc), 90 88 bytes
l=10;u(c,k,y){for(y=0;c<=k;)c++%l+c/l%l+c/100%l-c/1000%l-c/10000%l-c/100000%l?:++y;c=y;}

Port of my Java answer. Try it online here. Thanks to ceilingcat for golfing two bytes.
Ungolfed:
l=10; // constant, we will be using the number 10 rather a lot
u(c, k, // function returning an integer and taking two integer arguments: lower and upper bound
  y) { // abusing the argument list to declare a variable of type integer: the number of lucky tickets found in the range
    for(y = 0; c <= k; ) // set count to 0 and loop through the range
        c++ %l + c/l %l + c/100 %l // if the digit sum of the second half of the ticket number ...
        - c/1000 %l - c/10000 %l - c/100000 %l // ... is the same as the digit sum of the first half ...
        ?: ++y; // ... it's a lucky ticket: increment the count
    c = y; // return the count
}

Suggest L'✐' instead of 10000 and assign 10 to a variable.

@ceilingcat I like that it gives me an extra variable name, but I couldn't save any bytes by assigning 10: https://bit.ly/2O5ND2Y As for the L'…' trick, that's neat; but does it save bytes? Seems to me that is a multi-byte character, so while saving chars, it can't save bytes … or can it?

@ceilingcat My mistake, two bytes can be saved by assigning 10 to a variable. Thank you.

J, 35 bytes
[:+/(6#10)([:=/_3+/\])@#:[+i.@>:@-~

Try it online!

VBA (Excel), 159 bytes
Using Immediate Window and Cells [A1] [A2] as input.
c=[A1]-[A2]:d=IIf(c<0,[A1],[A2]):For x=d To d+Abs(c):e=String(6-Len(x),"0")&x:For y=1To 3:i=i+Mid(e,y,1):j=j+Mid(e,7-y,1):Next:z=IIf(i=j,z+1,z):i=0:j=0:Next:?z

F#, 110 bytes
let t=string>>Seq.sumBy(int>>(-)48)
let r s e=Seq.where(fun n->t(n/1000)=t(n-(n/1000)*1000)){s..e}|>Seq.length

Try it online!
t converts the string into numbers and sums them up. r takes the range of numbers from s to e, and filters out the numbers that are unlucky. The first three digits are collected by n/1000. The second three digits are computed by n-(n/1000)*1000.