text:
Shorten an absolute path
Sometimes a long absolute path, in e.g. a command-line parameter to a linux tool, can be shortened, using current working directory as reference:
$ pwd
/home/heh

$ cat /home/heh/mydir/myfile
my stuff

$ cat mydir/myfile
my stuff

In this challenge, you should make a function or a program that receives two parameters:

Absolute path, using the linux format (starts with /)
Current directory, using the same format

The output is the shorter of the following:

Input 1 unchanged
Relative path that refers to the same file/directory as the absolute path

Fine points:

If your operating system is compatible with linux, you can use the system's current directory instead of receiving it as input
You can assume the inputs contain only alphanumeric characters (and path separators)
You can assume the input absolute path doesn't have a path separator / at the end
You can assume the input current directory has a path separator / at the end
You cannot assume that the absolute path refers to an existing file, or that any part of it is an accessible directory; however, the current directory can be assumed valid
You can assume there are no symlinks anywhere near either path - because I don't want to require any special way of dealing with symlinks
No need to support the case where either of the inputs is the root directory
"The current directory" should be output as . (an empty string is not valid)

Test cases (input1, input2, output):
/home/user/mydir/myfile
/home/user
mydir/myfile

/var/users/admin/secret/passwd
/var/users/joe/hack
../../admin/secret/passwd

/home/user/myfile
/tmp/someplace
/home/user/myfile

/dir1/dir2
/dir1/dir2/dir3/dir4
../..

/dir1/dir2
/dir1/dir2
.

"You can assume the input current directory has a path separator / at the end". However, in your examples, this is not the case.

I like it this way, but some people like it the other way

Closely related.

What should happen if absolute and relative path have the same length?

If same length, either output is good.

You cannot assume that the absolute path refers to an existing file and you can use the system's current directory instead of receiving it as input seem to contradict each other.

Do we have to deal with symlinks? Can we if it's shorter.

@Dennis The absolute path (input 1) may refer to a non-existent file, while the current directory (input 2) is always valid. I guess I'll add the latter to the list of possible assumptions.

Regarding symlinks - I don't want to decide either way. If there are symlinks, any behavior is acceptable.

Do the inputs need to be strings?

Can we make any assumptions on the current directory content ? E.g. to assume it will be empty ?

@Tutleman I think anything else than strings would be too cheesy. However, if the "get current directory" function returns something other than string (some kind of "filesystem path object"), you can use this format for current directory.

@zeppelin Of course, no!

I now want someone to write a program that anytime someone uses an absolute path that could be shorter, echos to the command line, "You know...you could have typed this [short path] instead." Just because computers can always be just a little bit more passive-aggressive.

This is missing some critical test cases:  /home/test /home/user/mydir/myfile /home/test and /a/b /a/b/d/e /a/b

What do you mean by shorter?

Julia 0.5, 32 bytes
!,~=relpath,endof
t->~t<~!t?t:!t

This uses the current working directory as base and cannot be tested on TIO at the moment.
Example run
Warning: This will alter your file system.
$ sudo julia --quiet
julia> function test(target,base)
       mkpath(base)
       cd(base)
       shorten(target)
       end
test (generic function with 1 method)
julia> !,~=relpath,endof
(relpath,endof)

julia> shorten = t->~t<~!t?t:!t
(::#1) (generic function with 1 method)

julia> test("/home/user/mydir/myfile","/home/user")
"mydir/myfile"

julia> test("/var/users/admin/secret/passwd","/var/users/joe/hack")
"../../admin/secret/passwd"

julia> test("/home/user/myfile","/tmp/someplace")
"/home/user/myfile"

julia> test("/dir1/dir2","/dir1/dir2/dir3/dir4")
"../.."

julia> test("/dir1/dir2","/dir1/dir2")
"."

Alternate version, 35 bytes (dyadic)
^,~=relpath,endof
t-b=~t<~t^b?t:t^b

This takes the base directory as input, so it can be tested without modifying the file system.
Try it online!

Redefining Base.- errors unless explicitly imported, no?

In 0.5, it may error, but only if you use - before redefining it. In 0.4, it prints a warning whether you use it before the redefinition or not.

JavaScript (ES6), 107 106 bytes
Takes the absolute path a and the current path c in currying syntax (a)(c).
a=>c=>(A=a.split`/`,s='',c.split`/`.map(d=>!s&A[0]==d?A.shift():s+='../'),s+=A.join`/`)[a.length]?a:s||'.'

Test cases

let f =

a=>c=>(A=a.split`/`,s='',c.split`/`.map(d=>!s&A[0]==d?A.shift():s+='../'),s+=A.join`/`)[a.length]?a:s||'.'

console.log(f
  ('/home/user/mydir/myfile')
  ('/home/user')
);

console.log(f
  ('/var/users/admin/secret/passwd')
  ('/var/users/joe/hack')
);

console.log(f
  ('/home/user/myfile')
  ('/tmp/someplace')
);

console.log(f
  ('/dir1/dir2')
  ('/dir1/dir2/dir3/dir4')
);

console.log(f
  ('/dir1/dir2')
  ('/dir1/dir2')
);

A very nice trick with [a.length] ! May I borrow it to improve my Node.js answer ?

@zeppelin Sure. Go for it!

Retina, 85 83 82 bytes
1 byte saved thanks to @MartinEnder
^(..+)(.*;)\1
%$2
(%?)(.*);(.*)
$1$3;$2
\w+(?=.*;)
..
%;/

;
/
.*//
/
%/?|/$

^$
.

Try it online!

ES6 (Node.js REPL), 56, 54, 46, 45 bytes

Use empty string, instead of "." to denote the current directory (on input), -1 byte
Borrowed the [f.length] trick from @Arnauld's answer, -6 bytes
Use the current directory instead of an explicit directory parameter, -2 bytes
Removed superfluous parentheses, -2 bytes

Golfed
f=>(r=path.relative("",f))[f.length]?f:r||"."

Test
> F=f=>(r=path.relative("",f))[f.length]?f:r||"."
[Function: F]

> F("/home/user/mydir/myfile")
'mydir/myfile'

> F("/var/users/admin/secret/passwd")
'../../admin/secret/passwd'

> F("/home/user/myfile")
'/home/user/myfile'

> F("/dir1/dir2")
'../..'

> F("/dir1/dir2")
'.'

Do we not allow node.js functions?

@Downgoat Javascript lambdas are widely accepted, as a form of answer, so I don't see why Node.js should be handled differently.

Python 2, 135 144 bytes
i=0
a,c=input()
b,d=a.split('/')*(a!=c),c.split('/')
while b[:i+1]==d[:i+1]:i+=1
print'.'[i:]or min('/'.join(['..']*len(d[i:])+b[i:]),a,key=len)

Try it Online!
Kind of long, but I wanted to do a solution without built-in path functions.
Edit: 9 bytes added to account for test case provided by Nathan Merrill

Zsh + realpath, 58 bytes
r=`realpath -m --relative-to=$*`
(($#2<$#r))&&r=$2
echo $r

Try it online!
Bash version, 62 bytes
r=`realpath -m --relative-to=$*`
((${#2}<${#r}))&&r=$2
echo $r

Try it online!

Why not post it in two different answers? Every language matters!

Python 3 – 53 bytes
Using os.path:
import os
lambda x:min(x,os.path.relpath(x),key=len)

Full program (61 bytes):
import os
x=input();print(min(x,os.path.relpath(x),key=len))

Oo, good point(s). Python's in the lead now, yay!

@anatolyg Ha, I knew I'd miss at least one test case...  All fixed now.

PHP, 204 Bytes
[,$l,$p]=$argv;$z=($d=array_diff_assoc)($y=($w=explode)("/",$p),$x=$w("/",$l));$m=str_pad("",3*count($z)-1,"../");$j=join("/",$r=$d($x,$y));echo$l!=$p?strlen($u=$m&&$j?"$m/$j":$m.$j)<strlen($l)?$u:$l:".";

Testcases
Expanded
[,$l,$p]=$argv;
$z=($d=array_diff_assoc)($y=($w=explode)("/",$p),$x=$w("/",$l));
$m=str_pad("",3*count($z)-1,"../");
$j=join("/",$r=$d($x,$y));
echo$l!=$p
    ?strlen($u=$m&&$j?"$m/$j":$m.$j)<strlen($l)
      ?$u
      :$l
    :".";

if an Output ../../ instead of ../.. is allowed it can be shorten to 175 Bytes
[,$l,$p]=$argv;$z=($d=array_diff_assoc)($y=($w=explode)("/",$p),$x=$w("/",$l));echo$l!=$p?strlen($m=str_pad("",3*count($z),"../").join("/",$r=$d($x,$y)))<strlen($l)?$m:$l:".";

C# - 66 bytes
Using a .NET builtin and forcing to be a valid path:
(f,t)=>f==t?".":new Uri("/"+t).MakeRelativeUri(new Uri("/"+f))+"";

Where f,t and output are string.
Try it online!


text:
Incremental Cipher
This task is rather simple, and makes use of three distinct "operator" characters. Your task is, given a simple sequence of letters, perform the following task to encode it using <,>,*. You may choose to use either upper or lowercase letters, you do not have to handle both.

Cipher Explanation
The cipher is simple, you're using increment and decrement operations to traverse from letter 1 to the end letter, with * being your "submit" function. The operator for "increment" will be > and "decrement" will be <.
An example using the word adbc:

Start with the first letter of the word, output that letter. a
Next, use > and < (like brainfuck) to "navigate" the current letter to the next one. a> would result in 'raising' a by 1 to the letter b. a< would result in z because you're lowering the letter (it wraps, you must always choose the direction resulting in the LEAST number of operations).
After outputting the correct minimalized combination of < and > output a * to denote that we've reached the next letter.

The steps to encode adbc would be:
a          # a
a>>>*      # ad
a>>>*<<*   # adb
a>>>*<<*>* # adbc

Examples
The steps to encode aza would be:
a       # a
a<*     # az
a<*>*   # aza

More examples:
"abcdef"    =  "a>*>*>*>*>*"
"zyaf"      =  "z<*>>*>>>>>*"
"zzzzzz"    =  "z*****"
"z"         =  "z"
"zm"        =  "z<<<<<<<<<<<<<*" or "z>>>>>>>>>>>>>*" (equidistant)
"zl"        =  "z>>>>>>>>>>>>*"
"alphabet"  =  "a>>>>>>>>>>>*>>>>*<<<<<<<<*<<<<<<<*>*>>>*<<<<<<<<<<<*"
"banana"    =  "b<*>>>>>>>>>>>>>*<<<<<<<<<<<<<*>>>>>>>>>>>>>*<<<<<<<<<<<<<*" OR "b<*<<<<<<<<<<<<<*>>>>>>>>>>>>>*<<<<<<<<<<<<<*>>>>>>>>>>>>>*"
"abcdefghijklmnopqrstuvwxyz" = "a>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*>*"
"abcdefz"   =  "a>*>*>*>*>*<<<<<<*"

Rules

We are encoding not decoding, so don't mess that up.
You may assume the message will contain letters [A-Z] or [a-z], your choice.
You may use any non-letter/numeric/reserved character to denote * (E.G. $).
You must have the ending *, it isn't implicit on repeats.
You may assume no empty strings, but a single character is possible.
If it is equidistant either way to the next letter, you may choose a direction.
This is code-golf, lowest byte-count wins.

Please explain your answer, it helps others learn this way.

Just to be clear, the last test case represents abcdefghijklmnopqrstuvwxyz and is not its own input?

@NickClifford yes.

I think zl should use >.

Could you please check the examples? alphabet is in my opinion a>>>>>>>>>>>*>>>>*<<<<<<<<*<<<<<<<*>*>>>*<<<<<<<<<<<* and zl should be z>>>>>>>>>>>>* and for banana should a second solution exists b<*<<<<<<<<<<<<<*>>>>>>>>>>>>>*<<<<<<<<<<<<<*>>>>>>>>>>>>>*

@xnor correct, was a manual typo from zm. @jorg good catches, fixed all of them, was a manual effort.

Jelly, 17 bytes
OIżN$ẋ"@€⁾><;€⁶ṭḢ

Uses a space character in place of * (a space, ⁶, or a newline, ⁷, saves one byte over ”*).
Works with either uppercase-only or lowercase-only input.
Try it online! or see a test suite (where those spaces are post-replaced by * for reading ease).
How?
OIżN$ẋ"@€⁾><;€⁶ṭḢ - Main link: string s          e.g. "adbc"
O                 - cast s to ordinals                [97,100,98,99]
 I                - incremental differences           [3,-2,1]
    $             - last two links as a monad:
   N              -     negate                        [-3,2,-1]
  ż               -     zip together                  [[3,-3],[-2,2],[1,-1]]
         ⁾><      - literal ['>','<']                 "><"
      "@€         - using reversed @arguments for €ach zip with("):
     ẋ            -     repeat (-n are like zeros)    [[">>>",""],["","<<"],[">",""]]
            ;€    - concatenate €ach with:
              ⁶   -     literal ' '                   [[">>>","",' '],["","<<",' '],[">","",' ']]
               ṭ  - tack to:
                Ḣ -     head of s (1st char)          [['a'],[">>>","",' '],["","<<",' '],[">","",' ']]
                  - implicit print   (" not printed:) "a>>> << > "

8086 machine code, 70 68 67 bytes
00000000  be 82 00 bf 43 01 57 31  d2 ac 3c 0d 74 2c 89 d1  |....C.W1..<.t,..|
00000010  88 c2 aa e3 f4 4f 28 c1  9f 88 e7 79 02 f6 d9 83  |.....O(....y....|
00000020  f9 0d 9f 76 05 83 e9 1a  f6 d9 30 fc 9e b0 3c 78  |...v......0...<x|
00000030  02 b0 3e f3 aa b0 2a aa  eb cf c6 05 24 b4 09 5a  |..>...*.....$..Z|
00000040  cd 21 c3                                          |.!.|
00000043

How it works:
            |   org 0x100
            |   use16
be 82 00    |       mov si, 0x82        ; source = command line arguments
bf 43 01    |       mov di, result      ; destination = result
57          |       push di
31 d2       |       xor dx, dx          ; clear dx
ac          |   n:  lodsb               ; al = *si++
3c 0d       |       cmp al, 0x0d        ; end of input reached? (newline)
74 2c       |       je q                ; jump to exit in that case
89 d1       |   @@: mov cx, dx          ; store last char in cl
88 c2       |       mov dl, al          ; and store the current char in dl
aa          |       stosb               ; *di++ = al
e3 f4       |       jcxz n              ; skip encoding this char if cx == 0 (only happens for the first char)
4f          |       dec di              ; move di pointer back
28 c1       |       sub cl, al          ; take the difference between this char and the last one
9f          |       lahf                ; store flags from last subtraction in bh
88 e7       |       mov bh, ah
79 02       |       jns @f
f6 d9       |       neg cl              ; make sure cl is positive
83 f9 0d    |   @@: cmp cl, 13          ; which way is shorter?
9f          |       lahf                ; also store these flags
76 05       |       jbe @f
83 e9 1a    |       sub cl, 26          ; invert cl if we're going backwards
f6 d9       |       neg cl
30 fc       |   @@: xor ah, bh          ; xor saved flags together
9e          |       sahf                ; load flags register with the result
b0 3c       |       mov al, '<'
78 02       |       js @f               ; now the sign flag tells us which operator to use
b0 3e       |       mov al, '>'
f3 aa       |   @@: rep stosb           ; while (cx--) *di++ = al
b0 2a       |       mov al, '*'         ; mark the end with an asterisk
aa          |       stosb
eb cf       |       jmp n               ; repeat
c6 05 24    |   q:  mov byte [di], '$'  ; mark end of string
b4 09       |       mov ah, 0x09        ; dos function: print string
5a          |       pop dx              ; dx = string pointer
cd 21       |       int 0x21            ; syscall
c3          |       ret
            |   result rb 0

This. This is beyond cool. You did this REALLY quickly too, dang.

Thanks. It's pretty much the trivial solution though. Just happens to be quite short in 8086.

Python 3, 87 bytes
r,*s=input();p=r
for c in s:d=(ord(p)-ord(c)-13)%26-13;r+='<'*d+'>'*-d+'*';p=c
print(r)

Try it online!
Works with either lowercase or uppercase.
The program builds the output string r as it iterates over the characters in the input string. It stores the previous character as p, and computes the incrementing operation to get from p to the new character c.
The interval between the characters is ord(c)-ord(p), and (ord(c)-ord(p)-13)%26-13 takes it modulo 26 to the interval [-13..12]. A negative result means it's shorter to step down, and a positive result means to step up.
This needs to be converted to a string of > or < depending on the sign. Rather than using abs or a conditional, we take advantage of Python's string multiplication s*n giving the empty string when n is negative. In the  expression '<'*-d+'>'*d, the wrong-signed part does not contribute.
The initial state is handled by splitting the input into its first character and the rest with Python 3's unpacking r,*s=input(). The initial character is used to start building the string, as well as the initial "previous" char.
Thanks to ovs for suggesting switching to Python 3 to do this unpacking.

Python 3, 110 93 bytes
r,*s=input()
b=r
for a in s:d=(ord(a)-ord(b))%26;r+=['>'*d,'<'*(26-d)][d>13]+'*';b=a
print(r)

Try it online!

Ooo... Works for both lower and uppercase, nice one (but I think you can shave off bytes by assuming one or the other).

Explanation please?

JavaScript (ES6), 118 109 107 bytes
The input string is case insensitive.
s=>s.replace(/./g,(c,i)=>(d=~~s-(s=parseInt(c,36)),i)?'<><>'[k=d/13+2|0].repeat([d+26,-d,d,26-d][k])+'*':c)

How it works
Unlike Python, the JS modulo operator returns a number having the same sign as the dividend rather than the divisor. Also, the JS repeat() method throws an error when given a negative number, rather than returning an empty string (and it's significantly longer than a simple * anyway).
These are rather unfavorable behaviors for this challenge. So, we'd better identify in which exact case we are rather than relying on math tricks. (Which doesn't mean that such tricks do not exist, but rather that I failed to find them.)
Below is a table describing the 4 possibles cases, where d is the signed distance between the current character and the previous one:
d           | floor(d / 13) + 2 | direction | repeat
------------+-------------------+-----------+-------
-25 ... -14 |         0         |     <     | d + 26
-13 ... -1  |         1         |     >     | -d
 +0 ... +12 |         2         |     <     | +d
+13 ... +25 |         3         |     >     | 26 - d

Test cases

let f =

s=>s.replace(/./g,(c,i)=>(d=~~s-(s=parseInt(c,36)),i)?'<><>'[k=d/13+2|0].repeat([d+26,-d,d,26-d][k])+'*':c)

console.log(f("abcdef"));
console.log(f("zyaf"));
console.log(f("zzzzzz"));
console.log(f("z"));
console.log(f("zm"));
console.log(f("zl"));
console.log(f("alphabet"));
console.log(f("banana"));
console.log(f("abcdefghijklmnopqrstuvwxyz"));
console.log(f("abcdefz"));

C++ ,210 190 bytes
My First Try At Golfing !
#include<iostream>
int g(char*a){char k,j,d;std::cout<<*a;a++;for(;*a;a++){for(j=*(a-1),d=j-*a,k=d>0?d>13?62:60:d<-13?60:62;j!=*a;j+=k-61,j=j<97?122:j>122?97:j)std::cout<<k;std::cout<<'*';}}

k stores which of < , > or * to print  .At first it simply prints the first element of array then runs a loop for a from first to last element of array . j stores the previous element and then by comparing if j closer to  *a by < or > set k to < ,> respectively and then print k then run this loop until j becomes equal to p . Then after every ending of second loop print * .

Welcome to the site! If I recall correctly *p!=0 can be replaced with *p.  I'm pretty sure the space in char *a is also unnecessary.  You will also need to #include <iostream> and using namespace std; (although I think it might be cheaper to just add std::) to make this a complete answer.

Welcome to the site! I think you need to include std:: or using namespace std; You'll probably also need #include <iostream> in your byte count.

+1, but do fix the two aforementioned things, welcome to PPCG ;). Checkout some of the languages around the TIO Nexus ( https://tio.run/nexus ) when you get a chance! Maybe introduce yourself to Dennis, he's a key dude floating around here.

Thanks everyone for suggestions and pointing out the mistakes. I will update the code shortly.

PHP, 127 Bytes
for($l=ord($r=($s=$argn)[0]);$x=ord($s[++$i]);$l=$x)$r.=str_pad("",($a=abs($n=$l-$x))<14?$a:26-$a,"><"[$n>0^$a>13])."*";echo$r;

Testcases
PHP, 137 Bytes
for($l=$r=($s=$argn)[0];$s[++$i];$l=$s[$i])$r.=str_pad("",$d=min($a=abs(ord($l)-ord($s[$i])),$b=26-$a),"><"[$d<$b^$l<$s[$i]])."*";echo$r;

Testcases

Haskell (lambdabot), 161 153 bytes
w(s:n)=s:(join.snd$mapAccumL(ap(,).g)s n);g c n|q<-[c..'z']++['a'..c],(Just l,s)<-minimum$first(elemIndex n)<$>[(q,'>'),(reverse q,'<')]=(s<$[1..l])++"*"

Try it online!

Explanation:
-- Encode a single letter
g c n | q          <- [c..'z']++['a'..c]        -- The alphabet starting from letter c, looping around
      , (Just l,s) <- minimum                   -- Choose the smallest of ..
                    $ first(elemIndex n)        -- the index of the letter n ..
                  <$> [(q,'>'),(reverse q,'<')] -- from the alphabet q and its reverse

      = (s<$[1..l]) -- Repeat < or > the same number of times as the index of n ..
     ++ "*"         -- and append *

-- Encode the whole string
w (s:n) = s                                -- Yield the first char of the input
        : ( join . snd                     -- Concatinate the result of ..
          $ mapAccumL (\a b->(b,g a b))s n -- executing the g function on each letter of the input string ..
                                           -- except the first, passing the previous letter as the 'c' ..
                                           -- argument on each iteration
          )

JavaScript (ES6), 111 103 bytes

f=
s=>s.replace(/./g,(c,i)=>(p=(n+26-(n=parseInt(c,36)))%26,i?'<>'[p+3>>4].repeat(p>13?26-p:p)+'*':c),n=0)
<input oninput=o.textContent=f(this.value)>

s=>[...s].map(c=>(n=parseInt(c,36),p&&(p=(n+26-p)%26,s+='><'[p+3>>4].repeat(p>13?26-p:p)+'*'),p=n),s=s[p=0])&&s

Originally version that took 111 bytes before I adapted @Arnauld's trick of setting n while computing p, I think there's probably another trick using s instead of n but it's getting late so I won't bother.:

EXCEL VBA 130 bytes
s="":p=Mid(s,1,1):For i=1 To Len(s)-1:b=Asc(Mid(s,i+1,1)):a=Asc(Mid(s,i,1)):p=p &String(abs(b-a),IIf(b>a,">","<"))&"*":Next:[a1]=p

Run it from Excel VBA Immediate window.
Explanation:
Simple for loop that with String function to repeat the ">" or "<" n number of times where n is the ascii difference between the i and i+1 character string.

C, 170 bytes
e(c){putchar(c);}i;m(a,b){i=b-a?a>b?b-a<14?b-a:-(a+26-b):a-b<14?-(a-b):b+26-a:0;while(i>0)e(62),i--;while(i<0)e(60),i++;}f(char*l){e(*l);while(l[1])m(*l,l[1]),e(42),l++;}

Detailed Live
e(c){ putchar(c); } // encode

g(a,b) // obtain required transition
{
    return (b-a) // calculate distance

         ? (a > b // distance is non-zero

             // if b comes after a
             ? (b-a < 14 // if forward is a shorter path
                 ? b-a // go forward
                 : -(a+26-b)) // otherwise go backward

             // if b comes before a
             : (a-b < 14 // if backward is a shorter path
                 ? -(a-b) // go backward
                 : b+26-a)) // otherwise go forward

         : 0; // if distance is 0
}

// transition
i;m(a,b)
{
    // obtain required transition
    i=g(a,b);

    // encode forward transition
    while(i>0)e('>'), i--;

    // encode backward transition
    while(i<0)e('<'),i++;
}

// incremental cipher function
f(char*l)
{
    e(*l); // encode first character

    while(*(l+1)) // while next character is not END-OF-STRING
        m(*l,*(l+1)), // do transition from current to next character
        e('*'), // encode
        l++; // next
}

Cool solution. The following is probably easier to understand, but 1 byte longer: #define x q<14?q:q+26 e(c){putchar(c);}i,q;m(a,b){q=b-a;i=q?(a>b?x:-x):0;while(i>0)e('>'),i--;while(i<0)e('<'),i++;}f(char*l){e(*l);while(*(l+1))m(*l,*(l+1)),e('*'),l++;}

@Moreaki Thx, but this is a code-golf, so we always aim to reduce byte count, anyway I have added detailed explanation on how my code works.

Java 7-, 232 bytes
class C{static void main(String[]a)throws Exception{int i=System.in.read(),j,d,c;p(i);while((j=System.in.read())>10){d=(j-i+26)%26;c=d>13?-1:1;while(d%26>0){d-=c;p(61+c);}p(42);i=j;}}static void p(int k){System.out.print((char)k);}}

Pretty much the trivial solution. Ungolfed and commented:
class C {
    static void main(String[] a) throws Exception {
        int i = System.in.read(), j, d, c; // i is the last character. j is the current character. d is the difference. c is the direction (-1 is left, 1 is right)
        p(i); // print the starting character first
        while ((j = System.in.read()) > 10) { // keep going until a newline is hit (or an EOF/EOL for -1)
            d = (j - i + 26) % 26; // get the difference (always positive) by wrapping around
            c = d > 13 ? -1 : 1; // get the direction by finding which way is shorter, going right when it's a tie
            while (d % 26 > 0) { // keep going until the current character is reached
                d -= c; // reduce d in the right direction
                p(61 + c); // < is 60 = 61 + (-1), > is 62 = 61 - (-1)
            }
            p(42); // print an asterisk
            i = j; // set the current character to the new reference point
        }
    }

    static void p(int k) {
        System.out.print((char) k);
    }
}

Haskell, 167 168 126 bytes
f=fromEnum
r=replicate
a?b=mod(f a-f b-13)26-13
c#x=r(c?x)'<'++r(-c?x)'>'
s(c,s)x=(x,s++c#x++"*")
e(x:y)=x:snd(foldl s(x,[])y)

Now using xnor's arithmetic solution. Call with e str where str :: String is the string to be encoded.

Haskell, 109 bytes
a#b=mod(a-b-13)26-13
r=replicate
h(a:b:s)=r(a#b)'>'++r(-a#b)'<'++'*':h(b:s)
h e=""
f(a:r)=a:h(fromEnum<$>a:r)

Try it online! Uses xnor's approach. Call with f "somestring".

05AB1E, 17 bytes
¬sÇ¥v„<>y0›èyÄ×ðJ

Try it online!
Explanation
Uses >, < and <space> to denote increment, decrement, submit
¬                  # get the first letter of the input string
 sÇ¥               # push a list of delta's of the character codes in the input string
    v              # for each delta
     „<>           # push the string "<>"
        y0›        # check if the delta is positive
           è       # use this to index into the string
            yÄ×    # repeat it abs(delta) times
               ðJ  # join to string with a space

And lost this one by 3 hours .

JavaScript (ES6), 140 128 129 111 113 bytes
I went down a different route to the other JS solutions but it didn't work out too well - here's what I have so far:

f=

([x,...s])=>x+s.map(y=>`<><>`[r=(d=y[c=`charCodeAt`]()-x[c](x=y))/13+2|0].repeat([d+26,-d,d,26-d][r])+`*`).join``

i.addEventListener("input",()=>o.innerText=i.value&&f(i.value))
console.log(f("adbc"))
console.log(f("aza"))
console.log(f("abcdef"))
console.log(f("zyaf"))
console.log(f("zzzzzz"))
console.log(f("z"))
console.log(f("zm"))
console.log(f("zl"))
console.log(f("alphabet"))
console.log(f("banana"))
console.log(f("abcdefghijklmnopqrstuvwxyz"))
console.log(f("abcdefz"))
<input id=i>

Saved 12 bytes thanks to a suggestion from Luke on destructuring the string.
Added 1 byte fixing a misreading of the challenge, which I thought allowed for an implicit final print character.
Saved another 18 bytes thanks to an extensive rewrite by Luke.
Added 2 bytes as it seems numbers are not valid print characters.

Original, 131 bytes

f=

([x,...s])=>x+s.map(y=>(t=(d=y[c=`charCodeAt`]()-x[c](x=y))<0?-d:d,`<>`[+((r=t<13)&&d>0)||+(!r&&d<0)].repeat(r?t:26-t)+`*`)).join``

i.addEventListener("input",()=>o.innerText=i.value&&f(i.value))
console.log(f("adbc"))
console.log(f("aza"))
console.log(f("abcdef"))
console.log(f("zyaf"))
console.log(f("zzzzzz"))
console.log(f("z"))
console.log(f("zm"))
console.log(f("zl"))
console.log(f("alphabet"))
console.log(f("banana"))
console.log(f("abcdefghijklmnopqrstuvwxyz"))
console.log(f("abcdefz"))
<input id=i>

([x,...s])=>x+s.map(...) saves 12 bytes. Note that you should append a print character to the end as well. I suggest using a number, which will only cost 2 bytes \1`+1instead of`*``.

Thanks, Luke; I'd forgotten I could destructure a string input like that. I must have misread the challenge last night; I could've sworn it said the last print character was implicit. Unfortunately, simply tacking it on after the join would have resulted in an invalid output for single letter inputs. However, moving the print character within the map method only cost 1 byte.

([x,...s])=>x+s.map(y=>'<><>'[r=(d=y[c='charCodeAt']()-x[c](x=y))/13+2|0].repeat([d+26,-d,d,26-d][r])+0).join\`` for 111 bytes

Thanks, again, @Luke. Before I edit it in, would you prefer to post the above as your own answer? I feel it differs sufficiently from mine (almost a hybrid of it and Arnauld's) for that to be OK.

Nah, you can edit it in. I tried golfing a reduce solution, but that turned out to be 115 bytes.

source: Stack Exchange

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

sort: votes


text:
GCD / LCM Polyglots!
Your challenge is to make a program or function that outputs the GCD of its inputs in one language and the LCM of its inputs in another. Builtins for GCD or LCM (I'm looking at you, Mathematica) are allowed but not encouraged. There will be 2 inputs, which will always be positive integers, never greater than 1000.
Test Cases
Each line is one test case in the format x y => GCD(x,y) LCM(x,y):
1 1 => 1 1
1 2 => 1 2
4 1 => 1 4
3 4 => 1 12
7 5 => 1 35
18 15 => 3 90
23 23 => 23 23
999 1000 => 1 999000
1000 999 => 1 999000
1000 1000 => 1000 1000

See this pastebin for all possible inputs with 0 < x, y < 31. Note that different versions of the same languages count as different languages.

So... an if based on a version of the language, if stored in a variable, is allowed?

@illidanS4 that is fine.

Jelly / Actually, 2 bytes
00000000: 1e 67                                            .g

This is a hexdump (xxd) of the submitted program. It cannot be tested online because TIO doesn't support the CP437 encoding. @Mego was kind enough to verify that this works on Cygwin, which implements CP437 as intended for Actually.
Jelly: GCD
Jelly uses the Jelly code page, so it sees the following characters.
œg

Try it online!
How it works
œ is an incomplete token and thus ignored. g is the GCD built-in.
Actually: LCM
Actually uses CP 437, so it sees the following characters.
▲g

Try it online!
How it works
▲ is the LCM input. Since g (GCD) requires two integer inputs, it isn't executed.

C / C++, 79 78 73 bytes
Thanks to @ETHproductions for saving a byte!
int f(int a,int b){int c,d=a*b;for(;a;b=c)c=a,a=b%a;auto e=.5;c=e?d/b:b;}

C calculates the GCD: Try it online!
C++ calculates the LCM: Try it online!
In C, auto e=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.
The function calculates the GCD with Euclid's algorithm, and the LCM by dividing the product of a and b by the GCD.
Omitting the return statement works at least on GCC. The 78 byte solution below should work with any compiler:
int f(int a,int b){int c,d=a*b;for(;a;b=c)c=a,a=b%a;auto e=.5;return e?d/b:b;}

an explanation would be cool, if you can

@cat Explanation added.

If I'm not mistaken, you can save a byte with for(;a;b=c)c=a,a=b%a;

@ETHproductions Thanks! I knew there was a reason to use for instead of while ;)

Actually / Jelly, 3 bytes
00000000: 11 1c 67                                         ..g

This is a hexdump (xxd) of the submitted program.
Try it online!1
Actually: GCD
Actually uses CP 437, so it sees the following characters.
◄∟g

Try it online!
How it works
     (implicit) Read a and b from STDIN and push them on the stack.
◄    Unassigned. Does nothing.
 ∟   Unassigned. Does nothing.
  g  Pop a and b and push gcd(a,b).
     (implicit) Write the result to STDOUT.

Jelly: LCM
Jelly uses the Jelly code page, so it sees the following characters.
×÷g

Try it online!
How it works
×÷g  Main link. Left argument: a. Right argument: b

×      Multiply; yield ab.
  g    GCD; yield gcd(a,b).
 ÷     Division; yield ab/gcd(a,b) = lcm(a,b).

Note: The formula gcd(a,b)lcm(a,b) = ab holds because a and b are positive.

1 TIO actually uses UTF-8 for Actually. Since both the ASCII characters and the CP437 characters 0x11 and 0x1c are unassigned, the program works nevertheless.

Alice and Jelly, 9 bytes
Alice computes the LCM:
//L
oi@g

Try it online!
What looks like a space is really 0x7F, the DEL control character.
Jelly computes the GCD. Since Jelly uses its own code page which is only compatible with printable ASCII, the linefeed and DEL character turn into ½ and linefeed, respectively:
//L½oi@
g

Try it online!
Explanations
Jelly is trivial: the first line defines a nonsensical helper link, the second line is the actual program and it simply contains the GCD built-in.
Alice is a little bit trickier, but it also uses a built-in:
/   Reflect to SE. Switch to Ordinal.
    While in Ordinal mode, the IP bounces diagonally up and down through the grid.
i   Read all input as a single string.
L   Compute the shortest common superstring of an empty string and the input. That
    is simply the input itself, so this does nothing.
    After two more bounces, the IP hits the top right corner and turns
    around, continuing to bounce up and down while moving west.
L   Still does nothing.
i   Try to read more input, but this simply pushes an empty string.
/   Reflect to W. Switch to Cardinal.
    The IP wraps to the last column.
L   Implicitly discard the empty string and convert the input to two integers.
    Compute their LCM.
/   Reflect to NW. Switch to Ordinal.
    The IP immediately reflects off the top boundary to move SW instead.
o   Implicitly convert the LCM to a string and print it.
    Reflect off the bottom left corner and move back NE.
/   Reflect to S. Switch to Cardinal.
i   Try to read a byte, but we're at EOF, so this pushes -1 instead. Irrelevant.
    The IP wraps back to the first line.
/   Reflect to NE. Switch to Ordinal.
    The IP immediately reflects off the top boundary to move SE instead.
@   Terminate the program.

What looks like a space doesn't really look like a space.

@EriktheOutgolfer depends on the font, I guess.

For me 0x7F (duh mini-markdown) has never looked like a space in any font, at least in my experience. But it always inserts that extra line spacing below the line it resides in...

Octave / MATLAB, 66 61 bytes
@(x,y)gcd(x,y)^(1-2*any(version==82))*(x*y)^any(version==82))

Saved 5 bytes thanks to Foon. (x*y)^any() was of course shorter than 1+(x*y-1)*any().

Well, at least it doesn't use the builtin for lcm.
Explanation:
This uses the builtin gcd to calculate the Greatest common divisor.
In Octave, this is raised to the power of 1-2*any(version==82). any(version==82) is 0 in Octave, so this is simply gcd(x,y)^1. It's multiplied by (x*y)^any(version==82), or (x*y)^0 = 1.
For MATLAB, gcd is raised to the power of 1-2*any(version==82). any(version==82) is 1 in MATLAB, so this is gcd(x,y)^-1. It multiplied by (x*y)^any(version==82), or (x*y)^1 = x*y. This gives the Least common multiple, since lcm(x,y) == x*y/gcd(x,y) for positive numbers.

Julia 0.4 / Julia 0.5, 18 bytes
log.(1)==0?lcm:gcd

Evaluates to gcd in Julia 0.4 (Try it online!) and to lcm in Julia 0.5 (Try it online!).
How it works
In Julia 0.4, log.(1) is a shorthand for getfield(log,1), which returns the memory location of the log builtin, e.g., the pointer Ptr{Void} @0x00007f2846cb6660. The result is thus non-zero, the comparison is false, and the expression evaluates to gcd.
In Julia 0.5, a new function vectorization syntax was introduced. log.(1) is now a shorthand for broadcast(log,1), which – since 1 is not iterable – simply evaluates log(1). The result is thus zero, the comparison is true, and the expression evaluates to lcm.

Jelly and MATL, 6 5 bytes
ZmD
g

This is a full program in either of the two languages. It computes the GCD in Jelly (Try it online!) and the LCM in MATL (Try it online!). The MATL program exits with an error (allowed by default) after producing the correct output.
Only ASCII characters are used, so they correspond to the same encoded bytes in the two languages.
Explanation of GCD in Jelly
ZmD    Unused link
g      Main link (gets called automatically). Builtin GCD function (g)

Explanation of LCM in MATL
ZmD    Compute LCM (builtin function Zm) and display immediately (D)
g      Tries to implicitly take input to do something with it (depending
       on the type of the input). Since there is no input, it errors out

Octave / MATLAB, 44 42 41 bytes
eval(['@' 'lcm'-[5 0 9]*all(version-82)])

This defines an anonymous function for GCD (@gcd) in Octave, and for LCM (@lcm) in MATLAB.
Example in Octave (or Try it online!):
>> eval(['@' 'lcm'-[5 0 9]*all(version-82)])
warning: implicit conversion from numeric to char
ans = @gcd
>> ans(12,16)
ans =  4

Example in MATLAB:
>> eval(['@' 'lcm'-[5 0 9]*all(version-82)])
ans =
    @lcm
>> ans(12,16)
ans =
    48

JS (ES6), CGL (CGL Golfing Language), 31 bytes (non-competing)
The LCM feature of CGL was added after this challenge.
 g=(a,b)=>b?g(b,a%b):a
//-LⓍ

What looks like a space is actually a non-breaking space, a comment for CGL. JS computes the GCD:
g=(a,b)=>b?g(b,a%b):a

And CGL computes the LCM:
//  does nothing
- decrements the current stack number, resulting in it pointing to input
L computes the LCM of the first and second stack items and pushes it to the stack
Ⓧ prints out the last stack item

Try it out:

Snippetify( g=(a,b)=>b?g(b,a%b):a
//-LⓍ
);
<script src="https://programmer5000.com/snippetify.min.js"></script>
<input type = "number">
<input type = "number">

Whispers v1/Whispers v2, 51 bytes
> Input
> Input
>> R1
>> 1⊓2
>> 1⊔2
>> Output 4

Try it online! (Whispers v1)
Try it online! (Whispers v2)
How it works
The pivotal line is interestingly the only line that isn't executed by either language:
>> R1

In Whispers (both versions), lines which don't match one of a certain set of regex are completely ignored. As a result, lines containing invalid commands are simply skipped over by the interpreter. R is a command  that returns the magnitude and angle of a vector, which was added in version 2. In version 1 however, it's an invalid command, so that line is removed.
In both versions, the execution pattern is the same: output the value on line 4, which is either the GCD or LCM of the inputs, depending on the version. In version 1, we remove the 3rd line, so line 4 is
>> 1⊔2

which simply runs the LCM command on the inputs. In version 2 however, the program is unchanged, meaning that line 4 is
>> 1⊓2

which is the GCD builtin applied to the two inputs.
Finally, in both versions, the value on line 4 is outputted and the program ends

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:
Compute a complex power
The Rundown
Given any input x and y, perform a complex operation, and print a corresponding result.
How your program should work

Given an input x and y in the form z = x+yi, find zi-z
If the absolute real value of zi-z is larger than the absolute imaginary part, print the real part; vice versa for the other way around. If both values are equal, print one of the values.

Example
x: 2
y: 0

Therefore:
z = 2
z^(i-z) ~= 0.192309 + 0.159740i

Since the real part has a larger absolute value than the imaginary part, the program returns
0.192309

More examples
z = 1+i >> 0.5
z = i >> 1
z = 0.5 >> 1.08787
z = -2+8i >> 2.22964E7
z = -10i >> 3.13112E7

Pro-tip: get rid of the bonus!

Things to avoid when writing challenges - bonuses in code-golf

It would be nice if you gave more input-output pairs.

@user1502040 Sure thing

Raising a complex numbers to a complex power is discontinuous and depends on the branch cut used. Can you specify that? Though I guess everyone will just be using built-in math operations and those probably all use the same convention.

Do we have to take X and Y as separate inputs? Some languages can take complex numbers as inputs.

@ScottMilner, No you can take z as an entire input.

Does "larger" mean to pick the value with greatest absolute value, rather than (what most have assumed) to pick the maximal value? A test case of -2+i could be used for that (z^(i-z)=3-4i so 3>-4 vs abs(-4)>abs(3)).

Will the real and imaginary parts of the input always be integers? Your test cases seem to suggest that.

what is the problem? why [on hold]? larger means larger and not abosolute larger... possible there is to clear if z=a+i*b with a and b in R or integers, but it is better in the set R

The "absolute value" clarification/change has invalidated most of the answers.

@YamB: https://github.com/DaveJarvis/sequential -- cheers from Victoria.

Jelly, 8 11 bytes
Thanks Johnathan Allan for updating the answer with the rules change.
ı_*@µĊ,ḞAÞṪ

Try it online!
ı_*@        z^(i-z)
    µ       new monadic link
     Ċ,Ḟ    pair real and imaginary parts
        AÞṪ sort by absolute value and take last value

Make it ı_*@µĊ,ḞAÞṪ and you may well have the only valid entry (given the change to require the maximal value in absolute terms, such that, for example, -2+1j returns -4.0 rather than 3.0).

Python 2, 45 bytes
def f(z):z=z**(1j-z);print max(z.real,z.imag)

Try it online - all test cases
Programming languages often use j instead of i. That is the case in Python. See this SO question for more information on why.

Mathematica, 21 22 bytes
Edit: Thanks to JungHwan Min for saving 3 btyes
Max@ReIm[#^(I-#)]&

Pure function which expects a complex number as an argument. If an exact number is passed, then an exact number will be returned (e.g. 1/2 gives Sqrt[2] Cos[Log[2]]). The problem spec was edited after I posted my solution to specify that the absolute value should be used. The best I can come up with for that is MaximalBy[ReIm[#^(I-#)],Abs][[1]]& or Last@MaximalBy[Abs]@ReIm[#^(I-#)]&, both 34 bytes.

Max does not need to be the head. It returns the max value no matter how deep the input List is (e.g. Max[1, {2, {3}}] returns 3). Also, the question only specifies that you print the values, so I don't think you would need N: Max@ReIm[#^(I-#)]& would work.

MATL, 10 bytes
Jy-^&ZjhX>

Try it online! Or verify all test cases.
Explanation
Consider input -2+8i as an example.
J     % Push i (imaginary unit)
      % STACK: i
y     % Implicit input. Duplicate from below
      % STACK: -2+8i, i, -2+8i
-     % Subtract
      % STACK: -2+8i, 2-7i
^     % Power
      % STACK: 3168271.58+22296434.47i
&Zj   % Real and imaginary parts
      % STACK: 3168271.58, 22296434.47
h     % Concatenate
      % STACK: [3168271.58 22296434.47]
X>    % Maximum. Implicitly display
      % STACK: 22296434.47

Octave, 29 bytes
@(z)max(real(z^(i-z)./[1 i]))

This defines an anonymous function. It works in MATLAB too.
Try it online!
Explanation
Element-wise dividing (./) the number z^(i-z) by the array [1 i] and taking the real part gives an array with the real and imaginary parts of z^(i-z).

TI-BASIC, 40, 32, 31 29 bytes
Saved a byte thanks to @Conor O'Brien
Z^(i-Z→A                   #Perform operation, store as A, 8 bytes
:real(A)>imag(A            #Test if real part is greater than imaginary, 9 bytes
:Ansreal(A)+imag(Anot(Ans  #Determine output and print, 12 bytes

Takes input as a complex number on the Z variable.
TI-BASIC uses its own encoding, you can find it here.

Pyth, 16 Bytes
=b^Q-Q.j;eS,ebsb

C (GCC), 93 79 + 4 (-lm) = 97 83 bytes
Saved 14 bytes thanks to @ceilingcat!
float f(_Complex z){z=cpow(z,csqrt(-1)-z);return cimag(z)>creal(z)?cimag(z):z;}

Including the header complex.h is longer than that ¯\_(ツ)_/¯
Try it online!

Why +4 bytes? I count 3,  -, l, and m.

@Riker normal compiling is gcc file.c -o exe, so this flag adds 4 bytes: space, -, l, and m. (At least that's how I see it counted when compiling.)

@ceilingcat oh didn't know that was possible. Thanks!

54 bytes

Ruby, 25 35 bytes
EDIT: Fixed to comply with new absolute value rule.
->z{(z**(1i-z)).rect.max_by(&:abs)}

Try it online!
This creates an anonymous function.

Perl 6, 24 bytes
{($_**(i-$_)).reals.max}

$_ is the possibly complex argument; $_ ** (i - $_) is the expression to be computed; .reals is a Complex method that returns a list of the real and imaginary parts; and finally .max returns the larger of the two.

TI-Basic, 19 16 bytes
Ans^(i-Ans
max(real(Ans),imag(Ans

real( and imag( are two-byte tokens.
Run with 5+3i:prgmNAME (5+3i being the argmuent, NAME being the program name.)

APL (Dyalog Unicode), 18 bytes
18 bytes (https://github.com/abrudz/SBCS/)
28 bytes (UTF-8)
⍵ is a complex number ajb = a+bi
{⌈/9 11∘.○⍵*0j1-⍵}

Try it online!

Axiom, 60 bytes
f(z:Complex Float):Float==(y:=z^(%i-z);max(real(y),imag(y)))

test code and results; i follow as the other the precedent version of the question...
(28) -> [[k,f(k)] for k in [1+%i,%i,1,-2+8*%i,-10*%i]]
   (28)
   [[1.0 + %i,0.5], [%i,1.0], [1.0,1.0],
    [- 2.0 + 8.0 %i,22296434.4737098688 53],
    [- 10.0 %i,31311245.9804955291 66]]

R, 38 bytes
pryr::f({z=z^(1i-z);max(Re(z),Im(z))})

Anonymous function. Takes a (possibly) complex number z, takes it to the specified power, and then returns the max of the Real and Imaginary parts.

C# - 189 Bytes
double f(double x, double y){double r,t,m,c;r=Math.Sqrt(x*x+y*y);t=Math.Atan2(y,x);m=Math.Pow(r,-x)*Math.Exp(y*t-t);c=Math.Cos((1-y)*Math.Log(r)-t*x);return m*(2*c*c<1?Math.Sqrt(1-c*c):c);}

Readable:
double f(double x, double y){
double r, t, m, c;
r = Math.Sqrt(x * x + y * y);
t = Math.Atan2(y, x);
m = Math.Pow(r, -x) * Math.Exp(y * t - t);
c = Math.Cos((1 - y) * Math.Log(r) - t * x);
return m * (2 * c * c < 1 ? Math.Sqrt(1 - c * c) : c); }

Explanation: Decided not to use any Complex libraries.
$$
\begin{align}
z & = x + iy \\
& = r e^{it} \\
z^{i-z} & = (re^{it})^{(-x +i(1-y))} \\
& = r^{-x} r^{i(1-y)} e^{-xit} e^{t(y-1)} \\
& = r^{-x} e^{t(y-1)} e^{i((1-y)\ln(r)-xt)} \text{ (as }r^i = e^{i\ln(r)}\text{)}
\end{align}
$$
Let this be equal to \$me^{ia}\$ where
$$m = r^{-x} e^{t(y-1)}$$
$$a = (1-y)\ln(r)-xt$$
Then \$\Re(z^{i-z})=m \cos a\$ and \$\Im(z^{i-z})=m \sin a\$
The maximum absolute value can be determined by the \$\cos a\$ and \$\sin a\$ terms, with these being equal at \$\frac{1}{\sqrt{2}}\$ (hence the test \$2c^2 < 1\$).
As mentioned, raising to a complex exponent is dependent on choosing a particular branch cut ( e.g. \$z = 1\$ could be \$e^{i\pi}\$ or \$e^{3i\pi}\$ - raising this to \$i\$ gives a real part of \$e^{-\pi}\$ or \$e^{-3\pi}\$ respectively), however, I have just used the convention of \$t \in [0,2\pi)\$ as per the question.


text:
Create a vortex!
Your mission today is to create a vortex given a single parameter.
This parameter determines the length of each arm in characters.
Each "layer" of each arm contains one more character than the last.
Here's how the vortex will look, given the arm length:
0:

#

1:

 #
###
 #

2:

 #
  # #
 ###
# #
   #

3:

##  #
  # #
 ###
# #
#  ##

4:

#     #
 ##  #
   # #
  ###
 # #
 #  ##
#     #

10:

             #
             #
             #
             #
            #
####        #
    ###     #
       ##  #
         # #
        ###
       # #
       #  ##
      #     ###
      #        ####
      #
     #
     #
     #
     #

Standard loopholes apply, trailing whitespace optional, any single non-whitespace character in ASCII can replace "#".
This is code-golf so the shortest answer in bytes wins.

The spec (such as there is) seems to contradict the examples. Where did the asymmetry come from in the last two?

Here is a corrected version.

@JonathanAllan see my edit's description: Removed the ugly black non-character, but they're still asimmetric. And no, I'm not taking over... Seems like a boring challenge to me (no offense)

Please re-open this. It is clear now.

@JonathanAllan Yeah, they had an issue as you said. Fixed.

Please take a look at the Mathematica answer. Is the extra spacing allowed, or would the user have to use the longer code?

Charcoal, 30 bytes
#ＮβＦβ«¿ι«×#⌊⟦ιβ⟧Ａ⁻βιβ↑»»‖←⟲Ｏ²⁴⁶

Explanation
#                                    Print "#"
 Ｎβ                                 Input number to b
    Ｆβ«                  »          For i in range(b)
        ¿ι«              »           If i is truthy (to skip 0)
           ×#⌊⟦ιβ⟧                   Print "#" * minimum of i and b
                  Ａ⁻βιβ↑            Assign b-i to b
                           ‖         Reflect right
                            ⟲Ｏ²⁴⁶  Rotate overlap 90, 180 and 270 degrees

Try it online!

Trim seems to work out golfier: ＮθＦθ⁺¶#×#ιＪ⁰¦⁰Ｔθ⁺¹θ#⟲Ｏ↖²⁴⁶ (⁺¹ is a workaround because Ｔ⁰¦⁰ doesn't work for some reason. and ⊕ didn't exist back then.)

MATL, 60 bytes
3<G+Eqt&OlG8M+t&(1G:8*X^Q2/kG+G:Gq+&vG2=+Z{(XJ3:"J@X!+]g35*c

Try it online! Or verify test cases: 0, 1, 2, 3, 4, 10.
This turned out to be funnier than I expected. Explaining is going to be harder, though...

Jelly, 48 bytes
Rȯ1ĖŒṙ‘Ė’ḣµ;NµN0¦€U;
Ç+;ẋ2W$+⁸<3¤µFṀR,þ$e€€ị⁾# Y

Try it online!
(Make it all more square by replacing the final Y with G, adding a space between each column).
How?
Builds a list of # coordinates of an arm relative to the centre. Transforms that to the coordinates of the four arms from the top-left corner and adds the centre coordinate. Builds a table of all the coordinates in the space and sets the arms to # and the space to  and joins up the rows with newlines.
Rȯ1ĖŒṙ‘Ė’ḣµ;NµN0¦€U; - Link 1, arm coordinates relative to centre: arm-length a
R                    - range: [1,2,...,a]
 ȯ1                  - or 1 (stops Œṙ erroring with arm-length 0; builds no redundant coordinates in the end)
   Ė                 - enumerate: [[1,1],[2,2],...[a,a]]  (or [[1,1]] if a=0)
    Œṙ               - run-length decode: [1,2,2,...,a,a,...,a] (or [1] if a=0)
      ‘              - increment: [2,3,3,...,a+1,a+1,...,a+1] (or [2] if a=0)
       Ė             - enumerate: [[1,2],[2,3],...,[T(a)-a,a+1],[T(a)-a+1,a+1],...,[T(a),a+1]] where T(a)=(a+1)*a/2 (or [[1,2]] if a=0)
        ’            - decrement: [[0,1],[1,2],...,[T(a)-a-1,a],[T(a)-a,a],...a[T(a)-1),a]] (or [[0,1]] if a=0)
         ḣ           - head to a (first a of those) - these are an arm's relative coordinates from the central `#` at [0,0])
          µ          - monadic chain separation (call that list r)
           ;         - r concatenated with
            N        - negate r (gets the opposite arm)
             µ       - monadic chain separation (call that list s)
                 €   - for €ach coordinate pair in s:
               0¦    -     apply to index 0 (the right of the two values):
              N      -         negate
                  U  - upend (reverse each pair of that, gives the other two arms)
                   ; - concatenate that list with s (gives all four arms)

Ç+;ẋ2W$+⁸<3¤µFṀR,þ$e€€ị⁾# Y - Main link: arm-length a
Ç                           - call the last link(1) as a monad (get centre-relative coordinates)
 +                          - add a (make the coordinates relative to the top-left)
      $                     - last two links as a monad:
   ẋ2                       -     repeat a twice: [a,a]
     W                      -     wrap in a list: [[a,a]] (the centre coordinate)
  ;                         - concatenate (add the centre coordinate)
           ¤                - nilad followed by link(s) as a nilad:
        ⁸                   -     link's left argument, a
         <3                 -     less than three?
       +                    - add (a in 0,1,2 are special cases requiring a grid one-by-one more than all the rest)
            µ               - monadic separation (call that c)
             F              - flatten c into one list
              Ṁ             - get the maximum (the side-length of the space)
                  $         - last two links as a monad:
               R            -     range: [1,2,...,side-length]
                ,þ          -     pair table: [[[1,1],[1,2],...,[1,side-length]],[[2,1],[2,2],...,[2,side-length]],...,[[side-length,1],[side-length,2],[side-length, side-length]]]
                   e€€      - exists in c? for €ach for €ach (1 if a # coordinate, 0 otherwise)
                       ⁾#   - literal ['#',' ']
                      ị     - index into
                          Y - join with new line characters
                            - implicit print

Mathematica 139 172 Bytes
The idea is to create a single arm with a function - {⌊.5+.5(-7+8#)^.5⌋,#-1} that spits out the index of each element of the arm assuming the middle element has index (0,0). No one has picked up on that yet, but I suspect this idea would result in a winning answer in a better golfing language. Then I rotate the arm through multiples of 90 degrees, re-index and construct the matrix.
SparseArray seemed like the obvious choice for constructing the matrix, but could have gone with BoxMatrix and ReplacePart.
Grid[SparseArray[Max@#+#+1&[Join@@Table[RotationMatrix[i Pi/2].#&/@{{0,0}}~Join~Array[{⌊.5+.5(-7+8#)^.5⌋,#-1}&,#],{i,4}]]->X,2#+1,""]]&

Ungolfed (Hard coded for arm length=3,% means previous output):
{{0,0}}~Join~Table[{Floor[1/2 (1+Sqrt[-7+8x])],x-1},{x,1,3}]
Table[RotationMatrix[i Pi/2].#&/@%,{i,4}]
Flatten[%,1]
Max[%]+%+1
Normal@SparseArray[%->X,Automatic,""]
Grid[%/. 0->""]

Usage
%@4
X                       X
    X   X           X
            X       X
        X   X   X
    X       X
    X           X   X
X                       X

As I've learned the output must be pure ASCII without extra spacing or formatting, the code has to get a little longer (172 bytes):
StringRiffle[ReplacePart[Array[" "&,{1,1}*2#+1],Max@#+#+1&[Join@@Table[RotationMatrix[i Pi/2].#&/@{{0,0}}~Join~Array[{⌊.5+.5(-7+8 #)^.5⌋,#-1}&,#],{i,4}]]->"#"],"\n",""]

#     #
 ##  #
   # #
  ###
 # #
 #  ##
#     #

Can the extra spacing between columns be removed? As this is an ASCII-art challenge, the output should be exactly as specified, with no extra spacing (@Papayaman1000 please confirm if this can be exempted)

I put in an edit for that if it turns out to be required.  Right now it seems debatable.

Hmm... I would prefer that, for competition's sake, you use the answer that gives the exact output. As @HyperNeutrino said, it is ASCII-art, so it should be as specified.

OK, I fixed it.


text:
Contradictory Polyglots
Well, everyone loves Polyglots. You will be given two integers, in any standard form of input (no hardcoding). Your task is to write a polyglot which finds the minimum value in a language and the maximum value between the two numbers in the other language, and performs the following operations:

The code which finds the maximum value must also compute their sum.
The program which finds the minimum value must also compute the result of their subtraction (max - min)
Here is the "tricky part":  If the two numbers are equal, both the programs must not output/ return anything (both to  STDOUT and STDERR or any other return method)
See the Output specs section for more details about formatting

Input
As stated above, two integers taken as input in any standard method, common to both languages.
Output specs

For the program which finds the max, the format should be: max_value, addition result
For the program which finds the min, the format should be min_value, subtraction result (max - min)
The results can be printed, with any clear delimiter ( ,\n,, or whatever else you want), returned from the function as a string containing the two expected values with a delimiter or as a list of numbers (e.g: [max_value,sum])

Examples:
Input   || Max Language Output || Min Language Output

100, 40 || 100, 140            || 40, 60
63, 67  || 67, 130             || 63, 4
-45, -5 || -5, -50             || -45, 40
21, 21  ||                     ||
-1, 1   || 1, 0                || -1, 2

Scoring:
This is code-golf, so try to write the shortest code to get the desired results, while taking note that Standard Loopholes are strictly disallowed. You must use two different languages, not other versions of the same language (e.g: Python 2-Python 3 pairs are not valid)

@downvoter why was that?

I'd recommend keeping questions at the sandbox for at least a couple of days so that they gain enough attention before posting on main. I didn't downvote.

Goddammit, wrote a Py2/Py3 answer and just as I was about to post saw the rule. 30 minutes i'll never get back Haha.

05AB1E / Jelly, 21 20 bytes
-1 byte after asking for some help - thanks Emigna! (` will push(uwrapped(pop())))
Raw bytes (the dump to the right shows what my Windows machine displays):
60 ca 69 b9 5a 73 4f 29 71 93 18 fa 2c d3 f7 d3    `Êi¹ZsO)q..ú,Ó÷Ó
cd 04 18 2f                                         Í../

Both take input from STDIN and output to STDOUT as a list representation [x, y].
The max language is 05AB1E:
`Êi¹ZsO)q“.ú,Ó÷ÓÍ../

Where the . represent unprintable bytes in it's codepage (cp1252), and probably here in whatever you are using (0x18=CAN and 0x04=EOT).
Try the 05AB1E version
The min language is Jelly:
İ__iỤZs0)qƓð«,ạẋạṠ¥ð/

Try the Jelly version.
How?
05AB1E:
`Êi¹ZsO)q“.ú,Ó÷ÓÍ../ - parsed left to right, executed as parsed
                     - implicit input taken
  i                  - If:
`                    -     push(unwrapped(pop()))
 Ê                   -     push(pop()!=pop())
                     - ...Then:
   ¹                 -     push(1st item from input history)
    Z                -     push(max(top of stack))
     s               -     push(reverse(pop(),pop()))
      O              -     push(sum(pop()))
       )             -     wrap(pop())
        q            -     quit - implicit print of top of stack
         “.ú,Ó÷ÓÍ../ - unexecuted and unparsed string

Jelly:
`ȮiỤZs0)qƓð«,ạẋạṠ¥ð/ - parsed left to right, not executed until parsed
`ȮiỤZs0              - a dyadic chain which would error if executed (monad from dyad, index of, grade up, transpose, split into chunks of length 0)
       )q            - currently unassigned code points each currently creates a new link
         Ɠ           - read and evaluate a line of input
          ð       ð  - dyadic chain separations
                   / - reduce by:
           «         -     minimum(left, right)
             ạ       -     absolute difference(left, right)
            ,        -     pair(result)
                 ¥   -     last two links as a dyad:
               ạ     -         absolute difference(left, right)
                Ṡ    -         sign(result) (i.e. {0:0, +x:1, -x:-1} but -x never happens)
              ẋ      -     repeat list left right times
                     - implicit print

C and C++ (gcc), 117 107 bytes
-10 bytes thanks to @Steadybox!
#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.
C - max language: Try it online!
C++ - min language: Try it online!

Very smart solution. I like the fact that no comments were used.

To save a few bytes, you could declare a variable auto c=.5, and then use c instead of sizeof'a'-1. In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

Python 3 / Jelly, 42 bytes
Using Jelly's code-page to encode the file.
Raw bytes:
6c 61 6d 62 64 61 20 78 2c 79 3a 5b 6d 61 78 28    lambda x,y:[max(
78 2c 79 29 2c 78 2b 79 5d 2a 28 78 21 3d 79 29    x,y),x+y]*(x!=y)
0a 23 7f fa 2c d3 f7 d3 cd 04                      .#.ú,Ó÷ÓÍ.

Both define an unnamed dyadic function.
Python (the max language) sees:
lambda x,y:[max(x,y),x+y]*(x!=y)
#\x7fú,Ó÷ÓÍ\x04

Tests as Python.
Jelly (the min language) sees:
lambda x,y:[max(x,y),x+y]*(x!=y)½#
«,ạẋạṠ¥

Tests as Jelly.
How?
Jelly interprets 0x0a as ½, the square root atom while Python interprets it as a newline. In Jelly 0x7f is interpreted as a separation between links (functions) and is represented by either a newline or a pilcrow in it's codepage. For Jelly the last link is the main function - here it does not call the link above (which the interpreter does still need to parse correctly). In Python 0x23, # instructs that anything after it and before 0x0a, a newline, is a comment.
The Python code that gets executed:
lambda x,y:[max(x,y),x+y]*(x!=y)
lambda x,y:                      - A function taking two inputs, x and y
           [        ,   ]        - A list with two items
            max(x,y)             - take the maximum of x and y
                     x+y         - x plus y
                           x!=y  - x not equal to y?
                         *(    ) - multiply - True is treated as if it were 1, False as if it were 0

The Jelly code that gets executed:
«,ạẋạṠ¥ - A dyadic link (function of two variables): x, y
«       - minimum(x, y)
  ạ     - absolute difference(x, y)
 ,      - pair left with right (creating a list)
      ¥ - last two links as a dyad:
     ạ  -     absolute difference(x, y)
    Ṡ   -     sign(result) (i.e. {0:0, +x:1, -x:-1} but -x never happens)
   ẋ    - repeat the list to the left right times (either the same list or an empty list)
        - return the result

Interesting language choice

It's almost certainly possible to combine the Jelly code with another golfing language to get the byte count down.

Umm... your code snippets appear to be different.

@EriktheOutgolfer those code blocks are just representations of the raw bytes (hence the \x7f and \x04 for the unprintables in the Python one).

@JonathanAllan No, I mean that your snippets are really different. Just see the Python code for each one.

@EriktheOutgolfer Thanks, fixed. copy + paste = >_<

Ruby / Python 3, 102 bytes
Ruby returns max/sum, Python returns min/difference. Input is an array object read from STDIN.
a=eval((0and gets or input()))
b=a.sort()
x,y=(b or a)
z=0 or 1
x==y or print([[y,x][z],[x+y,y-x][z]])

Try it online: Ruby
Try it online: Python
The main quirk used here is the use of the truthy 0 in Ruby, which is falsy in Python. The other thing worth mentioning is that Python's sort function modifies the list in-place and returns None, while Ruby's doesn't and returns the sorted array, hence the need to use b or a to get the min/max.
Python 3 is required because Python 2 complains if you try to call print after the or statement in the last line.

That's clever! +1

Java/AWK, 219 217 212 196 bytes
/*#\/* /
{$0=((x=$1)<y=$2)?x" "y-x:y" "x-y}x!=y
#*/interface B{static void main(String[]A){Integer x=Integer.parseInt(A[0]);int y=x.parseInt(A[1]);System.out.print(x==y?"":(x<y?y:x)+" "+(x+y));}}

Try it online!
Java outputs the max and sum, AWK outputs min and difference. No output for either if the inputs are identical.
This is my first polyglot and first TIO :)

JavaScript (ES6)/ QBasic, 172 171 bytes
'';f=x=>{m=Math.max(...x);s=Math.min(...x);if(x[0]!=x[1])alert([m,m-s])}/*
INPUT c
LET m=c
LET s=c
INPUT n
IF n>c THEN m=n
IF n<c THEN s=n
IF n<>c THEN PRINT m,m+s
END
'*/

Based on this solution of mine of a similar polyglot question.
This solution too use the comment approach!
JavaScript is the min-language. It takes in an array containing numbers as input. Outputs two numbers separated by , (1st number is the smallest value of the input-array and 2nd number is the difference of the greatest and the smallest values of the input-array) by alert()ing. Does not alert() anything if the numbers are equal. You can call the function like f([100,40]).
QBasic is the max-language. Repeatedly asks for input, twice. Prints the largest number of the input-numbers as well as the sum of largest and smallest numbers of the input. Does not PRINT anything if the numbers are equal.

How does it work?
In QBasic (a language of structured BASIC family; it does not require line numbers), ' marks the beginning of a comment which goes till the end of the line. Whereas in JavaScript, it marks the start of a string. So, the whole first line is marked as a comment in QBasic but in JavaScript, the line is executed (and this line contains the JavaScript part that computes the smallest number and the difference of greatest and smallest numbers, as well as a /* at the end which starts a comment in order to hide the rest of the QBasic code from JavaScript interpreter.)
The code from second line to second-last line contains the QBasic code to compute the greatest number and the sum of greatest and smallest number (the code is very self-explanatory).
The last line contains '*/. ' causes the QBasic interpreter to interpret the following code as a comment, whereas in JavaScript, it does not have any effect as it is a part of a comment (which was started at the end of the first line). The following code (*/) causes JavaScript to end the comment which was started in the first line, but it is not executed in QBasic because QBasic thinks it's a part of a comment.

Test Cases
JavaScript (min-language):

'';f=x=>{m=Math.max(...x);s=Math.min(...x);if(x[0]!=x[1])alert([m,m-s])}/*
INPUT c
LET m=c
LET s=c
INPUT n
IF n>c THEN m=n
IF n<c THEN s=n
IF n<>c THEN PRINT m,m+s
END
'*/

f([100,40]);

QBasic (max-language):
Go to this website. Copy paste the following code in their text-editor :
1 '';f=x=>{m=Math.max(...x);s=Math.min(...x);if(x[0]!=x[1])alert([m,m-s])}/*
2 INPUT c
3 LET m=c
4 LET s=c
5 INPUT n
6 IF n>c THEN m=n
7 IF n<c THEN s=n
8 IF n<>c THEN PRINT m,m+s
9 END
10 '*/

The reason why line numbers are required is that the website I mentioned only supports unstructured BASIC languages. And that website is the only decent online BASIC interpreter I could find. However, running the code present in the top of the post (the code without line numbers) should work fine in any good QBasic interpreter that supports structured BASIC and ' as a comment-starter (few do not, most do, though)


text:
Plus or minus polyglots!
Your submission must take a list of numbers (in whatever list format your language supports, or using multiple function / command-line parameters) or a string of numbers separated by any character that is not 0123456789. In one language, it must add all of them and output the sum. In another language, it must output them subtracted from each other in order. Example:
12
5
7
2

In one language, it must output 26, and in another it must output -2. Note that all numbers inputted will be positive integers less than 100. There will never be more than 20 numbers provided, so you will never output greater than 2000 or less than -1899. Any questions? Comment below!

Is trailing whitespace in the output allowed?

Are two different versions of the same language allowed? See the Python 2 / 3 Answer by HyperNeutrino

@Mr.Xcoder it's allowed.

@BasicSunset yes. You may also require a trailing newline in the input.

Ugh, so many polyglot questions recently :P

@BetaDecay is there...a problem??

Nah, just it'd be nice if there was a little more variation

@BetaDecay you think that's a problem, check out code-golf!

@programmer5000 You mean [code-golf] -[polyglot]?

Jelly / 05AB1E, 3 bytes
00000000: c6 71 53                                         .qS

This is a hexdump (xxd) of the submitted program.
Try it online!
Jelly: Sum
Jelly uses the Jelly code page, so it sees the following characters.
İqS

Try it online!
How it works
İqS  Main link. Argument: A (array)

İ    (ignored)
 q   Unrecognized token. This breaks the link; nothing to the left is executed.
  S  Take the sum of A.

05AB1E: Difference
05AB1E uses Windows-1252, so it sees the following characters.
ÆqS

Try it online!
How it works
Æ     Take the difference of the input.
 q    Quit.
  S   (ignored)

Python 2 / 3, 52 bytes
lambda l:sum(l[:1]+[x*int(1-(1/2)*4)for x in l[1:]])

int(1-(1/2)*4) returns 1 in Python 2 because 1/2 evaluates first to 0, and then 0 * 4 = 0.
int(1-(1/2)*4) returns -1 in Python 3 because 1/2 evaluates first to 0.5, and then int(0.5 * 4) = int(2.0) = 2.

Is using the same language, with other versions even allowed?

@Mr.Xcoder I don't see why not, I've seen other languages using either different versions of C, Java, Python, and Befunge. I'll ask on meta though or see if I can find a related meta post.

Good use of math tricks due to version changes, though.

@Mr.Xcoder Thanks! I've asked the question on meta here; I should hopefully get an answer soon.

And I've asked the author of the challenge :)

@Mr.Xcoder I've also asked on TNB :P

@Mr.Xcoder Turns out that it's up to OP, so we'll just wait for programmer5000 to answer your comment on the OP. :) Also move to chat if there's anything else you want to discuss to avoid chatty comments :)

@Mr.Xcoder as I said above, it's OK.

Why does 1/2 evaluate to 0?

@programmer5000 Integer division.

C and C++ (both from GCC), 81 75 73 bytes
int c;int f(int*a,int l){auto d=.5;c=*a++;for(;--l;a++)c+=*a-4*d**a;c=c;}

Takes a pointer to array and length.
Explanation: still using @Steadybox' explanation :p In C, auto d=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5.
C - plus language: Try it online!
C++ - minus language: Try it online!

Should I consider it ironic that C is the plus language and that C++ is the minus language?

@user that was intentional :p

05AB1E / Jelly, 5 bytes
00000000: 4f71 7f5f 2f                             Oq._/

Try it online! (05AB1E)
Try it online! (Jelly)
05AB1E sees:Oq_/Explanation:
Oq_/ 1 implicit argument.
O     Take the sum of the first input item.
 q    Quit.
  _/ Not functional.
Jelly sees:Oq
_/Explanation:
_/ Main link. Arguments: z
_/ Subtract z's elements in order.

Oq Helper link. Not functional.

Does this use the Jelly codepage?

@programmer5000 This is a raw bytestream that uses CP-1252 for 05AB1E and JELLY for Jelly. Hence the 7f.

Oh, didn't realize that!

Actually / Jelly, 4 bytes
00000000: e4 81 5f 2f                                      .._/

This is a hexdump (xxd) of the submitted program. It cannot be tested in raw form online; TIO doesn't support the CP437 encoding.
Actually: Sum
Actually uses CP 437, so it sees the following characters.
Σü_/

Try it online!
How it works
Σ     Take the sum on the input.
 ü    Print and empty the stack.
  _   Natural logarithm. Ignored since the stack is empty.
   /  Float division. Ignored since the stack is empty.

Jelly: Difference
Jelly uses the Jelly code page, so it sees the following characters.
ỵ¹_/

Try it online!
How it works
ỵ¹_/  Main link. Argument: A (array)

ỵ     Unrecognized token. Splits the link.
 ¹    Identity; yield A.
  _/  Reduce (/) A by subtraction (_).

I read that as actually, Jelly. :)

You abused the fact that an undefined character acts like ṛ :)

@EriktheOutgolfer More or less. To be perfectly honest, I'm not quite sure what unrecognized tokens do.

On second thought, I think that you just chose Actually just because it has ü assigned to the perfect function >_>

@programmer5000 It's jelly, actually.

Python 2 and 3, 44 41 bytes
lambda l:eval(l.replace(' ','-+'[1/2>0]))

Takes space-separated numbers.

-3 bytes thanks to @JonathanAllan
Try it online: Python 2 (minus)
Python 3 (plus)

Use '-+'[1/2>0] to save three bytes.

CJam/Jelly, 6 bytes
q~:-
S

CJam
q~    e# Read a list from input
:-    e# Reduce by subtraction
S     e# Push a space
      e# Implicit output

Try it online!
Jelly
(using UTF-8, not the Jelly code page)
q~:- is the helper link. Since it doesn't get called, it really doesn't matter what it does. S computes the sum of an array.
Try it online!

Jam and Jelly. Makes sense to use two similar things together.

This is invalid. Jelly has 0x7f for newline, this has 0x0a for newline. In Jelly, this is actually the same as q~:-½S. Unfortunately, the fix (q~:-e#\x7fS) is larger. Try it online! (CJam) and Try it online!, each one with its own encoding to test for yourself.

Alternatively, you can use UTF-8 encoding for Jelly, which makes this valid as it currently is, but please specify it.

JavaScript / Cubix, 36 bytes
//.!v+u;$I^@O<.Iu
a=>eval(a.join`-`)

Try it!
The JavaScript function can be tested using the snippet below, the Cubix program can be tested here.
How does this work?
JavaScript
The first line is a line comment to JavaScript, since it starts with two slashes, so JavaScript only sees the bottom line (a=>eval(a.join`-`)), which takes an array as input, joins it with minus signs inbetween, and then runs that as code, resulting in the subtraction of all elements in the array.

let f=
//.!v+u;$I^@O<.Iu
a=>eval(a.join`-`)

console.log(f([1,2,3,4,5]))
console.log(f([3,1,4,1,5]))

Cubix
Cubix sees the following cube (notice that Cubix ignores all whitespace):
      / / .
      ! v +
      u ; $
I ^ @ O < . I u a = > e
v a l ( a . j o i n ` -
` ) . . . . . . . . . .
      . . .
      . . .
      . . .

The Beginning
The IP starts on the third line, pointing east. It hits the 'I' command, which takes a number from the input, and pushes it to the stack. Then, it is redirected by '^' into the sum-loop.
Sum-loop
I removed all characters not part of the sum loop, and replaced them by no-ops ('.'). The IP initally arrives on the second line, pointing east.
      . . .
      ! v +
      u ; $
. . . . . . I u . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

First, the '!' command checks the top element. If that is 0 (i.e. we have reached the end of the input), the next instruction ('v') is executed, reflecting the IP out of the loop. If we have not yet reached the end of the input, we add the top two items together ('+', the second item is the sum up to that point, the top item the new input). Then, the IP wraps to another face of the cube, into the 'u' character, which causes the IP to make a u-turn, and execute a 'I' command (read another input integer), while pointing north. The IP wraps back to the top face, skips ('$') the delete instruction (';') and makes another u-turn, back to the point at which we started.
The End
If the IP is reflected out of the loop, the following characters are executed:
      . . .
      . v .
      . ; .
. . @ O < . . . . . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

These instructions delete the top element (which is zero), and then output the top element (the sum) as an integer. Then the '@' command is reached, so the program ends.

JS (ES6), CGL (CGL Golfing Language), 32 26 bytes
 x=>eval(x.join`-`)
//-⨥

JS does the subtraction and CGL does the addition.
JS:
x=>eval(x.join`-`)

An anonymous function that subtracts each element in the array using Array#reduce.
//-⨥

A comment.
CGL
 x=>eval(x.join`-`)

What looks like a space on the first line is actually a non-breaking space, a comment in CGL. The first line is ignored.
//-⨥

The /s do nothing. The - decrements the current stack pointer so it is pointing to input. ⨥ adds the current stack (input) together, pushes that to the next stack, and increments the current stack. It is implicitly outputted.

You can shorten the JS version by using x=>eval(x.join\-`)`, saving 5B

Looks like 26 bytes.

@Adám you are right. Fixed.

JavaScript (ES6) / QBasic, 84 83 bytes
'';f=x=>eval(x.join`+`)/*
INPUT a
FOR i=1 TO 2
i=0
INPUT n
a=a-n
PRINT a
NEXT i
'*/

Another solution with the comment hack!
JavaScript computes the sum. It takes in an array containing numbers as input. Outputs as function return. You can call the function like alert(f([10,20,30])).
QBasic computes the difference. Repeatedly asks for input. As soon as you enter a value, it outputs the difference of all the numbers you have entered 'til  the time of hitting Enter and again asks for input. Keeps on doing the same until the end of everything.

How does it work?
In QBasic (a language of structured BASIC family; it does not require line numbers), ' marks the beginning of a comment which goes till the end of the line. Whereas in JavaScript, it marks the start of a string. So, the whole first line is marked as a comment in QBasic but in JavaScript, the line is executed (and this line contains the JavaScript part that adds the numbers as well as a /* at the end which starts a comment in order to hide the rest of the QBasic code from JavaScript interpreter.)
The code from second line to second-last line contains the QBasic code to compute the difference of all the input numbers (the code is very self-explanatory).
The last line contains '*/. ' causes the QBasic interpreter to interpret the following code as a comment, whereas in JavaScript, it does not have any effect as it is a part of a comment (which was started at the end of the first line). The following code (*/) causes JavaScript to end the comment which was started in the first line, but it is not executed in QBasic because QBasic thinks it's a part of a comment.

Test Cases
JavaScript (adds):

'';f=x=>eval(x.join`+`);/*
INPUT a
FOR i=1 TO 2
i=0
INPUT n
a=a-n
PRINT a
NEXT i
'*/
console.log(f([12,5,7,2]));

QBasic (subtracts):
Go to this website. Copy paste the following code in their text-editor :
1 '';f=x=>eval(x.join`+`);/*
2 INPUT a
3 FOR i=1 TO 2
4 i=0
5 INPUT n
6 a=a-n
7 PRINT a
8 NEXT i
9 '*/

The reason why line numbers are required is that the website I mentioned only supports unstructured BASIC languages. And that website is the only decent online BASIC interpreter I could find. However, running the code present in the top of the post (the code without line numbers) should work fine in any good QBasic interpreter that supports structured BASIC and ' as a comment-starter (few do not, most do, though).

Notes

This is my first polyglot post! I hope it's a good one!
The QBasic part of the code does not require END because the interpreter will never reach it! (It will forever be stuck in the infinite loop; always asking for more input.)

@DomHastings I've made a minor edit for you

Thank you! Apologies again...

Python 2 and 3, 33 bytes
lambda l,*r:l+sum(r)*(1/2>0 or-1)

Takes input as separate parameters.

Python 2.
Python 3.

lambda l,*r:l+sum(r)*(1/2-.5)*2 for 31 bytes

@ovs I purposefully avoided returning a float. If you are allowed to, then *(1/2*4-1) is a byte less than yours.

I think the return type does not really matter as long the value is correct

Brain-Flak / Brain-Flueue, 20 bytes
({}<([({{}})]){}>{})

Try it online! (Brain-Flak) (plus)
Try it online! (Brain-Flueue) (minus)
Explanation
The only difference between Brain-Flak and Brain-Flueue is that Brain-Flueue replaces the two stacks (last in first out) used in Brain-Flak with two queues (first in first out). Naturally this program uses this difference.
Annotated Code
(                  ) Push the sum of...
 {}                   the first input,
   <            >     zero,
                 {}   the remaining sum (see below)
    ([      ])       Push the of below line
      ({{}})         Pop all the input sans first, push the sum
              {}     Pop (in Brain-Flak, this discards the negative sum,
                            in Brain-Flueue, the positive)

Whispers v2/Add++, 72 bytes
D,f,@:,v¦Ω_
y:''
Dx,]getchar,`y,+x,`x
$f>y
> Input
>> ∑1
>> Output 2

Try it online! (Whispers v2)
Try it online! (Add++)
Both are encoded as UTF-8, despite Add++ having it's own code page. Whispers takes the sum, Add++ takes the difference. This assumes that both languages take input from STDIN. Add++ exits with an error after having output the difference, which is allowed by default.
How it works (Whispers)
Whispers is very nice to polyglot, as it simply ignores every line that doesn't begin with >. As a result, the executed code is
> Input
>> ∑1
>> Output 2

This simply takes in input, calculates its sum and outputs it.
How it works (Add++)
Add++ will error as soon as it reaches > Input, so only the stuff before that matters:
D,f,@:,v¦Ω_
y:''
Dx,]getchar,`y,+x,`x
$f>y

Taking input from STDIN is much longer in Add++ than from ARGV, but I wanted to be consistent across languages. Add++ doesn't have a builtin for reading from STDIN, aside from the ]getchar command, which simply reads in a character (similar to brainfucks , command), and assigns it to the active variable (in this case x). Therefore, in order to read something from STDIN, we need the following structure:
y:''
Dx,]getchar,`y,+x,`x

As ]getchar returns the empty string when it reaches the end of the input, we can use a do-while loop to read each character in. We start by declaring a variable y equal to the empty string. Next, we enter a do-while loop that runs until x is falsey (i.e. the empty string). This loop reads in a character from STDIN and concatenates it to y. Eventually, y is equal to the contents of STDIN.
Next, we define and run a function on the input:
D,f,@:,v¦Ω_
$f>y

As there is no way to evaluate a string in non-functional Add++ code, we're stuck with y as a string, rather than an array, which is what we need. Therefore, we have to pass the string into a function:
$f>y

The function itself is fairly basic to understand:
D,f,     ; Define a function which...
    @:,  ; Takes 1 argument and outputs its return value
         ; This argument is the unevaluated string input, and the : flag saves a byte when it comes to outputting the final result
    v    ; Evaluate the input (convert from a string to an array)
    ¦Ω_  ; Reduce that array by subtraction
         ; Return and output this value

Very simply, both languages ignore each other's code, either due to how the code is parsed, or by erroring before it's actually reached.

Befunge-93 / Befunge-98 (FBBI), 23 bytes
#<&01v>-.@.+
~^#+&_^#+1

Try it online! (Befunge-93) (minus)

Try it online! (Befunge-98) (plus)
(Note: there must not be trailing whitespace in the input.)
Explanation (both languages)
The control flow is the same in both languages until we reach EOF.
#<&01v>-.@.+
#<               # (skipped)
  &              # Get the first number
   0             # Push 0
    1            # Push 1
     v           # Go down to the next line

~^#+&_^#+1
     _           # The top 1 is nonzero, so the we go to the left
                 (begin loop)
    &            Get the next number
   +             Add it to the running total (which starts as the 0 we pushed)
 ^#              (skipped)
~                Get the next separator character
        +1       Add 1
      ^#         (skipped)
     _           The separator plus 1 is nonzero, so we keep going left
                 (repeat)

By the time we run out of input, the top stack element is the sum of all the numbers but the first, and the first number is underneath it. When we reach EOF, the control flow diverges, because Befunge-93 pushes -1, while Befunge-98 reflects the instruction pointer.
Explanation continued (Befunge-93)
~^#+&_^#+1
    &         # Get the last number
   +          # Add it to the running total
 ^#           # (skipped)
~             # On EOF: push -1
        +1    # Add 1 to get 0
      ^#      # (skipped)
     _        # The top of the stack is 0, so we turn to the right
      ^       # Go up to the first line

#<&01v>-.@.+
      >       # Turn to the right
       -      # Subtract, from the first number, the sum of all the others
        .     # Print the result
         @    # End the program

Explanation continued (Befunge-98)
~^#+&_^#+1
    &         # Get the last number
   +          # Add it to the running total
 ^#           # (skipped)
~             # On EOF: reverse direction
 ^            # Go up to the first line

#<&01v>-.@.+
 <            # Turn to the left
#             # No-op
           +  # Αdd the first number to the sum of all the others
          .   # Output the result
         @    # End the program

Python 3 / Javascript, 55 bytes
1//1;"""
f=(l)=>eval(l.join`-`)//""";f=lambda l:sum(l)

Javascript function taken from Luke's Javascript / Cubix answer. Python function is trivial. Works by abusing the fact that // is an operator in python and a line commentor in javascript, and then using """ to comment out the javascript section.
Running the code
In Python:
1//1;"""
f=(l)=>eval(l.join`-`)//""";f=lambda l:sum(l)

print(f([1, 2, 3]))

In Javascript:
1//1;"""
f=(l)=>eval(l.join`-`)//""";f=lambda l:sum(l)

console.log(f([1, 2, 3]));

If you wanted the full program to be a polyglot, you could add ;print=console.log to the python multiline string.

JavaScript ES6/ES10, 29 bytes
x=>eval(x.join(x.at?'+':'-'))

Try it online!
Decide if Array.prototype.at exist
x86 16-bit/32-bit, 15 bytes
    lodsw
    xchg ax, dx
    jmp b
a:  lodsw
    mov bx, 0 ; skip next instruction in 32-bit
    neg ax
    add dx, ax
b:  loop a
    ret


text:
Self Referential Puzzle - medium 2
The following puzzle was asked in puzzling SE. This puzzle is quite hard to solve by hand because every answer depends on another answer. So, for example, a solution with all answers being A does not work because then the question 7 would contradict question 8, for example.
One of the answers there at puzzling SE suggested to write a program to test all possible answers and show one of them (if it exists). So, I'm bringing this to the experts :)
The puzzle consists in finding an array of ten characters (each one of them being either A, B, C, D or E) that satisfies all the following questions (where each character in the array is an "answer" and its index is a "question") without contradiction:

The first question whose answer is D is the question

A.  8
  B.  7
  C.  6
  D.  5
  E.  4

Identical answers have questions

A.  3 and 4
  B.  4 and 5
  C.  5 and 6
  D.  6 and 7
  E.  7 and 8

The number of questions with the answer E is

A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions with the answer A is

A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions with the answer A equals the number of questions with the answer

A.  A
  B.  B
  C.  C
  D.  D
  E.  none of the above

The last question whose answer is B is the question

A.  5
  B.  6
  C.  7
  D.  8
  E.  9

Alphabetically, the answer to this question and the answer to the following question are

A.  4 apart
  B.  3 apart
  C.  2 apart
  D.  1 apart
  E.  the same

The answer to this question is the same as the answer to the question

A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions whose answers are consonants

A.  3
  B.  4
  C.  5
  D.  6
  E.  7

The answer to this question is

A.  A
  B.  B
  C.  C
  D.  D
  E.  E

The objective of this chalenge is to write the shortest program that can generate all the possible answers and check how many of them (if any) satisfy what every one of the previous questions are asking (the output of the program would be the list of the answers that satisfy all the questions without contradiction).
The original test can be found here (although it is irrelevant for this chalenge).

Add an objective winning criterion (such as shortest code length, most popular answer after X days,  or something of that ilk). That's a requirement for posted things here to not be closed; short of that, this looks fun.

Hello and welcome to our site.  There are a few things that need to be changed about this question.  1) in order to be on topic all questions need an "Objective winning criterion", that is a way to score answers so that people have a goal other than simply completing the challenge.  The most popular one is [tag:code-golf]. 2) right now this challenge is a bit underspecified.  Without clicking the puzzling link I have no idea what is being asked.  You should aim to outline exactly what answers must do to their input.  Test cases which you included are always welcome.

Is #5 correct? It seems the answer will always be A. And what happens with #2 if a set of possible answers has identical answers to #4, #5, and #6?

@GregMartin the way I understand it, the way these questions work is that they might have multiple correct answers but some of those answers might cause the other questions to have no correct answers and are thus invalid. If a question does have multiple correct answers that don't cause another question to have no valid answers then there are multiple solutions to the puzzle.

@usernameiwantedwasalreadytaken it's a step in the right direction. One thing you still need to clarify though is what exactly you want as output. Should the program output all 9765625 possible answers along with whether each works or doesn't work? Or should it output just the correct solutions? In relation to that what exactly does "generate and check all the possible answers" mean? What it mean to generate an answer and what does it mean to check it? How much checking are people allowed to optimize away? One extreme would be hardcoding the answer which you probably don't want.

I'm not sure that the validity check is objective here (making it hard to know who's won and who needs to be disqualified). How are we excluding answers that just hardcode assumptions about the problem? The normal fix to this would be to take the list of questions as input, but I'm not sure that works here because the questions don't follow a common structure.

Note: I found a slight wording difference between the source of this (the linked webpage) and the original paper from which that was sourced. I don't think it makes any difference to the solution-set (which I believe is of size 0, yet ought to be of size 1 as has the question-set of which it is supposedly an isomorphism). Where this says "5. The number of questions with the answer A equals the number of questions with the answer (A) A (B) B (C) C (D) D (E) none of the above" the paper says "...(A) A (B) B (C) D (D) E (E) none of the above".

@0, @ais523 Thanks for the suggestions! I've made same corrections, maybe it is clearer now...

@JonathanAllan, someone at Puzzling.SE saw that too (see the last paragraph of this answer...). Apparently this does not make much of a difference...

@usernameiwantedwasalreadytaken I am that someone

@JonathanAllan Oh sorry! Just saw that... I feel so silly now...

@usernameiwantedwasalreadytaken the output specification looks good. The only thing left to fix with your challenge is with "generate all possible answers". I might be interpreting this in the wrong way but it sounds to me like this is an algorithm requirement which is a non-observable program requirement. Such requirements are not allowed in [tag:code-golf].

Pyth, 104 bytes
f!s[nhd-8xd3@.+d+3@d1nh@d2/d4nh@d3/d0!&/3@d4!-/d0/d@d4!-10x_d1@d5n@d6a4@.+d6n@d7@d@d7!+3@d8@ds/LdS3)^U5T

It... uh... takes a while to run. Try it online... if the server doesn't time out or run out of memory.
Explanation coming SoonTM.  Prints all the valid solutions as a 0-based list (ten elements long in which A is represented by 0, B by 1, and so on).
This is a naive solution that can probably be golfed a lot.  Just wanted to get something out there.