text:
Determine Tic-Tac-Toe winner (round based)
Let's play some code-golf!
The challenge is to find the winner of a game of Tic-Tac-Toe.
This has been done many times by giving a board that has one clear winner but here is the twist:
The cells are numbered like this:
1|2|3
-+-+-
4|5|6
-+-+-
7|8|9

You get an array of exactly 9 moves like that:
{3, 5, 6, 7, 9, 8, 1, 2, 3}

This is parsed as follows:

Player 1 marks cell 3
Player 2 marks cell 5
Player 1 marks cell 6
Player 2 marks cell 7
Player 1 marks cell 9
Player 1 has won

Note: The game does not stop after one player has won, it may happen that the losing player manages to get three in a row after the winning player, but only the first win counts.
Your job is now to get 9 numbers as input and output the winning player and the round in which the win occured.
If no one wins, output something constant of your choice. You can receive input and provide output through any standard mean / format.
Have fun!
Some more examples as requested:
{2,3,4,5,6,7,1,8,9} => Player 2 wins in round 6
{1,2,4,5,6,7,3,8,9} => Player 2 wins in round 8
{1,2,3,5,4,7,6,8,9} => Player 2 wins in round 8

Welcome to PPCG! This is a nice first post, but usually we do not like very restrictive input / output formats. Would you consider removing the "Player X wins in round Y" and let us output in any reasonable format, like a list [X, Y]? In case of a tie, can we output any other consistent value instead? I recommend so, because printing those exact strings aren't really part of golfing. For future challenge ideas, I recommend using the sandbox. :-)

Sorry, my bad. I think it is correct now.

Read the challenge to the end, I say that there may be a draw and that you can output something of your choice when it happens. I return {2,6} when player 2 wins in round 6 and {0,0} when no one wins.

Can we use 0-indexed everything? (cells, players, rounds)

"You get an array of exactly 9 moves like that: {3, 5, 6, 7, 9, 8, 1, 2, 3}" - should 3 really appear twice?

@JonathanAllan I think it's a typo, maybe they meant to type 4 instead (not editing though).

Retina, 114 bytes
(.)(.)
$1O$2X
^
123;;456;;789¶X
{`(.)(.*¶)(.)\1
$3$2
}`.*(.)(.)*\1(?<-2>.)*(?(2)(?!))\1.*¶(..)*
$1$#3
.*¶
T
T`d`Rd

Try it online! Based on my answer to Tic-Tac-Toe - X or O?. Outputs X<N> if the first player wins after N turns, O<N> if the second player wins, T if neither wins. Explanation:
(.)(.)
$1O$2X
^
123;;456;;789¶X

Creates an internal board, and also marks each move with the player whose move it is.
{`(.)(.*¶)(.)\1
$3$2

Applies a move.
}`.*(.)(.)*\1(?<-2>.)*(?(2)(?!))\1.*¶(..)*
$1$#3

Searches for a win, and if one is found, then replace the board with the winner and the number of remaining moves.
.*¶
T

If the moves are exhausted and nobody has won then the game is a tie.
T`d`Rd

Calculate the number of the round from the number of remaining moves.

This is one of the more.... voluptuous answers I've seen here.

MATL, 39 bytes
3:g&+XIx"IX@oXK@(XIt!yXdyPXd&hK=Aa?KX@.

Output is

1 and R, in separate lines, if user 1 wins in round R;
0 and R, in separate lines, if user 2 wins in round R;
empty if no one wins.

Try it online! Or verify all test cases.
Explanation
3:       % Push [1 2 3]
g        % Convert to logical. Gives [true true true]
&+       % Matrix of all pairs of additions. Gives a 3×3 matrix, which represents
         % the board in its initial state, namely all cells contain 2. This value
         % means "cell not used yet". 1 will represent "cell marked by user 1",
         % and 0 will represent "cell marked by user 2"
XI       % Copy into clipboard I
x        % Delete
"        % Implicit input: array with moves. For each move
  I      %   Push current board state
  X@     %   Push iteration index (starting at 1), that is, current round number
  o      %   Modulo 2: gives 1 or 0. This represents the current user
  XK     %   Copy into clipboard K
  @      %   Push current move ((that is, cell index)
  (      %   Write user identifier (1 or 0) into that cell. Cells are indexed
         %   linearly in column-major order. So the board is transposed compared
         %   to that in the challenge, but that is unimportant
  XI     %   Copy updated board into clipboard I
  t!     %   Duplicate and transpose
  y      %   Duplicate from below: push copy of board
  Xd     %   Extract main diagonal as a 3×1 vector
  y      %   Duplicate from below: push copy of transposed board
  PXd    %   Flip vertically and extract main diagonal. This is the anti-diagonal
         %   of the board
  &h     %   Concatenate stack horizontally. This concatenates the board (3×3),
         %   transposed board (3×3), main diagonal (3×1 vector) and anti-diagonal
         %   (3×1) into an 3×8 matrix
  K=     %   Push current user identifier. Test for equality with each entry of the
         %   3×8 matrix
  A      %   For each column, this gives true if all its entries are true. Note
         %   that the first three columns in the 3×8 matrix are the board columns;
         %   the next three are the board rows; and the last two columns are the
         %   main diagonal and anti-diagonal. The result is a 1×8 vector
  a      %   True if any entry is true, meaning the current user has won
  ?      %   If true
    K    %     Push current user identifier
    X@   %     Push current round number
    .    %     Break for loop
         %   Implicit end
         % Implicit end
         % Implicit display

Javascript (ES6), 130 bytes
m=>m.reduce((l,n,i)=>l||(b[n-1]=p=i%2+1,"012,345,678,036,147,258,048,246".replace(/\d/g,m=>b[m]).match(""+p+p+p)&&[p,i+1]),0,b=[])

f=m=>m.reduce((l,n,i)=>l||(b[n-1]=p=i%2+1,"012,345,678,036,147,258,048,246".replace(/\d/g,m=>b[m]).match(""+p+p+p)&&[p,i+1]),0,b=[])
console.log(JSON.stringify(f([3,5,6,7,9,8,1,2,3])))
console.log(JSON.stringify(f([2,3,4,5,6,7,1,8,9])))
console.log(JSON.stringify(f([1,2,4,5,6,7,3,8,9])))
console.log(JSON.stringify(f([1,2,3,5,4,7,6,8,9])))

Explanation
m=>m.reduce((l,n,i)=>               // Reduce the input array with n as the current move
  l||(                              //  If there is already a winner, return it
  b[n-1]=p=i%2+1,                   //  Set the cell at b[n-1] to the current player p
  "012,345,678,036,147,258,048,246" //  For every digit in the list of possible rows:
    .replace(/\d/g,m=>b[m])         //   Replace it with the player at the cell
    .match(""+p+p+p)                //  If any of the rows is filled with p:
      &&[p,i+1]                     //   Return [p, current move]
),0,b=[])

Would you mind providing an explanation or an ungolfed version please? I'm interested in understanding your solution.

Java (OpenJDK 8), 445 bytes
int[] t(int[]m){int[][]f=new int[3][3];boolean z=false;for(int i=0;i<9;i++){f[m[i]%3][m[i]/3]=z?2:1;if(f[m[i]%3][0]==(z?2:1)&&f[m[i]%3][1]==(z?2:1)&&f[m[i]%3][2]==(z?2:1)||f[0][m[i]/3]==(z?2:1)&&f[1][m[i]/3]==(z?2:1)&&f[2][m[i]/3]==(z?2:1)||m[i]%3+m[i]/3==2&&f[0][2]==(z?2:1)&&f[1][1]==(z?2:1)&&f[2][0]==(z?2:1)||m[i]%3==m[i]/3&&f[0][0]==(z?2:1)&&f[1][1]==(z?2:1)&&f[2][2]==(z?2:1)){return(new int[]{(z?2:1),++i});}z=!z;}return(new int[]{0,0});}

Try it online!
Return value {1,8} means that player 1 won in round 8.
Return value {0,0} means draw.

Unless you remove all the unnecessary spacing, this answer is considered invalid due to the lack of golfing effort. Moreover, it is not really recommended to answer your own challenge that fast, and you might want to add a TIO link such that we can test your code.

Reference links: Serious contender, compete in your own challenge

I am sorry, I copied the wrong thing. It is in fact way shorter

You can see the tips for golfing in Java question to remove some bytes. For example false can be replaced by 1<0, and the space after the first ] can be removed.

442 bytes. Also the reason why the "Header" and "Footer" section exists on TIO is that you don't need to comment //Code that was submitted and //End of code.

372 bytes.

@HermanLauenstein Your code seems to give the incorrect result (2 8 instead of 2 6), although I don't know where the error is. For now here is an alternative of 302 bytes.

Kotlin, 236 bytes
i.foldIndexed(l()to l()){o,(a,b),p->fun f(i:(Int)->Int)=b.groupBy(i).any{(_,v)->v.size>2}
if(f{(it-1)/3}|| f{it%3}|| listOf(l(1,5,9),l(3,5,7)).any{b.containsAll(it)}){return p%2+1 to o}
b to a+p}.let{null}
fun l(vararg l:Int)=l.toList()

Beautified
    i.foldIndexed(l() to l()) { o, (a, b), p ->
        fun f(i: (Int) -> Int) = b.groupBy(i).any { (_, v) -> v.size > 2 }
        if (f { (it - 1) / 3 } || f { it % 3 } || listOf(l(1, 5, 9), l(3, 5, 7)).any { b.containsAll(it) }) {
            return p % 2 + 1 to o
        }
        b to a + p
    }.let { null }
fun l(vararg l:Int)= l.toList()

Test
fun f(i: List<Int>): Pair<Int, Int>? =
i.foldIndexed(l()to l()){o,(a,b),p->fun f(i:(Int)->Int)=b.groupBy(i).any{(_,v)->v.size>2}
if(f{(it-1)/3}|| f{it%3}|| listOf(l(1,5,9),l(3,5,7)).any{b.containsAll(it)}){return p%2+1 to o}
b to a+p}.let{null}
fun l(vararg l:Int)=l.toList()

data class Test(val moves: List<Int>, val winner: Int, val move: Int)

val tests = listOf(
        Test(listOf(3, 5, 6, 7, 9, 8, 1, 2, 3), 1, 5),
        Test(listOf(2, 3, 4, 5, 6, 7, 1, 8, 9), 2, 6),
        Test(listOf(1, 2, 4, 5, 6, 7, 3, 8, 9), 2, 8),
        Test(listOf(1, 2, 3, 5, 4, 7, 6, 8, 9), 2, 8)
)

fun main(args: Array<String>) {
    tests.forEach { (input, winner, move) ->
        val result = f(input)
        if (result != winner to move) {
            throw AssertionError("$input ${winner to move} $result")
        }
    }
}

TIO
TryItOnline

Python 2, 170 bytes
q=map(input().index,range(1,10))
z=zip(*[iter(q)]*3)
o='',
for l in[q[2:7:2],q[::4]]+z+zip(*z):
 r=[n%2for n in l];y=all(r)*2+1-any(r)
 if y:o+=[max(l)+1,y],
print min(o)

Try it online! or Try all test cases
#swap cell number / turn
q=map(input().index,range(1,10))
#split in 3 parts (rows)
z=zip(*[iter(q)]*3)
#starting value for the list with the results
#since string are "greater" than lists, this will
#be the output value when there is a draw
o='',
#iterate over diagonals, rows and columns
for l in[q[2:7:2],q[::4]]+z+zip(*z):
 #use %2 to separate between player 1 and 2
 r=[n%2 for n in l]
 #store in y the value of the player if the trio is a valid win, 0 otherwise
 #it's a win if all moves are from the same player
 y=all(r)*2+1-any(r)
 #if y has a valid player, add the highest turn of the trio, and the player to o
 if y:o+=[max(l)+1,y],
#output the smaller turn of the valid winning trios
print min(o)

Jelly, 38 bytes
;⁵s2ZṬḤ2¦SṖs3µ,ṚJị"$€;;ZEÐfṀḢµ$ƤµTḢ,ị¥

Try it online!
Player 1 win: [round, 1]
Player 2 win: [round, 2]
Tie: [0, 0]

Python 3.6+, 137 bytes
n=m=c=z=0
for a in input():m+=1<<~-int(a);c+=1;z=z or f'{c&1}:{c}'*any(m&t==t for t in[7,56,448,73,146,292,273,84]);n,m=m,n
print(z or-1)

Output format is winner number:round or -1 for a tie. Player 2 is 0 Player 1 is 1. Input in the form of a undeliminated string of 1-indexed square numbers.

Jelly, 35 bytes
9s3,ZU$$;ŒD$€Ẏf€⁸L€3e
s2ZÇƤ€ZFTḢ;Ḃ$

A monadic link taking a list of the moves and returning a list, [move, player] where the players are identified as 1 (first to act) and 0 (second to act).
Try it online!
How?
9s3,ZU$$;ŒD$€Ẏf€⁸L€3e - Link 1: any winning play?: list of player's moves:
9s3                   - (range of) nine split into threes = [[1,2,3],[4,5,6],[7,8,9]]
       $              - last two links as a monad:
      $               -   last two links as a monad:
    Z                 -     transpose = [[1,4,7],[2,5,8],[3,6,9]]
     U                -     upend     = [[7,4,1],[8,5,2],[9,6,3]]
   ,                  -  pair = [[[1,2,3],[4,5,6],[7,8,9]],[[7,4,1],[8,5,2],[9,6,3]]]
           $€         - last two links as a monad for €ach:
         ŒD           -   diagonals = [[1,5,9],[2,6],[3],[7],[4,8]] or [[7,5,3],[4,2],[1],[9],[8,6]]
        ;             -  concatenate = [[1,2,3],[4,5,6],[7,8,9],[1,5,9],[2,6],[3],[7],[4,8]] or [[7,4,1],[8,5,2],[9,6,3],[7,5,3],[4,2],[1],[9],[8,6]]
             Ẏ        - tighten = [[1,2,3],[4,5,6],[7,8,9],[1,5,9],[2,6],[3],[7],[4,8],[7,4,1],[8,5,2],[9,6,3],[7,5,3],[4,2],[1],[9],[8,6]]
                      -    i.e.:    row1    row2    row3    diag\   x     x   x   x     col1    col2    col3    diag/   x     x   x   x
                      -    where x's are not long enough to matter for the rest...
                ⁸     - chain's left argument, list of player's moves
              f€      - filter to keep those moves for €ach of those lists to the left
                 L€   - length of €ach result
                   3e - 3 exists in that? (i.e. were any length 3 when filtered down to only moves made?)

s2ZÇƤ€ZFTḢ;Ḃ$ - Main link: list of the moves  e.g. [2,3,4,5,6,7,1,8,9]
s2            - split into twos                    [[2,3],[4,5],[6,7],[1,8],[9]]
  Z           - transpose                          [[2,4,6,1,9],[3,5,7,8]]
    Ƥ€        - for Ƥrefixes of €ach:
   Ç          -   call last link (1) as a monad     [0,0,0,0,0] [0,0,1,1]
      Z       - transpose                          [[0,0],[0,0],[0,1],[0,1],[0]]
       F      - flatten                            [0,0,0,0,0,1,0,1,0]
        T     - truthy indices                     [          6   8  ]
         Ḣ    - head (if empty yields 0)           6
            $ - last two links as a monad:
           Ḃ  -   modulo by 2 (evens are player 2) 0
          ;   -   concatenate                      [6,0]

Clean, 244 ... 220 bytes
import StdEnv
f[a,b]i#k= \l=or[and[isMember(c+n)(take i l)\\c<-:"123147159357"%(j,j+2)]\\j<-[0,3..9]&h<-:"\0\0",n<-[h-h,h,h+h]]
|k a=(1,i*2-1)|i>4=(0,0)|k b=(2,i*2)=f[a,b](i+1)
@l=f(map(map((!!)l))[[0,2..8],[1,3..7]])1

Try it online!
The string iterated into h contains nonprintables, and is equivalent to "\003\001\000\000".

Python 2, 140 136 134 bytes
lambda a,i=0:i<9and(any(set(a[i%2:i+1:2])>=set(map(int,t))for t in'123 456 789 147 258 369 159 357'.split())and(i%2+1,i+1)or f(a,i+1))

Try it online!
EDIT: 4 bytes + 2 bytes thx to Eric the Outgolfer.
Outputs a tuple (playerNumber, roundNumber) or False if there is no winner.

134 bytes

@Erik - Yah, I should have done that already; but I'm fighting the flu and my eyes were hurting :). Thx!

Well, get well soon. :)

Python 2, 168 bytes
import itertools as z
f=lambda g:next(([i%2+1,i+1]for i in range(9) if any(c for c in z.combinations([[0,6,1,8,7,5,3,2,9,4][j]for j in g[i%2:i+1:2]],3)if sum(c)==15)),0)

Outputs (player,round) or 0 for a tie.
Maps the game onto a 3-by-3 magic square and looks for sets of 3 Os or Xs that sum to 15.

source: Stack Exchange

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

sort: votes


text:
Compare two numbers given as strings
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have "0001 " from one database and " 1  " from the other one.
I solved the problem in C# with the following code:

 Func<string, string, bool> f = (a,b) => int.Parse(a.Trim()) == int.Parse(b.Trim())

The challenge
This is a really simple challenge, suitable for beginners and any kind of esoteric languages. Given two numbers as strings that may come with leading zeroes and/or leading/trailing spaces, write the shortest code that checks if the two strings represent the same number.

The inputs need to be two strings or the equivalent in your language (a char array is OK), and they will always represent integer values greater than zero.
The output must be any two consistent values that represent a truthy value and a falsey value.

Examples
A          B          Result
----------------------------
"0001"     "1    "    true
"1450"     "1450 "    true
"0010001 " " 10001  " true
"0010000"  "  10  "   false
"101023"   "101024"   false

This is code-golf, so may the shortest code for each language win!

...

As least it isn't inspired by your kids this time...

@cairdcoinheringaahing my own work is my second source of inspiration. I know this is a very simple challenge, but I think these easy challenges are also needed sometimes. I'll try to come up with something more difficult next time.

By the way, it seems that my work-inspired challenges are either too easy or too hard...

@JonathanAllan no, each input string will represent only one number. There won't be any spaces inbetween the strings.

Related sub-problem: Test if two numbers are equal: just the compare part, with the inputs already as a numeric type.  (Too trivial for codegolf in most languages; only a few languages like Brainfuck have interesting answers).

In your C# solution, is Trim() necessary? As far as I can tell, int.Parse can handle white space.

@Ayb4btu no, it's most probably not needed, but I wrote the code like that on purpose so that people could golf my C# answer.

Another task: guess the DBs. I call SAP to be one of them.

ah ok @charlie, I just wrote that shorter c# solution before reading these comments

Javascript, 11 bytes
a=>b=>+a==b

Abusing Javascript's casting rules a bit; +a coerces a into a numeric type.
-6 bytes thanks to Shaggy and Martin Ender♦
Also a cool take by LiefdeWen:
a=>b=>~~a==~~b

Welcome to PPCG. You can do this in 11 bytes using currying and by only converting one of the inputs to an integer: https://tio.run/##y0osSyxOLsosKNHNy09J/Z@cn1ecn5Oql5OfrqHxv8LWrtLWTrvC1rbyv6aGkoKBhRKQAhKa/wE Note as well that, unless a function references itself, you don't need to include the variable assignment in your byte count.

Welcome to PPCG! Unnamed functions are fine so you don't need c=, and currying is also fine so you can use a=>b=>... instead of (a,b)=>. Finally, my JavaScript is a bit rusty, but I think something like !(a-b) would also work?

The same bytes but it looks much cooler is ~~a==~~b

Hey, thanks for the warm welcome and the cool tips!
For some reason I didn't realize that currying could be used to actually save bytes. I'll update the answer in a minute. Thanks again! :)

See the tips for golfing in ES6 (and general JS golfing tips) for more tricks to squeeze bytes out of your solutions.

The cool versiopn is cool but limited in scope, try input '9123456789' and '533522197'. These are string rapresentation of integer values, are well inside the valid range of integers in javascript (but more than 32 bit)

Your text no longer matches the code; there's no subtraction.  You're coercing a to a numeric type with unary +.

You are right, updated.

05AB1E, 1 byte
Q

Try it online!
Explanation
Comparison for equality Q will automatically try to evaluate strings as ints before comparing.

Oh really? And I thought |0+Q was short enough...

Operation Flashpoint scripting language, 33 bytes
f={call format(["%1==%2"]+_this)}

Call with:
hint format["%1\n%2\n%3\n%4\n%5",
    ["0001", "1    "] call f,
    ["1450", "1450 "] call f,
    ["0010001 ", " 10001  "] call f,
    ["0010000", "  10  "] call f,
    ["101023", "101024"] call f]

Output:

Alternative version (41 bytes):
f={{t=call _x;r=t==s;s=t}forEach _this;r}

Still 5 bytes shorter than the more straightforward f={t=_this;call(t select 0)==call(t select 1)}
39 bytes:
f={{t=call _x;r=t==s;s=t}count _this;r}

count (which returns the size of an array) works instead of forEach, because you can give it a "lambda" that is used as a condition to count only the array elements that meet that condition. The "condition" used in this case is not a valid condition, but it doesn't matter here because it doesn't cause an error and the return value of the count is not needed.

I like the variety of situations you take screenshots of your code in.

Taxi, 488 bytes
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Equal's Corner.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:n 1 l 1 l 1 l.Switch to plan "b" if no one is waiting.'1' is waiting at Writer's Depot.[b]'0' is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

Try it online!
Ungolfed:
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Equal's Corner.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner: north 1st left 1st left 1st left.
Switch to plan "b" if no one is waiting.
'1' is waiting at Writer's Depot.
[b]
'0' is waiting at Writer's Depot.
Go to Writer's Depot: north 1st left 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st right 2nd right 1st left.

Taxi is (relatively) well-suited to this challenge because strings are the only input or output type allowed. The Babelfishery is what converts strings to number (and vice versa) and it handles stripping all the spaces and leading zeroes. It will also handle negative numbers if the - is immediately before the first digit. After that, Equal's Corner checks the two values against each other and Writer's Depot provides the output in string format. Output is 1 for truthy and 0 for falsey.

Nice one! Just out of curiosity, why is the debug window showing the message error: The boss couldn't find your taxi in the garage.  You're fired!?

@Charlie Taxi requires you to drive back to the taxi garage when you're done with your route. If you don't bring the car back, you get fired. (You also have to be sure to stop and refuel every now and then or you run out of gas.) In [tag:code-golf] questions that don't disallow output to STDERR, I generally don't worry about getting fired. You can add this to get rid of the error if you don't want to lose your job: Go to Taxi Garage:n 1 r 1 l 1 r.

This answer and its comments are totally surrealistic. I love this community.

@RightLeg My favorite Taxi program I've written took me two weeks and a lot of debugging. You really want a trip, though? Check out Shakespeare.

C (gcc), 27 bytes
f(s,t){s=atoi(s)==atoi(t);}

With -O0 (which is the default setting).
Try it online!
C, 32 bytes
f(s,t){return atoi(s)==atoi(t);}

Try it online!

In the debug window you can see that the types of s and t default to int, but still you can pass strings as parameters? C will always amaze me...

@Charlie In C, strings are arrays of char, and when you pass an array to a function you actually just pass the pointer to the first element of the array. Here, the pointers to the char arrays are implicitly converted to integers when passed to the function, and the integers are converted back to pointers when calling atoi.

which could blow up horribly on a platform where pointers are wider than ints ... just saying, of course it's fine for site standards here :)

If you want to use ridiculous crap like s=foo; instead of return foo; you need to label this as "x86 gcc with optimization disabled", not just "C", because this code doesn't return a value except as an implementation artefact.

@PeterCordes Well, yeah. I'm not a big fan of "returning" this way, either, but you see it on this site a lot (because answers here can have undefined behaviour as long as they work seemingly consistently) and it's always just labeled as C (gcc). I added the x86, but because -O0 is the default for gcc, the "optimizations disabled" doesn't need to be explicitly mentioned.

In the real world, most people who build code with gcc do so with optimization enabled (usually with a CFLAGS= setting in a Makefile that came with the code...).  x86 gcc implies (to me) that the code uses some C extensions that gcc provides, like __builtin_ia32_crc32qi (for the CRC32 instruction), and will work with any gcc options.  i.e. the word GCC means "Gnu Compile Collection", not that it only works with a bare gcc command, and not with any options.  I think the hack is dumb, and we shouldn't let people get away with it without a big ugly warning label to show how hacky it is.

I went looking to see if there were any architectures where s=retval; instead of return retval; actually broke.  It looks like gcc's internal logic (with -O0 only) actually treats the last expression as the return value, maybe the same way that a GNU C statement-expression works.   (But it does require s=). On ARM32, it calculates the == result in r3, and then uses an extra mov r0, r3 to make that the return value!  So it's not an x86-specific hack, it's a gcc -O0 hack that gcc seems to go out of its way to support.

https://godbolt.org/g/44nzQy

For f(s,t), if sizeof(char*) != sizeof(int) this will fail, such as on old Windows with 16 bit integers but 32 bit FAR pointers, and here is an example on more modern architectures.

@KenY-N You're missing the entire point of c code golf. It's about finding those specific hacky edge cases where you can input the minimum amount of code and get the results you want, not providing a portable experience.

J, 4 bytes
=&do

Compare = after & evaluating do. Can also be =&".
Try it online!

Interestingly enough this will work for both negatives as other languages understand them (e.g. -10) and negatives as J understands them (e.g. _10) due to the way monadic - works.

Retina, 11 bytes
.+
$*
D`
¶$

Try it online!
Input is linefeed separated, but the test suite uses comma separation for convenience. Prints 1 for equality and 0 for inequality.
Explanation
.+
$*

Convert each line to unary. This ignores leading zeros and spaces.
D`

Deduplicate: clear the second line if both are the same.
¶$

Check that the string now ends in a linefeed.

Brain-Flak, 22 bytes
(([{}]{})[{(){}}](){})

Try it online!
Saved 4 bytes thanks to Jo King.

22 bytes

Python 3, 25 bytes
lambda a,b:int(a)==int(b)

Try it online!

Triangularity, 17 bytes
..)..
.Ii).
@Ii=.

Try it online!
Triangularity is, for once, competitive!
How it works
Triangularity requires the code to have a triangular distribution of the dots. That is, the length of each row must be equal the number of rows multiplied by 2 and decremented, and each row must have (on each side) a number of dots equal to its position in the program (the bottom row is row 0, the one above it is row 1 and so forth). Keeping this in mind, let's analyse how the code works:
..).. || Push a 0 onto the stack.
.Ii   || Get the 0th input and cast it to an integer.
   ). || Push another 0 onto the stack.
@I    || Increment the ToS => 1. Get the first input.
  i=. || Then cast it to an integer and compare their equality.

APL (Dyalog), 4 bytes
3 bytes saved thanks to @Adám
=/⍎¨

Try it online!

=/⍎¨

Japt, 3 bytes
¥Vn

Try it
Converts the second input to an integer and compares equality with the first.

Alice, 7 bytes
X/n
o@i

Try it online!
Any non-digit separator works. Prints 1 for equality and 0 otherwise.
Explanation
X   XOR, does nothing.
/   Switch to Ordinal mode.
i   Read all input as a string.
/   Switch to Cardinal mode.
X   XOR. Implicitly finds all integers in the string and pushes them separately
    onto the stack. The XOR gives 0 if the values are identical.
n   Logical NOT. Gives 1 for equal inputs and 9 otherwise.
/   Switch to Ordinal.
o   Print the 0 or 1 as a string.
/   Switch to Cardinal.
@   Terminate the program.

jq, 24 characters
map(tonumber)|.[0]==.[1]

The 2 strings are passed as items of an array.
Sample run:
bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010001 ", " 10001  "]'
true

bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010000", "  10  "]'
false

Try it online! (All test cases)

Excel VBA, 27 16 Bytes
-9 Thanks to @Nayrb and @TaylorScott
[C1]=[A1]-[B1]=0

Where you input the values on the Cells with 'string.

Where x and y are the input Strings and z is a Boolean output.
If CInt(x)=CInt(y) Then z=1
Using CInt

Why not: z=x-y=0?

Unfortunately this solution is invalid as it does not take input and rather relies on having predefined values (which has been deemed against the community's rules) and outputing to a variable (which is also against community rules)

As for a valid solution perhaps a vbe immediate window function such as  ?[Int(A1)=Int(B1)] that takes input from the ranges A1 and B1 and outputs to the VBE immediate window

Husk, 3 bytes
¤=r

Try it online!
Explanation
¤    -- combine both arguments of ..
 =   -- .. equality ..
  r  -- .. with read

If you take input as a two-element list, Ër works too.

PowerShell, 20 bytes
param($a,$b)+$a-eq$b

Similar to the JavaScript answer, just longer because PowerShell doesn't have currying. Uses + to cast the first string to integer, and then the -equals automatically casts the second string to integer. Output is True/False.
Try it online!

T-SQL, 35 bytes
Per our standards, data is input via pre-existing table t with varchar fields a and b.
    SELECT IIF(ABS(a)=ABS(b),1,0)FROM t

Returns 1 if they match, 0 if they don't.
A few of SQL's mathematical functions (including ABS, FLOOR and CEILING) will do an implicit conversion to numeric if given string parameters, this is shorter than an explicit CAST(a AS INT) or CONVERT(INT,b), and works in this case since we know the input values are always positive.
IIF is specific to MS SQL 2012 and above, so no guarantee about other implementations.

Jelly, 8 bytes
t€⁶V€€ḌE

Try it online! or see the test suite
35 answers, and no Jelly submission? Takes the argument as a list (["0001", "1    "] for the first example)
How it works
t€⁶V€€ḌE - Main link. Argument: list       e.g.    ["0001", "1    "]
 €       - For €ach element...                     ["0001", "1"]
t        -   trim from both sides...
  ⁶      -   spaces
     €   - For €ach element...
   V€    -   evaluate €ach character               [[0, 0, 0, 1], [1]]
      Ḍ  - Convert from digits                     [1, 1]
       E - Are they equal?                         1

Isn't this surprisingly long for Jelly?

@Charlie V (eval) is evil, meaning that it can't use the same approach as most other submissions

Excel, 8 bytes
=A1-B1=0

Excel does the string to num conversion for us.
(To input as string, prefix values with '.)

Q (Kdb+), 13 bytes
=/["J"$(x;y)]

Explanation
(x;y) : a list of the two inputs.
"J"$ :  casting each input to a long (7j) type from string (10c), which can correctly interpret
           white space and  leading 0s.
=/ : checks equality over elements in a list (each subsequent pair).
As there is only one pair, returns single boolian 0b/1b.

Welcome to PPCG! Usually, a link to an online interpreter/compiler is appreciated, and if not obvious, an explanation as well.

Thanks!
Explanation added there.
I doubt there is an online interpreter for q, I did a quick look and couldn't find one.

I would say that this should be written as a lambda including the curly braces, i.e. {=/["J"$(x;y)]} for 15 bytes... Although for 8 bytes you could have this: (~/)"J"$ if you are just using the REPL and passing the inputs as a list of strings... or {(~/)"J"$x} for 11 as a function.

PowerShell, 19 bytes
$args-join'-eq'|iex

Try it online!
-join the argument array ($args) with the string representation of the comparison operator (-eq) then evaluate the expression with Invoke-Expression (iex).

Interesting. I wonder how you get by without needing to cast to integer, whereas mine breaks if I remove the + since it's doing string equality checking.

@AdmBorkBork because I'm essentially generating PowerShell code and then executing it, and since leading zeroes and leading/trailing spaces don't matter for the interpreter, it "just works". If the 2 numbers are 00009   and 077  then the resultant code is 00009  -eq077 , a perfectly valid piece of code. You're dealing directly with the string at runtime, so you must cast it first so the operation is done on a numeric.

Right, yes, that makes sense. Thanks for the explanation.

R, 28 27 bytes
!diff(as.double(scan(,'')))

Reads numbers as strings, converts them to doubles and checks if their difference is not zero.
Try it online!
−1 byte thanks to Giuseppe

Just "" is sufficient

Haskell, 20 bytes
-11 bytes thanks to Laikoni. -2 bytes thanks to Zgarb.
a#b=0+read a==read b

Try it online!

@Laikoni It's even better to not bind read: a#b=0+read a==read b

Lua, 20 bytes
print(...-arg[2]==0)

Try it online!

Sinclair ZX81/Timex TS1000/1500 BASIC, ~29 tokenized BASIC bytes
New solution thanks to Neil (thanks for the tip).
 1 INPUT A$
 2 INPUT B$
 3 PRINT VAL A$=VAL B$

This solution requires user input, so enter in two strings with white spaces and/or leading zeros, or enter two strings of non-equal numeric value; 0 is false and 1 is true once line three has compared the value of each string entered.
Old solution: Sinclair ZX81/Timex TS1000/1500 BASIC, ~46 tokenized BASIC bytes
 1 LET A$=" 001 "
 2 LET B$="1"
 3 PRINT (VAL A$=VAL B$)

The actual check is done in line three, which is only ~16 tokenized BASIC bytes; so entering each test case pair using direct mode will save ~30 bytes from the listing. Note that this byte count does not include the var stack.

Shouldn't you use INPUT A$ and INPUT B$? Also I don't think you need the ()s.

Yes, I could use that also - I just wanted a proof of concept

Gema, 21 characters
*\n*=@cmpn{*;*;0;1;0}

No boolean in Gema. As the @get-switch{}/@set-switch{} functions use 0 and 1 to represent switch statuses, also used 0 and 1.
The 2 strings are passed on separate input lines.
Sample run:
bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010001\n10001  '
1

bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010000\n  10  '
0

Perl 5, 9 + 1 (-p) = 10 bytes
$_=$_==<>

try it online

Stacked, 8 bytes
[#~\#~=]

Try it online!
Explanation
[#~\#~=]   anonymous function
 #~        eval TOS
   \       swap top two
    #~     eval TOS
      =    push equality of top two

Swift, 80 79 78 bytes
import Foundation;func r(g:[NSString])->Bool{return g[0].intValue==g[1].intValue}

Try it online!

Welcome to the site! As Uriel mentioned, this currently counts as a snippet, rather than a function or full program, as it assumes the input is stored in variables. You should change this to be in accordance to these I/O rules. Also, you can check out these tips for golfing in Swift!

@Uriel Edited my answer.

Attache, 11 bytes
Same@Map&:N

Try it online!
This takes an array of strings, such as V["0001", "1   "]. Simply stated, Map&:N is a function that maps N over its argument, and Same checks that the array contains only equal members. (Fun fact: this function works for more than 2 string arguments.)

AWK, 12 bytes
{$0=$1==$2}1

Try it online!
AWK, 9 bytes
$0=$1==$2

Alternate version: outputs 1 on match, otherwise outputs nothing
Try it online!

Oftentimes nothing is not considered a falsey value. If this is run on mutliline input, it's not possible to tell which lines fail. Just my $0.02. Adding {}1 would print the 0 falsey values.

SNOBOL4 (CSNOBOL4), 42 bytes
	OUTPUT =EQ(EVAL(INPUT),EVAL(INPUT)) 1
END

Try it online!
Outputs 1 for truthy, nothing for falsey. Since  (space) is the concatenation operator in SNOBOL, EVALing a number with leading/trailing spaces yields the number itself, and it also neatly takes care of any leading zeroes. EQ tests for numerical equality, conditionally setting OUTPUT to 1 on Success.

Java 8, 58 51 bytes
7 bytes thanks to Kevin
b->c->new Long(b.trim()).equals(new Long(c.trim()))

Try it online!
Explanation
Trims off spaces, casting to Long removes leading zeros, and then returns boolean value if they are equal or not.

You can save a byte by using currying: b->c-> instead of (b,c)->. In addition, the trailing semi-colon doesn't have to be counted with Java/.NET lambdas. Try it online: 56 bytes

51 bytes by using new Long(...) instead of Long.parseLong(...)

Had to check the docs, cause I did not think equals would work, but it does, Long equals checks value not the object

@dwana Yea, I wish == didn't compare objects or I could have used that and saved a few bytes :P

APL (NARS2000), 7 bytes
=⍥⍎

Well, yes, I do know NARS2000 can't compete over Dyalog here since it uses Unicode, but I thought I'd rather show off ⍥ (called Composition in NARS2000, even though it's actually unrelated to function composition), something Dyalog doesn't have as a built-in and I haven't ever seen used here. In Dyalog, it has to be implemented as {(⍵⍵⍺)⍺⍺⍵⍵ ⍵}. What it does is call the right operand monadic function on both the left and right argument, and then call the left operand dyadic function on the results.
Here, the right operand is ⍎ (Execute, i.e. eval) and the left operand is = (Equal To, i.e. check if its arguments are equal).

Are composition and execute supposed to render as whitespace?

@JohnDvorak um, no? They're not whitespace, the second char is U+2365 APL FUNCTIONAL SYMBOL CIRCLE DIAERESIS and the third is U+234E APL FUNCTIONAL SYMBOL DOWN TACK JOT.

@JohnDvorak Whatever font you're viewing this in may not have symbols for those codepoints.

@Οurous I highly suspect that's the case too, but if you're using well-updated software you shouldn't have any problem viewing such chars.

R, 37 35 bytes
pryr::f(as.double(x)==as.double(y))

There's probably some cleverer way to coerce strings to numerics but I haven't figured it out yet.
Try it online!

as.double is shorter.

><>, 2 + 3 = 5 bytes
=n

Try it online!
Uses the -v flag to pass the values into the program. This automatically converts them to numbers, removing the spaces and leading 0s. It then outputs if the two are equal, and exits with an error as it tries to compare an empty stack.

dc, 9 bytes
[1p]sQ?=Q

Outputs 1 if the numbers are equal, or nothing if unequal. The input numbers are separated by ',', and this gives a warning since data is code in dc. I wasn't sure if space was allowed as delimiter, so I chose one that doesn't stop the program.
Try it online!

Batch, 89 bytes
@call:c %1
@set e=%errorlevel%
@call:c %2
@if %e%==%errorlevel% echo 1
:c
@exit/b%~1

Prints 1 if the two numbers are the same. Explanation: Batch's numeric processing usually uses leading zeros to indicate an octal number, however exit/b always takes a decimal number. The ~ removes any quotes that would be needed to pass leading or trailing spaces in the parameter.

Ruby, 23  bytes
s=->x,y{x.to_i==y.to_i}

Usage: s.call("0123", "123")

Tcl, 45 bytes
proc x a\ b {expr [scan $a %d]==[scan $b %d]}

Try it online!

Failed outgolf proc x L {expr [join [lmap n $L {scan $n %d}] ==]} on https://tio.run/##TcsxCsMwDAXQPaf4iHS323TMDXoD4yG4HlpSxyQpGIzO7koNhWrR5@lrD3NreV0CCm6oseQV7rk8Etz8mjISeuEtTBISTnf2GEfP7XuMqJWMMZZAFjLEqGSHq1GQdYAUtARBHOnftQvx37fg@aL/GgZiwS6/9w2uoI@@4/YB has 50 bytes

Perl 6, 4 bytes
*==*

Test it
The == operator converts to Numeric which ignores leading and trailing whitespace, and leading 0's get ignored just the same. (0o127 is how you write an octal)
The two * are just there to turn it into a lambda that takes two arguments.

Julia 1.0, 26 bytes
~x=parse(Int,x);a%b=~a==~b

Try it online!

Julia 1.0, 30 bytes
a%b=eval(Meta.parse("$a==$b"))

Try it online!
Some meta programming fun, not the shortest solution though

Pyth, 4 bytes
qFsM

Try it online!
Int-parse each element of the input list with sM(Q), then Fold over equality.

Wolfram Language, 27 bytes
ToExpression[#1<>"=="<>#2]&

Test cases:
In[1]:= ToExpression[#1 <> "==" <> #2] &["0001", "1"]
Out[1]= True

In[2]:= ToExpression[#1 <> "==" <> #2] &["1450", "1450 "]
Out[2]= True

In[3]:= ToExpression[#1 <> "==" <> #2] &["0010001", " 10001"]
Out[3]= True

In[4]:= ToExpression[#1 <> "==" <> #2] &["0010000", "  10  "]
Out[4]= False

In[5]:= ToExpression[#1 <> "==" <> #2] &["101023", "101024"]
Out[5]= False

Clean, 52 bytes
import StdEnv
$n=toInt{#c\\c<-n|c>' '}
?n=(==)($n)o$

Try it online!

C++ (gcc), 65 bytes
#include<cstdlib>
auto a(auto b,auto c){return atoi(b)==atoi(c);}

Try it online!
I initially tried used a lambda expression, but auto a=[] is three more characters, and less one more for no trailing semicolon. On the other hand, since atoi is not referenced until the lambda is instantiated, could I delete the #include and put that in the test harness footer instead?

Javascript, 6 bytes
Pretty standard stuff, but using Javascript's auto type casting
!(a-b)

Or if we don't need it as a function (19 bytes)
let f=(a,b)=>!(a-b)

Try it online! https://jsfiddle.net/pgz4ctLy/2/

Welcome to the site! Note that this is quite similar to the existing Javascript answer...

Thanks @charlie, I saw that answer and I didn't believe it met the requirements of "inputs and output" so I posted this answer. Unfortunately being new to the site I wasn't allowed to comment on the other answer so this seemed like the most suitable option and is different enough to stand as it's own.

There's a lot of ways you can post a valid answer, and one of them is writing a lambda expression. So a valid answer (using your code) would be just (a,b)=>-a==-b. If you use currying, you can write a=>b=>-a==-b.

Just to let you know even duplicate answers are fine (although they're rare).

I have edited my post to be a bit more unique and shorter ;)

PHP 5.6+, 16 (42 when callable) bytes
The minimum code that meets the puzzle's requirements (16 bytes):
(int)$a==(int)$b

In callable form (42 bytes):
function f($a,$b){return(int)$a==(int)$b;}

Try it online, with tests
Explanation
Declare a regular function with a single-character name f with two, otherwise undetermined parameters. It returns the result of comparing both arguments after casting each to integers, which safely removed the padding and whitespace.
The code could have been made 2 bytes shorter by converting the function to a closure, but then the closure would not be assigned (which takes another 3 bytes), and therefore not callable.

Welcome to PPCG! All answers need to be full programs or callable functions (although they may be unnamed function expressions). So the first snippet isn't valid, but the second one is fine.

@Xano, PHP's type juggling will implicitly convert "numerical looking" strings to numbers, so all you need to do is use the == operator, as long as one is a number.  A 32 byte solution using type-coercion would be: function($a,$b){return$a==0+$b;} TIO: https://tio.run/##ZY7BisMgEIbP9SmGQTBhhZrd9rLW9rZPsLckBxOUFEoSojmVPnt2TMKysB50nO/7dcZuXC63sRuBe7P4uW/jfegzbiVv8ufk4jz13Bqj3nijX4vm0YUYwEDJDiUqpQqUgAXQwlrSfjgeIU6zS7g4ndWK6VzxX0jRFAeUCFuVlP@GSgIZv9jbR9ieJ/7@QXgtTjuGXag1Y36YnG27DPaxbaAKcngy0h73EIlYCbyhniGkU9@13QAChVwZVljFCjFZ@w3MFcrU8NmWzuEG4pumFvAJ4it9T2msqx41ey0/

Mumps, 7 bytes
W +X=+Y

In Mumps, all data are strings, the '+' operator evaluates the string to a numeric value. There is no implicit output function, so the 'W' (Write) function provides the output.

K (oK), 5 bytes
Solution:
=/.:'

Try it online!
Examples:
=/.:'("0001";"1    ")
1
=/.:'("1450";"1450 ")
1
=/.:'("0010001";" 10001  ")
1
=/.:'("0010000";"  10  ")
0
=/.:'("101023";"101024")
0

Explanation:
Convert each input to an integer, and then check for equality.
=/.:' / the solution
  .:' / value (.:) each ('), converts char list to integer
=/    / equality (=) over (/)

Implicit, 5 bytes
'ì'ì=

Try it online!
'ì'ì=
'      «read string, push to stack                  »;
 ì     «swap type (integer/string) of top of stack  »;
  'ì   «do it again for the second integer string   »;
    =  «compare for equality                        »;

C# (32 bytes)
a=>b=>int.Parse(a)==int.Parse(b)

Try it online
as already mentioned in the comments, you can do it shorter than the C# provided in the question. I wrote this thinking I was clever before reading the reply to the comments by the OP. :)

The whitespace isn't needed at all, and currying can save an additional byte. Try it online!

R, 55 bytes
V<-strtoi(gsub(" ","",c(A,B),fixed=T),base=9)
V[1]==V[2]

This is my first attempt at codegolf; gave it my best try. Suggestions welcome!
Assumptions:

The inputs are given as strings A and B
The integers contained are less than 1888888888. Larger values will cause strtoi() to return NA.

Vyxal, 3 bytes
"⌊≈

Try it Online!
Explained
"⌊≈
"   # pair both inputs into list
 ⌊  # floor
  ≈ # all items equal?

J-uby, 9 bytes
:*&Z|+:==

Attempt This Online!
Explanation
:* & Z |       # Map with to_i (Z), then
         +:==  # Compare

I think this would be 7 bytes with J-uby’s ** operator:
Z**+:==

…but it’s broken or removed in the current version.

nroff, 51 bytes
1 and 0 for truthy and falsey.
Wish type convertion were available.
.nr X \\$1=\\$2 did not work for some input.
.de F
.nr X \\$1
.nr Y \\$2
.nr X \\nX=\\nY
\\nX
..

Attempt This Online!

Thunno 2, 2 bytes
Nạ

Attempt This Online!
The "cast to integer" built-in (N) handles leading/trailing spaces and leading zeros. Then, we can just check equality with ạ.

Stratos, 3 bytes
_=_

Both of the _ take an input as a string and convert it to a number, then negate it.
Java converts the input to a number by removing 0s and spaces.
The = takes the results of this and checks for equality
Try it!

Pyt, 1 byte
=

Explanation
         Implicitly takes two inputs, and casts them to integers/floats if possible.
=        Checks if the two are equal

Try it online!

FALSE, 36 bytes
[0[^$9>][$32>[48-+10*]?]#%10/]$!\!=.

Numbers are received from the console, separated by a tab character.
True=-1, False=0.

Ruby, 21 bytes
Pretty boring.
->a,b{a.to_i==b.to_i}

Attempt This Online!

Factor, 29 bytes
[ [ " "without dec> ] same? ]

Try it online!
Factor's number parser can't handle spaces so I have to remove them first.

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

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


text:
Minimise the count of prime factors through insertion
Given two positive integers A and B, return the position p that minimises the number of prime factors (counting multiplicities) of the resulting integer, when B is inserted in A at p.
For example, given A = 1234 and B = 32, these are the possible insertions (with p being 0-indexed) and the corresponding information about their prime factors:

p | Result | Prime factors         | Ω(N) / Count

0 | 321234 | [2, 3, 37, 1447]      | 4
1 | 132234 | [2, 3, 22039]         | 3
2 | 123234 | [2, 3, 19, 23, 47]    | 5
3 | 123324 | [2, 2, 3, 43, 239]    | 5
4 | 123432 | [2, 2, 2, 3, 37, 139] | 6

You can see that the result has a minimal number of prime factors, 3, when p is 1. So in this particular case, you should output 1.
Specs

If there are multiple positions p that minimise the result, you can choose to output all of them or any one of them.

You may choose 0-indexing or 1-indexing for p, but this choice must be consistent.

A and B can be taken as integers, strings or lists of digits.

You can compete in any programming language and can take input and provide output through any standard method, while taking note that these loopholes are forbidden by default. This is code-golf, so the shortest submission (scored in bytes) wins!

Test cases

A, B -> p (0-indexed) / p (1-indexed)

1234, 32           -> 1 / 2
3456, 3            -> 4 / 5
378, 1824          -> 0 / 1
1824, 378          -> 4 / 5
67, 267            -> Any or all among: [1, 2] / [2, 3]
435, 1             -> Any or all among: [1, 2, 3] / [2, 3, 4]
378100, 1878980901 -> Any or all among: [5, 6] / [6, 7]

For convenience, here is a list of tuples representing each pair of inputs:
[(1234, 32), (3456, 3), (378, 1824), (1824, 378), (67, 267), (435, 1), (378100, 1878980901)]

I get the feeling this is biased towards 05AB1E...

Can we output the resulting number that has minimized prime factors instead of the index of the insertion? e.g. in your first test case 132234 instead of 1.

@dylnan I am going to say no this time.

Husk, 16 bytes
§◄öLpr§·++⁰↑↓oΘŀ

Expects input as strings, try it online!
Explanation
§◄(öLpr§·++⁰↑↓)(Θŀ)  -- input A implicit, B as ⁰ (example "1234" and "32")
§ (           )(  )  -- apply A to the two functions and ..
  (ö          )      --   | "suppose we have an argument N" (eg. 2)
  (    §      )      --   | fork A and ..
  (         ↑ )      --     | take N: "12"
  (          ↓)      --     | drop N: "34"
  (     ·++⁰  )      --   | .. join the result by B: "123234"
  (   r       )      --   | read: 123234
  (  p        )      --   | prime factors: [2,3,19,23,47]
  ( L         )      --   | length: 5
  (öLpr§·++⁰↑↓)      --   : function taking N and returning number of factors
                            in the constructed number
               ( ŀ)  --   | range [1..length A]
               (Θ )  --   | prepend 0
               (Θŀ)  --   : [0,1,2,3,4]
 ◄                   -- .. using the generated function find the min over range

MATL, 25 bytes
sh"2GX@q:&)1GwhhUYfn]v&X<

Inputs are strings in reverse order. Output is 1-based. If there is a tie the lowest position is output.
Try it online! Or verify all test cases.
Explanation
s         % Implicitly input B as a string. Sum (of code points). Gives a number
h         % Implicitly input A as a string. Concatenate. Gives a string of length
          % N+1, where N is the length of A
"         % For each (that is, do N+1 times)
  2G      %   Push second input
  X@      %   Push 1-based iteration index
  q       %   Subtract 1
  :       %   Range from 1 to that. Gives [] in the first iteration, [1] in
          %   the second, ..., [1 2 ... N] in the last
  &)      %   Two-output indexing. Gives a substring with the selected elements,
          %   and then a substring with the remaining elements
  1G      %   Push first input
  whh     %   Swap and concatenate twice. This builds the string with B inserted
          %   in A at position given by the iteration index minus 1
  U       %   Convert to string
  Yf      %   Prime factors
  n       %   Number of elements
]         % End
v         % Concatenate stack vertically
&X<       % 1-based index of minimum. Implicitly display

Pyth, 20 13 11 bytes
.mlPsXbQzhl

Try it online
Explanation
.mlPsXbQzhl
.m    b         Find the minimum value...
         hl     ... over the indices [0, ..., len(first input)]...
  lP            ... of the number of prime factors...
    sX Qz       ... of the second input inserted into the first.

Jelly, 21 bytes
D©L‘Ṭœṗ¥€®żF¥€VÆfL€NM

Try it online!
-1 thanks to Mr. Xcoder.
Returns all possible positions.

Japt, 22 21 bytes
This felt far too long as I was writing it up but, looking at some of the other solutions, it actually seems somewhat competitive. Still, there's probably a bit of room for improvement - The cNq) in particular is annoying me. Explanation to follow.
Takes the first input as a string and the second as either an integer or a string. Result is 0-indexed and will return the first index if there are multiple solutions.
ÊÆiYVÃcNq)®°k Ê
b@e¨X

Try it

Explanation
      :Implicit input of string U and integer V.
Ê     :Get the length of U.
Æ     :Generate an array of the range [0,length) and map over each element returning ...
iYV   :  U with V inserted at index Y.
Ã     :End mapping
c     :Append ...
Nq    :  The array of inputs joined to a string.
®     :Map over the array.
°     :Postfix increment - casts the current element to an integer.
k     :Get the prime divisors.
Ê     :Get the length.
\n    :The newline allows the array above to be assigned to variable U.
b     :Get the first index in U that returns true ...
@     :  when passed through a function that ...
e     :    checks that every element in U...
¨     :    is greater than or equal to...
X     :    the current element.
      : Implicit output of resulting integer.

PowerShell, 228 bytes
param($a,$b)function f($a){for($i=2;$a-gt1){if(!($a%$i)){$i;$a/=$i}else{$i++}}}
$p=@{};,"$b$a"+(0..($x=$a.length-2)|%{-join($a[0..$_++]+$b+$a[$_..($x+1)])})+"$a$b"|%{$p[$i++]=(f $_).count};($p.GetEnumerator()|sort value)[0].Name

Try it online!
(Seems long / golfing suggestions welcome. Also times out on TIO for the last test case, but the algorithm should work for that case without issue.)
PowerShell doesn't have any prime factorization built-ins, so this borrows code from my answer on Prime Factors Buddies. That's the first line's function declaration.
We take input $a,$b and then set $p to be an empty hashtable. Next we take the string $b$a, turn it into a singleton array with the comma-operator ,, and array-concatenate that with stuff. The stuff is a loop through $a, inserting $b at every point, finally array-concatenated with $a$b.
At this point, we have an array of $b inserted at every point in $a. We then send that array through a for loop |%{...}. Each iteration, we insert into our hashtable at position $i++ the .count of how many prime factors f that particular element $_ has.
Finally, we sort the hashtable based on values, take the 0th one thereof, and select its Name (i.e., the $i of the index). That's left on the pipeline and output is implicit.

05AB1E, 27 21 bytes
ηõ¸ì¹.sRõ¸«)øεIýÒg}Wk

Try it online!
It returns the lowest 0-indexed p.
Thanks to @Emigna for -6 bytes !
Explanation
ηõ¸ì                  # Push the prefixes of A with a leading empty string -- [, 1, 12, 123, 1234]
    ¹.sRõ¸«)          # Push the suffixes of A with a tailing empty space. -- [1234, 123, 12, 1, ]
            ø         # Zip the prefixes and suffixes
             ε    }   # Map each pair with...
              IýÒg    # Push B, join prefix - B - suffix, map with number of primes
                   Wk # Push the index of the minimum p

Using the same method, you could save 6 bytes by rewriting this as ηõ¸ì¹.sRõ¸«)øεIýÒg}Wk.

05AB1E, 18 bytes
gƒ¹õ«N¹g‚£IýÒg})Wk

Try it online!

Python 2, 165 146 bytes

Saved nineteen bytes thanks to Erik the Outgolfer.

O=lambda n:n>1and-~O(n/min(d for d in range(2,n+1)if n%d<1))
def f(A,B):L=[int(A[:j]+B+A[j:])for j in range(len(A)+1)];print L.index(min(L,key=O))

Try it online!

146 bytes

@EriktheOutgolfer Thank you.

Clean, 165 ... 154 bytes
import StdEnv,StdLib
@n h#d=hd[i\\i<-[2..h]|h rem i<1]
|d<h= @(n+1)(h/d)=n
?a b=snd(hd(sort[(@0(toInt(a%(0,i-1)+++b+++a%(i,size a))),i)\\i<-[0..size a]]))

Try it online!

Jelly, 16 bytes
;ṭJœṖ€$j€¥VÆfẈNM

Try it online!
Takes A as a list of digits and returns all 1-indices
How it works
;ṭJœṖ€$j€¥VÆfẈNM - Main link. Takes A on the left and B on the right
;                - Concatenate B to the end of A
         ¥       - Group the previous 2 links into a dyad f(A, B):
      $          -   Group the previous 2 links into a monad g(A):
  J              -     Indices of A; [1, 2, ..., len(A)]
     €           -     Over each index:
   œṖ            -       Partition A at that index
        €        -   Over each partition:
       j         -     Join with B
 ṭ               - Append the concatenated number to the end of this list
          V      - Evaluate each as a number
           Æf    - Calculate the prime factors of each
             ẈN  - Get the lengths of each and negate
               M - Indices of maximal elements, which gives the minimal indices when negated

JavaScript (ES6), 120 bytes
Takes input as 2 strings. Returns a 0-indexed position.
f=(a,b,i=0,m=a)=>a[i>>1]?f(a,b,i+1,eval('for(n=a.slice(0,i)+b+a.slice(i),x=k=2;k<n;n%k?k++:n/=x++&&k);x')<m?(r=i,x):m):r

Test cases

f=(a,b,i=0,m=a)=>a[i>>1]?f(a,b,i+1,eval('for(n=a.slice(0,i)+b+a.slice(i),x=k=2;k<n;n%k?k++:n/=x++&&k);x')<m?(r=i,x):m):r

console.log(f('1234','32'))   // 1
console.log(f('3456','3'))    // 4
console.log(f('378','1824'))  // 0
console.log(f('1824','378'))  // 4
console.log(f('67','267'))    // 1
console.log(f('435','1'))     // 1

Python 3, 128 bytes
0-indexed; takes in strings as parameters. -6 bytes thanks to Jonathan Frech.
from sympy.ntheory import*
def f(n,m):a=[sum(factorint(int(n[:i]+m+n[i:])).values())for i in range(len(n)+1)];return a.index(min(a))

:\n a -> :a.

J, 60 Bytes
4 :'(i.<./)#@q:>".@(,(":y)&,)&.>/"1({.;}.)&(":x)"0 i.>:#":x'

Explicit dyad.
Takes B on the right, A on the left.
0-indexed output.
Might be possible to improve by not using boxes.
Explanation:
  4 :'(i.<./)#@q:>".@(,(":x)&,)&.>/"1({.;}.)&(":y)"0 i.>:#":y'  | Whole program
  4 :'                                                       '  | Define an explicit dyad
                                                     i.>:#":y   | Integers from 0 to length of y
                                                  "0            | To each element
                                     ({.;}.)&(":y)              | Split y at the given index (result is boxed)
                     (,(":x)&,)&.>/"1                           | Put x inbetween, as a string
                  ".@                                           | Evaluate
                 >                                              | Unbox, makes list
             #@q:                                               | Number of prime factors of each
      (i.>./)                                                   | Index of the minimum

Python, 122 bytes
f=lambda n,i=2:n>1and(n%i and f(n,i+1)or 1+f(n/i,i))
g=lambda A,B:min(range(len(A)+1),key=lambda p:f(int(A[:p]+B+A[p:])))

In practice, this exceeds the default max recursion depth pretty quickly.


text:
Loop It

Note: The title of this question should be "Loop It", but because title needs to be at least 15 characters, there are some invisible spaces. This note is such that the challenge can be searched for.

Challenge
Given a finite list of unique integral points in the plane, find a polygon whose vertices are exactly those points, which does not self intersect.
Details

As input you can take e.g. two lists with each the x- and y-coordinates or a list of pairs.
The input list contains at least 3 points.
Note that this means there is never a unique solution.
The list of inputs is can be assumed to be not co-linear (the points cannot be contained in one line), this means there actually is such a non-self-intersecting polygon.
The angles at each vertex is arbitrary, this includes 180°.
For an input of length n, the output should be a permutation (p1,p2,p3,...,pn) of (1,2,3,...,n) where the k-th entry pk represents  the p-th point in the input list. This means we have a line from p1 to p2, a line from p2 to p3 etc, as well as a line from pn to p1. (You can also use the 0-based indices.) Alternatively you can just output the list of input points in the right order.

Examples
Let's say we have the points [(0,0),(0,1),(1,0),(-1,0),(0,-1)] and we want to represent following path:

This means we would output the list [5,1,4,2,3]
Here some more suggestion to try (I recommend looking at the corresponding plots to verify the goals.)
Triangle
[(0,0),(0,1),(1,0)]

S-Curve
[(0,0),(0,1),(0,2),(0,3),(0,4),(1,0),(2,0),(2,1),(2,2),(2,3),(2,4),(3,4),(4,0),(4,1),(4,2),(4,3),(4,4)]

L-Shape
[(4,0),(1,0),(3,0),(0,0),(2,0),(0,1)]

Menger Sponge
[(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1),(11,1),(12,1),(13,1),(14,1),(15,1),(16,1),(17,1),(18,1),(19,1),(20,1),(21,1),(22,1),(23,1),(24,1),(25,1),(26,1),(27,1),(1,2),(3,2),(4,2),(6,2),(7,2),(9,2),(10,2),(12,2),(13,2),(15,2),(16,2),(18,2),(19,2),(21,2),(22,2),(24,2),(25,2),(27,2),(1,3),(2,3),(3,3),(4,3),(5,3),(6,3),(7,3),(8,3),(9,3),(10,3),(11,3),(12,3),(13,3),(14,3),(15,3),(16,3),(17,3),(18,3),(19,3),(20,3),(21,3),(22,3),(23,3),(24,3),(25,3),(26,3),(27,3),(1,4),(2,4),(3,4),(7,4),(8,4),(9,4),(10,4),(11,4),(12,4),(16,4),(17,4),(18,4),(19,4),(20,4),(21,4),(25,4),(26,4),(27,4),(1,5),(3,5),(7,5),(9,5),(10,5),(12,5),(16,5),(18,5),(19,5),(21,5),(25,5),(27,5),(1,6),(2,6),(3,6),(7,6),(8,6),(9,6),(10,6),(11,6),(12,6),(16,6),(17,6),(18,6),(19,6),(20,6),(21,6),(25,6),(26,6),(27,6),(1,7),(2,7),(3,7),(4,7),(5,7),(6,7),(7,7),(8,7),(9,7),(10,7),(11,7),(12,7),(13,7),(14,7),(15,7),(16,7),(17,7),(18,7),(19,7),(20,7),(21,7),(22,7),(23,7),(24,7),(25,7),(26,7),(27,7),(1,8),(3,8),(4,8),(6,8),(7,8),(9,8),(10,8),(12,8),(13,8),(15,8),(16,8),(18,8),(19,8),(21,8),(22,8),(24,8),(25,8),(27,8),(1,9),(2,9),(3,9),(4,9),(5,9),(6,9),(7,9),(8,9),(9,9),(10,9),(11,9),(12,9),(13,9),(14,9),(15,9),(16,9),(17,9),(18,9),(19,9),(20,9),(21,9),(22,9),(23,9),(24,9),(25,9),(26,9),(27,9),(1,10),(2,10),(3,10),(4,10),(5,10),(6,10),(7,10),(8,10),(9,10),(19,10),(20,10),(21,10),(22,10),(23,10),(24,10),(25,10),(26,10),(27,10),(1,11),(3,11),(4,11),(6,11),(7,11),(9,11),(19,11),(21,11),(22,11),(24,11),(25,11),(27,11),(1,12),(2,12),(3,12),(4,12),(5,12),(6,12),(7,12),(8,12),(9,12),(19,12),(20,12),(21,12),(22,12),(23,12),(24,12),(25,12),(26,12),(27,12),(1,13),(2,13),(3,13),(7,13),(8,13),(9,13),(19,13),(20,13),(21,13),(25,13),(26,13),(27,13),(1,14),(3,14),(7,14),(9,14),(19,14),(21,14),(25,14),(27,14),(1,15),(2,15),(3,15),(7,15),(8,15),(9,15),(19,15),(20,15),(21,15),(25,15),(26,15),(27,15),(1,16),(2,16),(3,16),(4,16),(5,16),(6,16),(7,16),(8,16),(9,16),(19,16),(20,16),(21,16),(22,16),(23,16),(24,16),(25,16),(26,16),(27,16),(1,17),(3,17),(4,17),(6,17),(7,17),(9,17),(19,17),(21,17),(22,17),(24,17),(25,17),(27,17),(1,18),(2,18),(3,18),(4,18),(5,18),(6,18),(7,18),(8,18),(9,18),(19,18),(20,18),(21,18),(22,18),(23,18),(24,18),(25,18),(26,18),(27,18),(1,19),(2,19),(3,19),(4,19),(5,19),(6,19),(7,19),(8,19),(9,19),(10,19),(11,19),(12,19),(13,19),(14,19),(15,19),(16,19),(17,19),(18,19),(19,19),(20,19),(21,19),(22,19),(23,19),(24,19),(25,19),(26,19),(27,19),(1,20),(3,20),(4,20),(6,20),(7,20),(9,20),(10,20),(12,20),(13,20),(15,20),(16,20),(18,20),(19,20),(21,20),(22,20),(24,20),(25,20),(27,20),(1,21),(2,21),(3,21),(4,21),(5,21),(6,21),(7,21),(8,21),(9,21),(10,21),(11,21),(12,21),(13,21),(14,21),(15,21),(16,21),(17,21),(18,21),(19,21),(20,21),(21,21),(22,21),(23,21),(24,21),(25,21),(26,21),(27,21),(1,22),(2,22),(3,22),(7,22),(8,22),(9,22),(10,22),(11,22),(12,22),(16,22),(17,22),(18,22),(19,22),(20,22),(21,22),(25,22),(26,22),(27,22),(1,23),(3,23),(7,23),(9,23),(10,23),(12,23),(16,23),(18,23),(19,23),(21,23),(25,23),(27,23),(1,24),(2,24),(3,24),(7,24),(8,24),(9,24),(10,24),(11,24),(12,24),(16,24),(17,24),(18,24),(19,24),(20,24),(21,24),(25,24),(26,24),(27,24),(1,25),(2,25),(3,25),(4,25),(5,25),(6,25),(7,25),(8,25),(9,25),(10,25),(11,25),(12,25),(13,25),(14,25),(15,25),(16,25),(17,25),(18,25),(19,25),(20,25),(21,25),(22,25),(23,25),(24,25),(25,25),(26,25),(27,25),(1,26),(3,26),(4,26),(6,26),(7,26),(9,26),(10,26),(12,26),(13,26),(15,26),(16,26),(18,26),(19,26),(21,26),(22,26),(24,26),(25,26),(27,26),(1,27),(2,27),(3,27),(4,27),(5,27),(6,27),(7,27),(8,27),(9,27),(10,27),(11,27),(12,27),(13,27),(14,27),(15,27),(16,27),(17,27),(18,27),(19,27),(20,27),(21,27),(22,27),(23,27),(24,27),(25,27),(26,27),(27,27)]

If we have 4 points O(0,0), A(1,0), B(0,1), C(0,2), is the polygon OABC self-intersecting?

@ngn That is a good point I did not consider! I'll have to think about it. If you have any argument for or against this please let me know.

@ngn I'd count this polygon as self-intersecting. The reason is that I'd define a polygon to be self intersecting if there is a common point of two edges that is not an endpoint.

@flawr I must withdraw my answer then, it fails when there are multiple co-linear points at maximum angle from the reference point.

Mathematica 29 28 Bytes
FindShortestTour (16 Bytes) does the trick but delivers some extraneous info not asked for (the path length, and a return to the starting point).
Most@*Last@*FindShortestTour

gives just the answer ( -1 byte thanks to @user202729 )
To visualize, use Graphics@Line[g[[%]]], where % is the permutation found above and g is the original point list.
Here is the visualization of the solution for the Menger Sponge:

Here is a solution on a 1000 random points:

The key here is knowing that the shortest tour or traveling salesman problem solution will never yield intersections when Euclidean distance is used as the metric.  One of the steps to localize a solution and ensure optimality is to remove such intersections.

Use NP algorithm to solve P problem just because it's shorter. +1 (???).

@* seems to save a byte.

Quick explanation for people who need it

JavaScript (ES6), 365 341 bytes
Without any built-in, this turned out to be much longer than I expected. Many bytes are spent detecting collinear overlapping segments.
Takes input as an array of [x,y] coordinates. Returns a permutation of the input.
f=(a,p=[],o=([p,P],[q,Q],[r,R])=>Math.sign((S=[(p>q?r<q|r>p:r<p|r>q)|(P>Q?R<Q|R>P:R<P|R>Q),...S],Q-P)*(r-q)-(q-p)*(R-Q)))=>[...p,p[0]].some((A,i,P)=>P.some((C,j)=>j>i+1&&P[++j+!i]&&[E=o(A,B=P[i+1],C,S=[]),F=o(A,B,D=P[j]),G=o(C,D,A),H=o(C,D,B)].some(v=>!v&!S.pop())|E!=F&G!=H))?0:a[0]?a.some((_,i)=>r=f(b=[...a],p.concat(b.splice(i,1))))&&r:p

Demo
This snippet logs the output and draws the corresponding path in a canvas.

f=(a,p=[],o=([p,P],[q,Q],[r,R])=>Math.sign((S=[(p>q?r<q|r>p:r<p|r>q)|(P>Q?R<Q|R>P:R<P|R>Q),...S],Q-P)*(r-q)-(q-p)*(R-Q)))=>[...p,p[0]].some((A,i,P)=>P.some((C,j)=>j>i+1&&P[++j+!i]&&[E=o(A,B=P[i+1],C,S=[]),F=o(A,B,D=P[j]),G=o(C,D,A),H=o(C,D,B)].some(v=>!v&!S.pop())|E!=F&G!=H))?0:a[0]?a.some((_,i)=>r=f(b=[...a],p.concat(b.splice(i,1))))&&r:p

draw(f([[0,0],[0,1],[1,0]]), 1, 1)
draw(f([[0,0],[0,1],[1,0],[-1,0],[0,-1]]), 61, 21)
draw(f([[4,0],[1,0],[3,0],[0,0],[2,0],[0,1]]), 101, 1)

function draw(a, dx, dy) {
  console.log(JSON.stringify(a));

  ctx = C.getContext('2d');
  ctx.beginPath();
  [...a, a[0]].forEach(p => ctx.lineTo(p[0] * 20 + dx, p[1] * 20 + dy));
  ctx.stroke();
}
<canvas id=C></canvas>

How?
Here is the structure of the main recursive function f(), leaving aside the intersection testing code for now:
f = (a, p = []) =>                    // a = array of points, p = current path
  [...p,                              // build a closed path array P[] by adding the first
         p[0]]                        // point at the end of p[]
  .some((A, i, P) =>                  // for each point A at position i in P:
    P.some((C, j) =>                  //   for each point C at position j in P:
      j > i + 1 &&                    //     test whether C is at least 2 positions after A
      P[++j +                         //     and C is not the last point
              !i] &&                  //     and i > 0 or C is not the penultimate point
      intersection(                   //     and there's an intersection between
        A, P[i + 1], C, P[j]          //     the segments (A, P[i + 1]) and (C, P[j + 1])
      )                               //     (j was incremented above)
    )                                 //   end of inner some()
  ) ?                                 // end of outer some(); if truthy:
    0                                 //   discard this path by stopping recursion
  :                                   // else:
    a[0] ?                            //   if there's at least one remaining point:
      a.some((_, i) =>                //     for each remaining point at position i:
        r = f(                        //       do a recursive call with:
          b = [...a],                 //         a copy b[] of a[] without a[i] and
          p.concat(b.splice(i, 1)))   //         the extracted point added to the path
      ) && r                          //     end of some(); return the result, if any
    :                                 //   else:
      p                               //     this is a valid path: return it

Below is the detail of the intersection() test. This page provides a comprehensive explanation about the algorithm used.
[                                     // build an array containing:
  E = o(A, B = P[i + 1], C, S = []),  //   E = test of (A, B, C) (+ initialization of S[])
  F = o(A, B, D = P[j]),              //   F = test of (A, B, D)
  G = o(C, D, A),                     //   G = test of (C, D, A)
  H = o(C, D, B)                      //   H = test of (C, D, B)
]                                     //
.some(v =>                            // the segments are collinear and overlapping if:
  !v &                                //   any value above is 0
  !S.pop()                            //   and the corresponding entry in S[] is falsy
) |                                   // the segments intersect if:
E != F & G != H                       //   E is not equal to F and G is not equal to H

Finally, here is the definition of the helper function o():
o = (                                             // given three points represented by
  [p, P], [q, Q], [r, R]                          // a lowercase letter for x
) =>                                              // and an uppercase letter for y:
  Math.sign(                                      //
    (                                             //   1) prepend to the array S[]
      S = [                                       //      a boolean which is true if the
        (p > q ? r < q | r > p : r < p | r > q) | //      segment (P, Q) would not contain
        (P > Q ? R < Q | R > P : R < P | R > Q),  //      the point R, assuming that the
        ...S                                      //      3 points are collinear
      ],                                          //
                                                  //   2) return the orientation of P, Q, R:
      Q - P                                       //        -1 = counterclockwise
    ) * (r - q) - (q - p) * (R - Q)               //         0 = collinear
  )                                               //        +1 = clockwise

... explanation please?

@user202729 (*wipes hand across forehead*) Done!

APL (Dyalog Classic), 42 38 bytes
{⍋(⍪,(|z)×¯1*⊢=⌈/)12○z←0j1⊥¨⍵-⍵[⊃⍋↑⍵]}

Try it online!
Input is a list of coordinate pairs.
Output is a 0-based permutation.
⍵ is the list of points - the argument to { }
⍵[⊃⍋↑⍵] is the leftmost-lowest point
⍵- translates all points so that leftmost-lowest is at the origin of the coordinate system
0j1 the imaginary unit i=sqrt(-1)
0j1⊥¨ decodes the coordinates as if digits in a base-i number system - i.e. turns (x,y) into a complex number ix+y
z← assign to z
12○ computes the complex numbers' arguments, a.k.a. theta angles, or APL circular function 12
(⍪,(|z)×¯1*⊢=⌈/) is a train that computes a boolean mask of where the angles are at a maximum (⊢=⌈/), turns the 0 1 in the mask into 1 ¯1 by raising ¯1 to the corresponding power (¯1*), multiplies by the magnitudes of the complex numbers |z, and concatenates that to the right (,) of a tall thin 1-column matrix (⍪) of the angles.
⍋ grade - returns the permutation that would sort the rows of the matrix lexicographically in ascending order

@user202729 they will be sorted according to the second criterion - distance (i.e. circular function 10, aka complex magnitude)


text:
Case-fold German
Given a German string and an indication of a case (lower/upper/title), fold the string to that case.
Specifications

Input will consist only of a–z plus äöüß-,.;:!?'" in uppercase and/or lowercase.
The target case may be taken as any three unique values (please specify what they are) of a consistent type; either three characters, or three numbers, or three bit patterns. (Other formats are currently not allowed to prevent "outsourcing" the answer to the case specification. Comment if you think that an additional format should be allowed.)
Titlecase means uppercase everything except letters that follow a letter (letters are a–z plus äöüß).

Gotchas

When ß needs to be uppercase, it must become ẞ. Some case-folding built-ins and libraries do not do this.

When ß needs to be titlecase, it must become Ss. Some case-folding built-ins and libraries do not do this.

ss may occur in the text, and should never be converted to ß or ẞ.

Examples
Upper case die Räder sagen "ßß ss" für dich, wegen des Öls!
is DIE RÄDER SAGEN "ẞẞ SS" FÜR DICH, WEGEN DES ÖLS!
Lower case  die Räder sagen "ßß ss" für dich, wegen des Öls!
is  die räder sagen "ßß ss" für dich, wegen des öls!
Title case die Räder sagen "ßß ss" für dich, wegen des Öls!
is Die Räder Sagen "Ssß Ss" Für Dich, Wegen Des Öls!

What would be the outputs for Ss? Also, the example input is missing a ss

@Rod SS Ss ss. Can you tell me why that's unclear?

Related

Am I allowed to make the three unique values Python functions? (see my answer)

No, that's exactly what intended to prevent by specifying that the three unique values must be either characters, numbers or bit patterns.

May we assume there are no capitals after the first letter in a word?

May we take input and give output in an ANSI codepage containing these symbols instead of UTF-8 etc.?

@Οurous Does such a codepage exist? If so, then I guess that's valid by default. At least as long as you program can fit in the codepage and that your interpreter/compiler will run/compile such files.

@HyperNeutrino I think that's a standard loophole actually, taking functions as inputs. I don't remember where the meta is tho

@ConorO'Brien Oh huh. That would make sense I guess.

@HyperNeutrino Relevant meta post ConorO'Brien was most likely talking about. EDIT: You were actually the first one to comment on that meta post I now noticed.. ;)

@KevinCruijssen Thanks. And huh that's interesting. I do remember reading and commenting on that meta post but I guess that the time I was trying to use that as a solution I didn't consider that :P

But...  gotcha #1 isn’t making sense, uppercase ß is just SS, a friend of mine has a 4 letter lowercase name and a 5 letter uppercase...?

@StanStrum Encoding has nothing to do with names. ß is a two-letter ligature.

@Adám not quite what I meant, but i see where you’re going. Just never really see an upper ß

@StanStrum It has been in use for over half a century.

Japt, 42 40 bytes
Saved 2 bytes thanks to @Oliver
r'ßQ=7838d)u mV,@W¦vW=X ?Xv :X¥Q?"Ss":Xu

Whew, that took quite some effort. Input is the string to convert, and a single character: u for uppercase, v for lowercase, m for title case.
Test it online!

Do you need the }0?

@Oliver Yeah, otherwise it'll... wait, maybe not...

Python 3, 92 bytes
lambda s,c:[str.lower,str.upper,str.title][c](s.replace("ẞ","ß").replace("ß"*c,"ẞ"*c))

Try it online!

Oh no! Unfortunately, that's a significant part of the challenge.

@EriktheOutgolfer fixed, thanks

Jelly, 50 bytes
⁽ñWỌ”ß;y⁸Œu
Ñ⁾SsÇ⁼?€1¦”ß
Œl
Çe€“Ġẹṇṣ‘ỌÇ;Øa¤Œg⁸ṁ⁹Ŀ€

Try it online!
Full program.
Phew, this took much time to golf...
Argument 1: String (may need to be escaped)
Argument 2: 1 for uppercase, 2 for title case, 3 for lowercase.

05AB1E, 23 bytes
Uses 0 = lower, 1 = upper, 2 = title
•^ŠX•4ôçIiR}`:"lu™"¹è.V

Try it online!

Clean, 649 279 275 274 246 bytes
Yes, that's 123 122 94 bytes of imports, which is already longer than every other answer.
from StdList import++,map,flatten
import StdLib,StdInt,StdBool,Text.Unicode,Text.Unicode.UChar
$ =fromInt
? =isAlpha
^ =toUpper
@0s=map^s
@1s=map toLower s
@2s=flatten(map(\[h:t]=if($223==h||h> $999)[$83,$115][^h]++ @1t)(groupBy(\a b= ?a== ?b)s))

Try it online!
Defines the function @, taking an Int and a UString, and returning a UString.
Conveniently, UString (Clean's default way of handling Unicode), is just a type alias for [Int] - which is a list of Int containing unicode codepoints of the characters in the string.
Inconveniently, Text.Unicode.UChar is really long, and I can't import StdEnv because the definitions in StdChar conflict with the definitions in Text.Unicode.UChar (as they are not intended for use together).
The three values are 0, 1, and 2 for Upper, Lower, and Title case.


text:
Square Triangles
A positive integer x is a square triangle number iff there are two different positive integers, y and z, which are smaller than x such that all of the sums
x + y
x + z
y + z
are perfect squares.
For example 30 is a square triangle number because
30 + 6 = 62
30 + 19 = 72
6 + 19 = 52

Your task is to write some code that takes a positive integer as input and determines whether or not it is a square triangle number.  You should output one of two distinct values, one if the input is a square triangle number and the other otherwise.
This is code-golf so answers will be scored in bytes with fewer bytes being better.
Testcases
Here are all of the square triangle numbers under 1000
30,44,47,48,60,66,69,70,78,86,90,92,94,95,96,98,108,113,116,118,120,122,124,125,126,132,138,142,147,150,152,154,156,157,158,159,160,165,170,176,180,182,185,186,188,190,192,194,195,196,197,198,200,207,212,214,216,218,221,222,224,227,230,232,234,236,237,238,239,240,246,248,253,258,260,264,266,267,268,270,273,274,275,276,278,280,281,282,283,284,285,286,290,296,298,302,303,306,308,310,312,314,317,318,320,322,323,324,326,328,329,330,331,332,333,334,335,336,338,340,344,347,350,351,352,356,357,360,362,364,368,370,371,372,374,376,377,378,380,382,384,385,386,387,388,389,390,392,394,396,402,405,408,410,413,414,415,418,420,422,423,424,426,429,430,432,434,435,436,438,440,442,443,444,445,446,447,448,449,452,456,458,462,464,466,467,468,470,472,476,477,479,480,482,484,485,488,490,491,492,494,496,497,498,500,501,502,503,504,505,506,507,508,509,510,512,515,516,518,522,523,524,527,528,530,533,536,538,540,542,543,546,548,549,550,551,552,554,557,558,560,562,563,564,566,568,569,570,571,572,573,574,575,576,578,579,582,585,588,590,592,593,594,598,600,602,603,604,605,606,608,610,612,613,614,615,616,618,620,621,623,624,626,627,628,630,632,633,634,636,638,639,640,641,642,643,644,645,646,650,652,656,657,658,659,660,662,666,667,668,670,672,674,677,678,680,682,683,686,687,689,690,692,694,695,696,698,700,701,702,704,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,722,723,726,728,730,734,737,739,740,742,744,745,746,750,752,755,756,758,760,762,764,765,767,768,770,772,773,774,776,778,779,780,782,783,784,785,786,788,789,790,791,792,793,794,795,796,797,798,800,802,803,804,805,810,812,814,816,817,818,819,820,822,825,826,827,828,829,830,832,833,834,836,837,838,840,842,846,847,848,849,850,851,852,854,855,856,858,860,861,862,863,864,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,882,884,888,890,891,893,896,897,898,902,903,904,905,908,912,913,914,915,916,918,920,923,924,926,927,928,929,931,932,933,935,936,938,940,941,942,944,946,947,948,950,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,970,972,974,976,978,980,981,984,986,987,988,992,993,995,996,998

OEIS A242445

This is OEIS A242445.

@Mr.Xcoder Thanks! I probably should have checked the OEIS first.  I'll add that to the body to make it more searchable.

For clarification purposes, "...iff there are two different positive integers, y and z, which are smaller than x..."  means that y < x and z < x or that y+z < x?

@J.Sallé The former

Here test case with input and output are absent

What does it mean:"You should output one of two distinct values, one if the input is a square triangle number and the other otherwise."? Perhaps it has to return true false...

Haskell, 62 bytes
f x|l<-(^2)<$>[1..x]=or[b>x|c<-l,b<-l,a<-l,a-x+b-x==c,c<b,b<a]

Try it online!

Jelly, 12 bytes
R²_fṖŒcS€Æ²Ẹ

Try it online!
How it works
R²_fṖŒcS€Æ²Ẹ  Main link. Argument: x

R             Range; yield [1, 2, ..., x].
 ²            Square; yield [1², 2², ..., x²].
  _           Subtract; yield [1²-x, 2²-x, ..., x²-x].
    Ṗ         Pop; yield [1, 2, ..., x-1].
   f          Filter; keep those values of n²-x that lie between 1 and x-1.
              This list contains all integers n such that n+x is a perfect square.
              We'll try to find suitable values for y and z from this list.
     Œc       Yield all 2-combinations [y, z] of these integers.
       S€     Take the sum of each pair.
         Æ²   Test each resulting integer for squareness.
           Ẹ  Any; check is the resulting array contains a 1.

Python 2, 93 87 86 bytes
-1 byte thanks to Dennis

lambda n:{0}in[{m**.5%1for m in[x+y,n+x,n+y]}for x in range(1,n)for y in range(1+x,n)]

Try it online!

Brachylog, 19 bytes
~hṪ>₁ℕ₁ᵐ≜¬{⊇Ċ+¬~^₂}

Try it online!
Also 19 bytes: ~hṪ>₁ℕ₁ᵐ≜{⊇Ċ+}ᶠ~^₂ᵐ
Explanation
~hṪ                    Ṫ = [Input, A, B]
  Ṫ>₁                  Ṫ is strictly decreasing (i.e. Input > A > B)
  Ṫ  ℕ₁ᵐ               All members of Ṫ are in [1, +∞)
  Ṫ     ≜              Assign values to A and B that fit those constraints
  Ṫ      ¬{       }    It is impossible for Ṫ…
           ⊇Ċ            …that one of its 2-elements subset…
            Ċ+           …does not sum…
              ¬~^₂       …to a square

PowerShell, 150 bytes
param($x)filter f($a,$b){($c=[math]::Sqrt($a+$b))-eq[math]::Floor($c)}1..($i=$x-1)|%{$y=$_;1..$i|%{$o+=+($y-ne$_)*(f $x $y)*(f $x $_)*(f $y $_)}};!!$o

Try it online! or Verify some test cases
Takes input $x. Establishes a filter (here equivalent to a function) on two inputs $a,$b, which returns a Boolean true iff the [math]::sqrt of $a+$b is -equal to the Floor of that square root (i.e., it's an integer square root).
The rest of it is the meat of the program. We double-for loop up from 1 to $x-1. Each iteration, we check whether $y is -notequal to $_ (i.e., $z), and whether the function is true for all combinations of $x, $y and $_. If it is, $o is incremented by one (which makes it non-zero).
Finally, at the end, we double-Boolean-negate $o, which turns 0 into False and non-zero into True. That's left on the pipeline and output is implicit.

JavaScript (ES7), 75 71 bytes

f=
n=>(g=i=>i?--j?[n+i,i+j,j+n].some(e=>e**.5%1)?g(i):1:g(j=i-1):0)(j=n-1)
<input type=number min=1 oninput=o.textContent=f(+this.value)><pre id=o>

Seems like you ninja'd me by 2 minutes. :) Ours answers are very close, so shall I delete mine?

@Arnauld No, I'm sure you arrived at your solution independently.

Haskell, 75 69 bytes
f x=or[all(`elem`map(^2)[1..x])[x+y,x+z,y+z]|y<-[1..x-1],z<-[1..y-1]]

Try it online!
Could probably be improved if someone knows a shorter way to test if a number is square. I'm pretty sure using sqrt ends up being longer because floor turns the result into an integral type so you need to put fromIntegral in somewhere before you can compare to the original.
EDIT: Thanks @Wheat Wizard for taking off 6 bytes!

05AB1E, 18 bytes
Lns-IL¨Ãæ2ù€OÅ²O0›

Try it online!
Thanks to Emigna for  -3  -1 byte and a fix!

You don't need the 2 €'s as both n and O vectorizes. This also doesn't work as the final 2 bytes will return true for any list with at least 1 value, even if only contains false values. This can be fixed (and shortened) by using Z instead.

@Emigna Thank you! (BTW I did need €O and that’s why the previous approach did work with \º`)

It didn't work though. Check for example 45, that should return false.

Um huh, ok. Anyway, updated now. Thanks

@Sanchises Fixed. Thanks

R, 79 bytes
function(x){s=(1:x)^2
S=outer(y<-(z=s-x)[z>0&z<x],y,"+")
diag(S)=0
any(S%in%s)}

Try it online!
computes all the values of y,z with y<-(z=s-x)[z>0&z<x], then computes all their sums with outer(y,y,"+"). This yields a square matrix where off-diagonal entries are potentially squares, as y==z only if they are on the diagonal. Hence, diag(S)=0 sets the diagonals to zero, which are not perfect squares, and we test to see if any element of S is %in%s.

SWI-Prolog, 88 bytes
s(A,B,C):-between(A,B,C),C<B,between(1,B,X),B+C=:=X*X.
g(X):-s(1,X,Y),s(Y,X,Z),s(Y,Z,Y).

Try it online!
s(A, B, C) :-
    between(A, B, C), % Find an integer C between A and B (inclusive),
    C < B,            % which is less than B.
    between(1, B, X), % Find an integer X between 1 and B (inclusive),
    B+C =:= X*X.      % of which (B+C) is the square.
g(X) :-
    s(1, X, Y), % Find Y: 1 <= Y < X, and X+Y is a perfect square
    s(Y, X, Z), % Find Z: Y <= Z < X, and X+Z is a perfect square
    s(Y, Z, Y). % Make sure that Z > Y and Y+Z is a perfect square

g(X) is the rule that takes an integer as parameter and outputs whether it is a square triangle number (true/false).

Jelly, 15 bytes
ṖŒc;€ŒcS€Æ²ẠƊ€Ẹ

Try it online!
How?

ṖŒc;€ŒcS€Æ²ẠƊ€Ẹ || Full program.
                ||
Ṗ               || Popped range. Yields [1, N) ∩ ℤ.
 Œc             || Pairs (two-element combinations).
   ;€           || Append N to each.
            Ɗ€  || For each of the lists, check whether:
           Ạ    || ... All ...
       S€       || ... The sums of each of their...
     Œc         || ... Disjoint Pairs
         Æ²     || ... Are perfect squares.
              Ẹ || Test whether there is any value that satisfies the above.

JavaScript (ES7), 72 bytes
Returns 0 or 1.
x=>(g=y=>z?y>z?![x+y,x+z,y+z].some(n=>n**.5%1)|g(y-1):g(x-1,z--):0)(z=x)

Demo

let f=

x=>(g=y=>z?y>z?![x+y,x+z,y+z].some(n=>n**.5%1)|g(y-1):g(x-1,z--):0)(z=x)

for(n = 1; n < 150; n++) {
  f(n) && console.log(n)
}

C, 113 bytes
p(n){return(int)sqrt(n)==sqrt(n);}f(x,y,z,r){for(r=y=0;++y<x;)for(z=y;++z<x;p(x+y)&p(x+z)&p(z+y)&&++r);return!r;}

Returns 0 if the number is square triangle, 1 otherwise.
Try it online!

I'm guessing the return(int)sqrt(n)==sqrt(n) is being parsed as return((int)sqrt(n))==sqrt(n) as opposed to the more obvious return(int)(sqrt(n)==sqrt(n))? If not can you explain what p is doing?

@MDXF Type cast has higher precedence than ==, so the expression is parsed as ((int)sqrt(n))==sqrt(n) like you guessed.

APL (Dyalog), 49 bytes
{∨/{0=+/(⍺=⍵),1|.5*⍨(⍺+⍵)(⍺+k)(⍵+k)}/¨,⍳2⍴1-⍨k←⍵}

Try it online!

Julia 0.6, 61 bytes
Start reading from the function all. The first argument is an anonymous function checking that the square root of a number is an integer, this is applied to each value in the second argument. The single argument to any is a Generator with two for loops, which for each iteration contains the output of the all function.
Thanks to Mr Xcoder for -2 bytes.

x->any(all(x->√x%1==0,[x+y,x+z,y+z])for y=1:x-1for z=1:y-1)

Try it online!

Clean, 95 88 86 bytes
import StdEnv
@x#l=[1..x-1]
=or[all(\n=or[i^2==n\\i<-l])[x+y,y+z,z+x]\\y<-l,z<-l|y<>z]

Try it online!

Ruby, 73 bytes
->n{(1...n).any?{|b|(1...b).any?{|c|[n+b,b+c,n+c].all?{|r|r**0.5%1==0}}}}

Try it online!

MATL, 20 19 18 bytes
q:2XN!tG+wsvX^1\aA

Try it online! Returns 1 for falsey, 0 for truthy.
Testcases up to 500: Try it online! (using H instead of G). Runtime is quadratic in the input size, so enumerating the testcases from 1 to n runs in O(n^3), which is why enumerating all testcases up to 1000 times out on TIO.

-1 byte and a conjecture less thanks to @LuisMendo
-1 byte by a more clever check of integer-ness.

Removing q generates a sequence with the desired sequence as a subset, but without the constraint that y and z be strictly smaller than x. An example is x=18, y=7, z=18.
q:    % Push 1...n-1
2XN   % Generate all permuations of choosing 2 numbers from the above.
!     % Transpose to take advantage of column-wise operators later on.
 G+   % Add n to these combinations, to have all combos of x+y and x+z
t  ws % Duplicate the combinations, swap to the top of the stack and sum to get y+z.
v     % Concatenate vertically. The array now contains columns of [x+y;x+z;y+z].
X^    % Element-wise square root of each element
1\    % Get remainder after division by 1.
a     % Check if any have remainders, columnwise. If so, it is not a square triangle.
A     % Check whether all combinations are not square triangle.

@LuisMendo Thanks. Too bad, I was hoping for an answer to my conjecture, but I can't just ask it at Math.SE without showing some effort for a proof...

https://qchu.wordpress.com/2009/07/02/square-roots-have-no-unexpected-linear-relationships/ here you go

Pyt, 63 bytes
0←Đ⁻Đ`⁻Đ3ȘĐ3Ș+√ĐƖ=4ȘĐ3ȘĐ3Ș+√ĐƖ=4ȘĐ3ȘĐ3Ș+√ĐƖ=4Ș6Ș**4Ș↔+↔łŕ⁻Đłŕŕŕ

Tests all possible combinations of y,z such that 1≤z<y<x
Returns 1 if x is a square triangle number, 0 otherwise
Try it online!


text:
Finding Lonely Primes
Lonely primes (as I call them) are primes, where given a number grid with width w ≥ 3, are primes which do not have any other primes adjacent to them orthogonally or diagonally.
For example, if we take this grid where w = 12 (primes highlighted in bold):
1   2   3   4   5   6   7   8   9   10  11  12
13  14  15  16  17  18  19  20  21  22  23...
 ...86  87  88  89  90  91  92  93  94  95  96
97  98  99  100 101 102 103 104 105 106 107 108
109 110 111 112 113 114 115 116 117 118 119 120
You can see that only the two primes 103 and 107 have no primes orthogonally or diagonally adjecant whatsoever. I've skipped over a section because there's no lonely primes there. (except 37, actually)
Your task is to, given two inputs w ≥ 3 and i ≥ 1, determine the first lonely prime in a number grid with width w, where said lonely prime must be greater than or equal to i. Inputs may be taken in any reasonable format (including taking them as strings). It is guaranteed there will be a lonely prime for width w.
The grid doesn't wrap around.
Examples:
w  i   output
11 5   11
12 104 107
12 157 157
9  1   151
12 12  37

As this is code-golf, shortest code wins!

Why is for w=12 not 37 a lonely prime? None of the numbers surrounding it -- {25, 26, 38, 49, 50} -- are prime.

@JonathanFrech Yes, a test case includes that.

C (gcc), 159 158 149 145 bytes

Saved a byte thanks to xanoetux; removing one newline character.
Saved nine thirteen bytes thanks to ceilingcat; golfing a break condition.

P(n,d,b){for(d=b=1<n;n>++d;)b*=n%d>0;n=b;}F(w,i){w=P(i)&!(P(i-w)|P(i+w)|i%w>1&(P(--i)|P(i-w)|P(i+w))|++i%w>0&(P(++i)|P(i-w)|P(i+w)))?i-1:F(w,i);}

Try it online!

You may save one byte skipping the newline. Try it online!

@ceilingcat Fine suggestion, thanks.

@ceilingcat Thank you.

JavaScript (ES6), 116 104 bytes
Takes input in currying syntax (w)(i).
w=>g=i=>!(C=(k,n=d=i+k)=>n>0?n%--d?C(k,n):d>1:1)(0)&[i,x=1,i-1].every(j=>C(x-w)&C(w+x--)|j%w<1)?i:g(i+1)

Test cases

let f =

w=>g=i=>!(C=(k,n=d=i+k)=>n>0?n%--d?C(k,n):d>1:1)(0)&[i,x=1,i-1].every(j=>C(x-w)&C(w+x--)|j%w<1)?i:g(i+1)

console.log(f(11)(  5)) // 11
console.log(f(12)(104)) // 107
console.log(f(12)(157)) // 157
console.log(f( 9)(  1)) // 151
console.log(f(12)( 12)) // 37

Commented
w =>                    // main function, taking w
  g = i =>              // g = recursive function, taking i
    !(                  //
      C = (             // define C:
        k,              //   a function taking an offset k
        n = d = i + k   //   and using n and d, initialized to i + k
      ) =>              //
        n > 0 ?         //   if n is strictly positive:
          n % --d ?     //     decrement d; if d does not divide n:
            C(k, n)     //       do a recursive call
          :             //     else:
            d > 1       //       return true if d > 1 (i.e. n is composite)
        :               //   else:
          1             //     return true (n is beyond the top of the grid)
    )(0) &              // !C(0) tests whether i is prime (or equal to 1, but this is safe)
    [                   // we now need to test the adjacent cells:
      i,                //   right side: i MOD w must not be equal to 0
      x = 1,            //   middle    : always tested (1 MOD w is never equal to 0)
      i - 1             //   left side : (i - 1) MOD w must not be equal to 0
    ]                   // for each value j defined above,
    .every(j =>         // and for x = 1, 0 and -1 respectively:
      C(x - w) &        //   test whether i - w + x is composite
      C(w + x--) |      //            and i + w + x is composite
      j % w < 1         //   or j MOD w equals 0, so that the above result is ignored
    ) ?                 // if all tests pass:
      i                 //   return i
    :                   // else:
      g(i + 1)          //   try again with i + 1

Python 2, 144 bytes
f=lambda w,i,p=lambda n:all(n%j for j in range(2,n))*(n>1):i*(any(map(p,~-i%w*(i+~w,i-1,i+w-1)+(i-w,i+w)+i%w*(i-w+1,i+1,i-~w)))<p(i))or f(w,i+1)

Try it online!
Arguments in order: w, i.
No external modules used here.
Python 2 + sympy, 127 bytes
import sympy
f=lambda w,i,p=sympy.isprime:i*(any(map(p,~-i%w*(i+~w,i-1,i+w-1)+(i-w,i+w)+i%w*(i-w+1,i+1,i-~w)))<p(i))or f(w,i+1)

Try it online!
Not worthy of a different post, since the only difference here is that it uses sympy.isprime instead of a manually implemented prime check function.

MATL, 38 bytes
xx`@1G*:5MeZpt3Y6Z+>3LZ)ft2G<~)X<a~}2M

Try it online! Or verify all test cases.
Explanation
The code essentially consists of a loop that keeps enlarging the grid as described in the challenge by one row at each iteration.
After creating the grid at each iteration, the last row is removed (we cannot know if those primes are lonely or not) and the remaining numbers are tested to see if at least one lonely prime exists. This is done via 2D convolution.
If there is some lonely prime we exit the loop and output the first such prime. Else we proceed with the next iteration, which will try a larger grid.
(The code actually uses a transposed version of the grid, which is enlarged by columns instead of by rows.)
xx        % Take two inputs (implicit): w, i. Delete them. They get copied
          % into clipboard G
`         % Do...while
  @       %   Push iteration index (1-based)
  1G      %   Push w
  *       %   Multiply
  :       %   Range from 1 to that
  5M      %   Push w again (from automatic clipboard M)
  e       %   Reshape into a matrix with w rows in column-major order
  Zp      %   Is prime? Element-wise
  t       %   Duplicate
  3Y6     %   Push neighbour mask: [1 1 1; 1 0 1; 1 1 1]
  Z+      %   2D convolution, maintaining size
  >       %   Greater than? Element-wise. Gives true for lonely primes
  3LZ)    %   Remove the last column
  f       %   Find linear indices of nonzeros
  t       %   Duplicate
  2G      %   Push i
  <~      %   Not less than?
  )       %   Use as logical index: this removes lonle primes less than i
  X<      %   Minimum. This gives either empty or a nonzero value
  a~      %   True if empty, false if nonzero. This is the loop condition.
          %   Thus the loop proceeds if no lonely prime was found
}         % Finally (execute on loop exit)
  2M      %   Push the first found lonely prime again
          % End (implicit). Display (implicit)

Julia 0.6,  135 bytes
using Primes
f(w,i,p=isprime)=findfirst(j->(a=max(j-1,0);b=min(j+1,w);c=a:b;!any(p,v for v=[c;c+w;c-w]if v>0&&v!=j)&&p(j)&&j>=i),1:w*w)

TIO doesn't have the Primes package. It's 5 bytes shorter if I'm allowed to return all lonely primes (findfirst becomes find). Julia's attempt to move functionality out of Base is hurting golfing (not a goal of Julia), Primes was included in 0.4.
Ungolfed (mostly)
function g(w,i)
    for j=i:w*w
        a,b=max(j-1,0),min(j+1,w)
        c=a:b
        !any(isprime,v for v=[c;c+w;c-w]if v>0&&v!=j)&&isprime(j)&&return j
    end
end

Perl 6, 113 104 bytes
->\w,\i{first {is-prime $_&none $_ «+«flat -w,w,(-w-1,-1,w-1)xx!($_%w==1),(1-w,1,w+1)xx!($_%%w)},i..*}

Try it online!

Jelly, 20 bytes
+‘ÆRœ^ḷ,ḷ’dạ/Ṁ€ṂḊð1#

Try it online!
How it works
+‘ÆRœ^ḷ,ḷ’dạ/Ṁ€ṂḊð1#  Main link. Left argument: i. Right argument: w.

                 ð    Combine the links to the left into a chain and begin a new,
                      dyadic chain with arguments i and w.
                  1#  Call the chain to the left with left argument n = i, i+1, ...
                      and right argument w until 1 of them returns a truthy value.
                      Return the match.
+                       Yield n+w.
 ‘                      Increment, yielding n+w+1.
  ÆR                    Yield all primes in [1, ..., n+w+1].
      ḷ                 Left; yield n.
    œ^                  Multiset OR; if n belongs to the prime range, remove it; if
                        it does not, append it.
       ,ḷ               Wrap the resulting array and n into a pair.
         ’              Decrement all involved integers.
          d             Divmod; map each integer k to [k/w, k%w].
           ạ/           Reduce by absolute difference, subtracting [n/w, n%w] from
                        each [k/w, k%w] and taking absolute values.
             Ṁ€         Take the maximum of each resulting pair.
                        A maximum of 0 means that n is not prime.
                        A maximum of 1 means that n has a prime neighbor.
               Ṃ        Take the minimum of the maxima.
                Ḋ       Dequeue; map the minimum m to [2, ..., m].
                        This array is non-empty/truthy iff m > 1.

Java 8, 176 165 bytes
w->i->{for(;!p(i)|p(i-w)|p(i+w)|i%w>1&(p(--i)|p(i-w)|p(i+w))|++i%w>0&(p(++i)|p(i-w)|p(i+w)););return~-i;}boolean p(int n){for(int i=2;i<n;n=n%i++<1?0:n);return n>1;}

Port of Jonathan Frech' C answer.
-11 bytes thanks to @ceilingcat.
Try it online.

Jelly,  30  29 bytes
My guess is this is probably beatable by a fair margin
ÆPŒR+€×¥+©⁸’:⁹Ġ®ṁLÞṪFÆPS’¬ð1#

A dyadic link taking i on the left and w on the right which returns the lonely prime.
Try it online!
How?
ÆPŒR+€×¥+©⁸’:⁹Ġ®ṁLÞṪFÆPS’¬ð1# - Link: i, w                     e.g. 37, 12
                           1# - find the 1st match starting at i and counting up of...
                          ð   - ...everything to the left as a dyadic link
                              - (n = i+0; i+1; ... on the left and w on the right):
ÆP                            -   is i prime: 1 if so, 0 if not     1
  ŒR                          -   absolute range: [-1,0,1] or [0]   [-1,0,1]
       ¥                      -   last two links as a dyad (w on the right):
      ×                       -     multiply (vectorises)           [-12,0,12]
    +€                        -     add for €ach       [[-13,-1,11],[-12,0,12],[-11,1,13]]
                              -     - i.e. the offsets if including wrapping
          ⁸                   -   chain's left argument, i
        +                     -   add                  [[24,36,48],[25,37,49],[26,38,50]]
                              -     - i.e. the adjacents if including wrapping
         ©                    -   copy to the register
           ’                  -   decrement            [[23,35,47],[24,36,48],[25,37,49]]
             ⁹                -   chain's right argument, w
            :                 -   integer division               [[1,2,3],[2,3,4],[2,3,4]]
              Ġ               -   group indices by value         [[1],[2,3]]
                              -     - for a prime at the right this would  be [[1,2],[3]]
                              -     - for a prime not at an edge it would be [[1,2,3]]
               ®              -   recall from register [[24,36,48],[25,37,49],[26,38,50]]
                ṁ             -   mould like           [[24,36,48],[[25,37,49],[26,38,50]]]
                  Þ           -   sort by:
                 L            -     length             [[24,36,48],[[25,37,49],[26,38,50]]]
                   Ṫ          -   tail                             [[25,37,49],[26,38,50]]
                              -     - i.e the adjacents now excluding wrapping
                    F         -   flatten                          [25,37,49,26,38,50]
                     ÆP       -   is prime? (vectorises)           [0,1,0,0,0,0]
                       S      -   sum                              1
                        ’     -   decrement                        0
                         ¬    -   not                              1

My guess is this is probably beatable by a fair margin are you sure? It's not an easy thing for golfing languages.

No, but it's my guess that (even) in Jelly (if not husk!!) that there could be a few ways to save on my method, or even a better approach.

Clean, 181 ... 145 bytes
import StdEnv
@w i=hd[x+y\\y<-[0,w..],x<-[1..w]|x+y>=i&&[x+y]==[a+b\\a<-[y-w,y,y+w]|a>=0,b<-[x-1..x+1]|0<b&&b<w&&all((<)0o(rem)(a+b))[2..a+b-1]]]

Try it online!
Ungolfed:
@ w i
    = hd [
        x+y
        \\ y <- [0, w..]
        ,  x <- [1..w]
        | x+y >= i && [x+y] == [
            a+b
            \\ a <- [y-w, y, y+w]
            | a >= 0
            ,  b <- [x-1..x+1]
            | 0 < b && b < w && all ((<) 0 o (rem) (a+b)) [2..a+b-1]
            ]
        ]