text:
The biggest square
This question is similar to Biggest Square in a grid.
Challenge
Given a matrix of 1 and 0 in a string format "xxxx,xxxxx,xxxx,xx.." or array format ["xxxx","xxxx","xxxx",...], You will create a function that determines the area of the largest square submatrix that contains all 1.
A square submatrix is one of equal width and height, and your function should return the area of the largest submatrix that contains only 1.
For Example:
Given "10100,10111,11111,10010", this looks like the following matrix:
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
You can see the bolded 1 create the largest square submatrix of size 2x2, so your program should return the area which is 4.
Rules

Submatrix must be one of equal width and height
Submatrix must contains only values 1
Your function must return the area of the largest submatrix
In case no submatrix is found, return 1
You can calculate the area of the submatrix by counting the number of 1 in the submatrix

Test cases
Input: "10100,10111,11111,10010" Output: 4
Input: "0111,1111,1111,1111" Output: 9
Input "0111,1101,0111" Output: 1

This is code-golf, so the shortest answer in bytes win.

Why string format?

Done, Thanks for your suggestions @StewieGriffin

Isn't this an exact duplicate of the question you linked to? The only thing different is the IO format and the delimiters.

Can we take the input as a binary (numeric) matrix?

This looks very similar to the (now deleted) challenge Squares, so many squares.

@Nit Not exactly. First the other one is a closed, out of topic question. also is not code-golf, it is fastest-code. That's why i came with this one. Hope it is no problem with it

@StewieGriffin No sorry. Just array or string input

@JonathanFrech Sorry, never saw that question. Hope there is no problem

Is ["xxxx";"xxxx";"xxxx";...] ok a input?

@StewieGriffin Yes

For [0] still required to output 1?

@l4m2 Yes. Remember, In case no submatrix is found, return 1

Hang about, why return 1 when no all-1 sub-matrix is found, wouldn't 0 make much more sense? (Otherwise it is simply a special case to handle)

As it stands I think both answerers would not mind if you changed the specs and I strongly recommend doing so because there's no point for returning 1 and it doesn't make the submissions more interesting.

This question appears to be taken from here.

Jelly, 18 bytes
+2 to handle no-all-1 sublist present output
ẆZṡ¥"L€$ẎȦÐfL€Ṁ²»1

Try it online! Or see the test-suite
How?
ẆZṡ¥"L€$ẎȦÐfL€Ṁ²»1 - Link: list of lists of 1s and 0s
Ẇ                  - all slices (lists of "rows") call these S = [s1,s2,...]
       $           - last two links as a monad:
     L€            -   length of each (number of rows in each slice) call these X = [x1, x2, ...]
    "              -   zip with (i.e. [f(s1,x1),f(s2,x2),...]):
   ¥               -     last two links as a dyad:
 Z                 -       transpose (get the columns of the current slice)
  ṡ                -       all slices of length xi (i.e. squares of he slice)
        Ẏ          - tighten (to get a list of the square sub-matrices)
          Ðf       - filter keep if:
         Ȧ         -   any & all (all non-zero when flattened?)
            L€     - length of €ach (the side length)
              Ṁ    - maximum
               ²   - square (the maximal area)
                »1 - maximum of that and 1 (to coerce a 0 found area to 1)

Awesome. Can you add some explanation?

I will, I'm trying to think of shorter first...

@Mr.Xcoder I have updated to handle the requirement for now

Haskell, 113 121 118 117 bytes
x!s=[0..length x-s]
t#d=take t.drop d
f x=last$1:[s*s|s<-min(x!0)$x!!0!0,i<-x!!0!s,j<-x!s,all(>'0')$s#i=<<(s#j)x,s>0]

Try it online!
-3 bytes thanks to Laikoni!
-1 byte thanks to Lynn!
+8 bytes for the ridiculous requirement of returning 1 for no all-1s sub-matrix..
Explanation/Ungolfed
The following helper function just creates offsets for x allowing to decrement them by s:
x!s=[0..length x-s]

x#y will drop y elements from a list and then take x:
t#d=take t.drop d

The function f loops over all possible sizes for sub-matrices in order, generates each sub-matrix of the corresponding size, tests whether it contains only '1's and stores the size. Thus the solution will be the last entry in the list:
--          v prepend a 1 for no all-1s submatrices
f x= last $ 1 : [ s*s
                -- all possible sizes are given by the minimum side-length
                | s <- min(x!0)$x!!0!0
                -- the horizontal offsets are [0..length(x!!0) - s]
                , i <- x!!0!s
                -- the vertical offsets are [0..length x - s]
                , j <- x!s
                -- test whether all are '1's
                , all(>'0') $
                -- from each row: drop first i elements and take s (concatenates them to a single string)
                              s#i =<<
                -- drop the first j rows and take s from the remaining
                                      (s#j) x
                -- exclude size 0...........................................
                , s>0
                ]

APL (Dyalog Unicode), 35 34 32 bytes
{⌈/{×⍨⍵×1∊{∧/∊⍵}⌺⍵ ⍵⊢X}¨⍳⌊/⍴X←⍵}

Try it online!
Adám's SBCS has all of the characters in the code
Explanation coming eventually!

You had me at 'explanation', lol.

Haskell, 99 97 bytes
b s@((_:_):_)=maximum$sum[length s^2|s==('1'<$s<$s)]:map b[init s,tail s,init<$>s,tail<$>s]
b _=1

Checks if input is a square matrix of just ones with s==('1'<$s<$s), if it is, answer is length^2, else 0. Then recursively chops first/last column/row and takes the maximum value it finds anywhere.
Try it online!

J, 33 27 bytes
-6 bytes thanks to FrownyFrog!
[:>./@,,~@#\(#**/)@,;._3"$]

Try it online!
Explanation:
I'll use the first test case in my explanation:
    ] a =. 3 5$1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1

I generate all the possible square submatrices with size from 1 to the number of rows of the input.
,~@#\ creates a list of pairs for the sizes of the submatrices by stitching ,. togehter the length of the successive prefixes #\ of the input:
   ,~@#\ a
1 1
2 2
3 3

Then I use them to cut x u ;. _3 y the input into submatrices. I already have x (the list of sizes); y is the right argument ] (the input).
 ((,~@#\)<;._3"$]) a
┌─────┬─────┬─────┬───┬─┐
│1    │0    │1    │0  │0│
│     │     │     │   │ │
│     │     │     │   │ │
├─────┼─────┼─────┼───┼─┤
│1    │0    │1    │1  │1│
│     │     │     │   │ │
├─────┼─────┼─────┼───┼─┤
│1    │1    │1    │1  │1│
└─────┴─────┴─────┴───┴─┘

┌─────┬─────┬─────┬───┬─┐
│1 0  │0 1  │1 0  │0 0│ │
│1 0  │0 1  │1 1  │1 1│ │
│     │     │     │   │ │
├─────┼─────┼─────┼───┼─┤
│1 0  │0 1  │1 1  │1 1│ │
│1 1  │1 1  │1 1  │1 1│ │
├─────┼─────┼─────┼───┼─┤
│     │     │     │   │ │
└─────┴─────┴─────┴───┴─┘

┌─────┬─────┬─────┬───┬─┐
│1 0 1│0 1 0│1 0 0│   │ │
│1 0 1│0 1 1│1 1 1│   │ │
│1 1 1│1 1 1│1 1 1│   │ │
├─────┼─────┼─────┼───┼─┤
│     │     │     │   │ │
│     │     │     │   │ │
├─────┼─────┼─────┼───┼─┤
│     │     │     │   │ │
└─────┴─────┴─────┴───┴─┘

For each submatrix I check if it consist entirely of 1s:
(#**/)@, - flatten the matrix, and mutiply the number of items by their product. If all items are 1s, the result will be their sum, otherwise - 0:
   (#**/)@, 3 3$1 0 0 1 1 1 1 1 1
0
   (#**/)@, 2 2$1 1 1 1
4

   ((,~@#\)(+/**/)@,;._3"$]) a
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 4 4 0
0 0 0 0 0

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

Finally I flatten the list of results for each submatrix and find the maximum:
>./@,
   ([:>./@,,~@#\(+/**/)@,;._3"$]) a
4

,~@#\ and "1 2 -> "$

@FrownyFrog Thank you! I didn't know about "$

# is shorter than adding up the 1s.

@ FrownyFrog Hmm, it really is. Cool, thanks!

K (ngn/k), 33 28 bytes
{*/2#+/|/',/'{0&':'0&':x}\x}

Try it online!

I never knew you had a K version!

Ruby -n, 63 bytes
p (1..l=$_=~/,|$/).map{|i|/#{[?1*i]*i*(?.*(l-i+1))}/?i*i:1}.max

Try it online!
Ruby version of my Python answer. Golfier as a full program. Alternatively, an anonymous lambda:
Ruby, 70 68 bytes
->s{(1..l=s=~/,|$/).map{|i|s=~/#{[?1*i]*i*(?.*(l-i+1))}/?i*i:1}.max}

Try it online!

Retina, 143 bytes
%`$
,;#
+%(`(\d\d.+;#)#*
$1¶$&¶$&#
\G\d(\d+,)|\G((;#+¶|,)\d)\d+
$1$2
)r`((11)|\d\d)(\d*,;?#*)\G
$#2$3
1,
#
Lv$`(#+).*;\1
$.($.1*$1
N`
-1G`
^$
1

Try it online! Link includes test cases. Takes input as comma-separated strings. Explanation:
%`$
,;#

Add a , to terminate the last string, a ; to separate the strings from the #s and a # as a counter.
+%(`
)

Repeat the block until no more subsitutions happen (because each string is now only one digit long).
(\d\d.+;#)#*
$1¶$&¶$&#

Triplicate the line, setting the counter to 1 on the first line and incrementing it on the last line.
\G\d(\d+,)|\G((;#+¶|,)\d)\d+
$1$2

On the first line, delete the first digit of each string, while on the second line, delete all the digits but the first.
r`((11)|\d\d)(\d*,;?#*)\G
$#2$3

On the third line, bitwise and the first two digits together.
1,
#

At this point, each line consists of two values, a) a horizontal width counter and b) the bitwise and of that many bits taken from each string. Convert any remaining 1s to #s so that they can be compared against the counter.
Lv$`(#+).*;\1
$.($.1*$1

Find any runs of bits (vertically) that match the counter (horizontally), corresponding to squares of 1s in the original input, and square the length.
N`

Sort numerically.
-1G`

Take the largest.
^$
1

Special-case the zero matrix.

JavaScript, 92 bytes
a=>(g=w=>a.match(Array(w).fill(`1{${w}}`).join(`..{${W-w}}`))?w*w:g(w-1))(W=a.indexOf`,`)||1

f=
a=>(g=w=>a.match(Array(w).fill(`1{${w}}`).join(`..{${W-w}}`))?w*w:g(w-1))(W=a.indexOf`,`)||1
console.log(f('0111,1111,1111,1111'));
console.log(f('10100,10111,11111,10010'));
console.log(f('0111,1101,0111'));

APL (Dyalog Classic), 21 20 bytes
×⍨{1∊⍵:1+∇2×/2×⌿⍵⋄0}

Try it online!

Recursion! Nice!

@Zacharý Thanks. Actually, instead of recursion I'd prefer something like k's f\x for a monadic f, which is  (x; f x; f f x; ...) until convergence, but there's no equivalent in APL (yet). Doing it with ⍣≡ takes too many bytes.

Python 2, 117 109 bytes
Credit to @etene for pointing out an inefficiency that cost me an additional byte.
lambda s:max(i*i for i in range(len(s))if re.search(("."*(s.find(',')-i+1)).join(["1"*i]*i),s))or 1
import re

Try it online!
Takes input as a comma-separated string. This is a regex-based approach that tries matching the input string against patterns of the form 111.....111.....111 for all possible sizes of the square.
In my calculations, doing this with an anonymous lambda is just a tad shorter than defined function or a full program. The or 1 part in the end is only necessary to handle the strange edge case, where we must output 1 if there are no ones in the input.

Python 2, 116 115 117 109 bytes
Credits to @Kirill for helping me golf it even more and for his clever & early solution
Edit: Golfed 1 byte by using a lambda, I didn't know assigning it to a variable didn't count towards the byte count.
Edit 2: Kirill pointed out my solution didn't work for cases where the input only contains 1s, I had to fix it and lost two precious bytes...
Edit 3: more golfing thanks to Kirill
Takes a comma separated string, returns an integer.
lambda g:max(i*i for i in range(len(g))if re.search(("."*(g.find(",")+1-i)).join(["1"*i]*i),g))or 1
import re

Try it online!
I independently found an answer that is close to Kiril's one, i.e regex based, except that I use re.search and a def.
It uses a regex built during each loop to match an incrementally larger square and returns the largest one, or 1.

Nice, I somehow automatically discarded the if approach as "too long for sure", but then had to make up some other way to make a bool value out of the match. Unfortunately, your solution misses one point - you cannot have just range(l) - it will miss the case when there are no zeroes at all. E.g., take 2nd test case and make it all 1s - it should become 16, not 9.

Damn, I thought about testing with all zeroes but not with all ones (never mentioned in the challenge...). I'll try to make something up.

@KirillL. by the way, you're fast ! I was still working on my answer when you posted yours and was a bit bummed (and proud!) when I saw our approaches were similar... the level around here is impressive.

Golfed a few more bytes by getting rid of duplicated find. Now that our codes are not identical anymore, I suggest we at least fix the obvious mistakes from each other - in your case the extra byte comes from using tuple ("1"*i,) instead of list.

Thank you, yeah the useless tuple is pretty stupid on my part. And the extra find too, that was clever of you.

Python 2, 138 128 bytes
def f(m):j=''.join;L=j(m);k=map(j,zip(*m));return len(L)and max(len(L)*(len(m)**2*'1'==L),f(k[1:]),f(k[:-1]),f(m[1:]),f(m[:-1]))

Try it online!

Saved

-10 bytes thanks to ovs

Perl 6, 61 60 58 bytes
{(^$_ X.. ^$_).max({[~&](.[|$^r||*])~~/$(1 x$r)/&&+$r})²}

Try it online!

Clojure, 193 bytes
#(apply max(for [f[(fn[a b](take-while seq(iterate a b)))]R(f next %)R(f butlast R)n[(count R)]c(for[i(range(-(count(first R))n -1)):when(apply = 1(for[r R c(subvec r i(+ i n))]c))](* n n))]c))

Wow, things escalated :o
Less golfed:
(def f #(for [rows (->> %    (iterate next)    (take-while seq)) ; row-postfixes
              rows (->> rows (iterate butlast) (take-while seq)) ; row-suffixes
              n    [(count rows)]
              c    (for[i(range(-(count(first rows))n -1)):when(every? pos?(for [row rows col(subvec row i(+ i n))]col))](* n n))] ; rectangular subsections
          c))


text:
Auto cycler quine
Make a quine but with a twist.
Statement
The quine prints its code but puts its first character at the end.
(You can do it in reverse but include that note in your answer)
The output must then be a program which is also an solution.
Example: Assume your code was foobar, running it will return oobarf which will be another valid program.
foobar -> oobarf
oobarf -> obarfo
obarfo -> barfoo
barfoo -> arfoob
arfoob -> rfooba
rfooba -> foobar
Rules

Your code must not be an output of some generation of someone else's code that's quite obviously stealing
Your code must be more than 2 characters long (so short code is no fun)
Your code must contain at least two different characters (ex: +++ is not valid)

Scoring
As a code-golf challenge the shortest code wins.

Well that's upsetting: https://codegolf.meta.stackexchange.com/a/14104/9365

@DomHastings You've had months to post that.

@DomHastings Oh well, sorry. I guess we both had the same idea. I have by no means stole your idea though, that would be a false claim.

@mbomb007 I have indeed! I'd kinda forgotten about the items in the sandbox, but there you go! :)

@IQuick143 Yeah no problem, I wasn't implying that at all! Life has been busy lately and I'd forgotten it was even in the sandbox until I saw your post!

Is [exactly 2 char] allowed? (seems not to avoid stack-based language AB)

@l4m2 It states more than 2 char because your code would actually print it's reverse which is kinda not the point, also if my expectation is correct some language allows for pushing two characters in stack and then emptying the stack by just 2 characters which Would fulfil a reverse quine challenge but not this one (technically). tl;dr I didn't mean to allow exactly 2 char but if you have a reason why I'm willing to listen.

@IQuick143 I think >2 characters is a good requirement for the reason you stated

In tcl, I couldonly do one step: puts [string index [set c [read [open $argv0]]] end][string range $c 0 end-1] https://tio.run/##NcoxCsAgDEbhq/yDa8GeRzKIBhFKlJiW3j5th47v41k53OdpC2mZdmnoUvl@iw0FSTlXpDFZELK2KxIRWCr9u2ZpjFAQP952cvcH

I'd recommend mentioning the standard valid quine rules

<marquee>my code</marquee>

Possible duplicate of Create a rotating quine

Retracted my close vote. The other question is in essence bowling if someone finds a solution.

Would this count as a 'rotating quine'? ;p

@jimmy23013 5083 is such a problem but code-bowling version

sorry no for it div the repeat part length

@jimmy23013 I checked if a challenge like this one exists and saw the one you linked but this is a different challenge. The point of this one is that your program must survive byte shifting while remaining functional while the mentioned one requires only rotating 2 or more whole parts.

Currently working on a non-cheating Funge-98 Quine. Progress: ~25%

Well, it's easy to think of languages this is impossible in... Any BF-like program doesn't work, because you can shift to arrive at an unbalanced bracket. Same for JS if you have = or parentheses or brackets. More widely stated: a program cannot contain any character that cannot also be the first character. That rules out so many...

@mbomb007 Finding a language that this is possible in is a part of the challenge

Slowly getting there, currently writing a C# program to generate the final source code in Befunge-98

Befunge-98 (PyFunge), 2600 bytes
ab*1'3:*2+*0pnd3*:::::::::::::::1'3:*3+*0p1'3:*5+*0p1'3:*d+*0p1'3:*f+*0p1'3:*fa++*0p1'3:*fd++*0p1'4'3*f-*0p1'4'3*7-*0p1'4'3*5-*0p6:*:*4-1p6:*:*4+1p6:*:*8+1p6:*:*a+1p6:*:*8+2p6:*:*f1++2p6:*:*f3++2pn75*1-:1'3:*4+*0p6:*:*f2++2pnaa*:::::::::::::::::1'3:*6+*0p1'3:*7+*0p1'3:*f1++*0p1'3:*f2++*0p1'3:*fe++*0p1'3:*ff++*0p1'4'3*e-*0p1'4'3*d-*0p1'4'3*4-*0p1'4'3*3-*0p6:*:*3-1p6:*:*2-1p6:*:*b+1p6:*:*c+1p6:*:*9+2p6:*:*a+2p6:*:*f4++2p6:*:*f5++2pn67*::::::::::1'3:*8+*0p1'3:*a+*0p1'3:*f4++*0p1'3:*f5++*0p1'4'3*f-5-*0p1'4'3*c-*0p1'4'3*2-*0p6:*:*1-1p6:*:*d+1p6:*:*b+2p6:*:*f6++2pna5*::1'3:*9+*0p1'3:*f3++*0p6:*:*1pn68*:::::1'3:*b+*0p1'3:*f8++*0p1'4'3*f-2-*0p1'4'3*9-*0p1'4'3*1+*0p6:*:*f7++2pne8*:::::::1'3:*c+*0p1'3:*f9++*0p1'4'3*f-1-*0p1'4'3*8-*0p1'4'3*2+*0p6:*:*f2++1p6:*:*f+2p6:*:*f8++2pnf4*:1'3:*e+*0p1'4'3*3+*2pn77*::::1'3:*f6++*0p1'4'3*f-4-*0p6:*:*f1++1p6:*:*c+2p6:*:*e+2pnb4*1-::1'3:*f7++*0p6:*:*f+1p6:*:*d+2pnf4*1-::1'3:*fb++*0p6:*:*7+2p1'3:*1+*2pnf4*2-1'3:*fc++*0pn95*:::1'4'3*f-3-*0p1'4'3*a-*0p1'4'3**0p6:*:*1+1pn87*1'4'3*b-*0pnac*2-:1'4'3*6-*0p1'4'3*3+*0pnf4*3-1'4'3*1-*0pn88*2-6:*:*5-1pnc9*1-6:*:*2+1pnb4*:6:*:*3+1p6:*:*6+1pn88*6:*:*9+1pnd4*1-6:*:*e+1pnc8*2-:1'3:**1p1'3:**2pnd7*2+6:*:*4+2pn75*6:*:*6+2pn>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>ab*1'3:*2+*0pnd3*:::::::::::::::1'3:*3+*0p1'3:*5+*0p1'3:*d+*0p1'3:*f+*0p1'3:*fa++*0p1'3:*fd++*0p1'4'3*f-*0p1'4'3*7-*0p1'4'3*5-*0p6:*:*4-1p6:*:*4+1p6:*:*8+1p6:*:*a+1p6:*:*8+2p6:*:*f1++2p6:*:*f3++2pn75*1-:1'3:*4+*0p6:*:*f2++2pnaa*:::::::::::::::::1'3:*6+*0p1'3:*7+*0p1'3:*f1++*0p1'3:*f2++*0p1'3:*fe++*0p1'3:*ff++*0p1'4'3*e-*0p1'4'3*d-*0p1'4'3*4-*0p1'4'3*3-*0p6:*:*3-1p6:*:*2-1p6:*:*b+1p6:*:*c+1p6:*:*9+2p6:*:*a+2p6:*:*f4++2p6:*:*f5++2pn67*::::::::::1'3:*8+*0p1'3:*a+*0p1'3:*f4++*0p1'3:*f5++*0p1'4'3*f-5-*0p1'4'3*c-*0p1'4'3*2-*0p6:*:*1-1p6:*:*d+1p6:*:*b+2p6:*:*f6++2pna5*::1'3:*9+*0p1'3:*f3++*0p6:*:*1pn68*:::::1'3:*b+*0p1'3:*f8++*0p1'4'3*f-2-*0p1'4'3*9-*0p1'4'3*1+*0p6:*:*f7++2pne8*:::::::1'3:*c+*0p1'3:*f9++*0p1'4'3*f-1-*0p1'4'3*8-*0p1'4'3*2+*0p6:*:*f2++1p6:*:*f+2p6:*:*f8++2pnf4*:1'3:*e+*0p1'4'3*3+*2pn77*::::1'3:*f6++*0p1'4'3*f-4-*0p6:*:*f1++1p6:*:*c+2p6:*:*e+2pnb4*1-::1'3:*f7++*0p6:*:*f+1p6:*:*d+2pnf4*1-::1'3:*fb++*0p6:*:*7+2p1'3:*1+*2pnf4*2-1'3:*fc++*0pn95*:::1'4'3*f-3-*0p1'4'3*a-*0p1'4'3**0p6:*:*1+1pn87*1'4'3*b-*0pnac*2-:1'4'3*6-*0p1'4'3*3+*0pnf4*3-1'4'3*1-*0pn88*2-6:*:*5-1pnc9*1-6:*:*2+1pnb4*:6:*:*3+1p6:*:*6+1pn88*6:*:*9+1pnd4*1-6:*:*e+1pnc8*2-:1'3:**1p1'3:**2pnd7*2+6:*:*4+2pn75*6:*:*6+2pn>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Try it online!
This making this was a hellfest.
How this works:
The program is a bunch of put statements that assembles a Program B around itself which then prints half of the source byte shifted twice.
The program is actually 2 copies of a 1300 byte program, this is so it's ensured that the whole 1300 byte program always gets ran as a whole.
Better explanation:
Every Befunge-98 quine needs to contain symbols such a @ or q and ,
Problem: None of those symbols are a good starting point especialy since @ and q terminate the program instantly.
Solution: Get rid of those characters in the source code
Problem: How?
Solution: Use p (put) commands to modify the source code to include the required characters which will print the contains of the source code shifted by one byte and not use the g command which is cheating.
Problem: (sigh when will these end)
A put command pops 3 values n x y which determine character, x-coord, y-coord however when the initialization of these values is split in half it can write bad characters in the beginning source code making it useless for quining.
Solution: (last one I promise)
Use 2 copies of the source code, the latter one being the "correct one" this accidentally fixes another problem which is that a put statement (p command + the constant initializers) which is split in half will not get executed, this is fixed by having 2 copies of each statement.
Last thing this needs to work is how do we make the whole source code out of a half?
Answer:

This is visual proof of why two copies of a string byte shifted == Two copies of a byte shifted string. That means we can take a half of the code, byte shift it, then print it twice (OR take half of the code, byte shift it, print, repeat [That's what actually happens])
How this is implemented:
Assume 0123456789abcdef is the source
Befunge Pseudocode:
0123456789abcv;;"123456789abcdef" < go this way <--
             >PS'0,   repeat 2x   ^

PS means Print Stack (not a real instruction).
We push half of the source code in reverse onto the stack using "" then we print the stack and then we fetch (' command) the first character 0 which we move in front of the ' and print it last which causes the byte shift, then we repeat the cycle once more to print the second copy.
One technicality to deal with are the symbols inside the source, this can cause trouble if we write it while executing the source code, I circumvented this by adding more put statements which take care of it externally.
This makes the code look something like this:

Explanation:
Green Highlight: Code that takes care of adding characters into the source
Grey Letters (probs poor visibility sorry): Code that gets added by green code
Red Highlight: Code that moves first character of the second half of source code into the Blue area.
Blue Highlight: See Red Highlight
Orange Highlight: Code that makes sure we terminate after we wrote 2 byte shifted copies by putting a @ (terminate) command into the Yellow Area.
Arrows should hopefully make it clearer how the code flow goes.
Here comes the last tough part:
Where do babies source code come from?
Short answer: C# Magic
Long answer: 100+ Befunge code snippets made by hand compiled by C# code.
I manually wrote about 100 constant initializers (a piece of befunge code that pushes a certain number to stack) by hand and then used a custom C# program to compile it into the 1300 byte Befunge output, which I then copy pasted twice and made the final program.
Are you still here? Great thank you for reading! (or at least scrolling to the end)
I hope my bad jokes were fun and not annoying.
Note: No put statement in this code creates a g command which would be cheating.
EDIT: I have verified the code using the following Javascript code in TIO using developer tools
setInterval(()=>{document.getElementById("code").value =
document.getElementById("output").value;
document.getElementById("run").click();}, 2000);

I'm really looking forward to the full explanation, but this seems like quite an achievement and certainly deserves the bounty!

@Nathaniel There goes the full Explanation hope you like it! :D

That part about dealing with p with incorrect arguments is genius.

@lQuick indeed I do!

Nice answer! 6:*:*4+ can be aa*d*. Do you still have a list of the initializers?

@ovs I have the list but there's no point in golfing this code because as you can see the >>>>>>>>> in the source code pad the code to be 1300 bytes. This is because I needed to know the size of the program before writing it so I made an estimate of 1300 bytes and worked with that. Thanks for the tip anyway :D. BTW: I think the list is too large for comments.

source: Stack Exchange

license: 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/

sort: votes


text:
Rope&Nail logic
Related, both rope, nail and falling, but reversed and some other differences
Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist.
Here, "fall down" means the rope can be moved far away from the nails. That means, we treat a rope just placing on nails as "fall down".
We express a roping way as the space where the rope go up/down the line where nails are placed, left-most space as space 0 and right-most space as space n.
Sample input:
(whether removed or not)
Nail1 Nail2 Nail3 Nail4 Fall
  0     0     0     0     0
  0     0     0     1     0
  0     0     1     0     0
  0     0     1     1     0
  0     1     0     0     0
  0     1     0     1     0
  0     1     1     0     0
  0     1     1     1     0
  1     0     0     0     0
  1     0     0     1     0
  1     0     1     0     0
  1     0     1     1     1
  1     1     0     0     0
  1     1     0     1     0
  1     1     1     0     0
  1     1     1     1     1

Sample output
0 1 2 4

Explanation

In this case, if we draw a horizontal line through the nails, it intersects the rope at position 0, 1, 2, 4 in the order of the rope. Note that because the loop is closed, if you use this output format then the length of the output is always even.
Sample input:
(whether removed or not)
Nail1 Nail2 Fall
  0     0    0
  0     1    1
  1     0    1
  1     1    1

Sample output
1 2 0 1 2 0

Explanation

The way to input is quite free. You can input as function, map, array with removed nail set in fixed order, or other reasonable method. Inverting either or both nail logic and fall logic are also allowed. Output should be array-like, so string separated by some char is also allowed.
Code golf, shortest code win. Optimizing the length of the output but weaker in code length won't be accepted, but may be upvoted.

@NathanMerrill That challenge is quite different from this one. That challenge asks whether the roping done will cause the picture to fall, this challenge asks for a roping given all removals of nails which will cause the picture to fall. The challenge you linked mentions nothing of removing nails.

Are the nails always in a row? Also some explanation of the output format would be nice, it took me some while to get that the numbers describe the space between nails.

Sandbox with totally symbolled explanation

The point of the sandbox is to get feedback on the question in the form in which you will post it. If you make major changes then you should edit the sandbox answer.

@user202729 done :)

In second sample,  with just second nail removed, rope won't fall. Isn't it?

@DeadPossum It turns into a rope placing on the left of the first nail

@DeadPossum When you remove the nail the remaining nail is entirely outside of the closed loop.  I implore you to actually attempt is either on paper or on string.  You will see that it most definitely does fall.

@WhatWizard Oh, now I get it, thank you

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


text:
Simple golfing interpreter
Challenge:
Your job is to create a simple interpreter for a simple golfing language.

Input:
Input will be in the form of string separated by spaces.
You can replace space separation with what you want

Output:
Output the result (a number or a string) obtained after performing all operations. If there are more than one output join the together to give a single result (no separators). The variable's initial value is always zero. i.e: It start at 0

Language Syntax :
The language has following operators :
inc  ---> add one to variable
dec  ---> remove one from variable
mult ---> multiply variable by 2
half ---> divide the variable by 2
Pri  ---> print the variable to console (or whatever your language has)
exit ---> end the program (anything after this is ignored)

Examples:
inc inc inc dec Pri exit                 ---> 2
dec inc mult inc inc Pri                 ---> 2
inc inc inc mult half Pri exit inc       ---> 3
inc Pri inc Pri inc Pri exit half mult   ---> 123
Pri exit                                 ---> 0
inc half Pri exit                        ---> 0.5

Restriction:
This is code-golf so shortest code in bytes for each language will win.

Note:

Input will always be valid . (string of operators separated with space)
You can round down to nearest integer if you don't want decimal places.

Can I take a list of strings? Can I use another capitalization?

Add exit case? exit should matter

@MuhammadSalman how many decimal places should we support? Is it okay if we round down when dividing?

@Cowsquack : I guess 2 decimal places will be fine ,  although yeah you can round down if you want.

So does that mean it is okay that inc half Pri gives 0 instead of 0.5?

@l4m2 : What do you mean ?

@Cowsquack : No , this should return 0.5 or 1 , No zero if even a single operation is performed. (I am willing to change it if it makes golfing easier since these things barely matter)

@MuhammadSalman let's continue this conversation in chat

Is it possible to separate each printed value with newlines or should they all be on the same line ?

@Kaldo : You can separate using new lines

Hmm, I wouldn't call that language "golfing language".

@PaŭloEbermann : Haha , Well I agree , but golfing language it is

This is Deadfish with double and half instead of square and longer command names

Should Pri print out without newline?

@idrougge : Yes

shell + sed + dc, 56 61 bytes
sed '1i0
s/.//2g;y"idmhe"+-*/q";i1
/[*/]/i1+
/P/crdn'|dc

Try it online!
Converts the program into a dc program, then evaluates it as dc code. This takes the input separated by newlines. Note that dc is stack-based and uses reverse polish notation, so 5 2- gives 3, and numbers are always rounded down.
The input is first piped to sed
1i0 on the first line of input, insert (prepend) a 0, this will be the accumulator
s/.//2g remove everything but the first character on each line
y"idmhe"+-*/q" transliterate idmhe into +-*/q respectively, + - * / are the arithmetic commands and q quits the program
i1 on every line insert a 1 - this satisfies addition and subtraction
/[*/]/ on every line containing * or /, i1+ additionally insert 1+ because of the preceding 1, which dc will eventually evaluate into 2
/P/ on every line containing P, crdn change it into rdn, equivalent to reverse the top two elements, to rid the inserted 1, and duplicate and output as a number without newline (whilst popping it, hence the earlier duplicate) in dc
Now this is evaluated as a dc expression.

I suppose it's not unreasonable to expect sed syntax to become even more alien than previously thought possible when golfing comes into play.

Jelly, 21 bytes
ḲḢ€O%11ị⁾’‘j“IȮḤH”¤VI

Try it online!

Note that the ASCII values of the first characters (idmhPe) modulo 11 are unique modulo 6.

Using modulo 16:
Jelly, 21 bytes
ḲḢ€O%⁴ị“ḢwġḞkz’ṃØJ¤VI

Try it online!
The string that is used to index into is ḤH‘’IȮ in this case. The ‘’ are no longer on the boundaries.

Using 11 bytes to represent a 6-byte string is... too bad. But... “” takes 2 bytes, ¤ takes 1 byte, the data itself takes 6 bytes, there are 2 bytes left to do something. Currently it's ⁾ and j, but ịØJ or ṃØJ is much worse, and Ọ doesn't work (because Unicode).

jli's string concept ("A string is a list of integers with a special flag to affect printing") is great.

R, 128 125 bytes
Reduce(function(x,y)switch(y,i=x+1,d=x-1,m=x*2,h=x/2,P={cat(x);x}),substr(el(strsplit(gsub("e.*$","",scan(,""))," ")),1,1),0)

Try it online!
Must be called with source(echo=FALSE) to prevent the return value from being printed automatically. The alternative would be to wrap everything in invisible but that's much less golfy (and ruins my [still] nice byte count).

05AB1E, 25 bytes
Î€¬"idmhPe"S"><·;=q"S‡J.V

Try it online!
Maps each of the language function with the corresponding 05AB1E function (using the first char of each function), and then executes the resulting string as 05AB1E code.

Python 3, 110 91 82 bytes
exit will cause the program to exit with an error.
x=0
for c in input():c=='P'==print(x,end='');x+=(1,-1,x,-x/2,c,0)['ndmhx'.find(c)]

Try it online!

Shorten your variable names to save 9 bytes. i='x+=1';d='x-=1';... and then in your exec call, change it to exec(eval(c[0]))

@mypetlion Thanks, but I found a better way.

I think this is valid: 82 bytes

@Lynn That's great! I couldn't think of a nice way to short-circuit to the print statement!

JavaScript (ES6), 77 75 bytes
(Borrowed (stole) @Arnauld's trick of using m as the variable name, saving 2 bytes.)
f=([c,...s],m=0)=>c<'x'?(c=='P'?m:'')+f(s,m+({h:-m/2,d:-1,n:1,m}[c]||0)):''

Recursively walks the string, looking for distinct letters per instruction and ignoring the rest:

n: inc
d: dec
m: mult
h: half
P: Pri
x: exit

Takes advantage of the fact that undefined is neither greater than nor less than 'x', causing the recursion to stop at the end of the string or when it encounters the 'x' in exit.

f=([c,...s],n=0)=>c<'x'?(c=='P'?n:'')+f(s,n+({h:-n/2,d:-1,n:1,m}[c]||0)):''

console.log(f('inc inc inc dec Pri exit'));                 //--> 2
console.log(f('dec inc mult inc inc Pri'));                 //--> 2
console.log(f('inc inc inc mult half Pri exit inc'));       //--> 3
console.log(f('inc Pri inc Pri inc Pri exit half mult'));   //--> 123
console.log(f('Pri exit'));                                 //--> 0
console.log(f('inc half Pri exit'));                        //--> 0.5

Following up to your deleted comment to which I can of course no longer reply, I forgot to paste in the link to the corrected code (d'oh!) but I found a new approach that's 2 bytes shorter than my original attempt anyway.

Charcoal, 37 35 bytes
≔⁰ηＦ⎇№θx…θ⌕θxθ≡ιn≦⊕ηd≦⊖ηm≦⊗ηh≦⊘ηrＩη

Try it online! Link is to verbose version of code. Inspired by @RickHitchcock's answer. Explanation:
≔⁰η

Clear the variable.
Ｆ⎇№θx…θ⌕θxθ≡ι

Truncate the input at the x if there is one, then loop over and switch on each character of (the remainder of) the input.
n≦⊕η

n increments the variable.
d≦⊖η

d decrements the variable.
m≦⊗η

m multiplies the variable by two (i.e. doubles).
h≦⊘η

h halves the variable.
rＩη

r prints the variable cast to string.

@RickHitchcock Sorry, didn't test that thoroughly enough. I found a workaround but it cost me a byte.

Red, 121 bytes
func[s][v: 0 parse s[any[["i"(v: v + 1)|"d"(v: v - 1)|"m"(v: v * 2)|"h"(v: v / 2.0)|"P"(prin v)|"e"(exit)]thru" "| end]]]

Try it online!
Readable:
f: func [s] [
    v: 0
    parse s [
        any [
            [ "i" (v: v + 1)
            | "d" (v: v - 1)
            | "m" (v: v * 2)
            | "h" (v: v / 2.0)
            | "P" (prin v)
            | "e" (exit)]
            thru [" " | end]
        ]
    ]
]

Python 2, 131 125 122 121 118 117 115 bytes
v=0;o=""
for x in input().split("x")[0].split():
 if"Q">x:o+=`v`
 else:v+=(1,-1,v,-v/2.)['idmh'.find(x[0])]
print o

Try it online!
-6 and -3 with thanks to @Rod
-3 and -2 with thanks to @etene
-1 by replacing "Pri"==x with "P"in x

you can split on "exit" and get the 1st block, instead breaking saving 4 bytes

You can remove the parentheses around 'idmh' and use find instead of index, that will save a few bytes

@Rod - can actually take that a bit further and split on exto save another 2

You can replace v=(v+1,v-1,v*2,v/2.) with v+=(1,-1,v,-v/2.) it should work, didn't tested though

@Rod - thought about that but couldn't work out how to do the half. So simple! Thanks.

A bit dirty, but you can save 2 more bytes by replacing if"P"in x with  if"Q">x

@etene - Thanks. I didn't know that worked for whole strings. Thought it was just individual characters.

Look at my last edit, actually since str.find returns -1 if the substring isn't found, you can remove the last letter in 'idmh' and it works the same thanks to negative indexing.

JavaScript (ES6), 83 79 bytes
Saved 4 bytes thanks to @l4m2
Iteratively replaces the instructions with either the output or empty strings.
s=>s.replace(/\S+./g,w=>m<s?'':w<{}?m:(m+={d:-1,e:w,i:1,m}[w[0]]||-m/2,''),m=0)

Try it online!
Commented
s =>                       // given the input string s
  s.replace(/\S+./g, w =>  // for each word w in s:
    m < s ?                //   if m is a string:
      ''                   //     ignore this instruction
    :                      //   else:
      w < {} ?             //     if w is 'Pri' ({} is coerced to '[object Object]'):
        m                  //       output the current value of m
      : (                  //     else:
          m +=             //       add to m:
            { d: -1,       //         -1 if w is 'dec'
              e: w,        //         w  if w is 'exit' (which turns m into a string)
              i: 1,        //         1  if w is 'inc'
              m            //         m  if w is 'mult'
            }[w[0]]        //       using the first character of w to decide
            || -m / 2,     //       or add -m/2 (for 'half') if the above result was falsy
        ''),               //       do not output anything
    m = 0                  //   m = unique register of our mighty CPU, initialized to 0
  )                        // end of replace()

s=>s.replace(/\S+./g,w=>k<s?'':w<{}?k:(k+={d:-1,e:w,i:1,m:k}[w[0]]||-k/2,''),k=0)

@l4m2 This w<{} is pure evil :p

s=>s.replace(/\S+./g,e=>m<s?'':e<{}?m:(m+={d:-1,e,i:1,m}[e[0]]||-m/2,''),m=0) also work

Haskell, 93 bytes
(0!)
a!(c:t)|c=='P'=show a++a!t|c>'w'=""|1<2=(a+sum(lookup c$zip"ndmh"[1,-1,a,-a/2]))!t;a!e=e

Try it online!
Essentially a translation of mbomb007's Python answer.

Lua, 207 bytes
s=0;n=0;for a in io.read():gmatch'.'do if s==0 then s=1;n=a=='i'and n+1 or a=='d'and n-1 or a=='m'and n*2 or a=='h'and n/2 or n;if a=='P'then print(n)elseif a=="e"then break end elseif a==' 'then s=0 end end

JavaScript (Node.js), 107 bytes
f=s=>s.split` `.map(([o])=>F?0:o=="i"?i++:o=="d"?i--:o=="m"?i*=2:o=="h"?i/=2:o=="P"?S+=i:F=1,F=i=0,S="")&&S

Try it online!

Shaved off two bytes

This as it is should be counted as 105 bytes afaik, as long as your function doesn't call itself you don't need to count f=

JavaScript, 107 bytes
s=>eval('x=0;x'+(s.split` `.map(v=>({i:"++",d:"--",m:"*=2",h:"/=2",P:";alert(x)",e:"//"})[v[0]]).join`;x`))

JavaScript (Node.js), 91 bytes
_=>_.split` `.map(o=>o<{}>!_?S+=+i:o<"e"?i--:o<"f"?++_:o<"i"?i/=2:o<"j"?i++:i*=2,i=S="")&&S

Try it online!
JavaScript (Node.js), 96 bytes
_=>_.split` `.map(o=>F?0:o<"Q"?S+=i:o<"e"?i--:o<"f"?F=1:o<"i"?i/=2:o<"j"?i++:i*=2,F=i=0,S="")&&S

Try it online!
JavaScript (Node.js), 99 bytes
s=>s.split` `.map(_=>eval('++i7--i7++e7u+=+i7i*=27i/=2'.split(7)[Buffer(e+_)[0]%11%6]),e=i=u='')&&u

Try it online!

Python 3, 114 110 109 116 bytes
Actually would have taken two bytes less in Python 2 because exec is a statement and doesn't need parentheses...

Saved 4 extra bytes thanks to @ElPedro
Saved an extra byte by taking advantage of the fact that find returns -1 on error, which can then be used as an index
+7 bytes because I hadn't noticed the no-newlines rule :(

i=0;exec(";".join("i+=1 i-=1 i*=2 i/=2 print(i,end='') exit()".split()["idmhP".find(h[0])]for h in input().split()))

Try it online!
Maps the first character of every input word to a piece of Python code. These are then concatenated and execed.
Pretty straightforward approach, that could probably be golfed a bit more. The difficulty mostly resides in finding the shortest form out of many possible ones...

112 Try it online! if you have the commands as a space seperated string and split it.

110 in fact as the brackets can go Try it online!

This doesn't give the correct output. The question says you must print without separators, so you need print(i,end=''). See the 4th test case.

I hadn't noticed, I'll fix it. Thanks !

@etene Comment when you've fixed it and I'll remove my downvote.

Ruby + -na, 81 73 65 bytes
x=0;$F.map{|w|eval %w{x+=1 x-=1 1/0 $><<x x*=2 x/=2}[w.ord%11%6]}

Try it online!
Pretty straightforward. For the first letter of each word, find the corresponding command string and eval it. Uses integer division, and exits by throwing a ZeroDivisionError.
-5 bytes: Use .ord%11%6 instead of a string lookup. Credit goes to user202729
-3 bytes: .ord only considers the first character of the string, so I can skip a [0].
-8 bytes: Use -a flag to automatically split input, thanks to Kirill L.

You can save even more bytes by adding -a option to do the autosplit for you, like this

Emojicode, 270 bytes
c 0j jincc➕c 1jdecc➖c 1jmultc✖c 2jhalfc➗c 2jPric 10

Try it online!

c 0
j
jincc➕c 1
jdecc➖c 1
jmultc✖c 2
jhalfc➗c 2
jPric 10

 inc inc inc dec Pri exit

 dec inc mult inc inc Pri

 inc inc inc mult half Pri exit inc

 inc Pri inc Pri inc Pri exit half mult

 Pri exit

 inc half Pri exit

C# (.NET Core), 186 Bytes
class P{static void Main(string[]a){int v=0;foreach(var s in a){var i=s[0];if(i=='i')v++;if(i=='d')v--;if(i=='m')v*=2;if(i=='h')v/=2;if(i=='P')System.Console.Write(v);if(i=='e')break;}}}

You can shave 26bytes off this by doing a few simple things, like declaring i with v, consulting an ASCII table so you can use small numbers, rearranging the ifs, and then using a ternary: class Z{static void Main(string[]a){int v=0,i;foreach(var s in a){i=s[0]%'d';if(i==1)break;if(i>9)System.Console.Write(v);else v=i<1?v-1:i<5?v/2:i<6?v+1:v*2;}}} (P.S. an explanation of how it works and how to use it (e.g. expects command line args) is always appreciated!)

(Oh that is embarrassing... I should have use %50 instead of %'d')

Perl 5 -a, 61 bytes
eval'$,'.qw(++ -- ;exit ;print$,||0 *=2 /=2)[(ord)%11%6]for@F

Try it online!
Stole @user202729's ord%11%6 trick
How?
-a            # split the input by whitespace, store in @F
eval          # Execute the string that results from:
'$,'          # $, (the accumulator)
.             # appending:
qw(           # create an array for the following whitespace separated values:
++ --            # operators for inc & dec
;exit            # exit
;print$,||0      # Pri  (||0 ensures that 0 is output if accumulator is null
*=2 /=2)         # mult div
[(ord)%11%6] # @user202729's trick selects one of the preceding operations
for@F        # for every term input

Pyth, 44 Bytes
Vmx"idmhPe"hdcwd=Z@[hZtZyZcZ2ZZ)NIqN4pZIqN6B

Test Suite
explanation
Vmx"idmhPe"hdcwd=Z@[hZtZyZcZ2ZZ)NIqN4pZIqN6B   ## full program
             cwd                               ## split input on space
Vmx"idmhPe"hd                                  ## iterate through list of numbers corresponding to operators
                =Z@[hZtZyZcZ2ZZ)N              ## assign the variable Z (initialliy Zero) it's new value
                                 IqN4pZ        ## print Z if the current operator is "Pri" (4)
                                       IqN6B   ## break if the current operator is "exit" (5)

SNOBOL4 (CSNOBOL4), 165 bytes
	P =INPUT ' exit '
	x =0
S	P LEN(1) $ L ARB ' ' REM . P	:S($L)F(end)
i	X =X + 1	:(S)
d	X =X - 1	:(S)
P	O =O X		:(S)
m	X =X * 2	:(S)
h	X =X / 2.	:(S)
e	OUTPUT =O
END

Try it online!
Gross.
	P =INPUT ' exit ' 				;* append ' exit ' to the input to guarantee that the program will stop
	x =0						;* initialize x to 0 else it won't print properly if the program is 'Pri'
S	P LEN(1) $ L ARB ' ' REM . P	:S($L)F(end)	;* set L to the first letter of the word and goto the appropriate label
i	X =X + 1	:(S)
d	X =X - 1	:(S)
P	O =O X		:(S)				;* append X to the output string
m	X =X * 2	:(S)
h	X =X / 2.	:(S)				;* divide by 2. to ensure floating point
e	OUTPUT =O					;* print whatever's in O, which starts off as ''
END

C (gcc), 120 114 111 bytes
-6 bytes thanks to ceilingcat.
x,d;f(char*s){for(x=0;s>1;s=index(d^1?s:"",32)+1)d=*s-100,x+=d?d==5:-1,x*=d^9?d^4?1:.5:2,d+20||printf("%d",x);}

Try it online!
124 bytes
Floating-point version:
d;f(char*s){for(float f=0;s>1;s=strchr(s,32)+1)d=*s-80,f+=d==25,f-=d==20,f*=d^29?d^24?1:.5:2,s=d^21?s:"",d?:printf("%f",f);}

Try it online!
I did not bother with a version that rounds down, but makes an exception for 0, which would be allowed, if I understand the comment-chain correctly.

TI-BASIC, 112 bytes
This takes advantage of some assumptions that are AFAIK perfectly acceptable.  Number one being that all variables are initialized to zero prior to execution; number two being that input is taken via Ans.
Ans+" E→Str1
While 1
I+4→I
sub(Str1,I-3,1→Str2
A+(Ans="I")-(Ans="D
If inString("MH",Str2
Then
I+1→I
2AAns+A/2(1-Ans
End
If Str2="P
Disp A
If Str2="E
Stop
Ans→A
End

Java (OpenJDK 8), 164 bytes
a->{int c=0;for(String g:a.split(" ")){char b=g.charAt(0);if(b==105)c++;if(b==100)c--;if(b==109)c*=2;if(b==104)c/=2;if(b==80)System.out.print(c);if(b==101)return;}}

Try it online!
Above is my solution that rounds off to integers, but below is my solution that handles decimals. The obnoxious way that java prints doubles adds another 55 byes to the score. I left the new lines to make the code more readable in the second submission only because it’s essentially the same solution with one extra command and an import statement.
Java (OpenJDK 8), 219 bytes
a->{
double c=0;
for(String g:a.split(" ")){
char b=g.charAt(0);
if(b==105)c++;
if(b==100)c--;
if(b==109)c*=2;
if(b==104)c/=2;
if(b==80)System.out.print(new DecimalFormat("0.#").format(c));
if(b==101)return;}}

Try it online!

143 bytes

33, 62 bytes
s'i'{1a}'d'{1m}'m'{2x}'h'{2d}'P'{o}'e'{@}It[mzsjk""ltqztItn1a]

Try it online!
This program takes the instructions delimited by newlines
Explanation:
It[mzsjk""ltqztItn1a]
  [mz            n1a] | Forever
It    jk       It     | - Get the first character of the next instruction
            qz        | - Call the function declared previously
     s  ""lt  t       | - Make sure we don't lose track of the variable

The code before that segment defines all the functions.

JavaScript (V8), 152 bytes
i=>{return n="",p=0,e=1,i.split(" ").map(i=>{e&&("inc"==i&&p++,"dec"==i&&p--,"mult"==i&&(p*=2),"half"==i&&(p/=2),"Pri"==i&&(n+=p),"exit"==i&&(e=0))}),n}

Try it online!


text:
Knight Distance
In Chess, a Knight on grid \$(x, y)\$ may move to \$(x-2, y-1)\$, \$(x-2, y+1)\$, \$(x-1, y-2)\$, \$(x-1, y+2)\$, \$(x+1, y-2)\$, \$(x+1, y+2)\$, \$(x+2, y-1)\$ or \$(x+2, y+1)\$ in one step. Imagine an infinite chessboard with only a Knight on \$(0, 0)\$:

How many steps is required for moving a Knight from \$(0, 0)\$ to \$(t_x, t_y)\$?

Inputs
Two integers: \$t_x\$, \$t_y\$;
\$-100 < t_x < 100\$, \$-100 < t_y < 100\$
Output
Minimal steps needed to move a Knight from \$(0, 0)\$ to \$(t_x, t_y)\$
Rules
This is code-golf so the shortest code in bytes wins
Testcases
  x    y -> out
  0,   0 ->  0
  0,   1 ->  3
  0,   2 ->  2
  1,   1 ->  2
  1,   2 ->  1
  3,   3 ->  2
  4,   0 ->  2
 42,  22 -> 22
 84,  73 -> 53
 45,  66 -> 37
 99,  99 -> 66
-45, -91 -> 46
-81,   1 -> 42
 11,  -2 ->  7

document.write('<div>');[..."EFEDEDCDCBCBCBCBCBCBCBCBCBCBCBCBCBCDCDEDEFE;FEDEDCDCBCBABABABABABABABABABABABCBCDCDEDEF;EDEDCDCBCBABABABABABABABABABABABABCBCDCDEDE;DEDCDCBCBABA9A9A9A9A9A9A9A9A9A9ABABCBCDCDED;EDCDCBCBABA9A9A9A9A9A9A9A9A9A9A9ABABCBCDCDE;DCDCBCBABA9A9898989898989898989A9ABABCBCDCD;CDCBCBABA9A989898989898989898989A9ABABCBCDC;DCBCBABA9A98987878787878787878989A9ABABCBCD;CBCBABA9A9898787878787878787878989A9ABABCBC;BCBABA9A989878767676767676767878989A9ABABCB;CBABA9A98987876767676767676767878989A9ABABC;BABA9A9898787676565656565656767878989A9ABAB;CBA9A989878767656565656565656767878989A9ABC;BABA98987876765654545454545656767878989ABAB;CBA9A987876765654545454545456567678789A9ABC;BABA98987676565454343434345456567678989ABAB;CBA9A987876565454343434343454565678789A9ABC;BABA98987676545434323232343454567678989ABAB;CBA9A987876565434323232323434565678789A9ABC;BABA98987676545432341214323454567678989ABAB;CBA9A987876565434321232123434565678789A9ABC;BABA98987676545432323032323454567678989ABAB;CBA9A987876565434321232123434565678789A9ABC;BABA98987676545432341214323454567678989ABAB;CBA9A987876565434323232323434565678789A9ABC;BABA98987676545434323232343454567678989ABAB;CBA9A987876565454343434343454565678789A9ABC;BABA98987676565454343434345456567678989ABAB;CBA9A987876765654545454545456567678789A9ABC;BABA98987876765654545454545656767878989ABAB;CBA9A989878767656565656565656767878989A9ABC;BABA9A9898787676565656565656767878989A9ABAB;CBABA9A98987876767676767676767878989A9ABABC;BCBABA9A989878767676767676767878989A9ABABCB;CBCBABA9A9898787878787878787878989A9ABABCBC;DCBCBABA9A98987878787878787878989A9ABABCBCD;CDCBCBABA9A989898989898989898989A9ABABCBCDC;DCDCBCBABA9A9898989898989898989A9ABABCBCDCD;EDCDCBCBABA9A9A9A9A9A9A9A9A9A9A9ABABCBCDCDE;DEDCDCBCBABA9A9A9A9A9A9A9A9A9A9ABABCBCDCDED;EDEDCDCBCBABABABABABABABABABABABABCBCDCDEDE;FEDEDCDCBCBABABABABABABABABABABABCBCDCDEDEF;EFEDEDCDCBCBCBCBCBCBCBCBCBCBCBCBCBCDCDEDEFE"].forEach(c=>document.write(c==';'?'<br>':`<span class="d-${c}">${c}</span>`));
document.write('<style>body{line-height:16px;color:rgba(255,255,255,0.2);}span{display:inline-block;width:16px;font-size:16px;text-align:center;}div{white-space:pre;}');[...'0123456789ABCDEF'].map((c,i)=>document.write(`.d-${c}{background:hsl(${60-4*i},80%,${65-2*i}%)}`));

Related OEIS
Here are some OEIS for further reading

A018837: Number of steps for knight to reach \$(n,0)\$ on infinite chessboard.
A018838: Number of steps for knight to reach \$(n,n)\$ on infinite chessboard.
A065775: Array \$T\$ read by diagonals: \$T(i,j)=\$ least number of knight's moves on a chessboard (infinite in all directions) needed to move from \$(0,0)\$ to \$(i,j)\$.
A183041: Least number of knight's moves from \$(0,0)\$ to \$(n,1)\$ on infinite chessboard.

You may take a reference of the formula given in https://oeis.org/A065775

Can I take input as a complex number x+yi?

@lynn i think it is acceptable.

@user202729 updated the code snippet to show the result.

A very fine map.

Wolfram Language (Mathematica), 64 bytes
Using the built-in KnightTourGraph.
Saved 2 bytes thanks to Mathe172.
GraphDistance[KnightTourGraph@@({x,y}=Abs@{##}+4),y+2,(x-2)y-2]&

Try it online!

Mathematica builtins strike again

Slightly shorter: GraphDistance[KnightTourGraph@@({x,y}=Abs@{##}+5),2y+3,(x-2)y-2]&

What's with this language? How come all these built-ins are preloaded? Does trying to complete a phrase with tab takes ages?

@OganM Mathematica doesn't support auto completion in its command line interface. The auto completion in the notebook interface looks like this.

@OganM Maybe the developers use a Trie (data structure), or just binary search on the list of sorted built-ins. Yes, why linear search? | Note that Mathematica is a non-free closed-source language, so no one know how the predictor actually works. | Real programmers don't need auto-complete. :P

@aleph Actually the long builtin names make this a bit uncompetitive... as usual.

Wow, it just like a semi-transparent image!

Just when you think Mathematica doesn't have enough builtins...

JavaScript (ES6), 90 75 72 bytes
Inspired by the formula given for A065775. Slow as hell for (not so) long distances.
f=(x,y,z=x|y)=>z<0?f(-y,x):z>1?1+Math.min(f(x-1,y-2),f(x-2,y-1)):z*3^x&y

Try it online!
How?
We define z as the bitwise OR between x and y.
Step #1
We first ensure that we are located in a specific quadrant by forcing both x and y to be non-negative. As long as z < 0 (which means that either x or y is negative), we process the recursive call f(-y, x):
(+1, -2) --> (+2, +1)
(-1, +2) --> (-2, -1) --> (+1, -2) --> (+2, +1)
(-1, -2) --> (+2, -1) --> (+1, +2)

Step #2
While we have z > 1 (which means that either x or y is greater than 1), we recursively try the two moves that bring us closer to (0, 0): f(x-1, y-2) and f(x-2, y-1). We eventually keep the shortest path.
Step #3
When z is less than or equal to 1, we're left with 3 possibilities which are processed with z*3^x&y (we could use z*3-x*y instead):

x & y == 1 implies x | y == 1 and means that x = y = 1. We need two more moves to reach (0, 0):

x & y == 0 and x | y == 1 means that we have either x = 1 / y = 0 or x = 0 / y = 1. We need three more moves to reach (0, 0):

x & y == 0 and x | y == 0 means that we already have x = y = 0.

Graphics borrowed from chess.com

Python 3, 90 bytes
Thanks tsh for -11 bytes!
def f(x,y):x=abs(x);y=abs(y);s=x+y;return(.9+max(x/4,y/4,s/6)-s/2+(s==1or x==y==2))//1*2+s
Try it online!
(inline code formatting to avoid readers having to scroll. Sorry, but I have to golf my program)
Very very efficient.

How could I come up with this!?
1. Parity
Assumes that the whole board is colored in the checkerboard pattern (that is, cells with x+y odd and x+y even are colored with different colors).
Note that each step must jump between two differently-colored cell. Therefore:

The parity of the number of steps must be equal to the parity of x+y.

2. Approximation
Assumes the knight starts from coordinate (0,0), and have moved n steps, and is currently at (x,y).
For simplicity, assumes x ≥ 0, y ≥ 0.
We can conclude:

Since each step x increases by at most 2, x ≤ 2×n. Similarly, y ≤ 2×n.
Since each step x+y increases by at most 3, x+y ≤ 3×n.

Therefore, n ≥ l(x,y) where l(x,y) = max(max(x,y)/2, (x+y)/3. (note that we don't need to include -x or x-y in the formula because by assumption, x ≥ 0 and y ≥ 0, so x+y ≥ max(x-y,y-x,-x-y) and x ≥ -x, y ≥ -y)
It turns out that a(x,y) = round(0.4 + l(x,y)) is a good approximation to n.

Assume a(x,y) is an approximation with error less than 1, the correct value is given by
f(x,y) = round((a(x,y) - (x+y)) / 2) * 2 + (x+y)

(round under subtracting x+y and dividing by 2)

3. Special cases that fails the formula
Assume x ≥ 0 and y ≥ 0. There are 2 special cases where the algorithm fails:

x == 1 and y == 0 or x == 0 and y == 1: The algorithm incorrectly returns 1 while the correct answer is 3.
x == y == 2: The algorithm incorrectly returns 2 while the correct answer is 4.

So, just special-case those. Add the result by 2 if the value of x and y are one of those.

@tsh But that is true for x==y==0 too.

Why max(x+y,x-y,y-x)?

@tsh: No, see: x = -5, y = 5. x+y = 0, abs(x-y) = 10 and therefore x+y < abs(x-y)

@Nova "Assume x ≥ 0 and y ≥ 0".

the link code doesnt print anything

TI-Basic, 86 54 bytes
Based on @user202729's older solution
Input :abs(X->C:abs(Y->D:C+Ans
Ans+2int(.9+(S=1 or C=2 and D=2)-.5Ans+max({C/4,D/4,Ans/6

Python 2, 87 bytes
f=lambda z,a={0}:1-({z}<=a)and-~f(z,{k+1j**i*(2-i/4*4+1j)for k in a for i in range(8)})

Try it online!
Takes input as a complex number z = complex(tx, ty).

Jelly, 27 26 25 23 bytes
1,-pḤµ;UÆị
¢ṗS€;0i
0ç1#

Try it online!
Very slow; times out on TIO for outputs over 6. Takes a complex number as input.
Explanation
The code uses complex numbers because it was shorter in an intermediate step and it also seems a lot faster; you could also use pairs by removing Æi and replacing 0 with 0,0 on the second line.
1,-pḤµ;UÆị    Helper link. No arguments.
1,-             Get the pair [1,-1].
    Ḥ           Double each to get [2,-2].
   p            Cartesian product: get [[1,2],[1,-2],[-1,2],[-1,-2]].
     µ          Start a new chain with the list of pairs as argument.
       U        Reverse each pair.
      ;         Append the reversed pairs to the list.
        Æi      Convert each pair [real,imag] to a complex number.

¢ṗS€;0i    Helper link. Arguments: iterations, target
¢            Call the previous link to get knight moves as complex numbers.
 ṗ           Get the iterations-th Cartesian power of the list. This will
             yield 8^n tuples containing move sequences.
  S€         Sum each move sequence to get the resulting square.
    ;0       Add the starting square, since the zeroth iteration results
             in no move sequences.
      i      Find the target squares (1-based) index in the results, or 0.

0ç1#    Main link. Argument: target
0         Starting from 0,
   #      find the
  1       first number of iterations where
 ç        calling the previous link results in a nonzero result.

Haskell, 79 72 bytes
p l|elem(0,0)l=0|r<-[-2..2]=1+p[(x+i,y+j)|(x,y)<-l,i<-r,j<-r,(i*j)^2==4]

Try it online!
Takes the input as a singleton list of pairs of numbers.
A simple brute force. Needs a lot of time and memory for results > 8. Starting with a single element list of coordinates (the input), repeatedly add all positions that can be reached for every element until (0,0) is in this list. Keep track of the recursion level and return it as the result.
Edit: -7 bytes thanks to @Lynn.

72 bytes

MATL, 29 bytes
`JEQ2J-htZjht_h@Z^2&sG=~}@Gg*

Input is a complex number with integer real and imaginary parts.
The code is very inefficient. Its memory requirements increase exponentially with the output. It times out in TIO for the test cases with output exceeding 7.
Try it online!

Kotlin, 148 146 140 bytes
fun s(x:Int,y:Int):Int=if(y<0)s(x,-y)else
if(x<y)s(y,x)else if(x+y<3)4-x-y and 3
else if(x!=3||y!=1)if(x!=4||y!=3)s(x-2,y-1)+1
else 3 else 2

Try it online!

Pretty sure you don't need the :Int to specify return type.

Recursive functions do require return type as the compiler isn't smart enough to figure out the type.

Oh, I missed the recursive calls. Whoops

JavaScript (ES6), 90 78 bytes
f=(x,y)=>y<0?f(x,-y):x<y?f(y,x):x+y<3?4-x-y&3:x-3|y-1?x-4|y-3?f(x-2,y-1)+1:3:2

Edit: Saved 12 bytes thanks to @supercat pointing out that x<0 implies either y<0 or x<y. Explanation: This is a recursive solution. The first two conditions just ensure the right quadrant for the other conditions. The third condition generates the answer for coordinates near the origin, while the last two conditions deal with the other two special cases (1 byte shorter than testing both moves):
0
32
2++
+2++
+++3+
++++++
(etc.)

All squares marked + can be determined by moving directly towards the origin and then recursing.

Do you need the x<0 test?  Given e.g. -3,6, the x<y test would turn that into 6,-3, which the y<0 test would turn into 6,3, which the x<y test would turn into 3,6.

@supercat Indeed, as Python would say, x>=y>=0...

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


text:
Creating a Y-shaped Recursive Tree
Challenge
In this challenge you will construct trees, in the form of ASCII Art using recursion. Basically you will generate the ASCII version of the Fractal Tree
Input

Number of iterations 0 < N <= 5

Output

The Nth iteration of the Fractal Tree. It must be a matrix of 63 rows and 100 columns. (i.e. 6300 printable characters) It should be composed entirely of underscores and ones.

Rules

Tree must be Y-shaped
Input 0 < N <= 5
It must be a matrix of 63 rows and 100 columns
It must be composed entirely of underscores _ and ones 1
Do not include any extra leading or trailing spaces.

Examples
N = 1
[encoded data, 6300 characters]

N = 2
[encoded data, 6300 characters]

N = 5
[encoded data, 6300 characters]

This is code-golf, so the shortest answer in bytes win.

The output format for this seems like a poor idea

@fəˈnɛtɪk that it where it gets complicated.

I think it'd be better if a smaller n was a smaller Y. Then you wouldn't need an upper bound on n or bounds for output width.

@fəˈnɛtɪk Why? (15 characters limit)

Not fully sure why this question is bounded at all. The bounding makes it less golfable because the only solution to this will be to hardcode "5". Would've been more interesting if you started small, explained the first 5 iterations, and didn't put a cap on it like mbomb noted. But I think that's a dupe of "create a tree" if I can find it...

Related (and imho how the challenge should've been written w/o bounding).

@MagicOctopusUrn How is the bound bad?

@MagicOctopusUrn See this.

@user202729 it's not bad, it's just arbitrary why 5? I'm guessing because OP didn't want to make iteration 6... Everything about this question (width of end ASCSII-art, height of end ASCII-art) is all bounded by the 5th iteration, which makes it (in my opinion, and it is an opinion not a fact) too constrained to be a good challenge...

@MagicOctopusUrn sorry for the late answer. I took five because the initial size of the first tree is always going to be 16 lines. The next iterations get half size of the last iteration so the second iteration tree's get 8 lines, the third 4 lines, the fourth 2 lines and the fifth 1 line. After 5 iteration you can not draw any tree because 1/2 = 0.5 and you can not print in half line. Hope I was clear

This challenge is from HackerRank

@user9549915 slowclap@OP

Python 2, 902 518 472 bytes
u='_';n='1';c=(31,47,55,59,62)[input()-1]
p=[u*100]*64+[u*18+'1_'*32+u*18]+[u*19+'1___'*15+n+u*20]*2+[u*20+'1_1_____'*8+u*16]+[u*21+(n+u*7)*8+u*15]*3+[u*22+(n+u*5+n+u*9)*4+u*14]+[u*23+('1___1'+u*11)*4+u*13]+[u*24+('1_1'+u*13)*4+u*12]+[u*25+(n+u*15)*4+u*11]*4
m=13;r=17
for x in range(26,33):p+=[u*x+n+u*m+n+u*r+n+u*m+n+u*(x+1)];m-=2;r+=2
p+=[u*33+n+u*31+n+u*34]*9
m=29
for x in range(34,49):p+=[u*x+n+u*m+n+u*(x+1)];m-=2
p+=[u*49+n+u*50]*16
print'\n'.join(p[:63-c]+p[-c:])

Try it online!
Needs a whole load of golfing but at least it works.


text:
Am I a Pillai prime?
A Pillai prime is a prime number \$p\$ for which there exists some positive \$m\$ such that \$(m! + 1) \equiv 0 \:(\text{mod } p)\$ and \$p \not\equiv  1\:(\text{mod }m)\$.
In other words, an integer \$p\$ is a Pillai prime if it is a prime number, if there exists another positive integer \$m\$ such that the factorial of \$m\$, plus \$1\$ is divisible by \$p\$ and if \$p - 1\$ isn't divisible by \$m\$.

Given a positive integer as input, decide whether it is a Pillai prime. The sequence of Pillai primes is OEIS A063980.
For example, \$23\$ is a Pillai prime because:

It is a prime number, having only 2 factors.
\$m = 14\$ and \$m = 18\$ satisfy the above conditions: \$23 \mid (14! + 1)\$ and \$14\$ does not divide \$22\$; \$23 \mid (18! + 1)\$ and \$18\$ does not divide \$22\$ either.

Test cases
Truthy:

23
59
83
109
139
593

Falsy:

5
7
8
73
89
263
437

For the truthy cases, the respective m's are [(23, [14, 18]), (59, [15, 40, 43]), (83, [13, 36, 69]), (109, [86]), (139, [16]), (593, [274])].

You can either follow the standard decision-problem output format (that is, truthy / falsy values) or have a consistent value for Pillai primes and a non-consistent value otherwise or vice-versa.
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 (in bytes) for every language wins.

Can the input be a composite integer?

@JungHwanMin Yes, the input can be a composite integer.

I suggest a test case like 437, which is composite but divides 18!+1.

@Nitrodon Added that test case, thank you!

could you pair the truthy cases with their respected m? so i understand why my solution fail to work :)

@DanielIndie Here you go: [(23, 14), (23, 18), (59, 15), (59, 40), (59, 43), (83, 13), (83, 36), (83, 69), (109, 86), (139, 16), (593, 274)]. I've also added them to the challenge.

Jelly, 11 8 bytes
Ṗ!%ẹ’ḍ’E

Returns 0 for Pillai prime, 1 otherwise.
Try it online!
How it works
Ṗ!%ẹ’ḍ’E  Main link. Argument: n

Ṗ         Pop; yield [1, ..., n-1].
 !        Take the factorial of each integer.
  %       Take the factorials modulo p.
   ẹ’     Find all indices of n-1.
     ḍ’   Test n-1 for divisibility by each of these indices.
       E  Return 1 if all of the resulting Booleans are equal (all 1 means there is
          no suitable m, all 0 means n is not prime), 0 if they are different.

That's roughly how I would have done it too, but I didn't manage to prove that m ∈ [1, n).

If m ≥ n, then m! is divisble by n, so m! + 1 ≡ 1 (mod n).

Python 2, 115 111 110 109 bytes
-6 bytes thanks to Mr. Xcoder

lambda n:n>2and cmp(*map(all,zip(*[[n%x==1or~f(x)%n,n%x]for x in range(2,n)])))<0
f=lambda x:0**x or x*f(x-1)

Try it online!
The functions consist of two parts ~-n%x<1or~f(x)%n>0 that verifies if n don't satisfies the "Pillai conditions", and n%x>0 for the prime validation.
After that all is applied to both items, the first item will contain False/0 if there is a valid "Pillai number", and the second will contain True/1 if n is prime.
These are passed to cmp that will return -1 in this cenario (is a valid Pillai prime). The other combinations [[0, 0], [1, 0], [1, 1]] will return 0 or 1

+1, clever algorithms (and their explanations) are why I love this SE

Pari/GP, 44 bytes
p->isprime(p)&&sum(m=2,p,p%m-1&&!((m!+1)%p))

Try it online!

Brachylog, 19 bytes
ṗ>.ḟ+₁;?%0&-₁;.%>0∧

Try it online!
Pretty straightforward translation of the question:
ṗ          Input is a prime
>.         And output is a number less than the input
ḟ+₁;?%0    And output's factorial + 1 mod input is 0
&-₁;.%>0   And input - 1 mod output is greater than 0
∧          No further constraints

J, 30 26 bytes
-4 bytes thanks to  FrownyFrog
1 e.i.((|1+!)~<1~:|)1&p:*]

Try it online!
Explanation:
                        1&p:*]      checks if the number is prime and if not sets it to 0
                   1~:|             checks if p is not 1 mod m
           (|1+!)~                  m factorial plus 1 modulo n
                  <                 are both conditions met?
       i.                           generates successive m's (a list 0..n-1)
   1 e.                             1's are at the indices of m, so if there's 1 - Pillai

Check that modulo n is less than 1~:| to save 2 bytes.

(]|1+!@[) is just (|1+!)~

@FrownyFrog - Thank you! I was thinking about ~ and it makes sence with your previous comment.

Python 2, 65 64 53 52 bytes
f=lambda n,k=3,m=2:~m%n<1<n%k%(n%~-k)or f(n,k+1,m*k)

Output is via presence or absence of an error.
Try it online!

as you probably can see in the tio link not all cases pass, thats because js cant handle big numbers,if such requirement exists ill try to implement it :)
there is a double check F%n>n-2&(F+1)%n<1 to prevent false positive(but not the other way around with js big number issues,we do really need (F+1)%n<1 for smaller numbers whice reduces the solution byte count to 60
JavaScript (Node.js), 90 88 86 72 68 bytes

thanks to Arnauld for reducing by 1 byte

f=(n,F=i=2,g=0)=>n%i?f(n,F*=++i,g|=F%n>n-2&(F+1)%n<1&~-n%i>0):i==n*g

Try it online!

Python 2, 109 107 bytes
lambda p:any(~-p%m>~l(m)%p<1for m in range(2,p))*all(p%i for i in range(2,p-1))
l=lambda a:0**a or a*l(a-1)

Try it online!

Explanation
The l finds the factorial of the number passed in, so 5 as input returns 120.
The all(p%i for i in range(2,p-1)) checks to see if a number is prime, we ignore 0 and 1 as our other conditions already rule those out.
Finally, we use any(~-p%m>-~l(m)%p==0for m in range(2,p)) to iterate through all potential m's looking to see if any satisfies our needs. ~-p means p+1.  Then we check to see if it is greater than -~l(m)%p (which translates to (m!-1)%p, and then we compare it to 0. Basically ~-p%m must be greater than 0 and -~l(m)%p must be 0.

Sources

Factorial by 0xKirill

Improvements

From 109 to 107, Mr. Xcoder

Brachylog, 13 bytes
>.ḟ+₁ḋ∋?-₁f≡ⁿ

Try it online!
Succeeds for Pillai primes, providing the smallest m through the output variable, and fails for anything else. Since a large part of how this saves bytes over sundar's solution is that it repeatedly computes the prime factorizations of some pretty big numbers, it's quite incredibly slow on larger inputs. (I'll probably run those cases on my local Brachylog installation once my laptop isn't on battery power.)
 .               The output
>                is less than the input,
       ?         the input
      ∋          is an element of
     ḋ           the prime factorization of
 .               the output's
  ḟ              factorial
   +₁            plus one,
           ≡ⁿ    and the output is not an element of
          f      the list of all factors of
       ?         the input
        -₁       minus one.

[Perl], 45 bytes
use ntheory":all";is_prime($n)&&is_pillai($n)

The number theory module has the predicates as built-in functions (is_pillai actually returns either 0 or the smallest m, so solves A063828 as well).  The underlying C and Perl code is not golfed (of course).  The C code looks like:
UV pillai_v(UV n) {
  UV v, fac = 5040 % n;
  if (n == 0) return 0;
  for (v = 8; v < n-1 && fac != 0; v++) {
    fac = (n < HALF_WORD) ? (fac*v) % n : mulmod(fac,v,n);
    if (fac == n-1 && (n % v) != 1)
      return v;
  }
  return 0;
}

(generically replace UV with uint64_t or similar, and HALF_WORD decides whether we can optimize the mulmod into simple native ops).
The pure Perl code is similar to:
sub is_pillai {
  my $p = shift;
  return 0 if $p <= 2;
  my($pm1, $nfac) = ($p-1, 5040 % $p);
  for (my $n = 8; $n < $p; $n++) {
    $nfac = mulmod($nfac, $n, $p);
    return $n if $nfac == $pm1 && ($p % $n) != 1;
  }
  0;
}

C (gcc), 64 bytes
f(n,k,m,r){for(k=m=1,r=0;k<n;m=m*++k%n)r|=m/~-n<<(n%k==1);r/=3;}

Try it online!

Whispers v2, 230 bytes
> 1
> Input
>> 1…2
>> L!
>> L+1
>> L∣2
>> L⋅R
>> 2%L
>> Each 4 3
>> Each 5 9
>> Each 6 10
>> Each 7 11 3
> {0}
>> 12∖13
>> Each 8 14
>> L≠1
>> Each 16 15
>> Each 7 17 15
>> 18∖13
>> [19]
>> 2’
>> 21⋅20
>> Output 22

Try it online!
This returns an empty list for non-Pillai primes, and a non-empty list otherwise.
How it works
Whispers was designed for manipulation on real/complex numbers, with a little bit of array commands added for good measure, hence the repeated use of Each to iterate over the generated lists.
A bit of background on Whispers:
Whispers is slightly different in it's execution path to most other languages. Rather than work through each line linearly, only branching at conditionals, Whispers begins on the last line in the file beginning with > (the rules are slightly more complicated than that, but that's all we need to know for now), and the meanings of numbers differ, depending on whether the line starts with > or >>.
If the line starts with >, such as > 1 or > Input, this is a constant line - it returns the same value each time. Here, numbers represent their numerical form, so the first line will always return 1 when called.
If the line starts with >> however, numbers are treated as references to other lines, sort of like function calls, if you will. For example, in the line >> 1…2, this does not perform the … command on the integers 1 and 2, but rather on the values returned from lines 1 and 2. In this case, those values are the integer 1 and whatever integer we're passed as input.
For this example, let's consider the input of 23. Keep in mind that, due to Whispers' preprocessing, the second line (> Input) is converted to > 23.
Our first command is on line 3: >> 1…2. … is dyadic range, in this case from 1 to 23, yielding {1, 2, ... 22, 23}. Next, we skip down to lines 9 through 12:
>> Each 4 3
>> Each 5 9
>> Each 6 10
>> Each 7 11 3

Here we have 4 consectutive Each statements, each of which iterate over the previous result, essentially mapping the 4 commands over the array on line 3: the range. The first three statements are simple maps, with lines 4, 5 and 6:
>> L!
>> L+1
>> L∣2

These three commands, over an integer n, yields (n!+1)∣x, where ! denotes factorial, ∣ denotes divisbility and x is the input. Finally, line 12 has a dyadic map structure.
A dyadic map structure takes three integers: the target, the left and the right, each indexes to other lines. Here, we zip the left and the right to produce a list of pairs, then reduce each pair by the dyadic command (the target). Here, if the input is 23, the lists are {1, 2, ... 22, 23} and {0, 0, ... 1, 0} and the command is
>> L⋅R

which multiplies the left argument by the right. This produces an array of integers, with 0 at the indexes of integers whose factorials incremented aren't divisible by the inputs, and the original index where they are. We'll call this array A. Next, we remove the 0s from A by taking the set difference between {0} and A:
> {0}
>> 12∖13

With our example input, this produces the set {14, 18, 22}. Next we take the remainder of the input being divided by each value in the set, and check if that remainder is not equal to 1:
>> 2%L
>> Each 8 14
>> L≠1
>> Each 16 15

Again, we have a list of either 0 or 1s and need to remove the 0s and replace the 1s with the original values. Here we repeat the code we saw above, but with >> 18∖13 rather than 12. Finally, we cast this resulting set to a list for a final check. Unfortunately, our code must also reject composite numbers which achieve all these criteria, such as 437. So we add our final check, multiplying our final list by the primality of the input. Due to how Python multiplication works on lists, 0 replaces it with an empty list, and 1 has no effect. So we calculate the primality of the input, multiply that by the list of ms for the input and ouput the final result:
>> 2’
>> 21⋅20
>> Output 22

APL(NARS), 65 chars, 130 bytes
{∼0π⍵:0⋄m←⎕ct⋄⎕ct←0⋄r←⍬≢a/⍨{0≠⍵∣p}¨a←k/⍨0=⍵∣1+!k←⍳p←¯1+⍵⋄⎕ct←m⋄r}

Here 23x it would mean 23r1 and so the fraction 23/1, so all the others; test:
  f←{∼0π⍵:0⋄m←⎕ct⋄⎕ct←0⋄r←⍬≢a/⍨{0≠⍵∣p}¨a←k/⍨0=⍵∣1+!k←⍳p←¯1+⍵⋄⎕ct←m⋄r}
  f¨23x 59x 83x 109x 139x 593x
1 1 1 1 1 1
  f¨5x 7x 73x 89x 263x 437x
0 0 0 0 0 0

C# (Visual C# Interactive Compiler), 138+22=160 bytes
n=>Enumerable.Range(2,n-2).All(x=>n%x>0)&Enumerable.Range(1,n).Any(x=>{BigInteger a,b=1;for(a=1;a<=x;a++)b*=a;return(b+1)%n<1&(n-1)%x>0;})

TIO has not implemented the System.Numerics library in it's release of Mono, so you can see the results Try it online! Here instead.
Explanation:
using System.Numerics; //necessary to handle large numbers created by the factorials

return
    Enumerable.Range(2,n-2).All(x=>n%x>0)       // is prime
    &
    Enumerable.Range(1,n).Any(x=>
    {
        BigInteger a,b=1;for(a=1;a<=x;a++)b*=a; //b = a!
        return (b+1)%n<1
               &                                //the condition for PPs
               (n-1)%x>0;
    });

Suggest a=0,b=1;for(;a++<x;)b*=a;return-~b%n<1&~-n%x>0 instead of a,b=1;for(a=1;a<=x;a++)b*=a;return(b+1)%n<1&(n-1)%x>0

CJam, 37 bytes
ri_mp\[_{_M)m!)@%!\_M)%1=!@&\}fM]);:|

Outputs 11 if input is a pillai prime, otherwise 00, 01 or 10
Explanation:
                                         e# Explanation | Stack
ri_mp\[_{_M)m!)@%!\_M)%1=!@&\}fM]);:|    e# Whole code | Example input: 593
ri                                       e# Read input as integer | 593
  _                                      e# Duplicate | 593 593
   mp                                    e# Is it prime? | 593 1
     \                                   e# Swap top two stack elements | 1 593
      [                         ]        e# Delimits an array. Any operations that
                                         e# push a value are placed into the array
       _                                 e# Duplicate | 1 593 [593]
        {                    }fM         e# A for loop from 0 to (n-1) looped through
                                         e# variable M
         _                               e# Duplicate top stack value | ...[593 593]
          M)                             e# Get M+1, as if we try M=0 we get an error
                                         e# | ...[593 593 1]
            m!                           e# Factorial | ...[593 593 1]
              )                          e# Add one | ...[593 593 2]
               @                         e# Rotate stack | ...[593 2 593]
                %                        e# Modulus | ...[593 2]
                 !                       e# Equal to 0? | ...[593 0]
                  \_                     e# Swap and duplicate | ...[0 593 593]
                    M)                   e# Push M+1 | ...[0 593 593 1]
                      %                  e# Modulus | ...[0 593 0]
                       1=!               e# Not equal to 1? | ...[0 593 1]
                          @              e# Rotate | ...[593 1 0]
                           &             e# AND | ...[593 0]
                            \            e# Swap | ...[0 593]
                             }
                                ]
                                 );      e# Dump and discard last element
                                         e# | 1 593 [...]
                                   :|    e# Flatten array with OR | 1 1
                                         e# Implicit output

Try it online!


text:
Vowel position changer
Challenge :
Sort the vowels (only vowels) in the given string .
Note :

Vowels are the following characters: A, E, I, O, U
Vowel sorting is cyclic i.e. After rearrangement the first vowel of sorted string goes where the original first vowel was

Input :
A string line, the original line (consisting of alphabets and white space only all of them in uppercase (save whitespace))

Output :
A sorted string, the given string with vowels sorted (All in uppercase)
Examples :
Input == STACK EXCHANGE
So the vowels are at index:
A -> 1
E -> 2
A -> 3
E -> 4

On pushing, indexes become:
A -> 1
A -> 2
E -> 3
E -> 4

∴ String will be: STACK AXCHENGE

Input == ZOMBIE BRAINZ
So the vowels are at index:
O -> 1
I -> 2
E -> 3
A -> 4
I -> 5

On pushing, indexes become:
A -> 1
E -> 2
I -> 3
I -> 4
O -> 5

∴ String will be: ZAMBEI BRIONZ

Note :
You will not change the indexes of constants (non-vowels) and white spaces. Only position of vowels will change.

Restriction :
This is code-golf so shortest code in bytes for each language wins

@ovs : You will find all vowels in the sentence re arrange them and then replace them with the new position.

I don't quite understand. Are we supposed to move the vowels (and only the vowels) so that they end up in alphabetical order? Ex. UAEBOI -> AEIBOU

@Scrooble: No , read the note at the end. Only change the position of vowels but do not change the position of constants. I will give an example

@Scrooble : Yep your example is correct

@ovs : added an example

@Scrooble : added another example

@MuhammadSalman I'd call this "sorting" the vowels, not "pushing" them. I'd also remove the "1 position to the left" bit, if I understand properly.

@Scrooble : ok canged to sorting , removed that part too

This isn't an exact duplicate... here there is only one valid solution per input because vowels are sorted instead of shuffled.

@Timtech, most of the solutions to the dupe target will be trivially modified for this challenge - sort lexicographically instead of randomly.