text:
Vowels up, consonants down
Challenge
You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" is a consonant.
Examples
Hello World -> hEllO wOrld
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVXWYZ -> AbcdEfghIjklmnOpqrstUvwxyz AbcdEfghIjklmnOpqrstUvxwyz

Info

The input string can contain letters A to Z, lowercase or uppercase, and spaces.

Input
The string
Output
The formatted string (Vowels uppercase and consonants lowercase).

Why on many challenges is "y" counted as a consonant ?

Because it is a consonant. ( unless you're using international phonetic alphabet, where it's the front-high-rounded vowel /y/)

@bigyihsuan It's a bit more complicated than that. Wikipedia says: "In the English writing system, it mostly represents a vowel and seldom a consonant." As a child, I was taught that the vowels were "A, E, I, O, U, and sometimes Y," which could lead to viewing Y as "not really a vowel" because it's not always a vowel. Y is also a consonant in some very common words like "yes" and "you." But these are just guesses; I'm not entirely sure why Y is often not considered a vowel in coding challenges.

JavaScript (Node.js),  55 ... 46  45 bytes
Saved 1 byte thanks to @KevinCruijssen
s=>Buffer(s).map(c=>c^(c^~68174912>>c)&32)+''

Try it online!
How?
The constant \$68174912\$ is a bitmask describing the positions of the vowels:
00000100000100000100010001000000
     v     v     v   v   v
zyxwvutsrqponmlkjihgfedcba`_^]\[

As per the ECMAScript specification, the following expression:
~68174912 >> c & 32

is equivalent to:
~68174912 >> (c % 32) & 32

and therefore evaluates to \$32\$ for a consonant or \$0\$ for a vowel, no matter the case of \$c\$.
Commented
s =>                   // s = input string
  Buffer(s)            // turn s into a buffer
  .map(c =>            // for each ASCII code c:
    c ^                //   change the case if:
      ( c              //     c is not in lower case
        ^              //     XOR
        ~68174912 >> c //     c is a consonant
      ) & 32           //
  ) + ''               // end of map(); coerce back to a string

Thank you for the answer, it is so beautiful!

Damn... I'll definitely try to use bit masks for future submissions...

Worth mention that space is treated as a consonant and don't turn into \0

C (gcc), 49 bytes
Port of my JS answer.
f(char*s){for(;*s;s++)*s^=(*s^~68174912>>*s)&32;}

Try it online!

C (clang), 48 bytes
A version suggested by @Neil
This is abusing the way clang is dealing with the pointer post-increment.
f(char*s){for(;*s;)*s++^=(*s^~68174912>>*s)&32;}

Try it online!

Ah, this is a binary lookup table of ASCII characters mod 32. Smart.

@S.S.Anne Yes, exactly. (I've just added an explanation to my JS answer.)

GCC is too clever, but if you switch to clang then you can (currently) get away with incrementing the pointer in the assignment statement thus saving a byte.

@Neil Nice find!

GCC actually generates these for long strings of comparisons. Of course, they're in machine code, but still.

@S.S.Anne Yes, you are absolutely right: for n==1|n==5|n==7|n==13, it will test the bitmask 0x20a2 (C to machine code) provided that the code is compiled with at least -O1.

Python 3, 55 bytes
lambda s:[[c,c.upper()][c in"aeiou"]for c in s.lower()]

Try it online!
Input: A string/sequence of characters
Output: a list of characters.
Explanation
The solution converts the string to lower case, then convert all vowels to uppercase.

for c in s.lower() converts the string to lower case, then loop through each character in the string.
[c,c.upper()][c in "aeiou"] converts any vowel to uppercase, and consonant to lower case.
c in "aeiou" evaluates to 0 or 1, which is used to index into the list [c,c.upper()].

Please could you share an explanation of how your lambda Python 3 function works, I'm new to code-golf and my own Python 3 attempt relies on a for loop through list.

@AryanBeezadhur the main trick to working out what this answer does is figuring out which meanings the brackets have. The outer ones are a list comprehension, the first inner bracket is a 2 element list, and the second pair of inner brackets are list indexing (using the coercion from booleans to integers)

@Potato44 +1, thanks!

Shouldn't the output be a formatted string?

Perl 5 -p, 20 19 bytes
-1 due to @NahuelFouilleul
$_=lc;y;aeiou;AEIOU

Try it online!
Convert everything to lower case, then change vowels to upper case.

can save one byte using ; as transliterator delimiter and ommiting the last Try it online!

Thanks for the reminder

Python, 53 bytes
lambda s:[(c*2).title().strip('aeiou')[-1]for c in s]

Try it online!
Outputs a list of characters.
Here is an explanation of how it transforms each character c, with examples c='A' and c='B':
                'A'  'B'
(c*2)           'AA' 'BB'  # Two copies of c in a two-character string
.title()        'Aa' 'Bb'  # Title case: uppercase first letter and the rest lowercase
                           # This disregards the case of c
.strip("aeiou") 'A'  'Bb'  # Remove any leading or trailing lowercase vowels 'aeiou'
                           # For a two-character string, this removes all such letters
[-1]            'A'  'b'   # Take the last letter

55 bytes
lambda s:[(c*2).title()[~(c in'aieouAEIOU')]for c in s]

Try it online!
If we were instead lowercasing vowels and uppercasing consonants, we wouldn't need the ~() and would have 52 bytes.

Alternative 53, Python 3 only: lambda s:[max({*(c*2).title()}-{*'aeiou'})for c in s]

CJam, 15 bytes
lel"aeiou"_euer

Try it online!
Explanation
l         e# Read line
el        e# To lowercase
"aeiou"   e# Push this string
_         e# Duplicate
eu        e# To uppercase
er        e# Transliterate. Implicitly display

Bash + Core utilities, 25 23 bytes
tr aeiou AEIOU<<<${1,,}

Try it online!
Saved 2 bytes thanks to a suggestion of Nahuel Fouilleul.
Input is passed as an argument, output is on stdout.

saved 2 bytes using lowercase expansion Try it online!

@NahuelFouilleul Thank you -- did you mean something like this? TIO wasn't working on your link ("The permalink could not be decoded"), but I modified the code to use lowercase expansion as you suggested, and saved two bytes.

Java 8, 86 34 bytes
S->S.map(c->c^(c^~68174912>>c)&32)

-52 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!!
Original 86 bytes answer:
s->{s=s.toLowerCase();for(var p:"aeiou".toCharArray())s=s.replace(p,p&=~32);return s;}

Try it online.
Explanation:
s->{                               // Method with String as both parameter and return-type
  s=s.toLowerCase();               //  Convert the entire String to lowercase
  for(var p:"aeiou".toCharArray()) //  Loop over the vowels as characters:
    s=s.replace(p,p&=~32);         //   And replace the lowercase vowels to uppercase ones
  return s;}                       //  Then return the modified String as result

Jelly,  9  7 bytes
Saved 2 using a variation of Luis Mendo's CJam approach
ØCŒHyŒu

A monadic Link accepting a list of characters which yields a list of characters.
Try it online!
How?
ØCŒHyŒu - Link: list of characters, S   e.g. "I am OK!"
ØC      - consonants                         "BCDF...XYZbcdf...xyz"
  ŒH    - split into two                     ["BCDF...XYZ", "bcdf...xyz"]
     Œu - convert (S) to upper-case          "I AM OK!"
    y   - translate                          "I Am Ok!"

This makes much more sense than the other "Jelly" answer. I fiddled with it and got an answer 1 byte longer: ØcṚŒHyŒl by doing the same thing but translating vowels.

Ruby, 33 bytes
->s{s.downcase.tr"aeiou","AEIOU"}

Straightforward solution: downcase everything, then upcase vowels.
Try it online!

APL (Dyalog Extended), 14 bytesSBCS
Anonymous tacit prefix function.
⌈@(∊∘'aeiou')⌊

Try it online!
⌊ lowercase
⌈@(…) uppercase at the following positions:
 ∊∘'aeiou' members of "aeiou"

sed, 41 25 24 bytes
Saved 16 bytes thanks to Surculose Sputum!!!
Saved a byte thanks to S.S. Anne!!!
s/./\L&/g
y/aeiou/AEIOU/

Try it online!

25 bytes

@SurculoseSputum Ah, yes of course. Very nice - thanks! :-)

24 bytes

@S.S.Anne Interesting, y commands ("Transliterate" according to the docs) act sort of like tr. Nice one - thanks! :-)

x86-64 machine code, 21 bytes
(Or 20 bytes for an x86-32 version with an explicit length input, allowing dec/jnz as the loop condition.  Using cl for a shift count makes it not a win to use loop, and 64-bit mode has 2-byte dec so it's break-even to make it explicit-length).
Callable as void vucd_implicit(char *rdi) with the x86-64 System V calling convention.  (It leaves RDI pointing to the terminating 0 byte if you want to use that bonus return value.)
# disassembly: objdump -drwC -Mintel
0000000000401000 <theloop>:
  401000:       b8 a0 bb ef fb          mov    eax,0xfbefbba0
  401005:       d3 e8                   shr    eax,cl
  401007:       30 c8                   xor    al,cl
  401009:       24 20                   and    al,0x20
  40100b:       30 c8                   xor    al,cl
  40100d:       aa                      stos   BYTE PTR es:[rdi],al
000000000040100e <vowel_up_consonant_down>:        # the function entry point
  40100e:       8a 0f                   mov    cl,BYTE PTR [rdi]
  401010:       84 c9                   test   cl,cl
  401012:       75 ec                   jne    401000 <theloop>
  401014:       c3                      ret

Notice that the function entry point is in the middle of the loop.  This is something you can do in real life; as far as other tools are concerned, theloop is another function that falls into this one as a tailcall.
This uses something like Arnauld's xor/and/xor idea for applying the lcase bit to an input character, instead of the more obvious and cl, ~0x20 to clear it in the original, and al, 0x20 to isolate it from the mask, and or al, cl to combine.  That would be 1 byte larger because and cl, imm8 can't use the AL,imm special encoding with no ModRM.
Having the bitmap left-shifted by 5 so the bit we want lines up with 0x20 is also due to @Arnauld's answer.  I had been planning to use bt/salc like in a previous vowel/consonant bitmap answer and mask that with 0x20 until I tried Arnauld's way and found it could be done even more efficiently.
NASM source (Try it online! with a test caller that does strlen on a command line arg and uses a write() system call afterward)
global vowel_up_consonant_down
theloop:
                                             ; consonant bitmap
    ;          ZYXWVUTSRQPONMLKJIHGFEDCBA@    For indexing with ASCII c&31 directly
    mov   eax, 111110111110111110111011101b << 5   ; line up with the lcase bit
                                             ; the low bit is 1 to preserve 0x20 ' '
    shr   eax, cl               ; AL & 0x20 is how the lowercase bit *should* be set
    xor   al, cl                ; bitdiff = (mask>>c) & c
    and   al, 0x20              ; isolate the lowercase bit
    xor   al, cl                ; flip the lcase bit if needed
    stosb                       ; and store
vowel_up_consonant_down:
    mov   cl, [rdi]
    test  cl, cl
    jnz  theloop               ; }while(c != 0)
    ret

Variants
no spaces: 19 bytes
If we didn't need to handle spaces (ASCII 0x20), we enter the function at the top, with the mov cl, [rdi] load at the top, but still leave the loop condition at the bottom.  So we'd load and re-store the terminating 0, and the XOR that produced it would set ZF.  The low bit of the bitmap would be 0 instead of 1.
vucd_pure_alphabetic:
.loop:
    mov   cl, [rdi]
   ...               ; same, but with bitmap[0] => 0
    xor   al,cl
    jnz  .loop       ; mask>>0 leave the terminating 0 unmodified; xor sets ZF

Upper-case-only input, like the A to Z in the question indicates: 19 bytes
(Or 17 without spaces either.)
If we can assume the lower-case bit was already cleared on input ASCII bytes, we can save one XOR (and change the other one to an OR)
    ...
    shr   eax, cl
    and   al, 0x20
    or    al, cl
    ...

Using the bt instruction:
Normally testing a bitmap is a job for the bt instruction, but where we're not branching on the result, it turns out to be cheaper to shift it, even though that means we can't easily use the loop instruction.  (I haven't gone back to this idea to re-golf it after realizing we need to handle spaces).
I suspect there's room for more golfing, but the first version of this I tried was
vucd:
.loop:
    mov   dl, [rdi]
    ;          ZYXWVUTSRQPONMLKJIHGFEDCBA@    1-indexed using ASCII codes directly
    mov   esi, 111110111110111110111011101b   ; consonant/vowel bitmap for use with bt
    bt    esi, edx              ; CF = mask & (1U << (c&31))
%if CPUMODE == 32
    salc                        ; 1B   only sets AL = 0 or 0xFF.  Not available in 64-bit mode
%else
    sbb   eax, eax              ; 2B   eax = 0 or -1, according to CF.
%endif
    xor   al, dl
    and   al, 0x20              ; just the lowercase bit
    xor   al, dl
    loop .loop
    ret

Not re-tested after tweaking to handle spaces.
bt + salc in 32-bit mode costs the same as shr reg,cl + the extra test cl,cl that's needed because we can't use loop.  So I think this is also 21 bytes.  But 32-bit mode explicit-length can just dec/jnz a reg other than cl for a 20-byte total.
mov esi, imm32 can be hoisted out of the loop, or we can use EAX.  Neither affects byte count, only efficiency or the calling-convention.

C (gcc), 75 \$\cdots\$72 71 bytes
Added 4 bytes to fixed a bug.
Saved a byte thanks to ceilingcat!!!
u;f(char*s){for(;*s;*s++=u-65&&u-69&&u-73&&u-79&&u-85?*s|32:u)u=*s&95;}

Try it online!

C (gcc), 58 \$\cdots\$ 58 bytes
f(char*s){for(;*s;)*s++=index("aeiou",*s|32)?*s&95:*s|32;}

I tried to find a pattern in the vowels' representations using the modulo operator but nothing short enough. Instead, use strchr.
Fixed a bug kindly pointed out by Noodle9 at the cost of 3 bytes.
-1 byte thanks to Noodle9!
-1 byte thanks to Surculose Sputum!
-1 byte thanks to ceilingcat!
Try it online!

x86 platform-independent machine code, 46 bytes.
Expects the string pointer to be passed in eax, trashes ebx and edx.
Entry point is located at 0x26.
Hex dump:
BA 22 82 20 00 D3 EA F6 C2 01 74 0B 8D
51 9F 83 FA 19 8D 59 E0 EB 09 8D 51 BF
83 FA 19 8D 59 20 0F 46 CB 88 08 40 0F
BE 08 85 C9 75 D3 C3

Disassembly:
00000000  BA22822000        mov edx,0x208222
00000005  D3EA              shr edx,cl
00000007  F6C201            test dl,0x1
0000000A  740B              jz 0x17
0000000C  8D519F            lea edx,[ecx-0x61]
0000000F  83FA19            cmp edx,byte +0x19
00000012  8D59E0            lea ebx,[ecx-0x20]
00000015  EB09              jmp short 0x20
00000017  8D51BF            lea edx,[ecx-0x41]
0000001A  83FA19            cmp edx,byte +0x19
0000001D  8D5920            lea ebx,[ecx+0x20]
00000020  0F46CB            cmovna ecx,ebx
00000023  8808              mov [eax],cl
00000025  40                inc eax
00000026  0FBE08            movsx ecx,byte [eax]
00000029  85C9              test ecx,ecx
0000002B  75D3              jnz 0x0
0000002D  C3                ret

byte count = 0x2E = 46

:( bytes in decimal please

Two possible options for golfing that bitmap >> (c&31) test of the immediate bitmap: use bts edx, ecx, or use a bitmap that's already shifted by 1 so the bit you want goes into CF instead of the low bit of EDX.  (Except that fails for CL&31=0 which doesn't clear CF).  Also, you aren't taking any advantage of AL,imm8 short forms like 2-byte test al, imm8.  Use ESI as the input pointer so you can lodsb / xchg eax,ecx to do cl = *esi++  Or with BTW, you don't need the byte in CL so it's also better for that reason.

@ASCII-only: I fixed the title line of this answer to count in decimal.  I think that's allowed even within codegolf's strict rules about not editing other people's code, only fixing formatting and maybe explanations.

@Krysztof: Turns out a right-shift works at least as well as bt / salc when you use the ASCII code directly, so it's 1-indexed.  I'm not sure why you need so much branching and cmov, though.  I think you're separately doing c-'a' and/or c-'A'.  You can just mask away the lower-case bit (What is the idea behind ^= 32, that converts lowercase letters to upper and vice versa?); Anyway my answer on this Q ended up branchless other than the loop, 21 bytes.

You also don't need a movsx load.  This is code-golf: performance isn't important so we don't need to avoid false dependencies or partial-register stalls (e.g. from using a 32-bit cmov after writing 8-bit partial registers).

Retina, 9 bytes
T`vVL`VVl

Try it online! Explanation:
T`v`V

Lowercase vowels get uppercased.
T`V`V

Uppercase vowels also get uppercased, to avoid being matched later.
T`L`l

All other uppercase letters get lowercased.

Javascript (V8), 97 bytes
s=>[...s].map(c=>{t="aeiouAEIOU";return(t.includes(c)?c.toUpperCase():c.toLowerCase())}).join('')

Takes a string, iterate over every chars and check if the char is a vowel. If so return the char in uppercase, otherwise in lowercase. Then join the return of the map with a void char.

First post/answer here, if you see some errors or missed case, or just want to improve my code feel free to do so

JavaScript (V8), 93...77 bytes
Log:

-5 bytes thanks to @Benji
-14 bytes: switched to case insensitive matching and .test()

s=>[...s].map(c=>/[aeiou]/i.test(c)?c.toUpperCase():c.toLowerCase()).join('')

Try it online!
s=> // es6 arrow function
    [...s]. // split input string into array
        map(c => // another es6 arrow function, this time for a callback iterating over the array
             /[aeiou]/i // case insensitive regex
                .test(c)? // use a ternary operator to check if the character matches the regex
                    c.toUpperCase(): // if true return character to uppercase
                        c.toLowerCase()) // otherwise return lowercase
                            .join('') // join the array back into a string

Methods mentioned:

arrow function
ternary operator

You could save a few bytes if you change /a|e|i|o|u/ -> /[aeiou]

right! thanks @Benji

Haskell, 68 bytes
import Data.Char
f=map(g.toLower)
g x|x`elem`"aeiou"=toUpper x|1<2=x

Try it online!

05AB1E,  9  6 bytes
Saved 3 using Luis Mendo's CJam approach
lžMDu‡

Try it online! (Footer formats the resulting list of characters as a plain string)
How?
lžMDu‡         e.g. input="LowEr"  stack: []
l      - push lower-case (input)          ["lower"]
 žM    - push lower-case vowels           ["aeiou", "lower"]
   D   - duplicate                        ["aeiou", "aeiou", "lower"]
    u  - upper-case                       ["AEIOU", "aeiou", "lower"]
     ‡ - transliterate                    ["lOwEr"]
       - implicit print                   lOwEr

YES...! I was assuming this was Jelly...................................... I was about to come here and comment that I couldn't even find it in the code but now I understand why! Thanks.

I have a Jelly answer too :)

Red, 83 82 bytes
func[s][v: charset"aoeiu"parse lowercase s[any[to v change t: v(uppercase t/1)]]s]

Try it online!

Io, 72 bytes
Takes input as a special format.
method(x,x map(i,if("aeiou"containsSeq(i),i asUppercase,i asLowercase)))

Try it online!

Python 3, 50 bytes
lambda s:bytes(c^(c^~68174912>>c%32)&32for c in s)

Try it online!
Port of Arnauld's JS answer using bytes object in Python. Because Python's >> does not imply %32 on its right argument, it must be done manually.

Japt v2.0a0 -m, 10 7 bytes
u r\c_v

Try it

T-SQL, 48 bytes
SELECT TRANSLATE(LOWER(v),'aeiou','AEIOU')FROM t

Takes input from a pre-existing table t with varchar column v, per our IO rules.
Converts the entire string to lowercase, then makes just the vowels uppercase. The function TRANSLATE works in SQL 2017 and later.

K (oK), 27 23 21 bytes
Solution:
`c$x-32*~^"aeiou"?x:_

Try it online!
Explanation:
Even nicer approach thanks to @ngn... either substract 0 or 32 from the input based on whether or not it's a vowel:
`c$x-32*~^"aeiou"?x:_ / the solution
                    _ / lowercase input
                  x:  / store as 'x'
          "aeiou"?    / lookup input in "aeiou" else null
         ^            / is null?
        ~             / not
    -32*              / multiply boolean list by -32 (yields 0 or -32)
   x                  / subtract from x
`c$                   / cast back to characters

Notes:

-6 bytes thanks to @ngn

hint: (-32*isvowel)+x leads to a shorter solution than @[;;;]

i was thinking of \c$(-32*x in"aeiou")+x:_` but yours is even better :)

-2: \c$x-32*~^"aeiou"?x:_`

Thanks - I managed to golf another byte as I was writing up the explanation - let me update with your latest :)

K4, 24 bytes
Solution:
.q.ssr/[;_v;v:"AEIOU"]@_

Explanation:
Replace each lowercase vowel with the uppercase equivalent.
.q.ssr/[;_v;v:"AEIOU"]@_ / the solution
                       _ / lowercase
                      @  / apply
.q.ssr/[;  ;         ]   / search/replace, iterate over vowels
            v:"AEIOU"    / store uppercase vowels as 'v'
         _v              / lowercase vowels

Julia 49 bytes
Try it!
f=l->map(c->in(c,"aeiou") ? c-32 : c,lowercase.(l))

Pyth, 20 bytes
K"aeiou"smrd}d+KrK1w

Try it online!
Explanation
                       w=input()
K"aeiou"               K="aeiou"
        s              "".join(
         m              map(
          r              lambda d:r(
           d              d,
             d             d
            }             in
               K           K
              +            +
                 rK1       K.upper())),
                    w    w)

Welcome to Code Golf, and nice answer!

Python 3, 68 bytes
lambda s:''.join([p.upper()if p in'aeiou'else p for p in s.lower()])

Try it online!

Zsh --extendedglob, 39
<<<${${(L)@}//(#m)[aeiou]/${(U)MATCH/}}

Try it Online
Code borrowed from the Zsh Manual, Globbing Flags

Scala 3, 94 59 bytes
59 bytes(Saved 35 bytes thanks to @movatica). Attempt This Online!
_.toLowerCase.map(c=>if("aeiou"contains c)c.toUpper else c)

94 bytes. Attempt This Online!
_.toLowerCase.map{case'a'=>'A';case'e'=>'E';case'i'=>'I';case'o'=>'O';case'u'=>'U';case c=>c}

59 bytes

Python 3, 85 84 bytes
x=''
for i in input():
 if i in'aAeEiIoOuU':x+=i.upper()
 else:x+=i.lower()
print(x)

Try it online!
Pretty new to codegolf, so probably not the shortest solution
edit 1: one byte saved because of a space

Something like this gets you 75 bytes, but judging by other Python answers, there are better approaches...

05AB1E, 8 7 6 bytes
-1 byte thanks to Kevin Cruijssen
lžODu‡

Try it online!

Fails when there are upper-case vowels present in the input

Also not sure why you're treating y as a vowel, usually it is not considered a vowel.

@JonathanAllan thanks, fixed the bug with uppercase vowels. Regarding your second comment,  y is sometimes not considered a vowel, but I sure wouldn’t say that’s “usual”. Y is the sixth vowel letter according to Wikipedia.

You can remove the surrounding map: try it online.

@KevinCruijssen thanks!

Charcoal, 14 bytes
⭆↧Ｓ⎇№aeiouι↥ιι

Try it online! Link is to verbose version of code. Explanation:
  Ｓ             Input string
 ↧              Lowercased
⭆               Map over characters and join
     aeiou      Literal string `aeiou`
    №           Count occurrences of
          ι     Current character
   ⎇            If non-zero
            ι   Current character
           ↥    Uppercased
             ι  Else current character
                Implicitly print

W d, 9 bytes
→d╧o╧╪0╨←

Uncompressed:
("aeiou":)Z

Explanation
(           % Convert to lowercase
 "aeiou"    % All vowel strings
        :   % Duplicate
         )  % Convert to uppercase
          Z % Transliterate

Batch, 118 115 Bytes
3 bytes saved thanks to Neil
@Set o=%*
@For %%A in (A E I O U b c d f g h j k l m n p q r s t v w x y z)do @Call Set o=%%o:%%A=%%A%%
@ECHO(%O%

Explanation:
Uses Call Set to update variable during operation of For Loop in conjunction with Substring Modification: VarName=%VarName:ToSub=SubValue%.
Substring modification is not case-sensitive - case is determined using the defined For loop set %%A in (set)

Given that the input is limited to letters and spaces, could you use @set o=%*?

Python 3, 70 bytes
lambda s:''.join(l.upper()if l in'aeiouAEIOU'else l.lower()for l in s)

Try it online!

SML 65 bytes
Try it!
map(fn c=>if contains"AEIOUaeiou"c then toUpper c else toLower c)

This requires open String and open Char. If those are not allowed, then it would be 87 bytes (String.map Char.contains Char.toUpper Char.toLower).

You can open the libraries, but then those calls are part of the code and should be counted. Thus, in this case it is best to open only Char but use String.map for 82 bytes: Try it online!

78 bytes by using this tip: Try it online!

Funky2, 57 bytes
s=>s:gsub("."c=>ifc:match"[aeiou]"c:upper()elsec:lower())
Relatively simple solution, benefits from Funky2's relatively concise language.
Attempt This Online!

Brachylog, 10 9 bytes
ḷ{∈Ṿ&ụ|}ᵐ

Try it online!
-1 byte thanks to @DLosc.
Explanation
ḷ             Lowercase the whole input
 {      }ᵐ    Map on each char of the input:
  ∈Ṿ             The char lowercased is in "aeiou"
     &ụ          Output the char uppercased
       |         Or do nothing

APL (Dyalog Unicode), 17 bytes SBCS
1⎕C@(∊∘'aeiou')⎕C

Try it on APLgolf!
A tacit function that ports @Adam's Dyalog Extended solution into vanilla Dyalog APL. Makes use of the system function ⎕C introduced in Dyalog 18.0 (hence, won't work in TIO).
1⎕C@(∊∘'aeiou')⎕C    ⍝ Tacit function.
               ⎕C    ⍝ Convert to lowercase. Then:
1⎕C                  ⍝ Convert to uppercase
   @                 ⍝ at the positions
    (∊∘'aeiou')      ⍝ that are part of the vowels.

Excel VBA, 78 75 bytes
Saved 3 bytes thanks to Taylor Raine because of course
t=LCase([A1]):For Each c in Split("A E I O U"):t=Replace(t,c,c,,,1):Next:?t

Code is run in the immediate window and uses the cell A1 from the active sheet as it's input. The method is simple:

Save the lowercase version of the input as t
Save the vowels as s
For each vowel, replace the lowercase version with the uppercase version
Print the result

You can use a For each loop to get this a bit smaller- t=[Lower(A1)]:For Each c in Split("A E I O U"):t=Replace(t,c,c,,,1):Next:?t for 75 bytes

Vim, 19 bytes
Vu:s/[aeiou]/\U&/g

Try it online!
Explanation
Vu

Select the current line and lowercase it.
:s/

In the current line, replace...
[aeiou]/

a vowel character with...
\U&/

the uppercase version of itself...
g<nl>

for every match on the line.

Vyxal, 7 bytes
ɽƛAß⇧;ṅ

Try it Online!
ɽƛAß⇧;ṅ # Takes the string as input
ɽ       # Lowercase the string
 ƛ   ;  # Map the characters in the string to...
  A     # Is character a vowel?
   ß⇧   # If truthy, uppercase the letter
      ṅ # Join by nothing

-1 byte: ɽ⟑Aß⇧₴

Arturo, 43 bytes
$=>[replace lower&split"aeiou"split"AEIOU"]

Try it

Vyxal s, 35 bitsv2, 4.375 bytes
⇩ƛAß⇧

Try it Online!
Bitstring:
11010011100001101111110111101101010

minus 6 bits thanks to pacmanboss256
Posted as a separate answer because a) vyncode isn't a golfing suggestion and b) it's different enough to be its own answer - it's not a byte shave from the other answer.
Explained (old)
ƛA[⇧|⇩
ƛ       # To each character:
 A[     #   if it is a vowel:
   ⇧    #     uppercase
    |   #   else:
     ⇩  #     lowercase

4.375

Thunno 2 J, 8 bytes
ıDṃh?R:L

Explanation
ıDṃh?R:L  # Implicit input
ı         # Map over each character
 D        # Duplicate the current character
  ṃh?     # If it's a vowel:
     R    #  Uppercase it
      :   # Otherwise:
       L  #  Lowercase it
          # Implicit output, joined into a string

Swift, 95 88 bytes
let c={($0+"").map{"aeiouAEIOU".contains($0) ?$0.uppercased():$0.lowercased()}.joined()}

R, 45 bytes
function(s)chartr('aeiou','AEIOU',tolower(s))

Try it online!

Pip, 9 bytes
LCaRXVUC_

Attempt This Online!
Explanation
LCaRXVUC_
LCa        ; Lowercase the input string
   R       ; Replace
    XV     ;  any lowercase vowel
      UC_  ;  with itself uppercased

JS 63 .. 59 Bytes
Hello this is how you can create it in JS using one line of code.
Code:
f=s=>s.toLowerCase().replace(/[aeiou]/g,v=>v.toUpperCase())

Test Cases:

Basic Test Cases:

Input: "Hello"

Expected Output: "hEllO"

Input: "Stack Exchange"

Expected Output: "stAck ExchAngE"

Input: "abcdefghijklmnopqrstuvwxyz"

Expected Output: "AbcdEfghIjklmnOpqrstUvwxyz"

Edge Cases:

Input: "" (Empty string)

Expected Output: "" (Empty string)

Input: "12345" (No vowels)

Expected Output: "12345"

Input: "AEIOU" (All vowels)

Expected Output: "AEIOU" (All uppercase)

Case Insensitivity Test:

Input: "HeLLoWorLD"

Expected Output: "hEllOwOrLD"

Special Characters Test:

Input: "@#$%"

Expected Output: "@#$%" (No vowels, no change expected)

Input: "hello$world"

Expected Output: "hEllO$wOrld" (Vowels in the middle of the string)

Long String Test:

Input: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

Expected Output: "lOrEm IpsUm dOlOr sIt AmEt, cOnsEc tEtUr AdIpIscIng ElIt. sEd dO EIUsmOd tEmpOr IncIdIdUnt Ut lAbOrE Et dOlOrE MAgnA AlIqUA."

Performance Test:

Input: "a" repeated 10^6 times (a million times)

Expected Output: "A" repeated 10^6 times

Input: "abcdefghijklmnopqrstuvwxyz" repeated 10^4 times

Expected Output: "AbcdEfghIjklmnOpqrstUvwxyz" repeated 10^4 times

Random Test Cases:

Input: "hElLo!"

Expected Output: "hEllO!" (Only 'e' should be capitalized)

Input: "HeLlO 123"

Expected Output: "hEllO 123" (Only vowels should be capitalized)

Input: "rAnDoMT3XT"

Expected Output: "rAndOmt3xt" (Only 'a' and 'o' should be capitalized)

Try it Online:

f=s=>s.toLowerCase().replace(/[aeiou]/g,v=>v.toUpperCase())

// Test Cases
function runTest(input, expectedOutput) {
    const output = f(input);
    console.log("Input:", input);
    console.log("Expected Output:", expectedOutput);
    console.log("Actual Output:", output);
    if (output === expectedOutput) {
        console.log("Test Passed!");
    } else {
        console.log("Test Failed!");
    }
    console.log("-------------------------");
}

// Basic Test Cases
runTest("Hello", "hEllO");
runTest("abcdefghijklmnopqrstuvwxyz", "AbcdEfghIjklmnOpqrstUvwxyz");

// Edge Cases
runTest("", "");
runTest("12345", "12345");
runTest("AEIOU", "AEIOU");

// Case Insensitivity Test
runTest("HeLLoWorLD", "hEllOwOrld");

// Special Characters Test
runTest("@#$%", "@#$%");
runTest("hello$world", "hEllO$wOrld");

// Long String Test
runTest("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "lOrEm IpsUm dOlOr sIt AmEt, cOnsEctEtUr AdIpIscIng ElIt. sEd dO EIUsmOd tEmpOr IncIdIdUnt Ut lAbOrE Et dOlOrE mAgnA AlIqUA.");

// Performance Test
runTest("a".repeat(1e6), "A".repeat(1e6));
runTest("abcdefghijklmnopqrstuvwxyz".repeat(1e4), "AbcdEfghIjklmnOpqrstUvwxyz".repeat(1e4));

// Random Test Cases
runTest("hElLo!", "hEllO!");
runTest("HeLlO 123", "hEllO 123");
runTest("rAnDoMT3XT", "rAndOmt3xt");

Nice answer, and welcome. You can remove all of the spaces in your code. Also, iirc in JS, it'll still compile/run even without the leading const  and trailing semi-colon, so it can be f=s=>s.toLowerCase().replace(/[aeiou]/g,v=>v.toUpperCase()) (59 bytes).

Thank you very much for your prompt reply.

Lexurgy, 111 bytes
Simple replacement
a:
{a,e,i,o,u,B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}=>{A,E,I,O,U,b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z}

Lua, 64 bytes
print(((...):lower():gsub('[aeiou]',load'return(...):upper()')))

Try it online!

Vyxal 3 s, 5 bytes
ʀƛA¿ɾ

Try it Online!
lowercase the entire string then uppercase the vowels

Gema, 36 characters
/[aeiou]/=@upcase{$0}
?=@downcase{?}

Sample run:
bash-5.2$ gema '/[aeiou]/=@upcase{$0};?=@downcase{?}' <<< 'Hello World'
hEllO wOrld

Try it online!

Swift, 125 bytes
Short version:
func c(_ t:String)->String{return t.lowercased().map({String($0)}).map({"aeiou".contains($0) ?$0.uppercased():$0}).joined()}

Verbose version:
func c2 (_ t: String) -> String {
    let s = t.map({String($0).lowercased()})
    let lv = ["a", "e", "i", "o", "u"]

    let r = s.map { l in
        lv.contains(l) ? l.uppercased() : l
    }.joined()

    return r
}

APL(NARS), 45 chars
{⍵∊⎕A∼'AEIOU':⎕a[⎕A⍸⍵]⋄⍵∊'aeiou':⎕A[⎕a⍸⍵]⋄⍵}¨

test & how to use:
      f←{⍵∊⎕A∼'AEIOU':⎕a[⎕A⍸⍵]⋄⍵∊'aeiou':⎕A[⎕a⍸⍵]⋄⍵}¨
      f 'Hello World'
hEllO wOrld

YASEPL, 155 147 145 bytes
=2)"aeiouAEIOU"±""=1'=i=l®1`1=k=f=m¥i,1`9!y¥f,2!m}7,y,8!k$`8!f+}2,10,9=j`2!j+!q$j»}7,m,2`3!j}1,90,5}2,65,5!f$j+32|6`5!f$j`6!k[7!f-32`7!f›!i+}2,l

i mistakenly uploaded this without testing my code. whoopsies, heres a fixed version

Uiua SBCS, 14 bytes
¯⍜▽¯∊,"AEIOU"⌵

Try it!
0.9.0 recently extended abs and negate to work on characters, making this much easier.
¯⍜▽¯∊,"AEIOU"⌵
             ⌵  # uppercase the input
    ∊,"AEIOU"   # mask of vowels
 ⍜▽¯            # swap case at indices given by the mask
¯               # swap case

Python 3, 82 bytes
f=lambda c:c.upper()if c in 'aeiou'else c.lower();lambda s:''.join(map(f,list(s)))


text:
Add N numbers without using + or -
Given N integers, output the sum of those integers.
Input
You may take the integers in any reasonable format, including:

stdin
arguments
an array or list

Rules

Your code must not include the characters + or -.

Standard loopholes apply. Take note of Abusing native number types to trivialize a problem.

This is code-golf. The shortest code in each language wins, which means that I will not be accepting an answer.

Testcases
n=2, 1, 2 -> 3
n=2, 2, 2 -> 4
n=2, 9, 10 -> 19
n=2, 7, 7 -> 14
n=2, 8, 8 -> 16
n=2, -5, 3 -> -2
n=2, -64, -64 -> -128
n=2, -3, 0 -> -3
n=2, 0, 3 -> 3
n=2, 0, 0 -> 0
n=2, -1, -1 -> -2
n=2, -315, -83 -> -398
n=2, 439, 927 -> 1366
n=3, 1, 2, 3 -> 6
n=3, 2, 2, 5 -> 9
n=3, 0, 9, 10 -> 19
n=3, 7, 0, 7 -> 14
n=3, 8, 8, 0 -> 16
n=3, -5, 3, -2 -> -4
n=3, -64, -64, 16 -> -112
n=3, -3, 0, 0 -> -3
n=3, 0, 3, 0 -> 3
n=3, 0, 0, 0 -> 0
n=3, -1, -1, -1 -> -3
n=3, -315, -83, -34 -> -432
n=3, 439, 927, 143 -> 1509
n=17, -74, 78, 41, 43, -20, -72, 89, -78, -12, -5, 34, -41, 91, -43, -23, 7, -44 -> -29

Testcases with partial sums that exceed 8 bits are only required if your integer type supports each partial sum (if any) and the final result. As a special case, n=2, -64, -64 -> -128 is only required if your integer type can represent -128.
Testcases involving negative integers are only required if your language natively supports negative integers.

I have one which I think is neat enough to be a notable mention though it doesn't strictly abide by the rules. Instead of summing a list, it only adds 2 numbers... Any chance I can still add it and let the votes decide?

@AviF.S., that would not be a valid solution to the challenge.

@Avi If you create another function that does the rest of the adding, then yes. Otherwise, no.

I see you've had mercy on languages that don't support numbers that require 8 bits, a generous allowance. Any chance it's also alright if our language doesn't support negative numbers? (I don't mean to keep poking at the question, but I'd really love to be able to submit answers in languages not meant for this sort of thing and still have them be reasonably elegant, even if not short!)

@AviF.S. That's acceptable. The other was not, as that would make the challenge extremely trivial.

Wonderful, and completely understood! Thanks a bunch!

Wolfram Language (Mathematica), 2 bytes
Tr finds the trace of the matrix or tensor list
Tr

Try it online!

@a'_' As far as I remember, it sums the elements on the diagonal of a matrix, or, if it's actually a vector, just sums everything.

Python 2, 97 95 93 88 87 bytes
Solution that doesn't use the built-in sum, eval or exec:
-2 bytes thanks to @JonathanAllan!
-1 byte thanks to @ovs!
x=y=1
for i in input():x<<=i*(i>0);y<<=abs(i)
y/=x
print" ~"[x<y],len(bin(x/y|y/x)[3:])

Try it online!
Input: a comma separated list of numbers, from stdin.
Output: the sum is printed to stdout. If the sum is negative, the ~ sign is used instead of - due to source code restriction.
How: Let \$p\$ be the sum of all positive numbers in the list, and \$n\$ be the magnitude of the sum of all negative numbers. Then the sum of the list is \$p-n\$.
Let \$x=2^p\$ and \$y=2^n\$, then \$\frac xy=2^{p-n}\$.
Thus if the sum is positive (aka \$x>y\$), we can calculate the sum by counting the number of zeros in the binary representation of \$\frac xy\$. Otherwise, we can calculate the magnitude of the sum as the number of zeros in the binary representation of \$\frac yx\$.

x<<=i*(i>0);y<<=abs(i*(i<0)) saves two over using max and min.

85 bytes

@ovs Thanks! I cannot use -3 since it contains -, but can still save 1 byte with y/=x.

JavaScript (ES6), 21 bytes
Takes input as an array of integers.
a=>eval(a.join`\x2B`)

Try it online!

JavaScript (ES6), 40 bytes
Takes input as an array of integers.
a=>a.reduce(g=(x,y)=>y?g(x^y,(x&y)*2):x)

Try it online!

Amazing formula! Waiting for an explanation on why this will eventually terminate.

@SurculoseSputum It is quite similar to a binary addition by hand: the XOR does the addition without the carries which are processed separately by the doubled AND. The recursion stop when there's no more carry. It is described here for instance, and some other variants can be found here.

APL (dzaima/APL), 2 bytesSBCS
Anonymous tacit prefix function
1⊥

Try it online!
Simply evaluates a "digit" list in base 1.

Absolutely brilliant! How ever did it occur to you? The best part is it's no longer than the normal way. Replacing +/ with 1⊥ in all golfed APL has to be the best way of obfuscating and impressing people ever...

@AviF.S. It is a common trick in tacit APL due to it being a dyadic function application rather than a monadic one which cannot be composed with a function on its left.

Whoops. Now that it's documented, I feel silly acting like it was so novel... But I do still think it's a brilliant trick!

C (gcc), 50 45 43 38 bytes
f(s,e)char**s;{s=s<e?&f(&s[1])[*s]:0;}

-7 bytes thanks to @S.S. Anne
-5 bytes thanks to @Bubbler
Takes for input start and end pointers. It uses the fact that the address of &a[b] equals a+b. Other than that, even I am a bit confused as to how this works.
Try it online!

Nicely done, but fails on multiple test cases, like 0, 3, 0 and 7, 0, 7 and 0, 9, 10.

You're right, let me see if I can fix that...

It also requires a terminating 0 element.

I think I've fixed it, but if not, please tell me.

Nice. 45 bytes using return hack.

Cool trick, thanks.

43 bytes using the brackets to avoid parentheses.

38 bytes with even more pointer abuse (and 64-bit ints, because TIO runs on a 64-bit machine.)

@Bubbler TIO doesn't have 64-bit int. No operating system that I know of uses that ABI (including but not limited to BSD, Linux, Windows, and Mac). long is 64-bit on Linux and Mac, though, and TIO runs on Mac.

@S.S.Anne I meant 64-bit integer type (the input arrays are in long long[] type). Also, I believe TIO runs on a Linux, not Mac, because the syscall numbers for Linux x86-64 work well on TIO (at least write=1 and exit=60).

@Bubbler Sorry, I know it runs on Linux. I had just written "Linux and Mac" and then wrote "Mac" instead of "Linux". Anyway, on x86-64 Linux, long is always 64-bit.

W, 1 bytes
Takes input as a list and... just a summation function... :-)
J

W j, 0 bytes
Haha, even more cheaty! The j flag automatically evaluates the J command at the end of the source code.

Japt, 1 byte
Trivial challenges get trivial solutions!
x

Try it

Python 2/Python 3, 3 bytes
sum

Try it online (Py 3)! or Try it online (Py 2)!

Also works in Haskell, and many other languages I'm sure.

GERMAN, 141 bytes
EINGABESCHLEIFENANFANGSUBTRAKTIONRECHTSEINGABESCHLEIFENANFANGSUBTRAKTIONRECHTSADDITIONLINKSSCHLEIFENENDELINKSSCHLEIFENENDERECHTSRECHTSAUSGABE

i'm disappointed this is just another brainfuck derivative rather than some complex combination of  german words

@JoKing I am sorry to disappoint you. Unfortunately, programming languages not based on English are quite rare ...

Mornington Crescent, 634 537 bytes
Take Northern Line to Bank
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Temple
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Parsons Green
Take District Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Angel
Take Northern Line to Bank
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

Try it online!
// initialize adder
Take Northern Line to Bank          // save input to Hammersmith
Take District Line to Parsons Green // get 0
Take District Line to Upminster     // set Upminster = 0

// set start of loop
Take District Line to Temple

// extract leading number
Take District Line to Hammersmith
Take District Line to Parsons Green

// add it to previous sum
Take District Line to Upminster     // accumulator = sum
                                    // Upminster = previous accumulator

// save sum in Upminster
Take District Line to Upminster

// get remaining string
Take District Line to Parsons Green

// check if it is equal to "" by translating the first char to its codepoint (0 if empty)
// we ride a few extra rounds here, adding 0s to the sum
Take District Line to Bank          // save string and
                                    // get string of previous round
Take Northern Line to Charing Cross // swap accumulator with Charing Cross
                                    // and get codepoint of previous values'
                                    // first char (that's from two rounds ago)
                                    // or 0 if empty

// if string is not empty (meaning, accumulator is non-zero), repeat
Take Northern Line to Angel

// else read sum
Take Northern Line to Bank          // get empty string
Take District Line to Upminster     // swap with Upminster

// and go home, outputting the number
Take District Line to Bank          // change lines, swapping data with Bank
Take Circle Line to Bank            // swap back
Take Northern Line to Mornington Crescent // go home

Python, 3 bytes
sum

Built in function which does the job
Try it online

With no built-in, 36 bytes in Python 2:
-3 thanks to ovs!
lambda a:eval(`a`.replace(*',\x2b'))

Try it online!
Note: a single value may be represented as a singleton list (meta)

'\x2b' is one bytes shorter than chr(43). Then replace(*',\x2b') is another two bytes shorter.

@ovs - very nice, thank you!

The built-in function also works in other versions.

C (gcc), 94 bytes
x,c;n(a,b){for(;b;b=x*2)x=a&b,a^=b;x=a;}f(a,t)int*a;{for(c=1;c<t;c=n(c,1))*a=n(*a,a[c]);c=*a;}

A non-trivial golfed reference implementation.
I realized I had worded myself out of an answer when I couldn't even use + or - for a counter variable.
Try it online!

Bash + GNU utilities, 57 bytes
printf %.f $(bc -l<<<"99*l(e(`sed 's@ @/99)*e(@g'`/99))")

Try it online!
Reads space-separated integers from stdin, and writes the output to stdout.
This applies the exponential function to each integer, multiplies the results, and then takes the natural logarithm of the product.  I need to scale the input numbers (and then "unscale" the result) so as not to overflow the exponentials on some of the starred test examples (that's what the 99* and /99 are doing there).

Pyth, 1 byte
s

Try it online!
Explanation
s(Q)
 (Q) : Implicit evaluated input
s    : Sum the input

Mornington Crescent, 1267 bytes
Try it online!
Poorly golfed, may have to have another attempt tomorrow.
Take Northern Line to Bank
Take Northern Line to Euston
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Temple
Take Circle Line to Moorgate
Take Circle Line to Bank
Take District Line to Parsons Green
Take District Line to Upney
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Hammersmith
Take Circle Line to Embankment
Take Northern Line to Charing Cross
Take Northern Line to Angel
Take Northern Line to Bank
Take District Line to Upney
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

I realized today that my past self was smarter and that my "better" solution is wrong -- it misses the edge case 0, which causes the program to terminate prematurely in the case of an input such as 3 0 4 1. Reverted, and see Dorian's Mornington Crescent answer as well for an improvement on how I handled this originally.

Jelly, 1 byte
S

A built-in monadic atom which given a list yields the sum.
Try it online!

No built-in, 2 bytes:
ḅ1

Converts from base one to an integer.
Try it online!

Keg, -hr, 2 bytes
÷⅀

Try it online!
The joys of not having implemented lists properly!  Simply item split and summate. Essentially uses a sum function, so no imaginary points for me.

Batch, 93 bytes
43 is the ASCII code for +:
@!! 2>nul||cmd/q/v/c%0&&exit/b
set c=cmd/c
set/pn=
%c%exit 43
%c%set/a !n: =%=exitcodeascii%!

Takes input via STDIN, delimited by space.

J, 4 bytes
1&#.

This was literally taken from here.

Haskell, 3 bytes
sum

Function that takes an argument as a list e.g. sum[1,2,3] and returns the sum of the list.

Brainetry, 143 bytes
a b c d e f
a b
a b c d e f
a b c d e f g h
a b c d e f g h
a b c d e

a b c d
a
a b c d e f g h i
a b c d e f
a b c d e f g h i

a b c d e f g

To try it online follow this repl.it link and paste the code in the btry/replit.btry file, then press the green "Run" button. Does I/O as ASCII codepoints.
The program above is the golfed version of this program:
Let me sum some numbers carefully.
Carefully enough
so that I do not use
the plus or minus signs, that'd be awful.
After I do this, oh so very carefully,
I just have to ...
Move the pointer
left and right for
a while.
This is the main gist of the whole program.
Of course this sounds somewhat uninteresting.
That is because you, my dear reader, lack depth.
(Is it "depth"?
Maybe that's not the correct English word...)

These brainerty poems are always very interesting.

Do you need the blank lines in the golfed program?

@pppery not sure if you are just making fun or if you really think they are funny. Yes, the blank lines are needed. In Brainetry a blank line moves the pointer to the left edge of the tape, cf. this quick reference table

Pip, 4 bytes
_MSg

Try it online!
MS maps a function to an iterable and sums its results.
_ is the identity function.
g is the list of command line args.

Python 3, 62/61 bytes
Without relying on sum in other functions.
def f(i,x=0):
	for y in i:
		while y:x,y=x^y,(x&y)*2
	return x

Can be shortened to 61 by removing the function definition (-13), replacing in i: with in eval(input()): (+12) and print instead of return at the end (+0).
Try it online!

PHP, 20 9 bytes
array_sum

Try it online!
still wondering if this is not too easy here..
EDIT: thanks to @640KB for saving 11 bytes!

Your answer could just be array_sum as an anonymous function for 9 bytes. https://tio.run/##K8go@G9jX5BRwMWlkmb7P7GoKLEyvrg09781F1dqcka@gkqahoJKYlF6mYKm9f//JsaW/y2NzAE

Thanks! I didn't know PHP would use the function properly when replacing what it seems to be an undefined constant. I also don't know yet all the rules of the site and would have left the semicolon inside the count too.

You are allowed to submit an anonymous "callable" function (example function($x) { return $x+1; }) which isn't really any different functionally than a pre-defined / built-in. While sometimes considered "not interesting", if there's a PHP function that answers the challenge then it's valid to submit just that. To note, there are other answers here doing the same (just with shorter built-in function names than PHP of course).

Haskell, 3 Bytes
sum

calculates the sum of a list

This answer was already posted here

Duplicate answers aren't invalid, but users are encouraged to check for existing answers before posting

05AB1E, 1 bytes
O

Input as a list.
Try it online or verify all test cases.
Slightly less boring:
1β

Try it online or verify all test cases.
Explanation:
O   # Sum the (implicit) input-list
    # (and output the result implicitly)

1β  # Convert the (implicit) input-list to base-1
    # (and output the result implicitly)

PowerShell, 60 24 bytes
$args-join[char]0x2b|iex

Try it online!
-36 bytes thanks to @mazzy

you can to save some bytes Try it online!

@mazzy much thanks!

Racket, 133 bytes
(define(f a[s 0])(if(null? a)s(let([c(car a)])(if(= 0 c)(f(cdr a)s)(f(cons((if(> 0 c)add1 sub1)c)(cdr a))((if(> 0 c)sub1 add1)s))))))

Try it online!
Well...

perl -ple, 18 bytes
s/ /\x2b/g;$_=eval

Try it online!
Reads a space separated list of numbers from STDIN, writes the sum to STDOUT.
perl -MList::Util=sum -alpe, 8 bytes
$_=sum@F

Try it online!

C++ (gcc), 83, 110 bytes
#include <iostream>
int n,x,c;int f(int i){while(i){c=n&i;n^=i;i=c<<1;}if(std::cin>>x)f(x);else std::cout<<n;}

Try it online!
Explanation: Reads in integer inputs and preforms bit-wise addition.
I tried to simplify the carry step like this but it gave me a negative result.

You have to have #include <iostream> and using namespace std; if you're going to use cout and cin. Once you fix that I can suggest some improvements.

std:: is, in fact, not only much better, but also shorter here. !=0 in the while condition can be removed.

101 bytes

You don't need the space between #include and <iostream>

Java 8, 35 bytes
x->x.stream().mapToInt(x->x).sum()

Takes a List of Integers.

Nice Java solution :) But i think there are two problems : 1) It doesn't compile because there is a naming conflict between the outer x and the x inside the map. 2) Because OP explicitly disallowed usage of the character - in the whole code, sadly that should include the Java lambda arrow -> which contains a - :(

x86-16 machine code, 8 bytes
33 D2       XOR  DX, DX         ; clear running sum (in DX)
        AN:
AD          LODSW               ; load next value into AX
03 D0       ADD  DX, AX         ; add AX to running sum
E2 FB       LOOP AN             ; loop until CX = 0
C3          RET                 ; return to caller

Input size in CX, data in [SI].  Output sum in DX.

SQL, 21 bytes
SELECT SUM(N) FROM T;

This assumes the numbers to be in table T, in a column named N.

MAWP 1.1, 21 bytes
%@[~@~1A]_1A[%M_1A]%:

Try it!
Input taken as:
number_of_inputs
n1
n2
n3
...
nN

Lua, 57 bytes
print(load("return "..table.concat(arg,('').char(43)))())

Try it online!

Java (JDK), 56 bytes
For once, in this challenge we can't use Java lambdas because its arrow -> contains the - sign!

So i think the shortest way in Java to add N numbers
(unlike using a pre-built function that only adds 2 numbers, which has also been explicitly disallowed by OP)
without using + and -, is this approach:
int f(int...a){return java.util.Arrays.stream(a).sum();}

Try it online!

Scala, 19 bytes
Try it online!
def f(a:Int*)=a.sum

Rust, 29 (maybe 10?) bytes
Since Rust supports signed integers natively we have to use a signed type, but the challenge lets us choose the type beyond that, so I choose i8 in order to save two bytes.
|n:&[i8]|n.iter().sum::<i8>()

Attempt This Online!
Depending on how the rules should be interpreted it could be possible to solve it using only 10 bytes:
|n|n.sum()

Attempt This Online!
by moving the type declarations into the driving code, but that requires the driving code to contain the - character, which I feel is against the rules.

Thunno 2 S, 0 bytes

That's right. No bytes. The S flag takes the sum.
Thunno 2, 1 byte
S

1 byte flagless. Built-in for sum.
Screenshots

Desmos, 50 bytes
\sum_{n=1}^{a.\operatorname{length}}a\left[n\right]

Takes input as array a
View it on Desmos

As I mentioned in a comment on one of your other posts, variable input (the variable a in this case) is not allowed as per meta consensus. With that in mind, something like f(a)=a.total would be a much shorter alternative to what you have currently.

Red, 4 bytes
:sum

Try it online!
Takes the input as a block (list)

Retina 0.8.2, 79 bytes
O`[^,\d]?\d\d*
\d\d*
$*
,[^,1]

^([^,1]1*),
$1;
,

\D?(1*);\1

^(\D)?(1*)
$1$.2

Try it online! Link includes test cases. Explanation:
O`[^,\d]?\d\d*

Sort the numbers.
\d\d*
$*

Convert the numbers to unary.
,[^,1]

Total the numbers that are less than zero.
^([^,1]1*),
$1;

Separate the numbers that are less than zero from those that are not less than zero.
,

Total the numbers that are not less than zero.
\D?(1*);\1

Add the less than zero total to the not less than zero total.
^(\D)?(1*)
$1$.2

Convert to decimal.
Adding nonnegative integers is much easier of course.
\d\d*
$*
1

Try it online! Explanation: Each integer is converted into unary and then the total is converted into decimal.

Charcoal, 3 bytes
ＩΣＡ

Try it online! Link is to verbose version of code. Explanation:
  Ａ Input as an array
 Σ  Take the sum
Ｉ   Cast to string
    Implicitly print

Ruby, 18 bytes
def f(*a)a.sum end

Try it online!

Pushy, 2 bytes
S#

Try it online!
As you can probably guess, S sums all values on the stack and # outputs this as a number.

Javascript (40 characters)
x=>eval(x.join(String.fromCharCode(43)))
The boring and obvious way to do this, I guess.
Javascript (48 characters)
x=>x.reduce((a,v)=>[...a,...Array(v)],[]).length
A bit lame, but my first attempt. Concatenates arrays of the length of each number, then finds the total length of that array.

Burlesque, 6 bytes
ps{}ms

Try it online!
Takes input as a space separated string from stdin. Explanation:
ps      # Parse input as block
    ms  # Map and sum result
  {}    # Empty mapping function

C++ (clang), 81 75 bytes
[](auto x){decltype(x)r;for(int a:x)r.insert(r.end(),a,0);return r.size();}

I used a generic lambda to avoid the need for #include.
It uses a temporary container, to which it appends lists of zeros of needed lengths. The output is the length of the resulting list.
Thanks to S.S. Anne for the idea of using decltype! I used auto earlier, and it was worse because I had to clear the list before working with it.
Try it online!

Try decltype...

SNOBOL4 (CSNOBOL4), 59 bytes
N S =S ' ' CHAR(43) ' ' INPUT :S(N)
O OUTPUT =EVAL(0 S)
END

Try it online!

Rockstar, 66 bytes
listen to N
R's0
while N
cast N
let R be with N
listen to N

say R

Try it here (Code will need to be pasted in, with each input integer on an individual line)

><> (Fish), 23 bytes
Takes input in unary, separated by NULL bytes.  A bit cheaty, let me know if you think this is valid or no.
i:0=?~:0(?v
       ;nl/

Try it
><> (Fish), 34 bytes
Input must be length prefixed. Uses p to modify the source code at runtime to insert + and - instructions.
'V'2,61p0iv
:?!v$i $1 >59*91p
;n$/

Try it

16 bytes for the first answer, clearing out the whitespace and also fixing the result being off by one

minigolf, 39 bytes
1i,ny*_:1<sv,1s/_:,:ny=!ns,,___s,_s,T*_

Attempt This Online!

Regex, 1 byte
x

Try it online! Takes input as space-delimited unary, outputs using the number of matches. This is a standard I/O format for regex that just happens to trivialise this challenge.

Swift, 87 bytes
The xor & carry based approach.
The return type of a function in Swift is defined using the arrow like f() -> Int with a "minus" character, so my function needs to print the value and not return it :-) (that way actually 5 bytes shorter than returning the result)
func s(_ a:[Int]){var r=0;for var c in a{while 0 != c{(r,c)=(r^c,(r&c)<<1)}};print(r)}

Gema, 35 characters
<N>=@set{s;@add{${s;};$0}}
?=
\Z=$s

Takes an input string with anything separated numbers.
Sample run:
bash-5.2$ gema '<N>=@set{s;@add{${s;};$0}};?=;\Z=$s' <<< '-64, -64, 16'
-112

Try it online! / Try all test cases online!

jq, 3 characters
add

Takes the input as array.
Sample run:
bash-5.2$ jq 'add' <<< '[-64, -64, 16]'
-112

Try it online! / Try all test cases online!

Java, 15 bytes
Math.addExact()

You give it your two variables as parameters

Welcome to CGCC! We don't allow predefined variables as input, however you can submit just the function itself as Math.addExact as a solution instead, since it fulfills the challenge specifications.

source: Stack Exchange

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

sort: votes


text:
Simulate D Flip-Flop
Objective
Simulate an edge-triggered D Flip-Flop.
What is D Flip-Flop?
A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. CLK). Usually CLK is a uniform pulse, but in this challenge, CLK may be not uniform.
Input
A bitstring with length \$n\$ will be given as CLK and another bitstring with length \$n-1\$ will be given as D. A bit represents the state of an input during a unit time (tick). CLK leads D by half a tick.
Output
The output (abbr. Q) is a bitstring with same length and starting timepoint as D. If CLK doesn't start with 01, the starting bit of Q is implementation-defined. Q is updated upon a rising moment of CLK to the bit of D at the time. On the other times, Q retains its state.
Examples
The red line indicates a rising moment of CLK.

Example 1:

Example 2:

Rules

If CLK isn't a tick longer than D, the entire challenge falls into don't care situation.
Though defined as bitstrings, the actual elements of CLK, D, and Q doesn't matter. In this case, if a string is not binary (that is, contains a third character), the entire challenge falls into don't care situation.

I haven't heard of most of these terms so I don't know what the challenge is asking for without following the link to the Wikipedia page. Please add the the relevant information to the challenge body itself.

@xnor the Output section actually specifies the output here

Thanks. If possible, a test case where people can copy and paste would be much appreciated.

With the well-illustrated examples, I think I now understand what the output section is asking for. Thinking of the bit strings as time series, whenever the CLK bit changes from 0 to 1, the output bit Q is set to the current value of the bit D. In all other cases, Q stays unchanged from what it was last.

The starting bit of Q is implementation-defined. Only if CLK does not start with 01? Or does the starting bit never matter?

@Jitse Only if CLK doesn't start with 01. Thanks for pointing that out.

Is 11100000111111111111111000000000011 a valid output for Example 1 (since CLK doesn't start with 01)?

@GalenIvanov Yes.

05AB1E, 15 14 13 bytes
εINTS+èÆi©ë®Θ

First input is \$D\$, second input is \$CLK\$.
Output \$Q\$ as a list of 0s and 1s.
Try it online or verify both test cases (and pretty-print).
Explanation:
ε            # Map over the (implicit) input-list D:
  N          #  Push the current map-index
   TS        #  Push 10 as digit-list: [1,0]
     +       #  Add them to the index: [index+1, index]
 I    è      #  Index both of them into the second input CLK
       Æi    #  If they are [1,0]:
         ©   #   Store the current map-value in variable `®` (without popping)
        ë    #  Else:
         ®   #   Push variable `®`
          Θ  #   And check whether it is exactly 1 (1 if truthy, 0 if falsey)
             #   (which is necessary, because `®` is -1 by default)
             # (after which the list is output implicitly as result)

J, 27 23 bytes
-4 bytes thanks to Bubbler!
;@(<@({.\);.1~1,2</\}.)

Try it online!
CLK is the left argument; D is the right one. When CLK doesn't start with 01, the starting bits are the same as the first bit of D.
                       ;.1  - cut
                          ] - the right argument (D)
   (          )             - where
         2 /\               - the previous element
             [              - of the left argument (CLK)
          <                 - is smaller than the next one
       }.                   - drop
      1                     - the first item
    1,                      - prepend with 1 (for cutting)
               (     )      - for each cut group
                   $        - make a list
                #           - of the same length as the group
                    {.      - with elements same as the first one
                 <@         - and box the list
  ;                         - unbox the sublists and flatten them
[:                          - function composition

K (oK), 27  23bytes
-4 bytes thanks to ngn!
{,/&\'|\'(0,&1_>':x)_y}

Try it online!

J, 23 bytes.

@Bubbler Great, thanks!

{(#x)#*x}' -> &\'|\'

@ngn Thank you, that's very interesting!

APL (Dyalog Extended), 16 bytes
∊⊣⊣\¨⍤⊂⍨1,1↓2</⊢

Try it online!
A dyadic tacit function whose right arg is CLK and left arg is D. Accepts both as Boolean vectors. The starting bit of Q follows that of D.
How it works
∊⊣⊣\¨⍤⊂⍨1,1↓2</⊢  ⍝ Input: left←D, right←CLK
            2</⊢  ⍝ Detect rising edges of CLK
        1,1↓      ⍝ Treat the very first tick as a rising edge
 ⊣    ⊂⍨          ⍝ Partition D into regions where
                  ⍝   each rising edge marks the start of each region
  ⊣\¨⍤            ⍝ On each region, overwrite all elements with the first one
∊                 ⍝ Enlist; form a simple vector

JavaScript (ES6),  40  39 bytes
Takes input as (clock)(data), where clock and data are arrays of binary digits.
C=>D=>D.map(c=>C[i]<C[++i]?p=c:p,i=p=0)

Try it online!

Io, 56 bytes
The space before := is mandatory, otherwise the colon would be part of the undefined identifier.
Argh. Just 1 byte away from Java!
method(c,d,q :=0;d map(i,x,q=if(c at(i)<c at(i+1),x,q)))

Try it online!
Explanation
method(c, d,                // Take 2 operands, c and d
    q := 0                  // Set the flip flop to 0
    d map (i, x,            // Map every item in d
                            // With the index i and the
                            // current item x
        q = \               // Set the current flip-flop as:
            if(c at(i)      // If the clock at the same index
            < c at(i + 1),  // Is less than the clock at the next index?
                            // I.e. the clock goes from 0 to 1
                x,          // Set the flip-flop as the current item x
                q           // Otherwise, make an identity function.
            )               // The assigned operand result is automatically
    )                       // returned to the map loop, so no
)                           // explicit reference of the flip-flop in the map.

Python 3.8, 57 bytes
lambda C,D,x=0:[x:=[x,d][a<b]for d,a,b in zip(D,C,C[1:])]

Try it online!
Input: 2 lists of 0s and 1s, the first list C represents the clock line, and the second list D represents the data line.
Output: The list Q representing the state of the flip-flop through time.
Explanation

for d,a,b in zip(D,C,C[1:]) iterates over the lines, where d is the current data bit, a is the previous clock bit, and b is the current clock bit
x stores the previous state of the flip-flop
x:=[x,d][a<b] updates the state of the flip-flop: if a<b is 1 (edge-rise moment), then the state is updated to the current data bit d. Otherwise, the state remains the same as previous state.

Why is there "(pre-release)" behind "Python 3.8"? Python 3.8 was released months ago.

@Mast true, I just copied the title from TIO and didn't think much about it

Java 8, 55 bytes
C->D->{int i=0,p=0;for(int c:D)D[i]=C[i]<C[++i]?p=c:p;}

Port of @Arnauld's JavaScript answer, so make sure to upvote him!!
Input as two integer-arrays. Stores the result (\$Q\$) in input \$D\$ instead of returning a new list to save bytes.
Try it online.
Explanation:
C->D->{                  // Method with two integer-arrays as parameter and no return-type
  int i=0,               //  Index-integer, starting at 0
      p=0;               //  Previous integer, starting at 0
  for(int c:D)           //  Loop over the digits of input D:
    D[i]=                //   Set the `i`'th value of array D to:
         C[i]            //    If the `i`'th value of array C
             <C[++i]?    //    is smaller than the `i+1`'th value of array C
                         //    (thus C[i] == 0 and C[i+1] == 1)
                     p=c //     Use the current digit `c`,
                         //     and also replace `p` with this digit
                    :    //    Else (they're [0,0], [1,0] or [1,1]):
                     p;} //     Use digit `p` instead

C (gcc), 80 67 bytes
t;f(c,d,n)int*c,*d;{for(t=*c++;n--;d++)*c++=t^*c&&(t^=1)?*d:c[-1];}

Try it online!
Inputs the clock and data as int arrays along with the length of the data array.
Returns the output in the clock array starting at one past the beginning.

Charcoal, 22 bytes
≔0ζＦＬη«Ｆ‹§θι§θ⊕ι≔§ηιζζ

Try it online! Link is to verbose version of code. Explanation:
≔0ζ

Initialise Q.
ＦＬη«

Loop over the elements of D.
Ｆ‹§θι§θ⊕ι

Did CLK transition from 0 to 1?
≔§ηιζ

If so then set Q to D.
ζ

Output Q.

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


text:
Pendulum Encoding
Given a string as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding. The test cases are split into individual items (which aren't quoted) for a visually appealing explanation.
How do I do that?
The current iteration index starts at 0.

If the iteration index is even, append the current item onto the output string.
If the iteration index is odd, prepend the current item onto the output string.

An example
The input is [a b c d e f g].
Note that the letters a-g are individual one-character strings, to prevent confusion from the iteration index.
N: the iteration index

N:0 Out:      [a]
N:1 Out:    [b a]
N:2 Out:    [b a c]
N:3 Out:  [d b a c]
N:4 Out:  [d b a c e]
N:5 Out:[f d b a c e]
N:6 Out:[f d b a c e g]

The output should be [f d b a c e g].
Another example
The input is [u d l n u e m p].

N:0 Out:        [u]
N:1 Out:      [d u]
N:2 Out:      [d u l]
N:3 Out:    [n d u l]
N:4 Out:    [n d u l u]
N:5 Out:  [e n d u l u]
N:6 Out:  [e n d u l u m]
N:7 Out:[p e n d u l u m]

Test cases
Here's a sample program doing this encoding.
Take note that the characters in the string aren't always unique.
Your output *has* to be flattened.

[a,b,c,d,e,f,g]   -> [f,d,b,a,c,e,g]
[]                -> []
[a]               -> [a]
[a,b,c,d]         -> [d,b,a,c]
[a,b]             -> [b,a]
[a,b,d]           -> [b,a,d]
[a,b,a,c,b,c]     -> [c,c,b,a,a,b]
[a,a,b,b,c,c]     -> [c,b,a,a,b,c]
[u,d,l,n,u,e,m,p] -> [p,e,n,d,u,l,u,m]

Can I/O be a string? If not, may we output a 2D-array?

yes I/O can be a string?

05AB1E, 4 bytes
ι`Rì

I/O as a list of characters.
Try it online or verify all test cases.
Explanation:
ι     # Uninterleave the (implicit) input-list (into 2 parts by default for lists)
      #  i.e. ["u","d","l","n","u","e","m","p"] → [["u","l","u","m"],["d","n","e","p"]]
 `    # Push both parts separated to the stack
  R   # Reverse the second part
      #  → ["p","e","n","d"]
   ì  # And prepend it in front of the first
      #  → ["p","e","n","d","u","l","u","m"]
      # (after which the result is output implicitly)

Python 3, 29 bytes
lambda l:l[1::2][::-1]+l[::2]

Try it online!
Input: A sequence
Output: The pendulum encoding of that sequence
How
Consider the sequence [0,1,2,3,4,5], whose pendulum encoding is [5,3,1,0,2,4]. We can see that all even indices ended up in order on the right, and all odd indices are in reversed order on the left.

l[1::2][::-1] takes all odd indices and reverses them, e.g [5,3,1]
l[::2] takes all even indices, e.g [0,2,4]

Too bad that you can’t simply write l[-2::-2] or similar instead of the longer and more complex l[1::2][::-1].

brainfuck, 24 21 18 bytes
,[[<],[>],<]>>[.>]

Try it online!
Thanks to Jo King for -3 bytes
,[          while input
  [<],      add new character to start of memory
  [>],      add new character to end of memory
  <         go one back, so the loop will run another time, moving the pointer to the start of memory
]
>>[.>]      print memory

21 bytes

APL (Dyalog Unicode), 11 bytes
I promised you'll see at least one interesting answer :)
{⍵[⍋-\⍳≢⍵]}

Try it online!
Uses my own tip about -\⍳, specifically the ⍋ variation, to generate the permutation needed for this challenge.
How it works
⍋-\⍳≢⍵ generates the target permutation for both even- and odd-length arrays:
⍋-\⍳≢⍵  ⍝ Length-7 vector  | Length-8 vector
    ≢   ⍝ Length
        ⍝ 7                | 8
   ⍳    ⍝ Range (1..n)
        ⍝ 1 2 3 4 5 6 7    | 1 2 3 4 5 6 7 8
 -\     ⍝ Cumulative alternating difference
        ⍝ 1 -1 2 -2 3 -3 4 | 1 -1 2 -2 3 -3 4 -4
⍋       ⍝ Grade up; permutation that will sort the input array
        ⍝ 6 4 2 1 3 5 7    | 8 6 4 2 1 3 5 7

Then ⍵[...] arranges the original elements in that particular order.

JavaScript, 36 bytes
Feels like forever since I posted a JS solution here!
Input as an array, output as a string. Handling the empty array cost 3 bytes.
a=>a.reduce((x,y,z)=>z%2?y+x:x+y,"")

Try it online!

... Did you outgolf Arnauld?

@a'_' Not only that, but he managed used reduce instead of map!

Haskell, 53 37 bytes
([]#)
p#(a:b:s)=(b:p++[a])#s
p#l=p++l

Try it online!
Golfed 16 bytes thanks to @xnor

37 bytes by merging the bases cases. Note that the f= doesn't have to be counted.

What does the first line do?

@corvus_192 It is easier to see if you click the "try it online" button. ([]#) defines the actual function that I am submitting, where # is an auxiliar function that takes two arguments; the left argument (that starts as []) is the string I'm building and the right argument is the string to be "parsed"

@corvus_192 Also see this HaskellWiki entry.

JavaScript (ES6), 42 bytes
A recursive function taking and returning a string.
f=([c,...a],k,o='')=>c?f(a,!k,k?c+o:o+c):o

Try it online!

Jelly,  6  5 bytes
-1 thanks to Unrelated String! (Use an initial value for reduction.)
;ṭƭƒ“

Try it online!
A full program that accepts a string and prints the result.
How?
;ṭƭƒ“ - Main Link: list of characters, S
    “ - get an empty list -> X
   ƒ  - reduce (X + S) using:
  ƭ   -   tie - this groups the last n (default 2) links together and calls them cyclically:
;     -     concatenate  (i.e. on the first, third, fifth,... we append)
 ṭ    -     tack         (     while on the second, fourth,... we prepend)
      - implicit, smashing print to STDOUT

It could be considered a bug that Jelly barfs if the non-initialised version of reduce, /, is provided with an empty list. If that were 'fixed' this becomes just the four-byte ṭ;ƭ/.

Since it's a full program, ;ṭƭƒ“ for 5?

Ah yes, nice job, thanks!

Keg, -lp, -ir, -hd, 15 bytes
⑫&(&⑶+&)⒁2%[⒂|&

Try it online!
Purely a literal interpretation of the question plus a bit to ensure even length strings don't break.
Explained
⑫&

First, we start by storing an empty string (pushed by ⑫) in the register. This will be used as the final output, meaning that it needs to be initalised.
(&⑶+&)

Then, we enter the main for loop, which has the implicit condition ! (take length of stack), as no explicit condition is provided. Now, there isn't anything on the stack at this point, so doing such a thing may seem pointless. But, by using the -lp flag (--lengthpops), we can have the ! command take input if the stack is empty and push the length of the input. Also, the -ir (--inputraw) command ensures that the input word is taken as a series of letters, rather than a single string.
Inside the for loop, we push the contents of the register, reverse it (⑶ reverses the top item of the stack) and then add whatever is next to the register. By doing so, we achieve the process behind the main algorithm, as consecutive letters are appended in the desired order.
⒁2%

At this point, the encoding has been fully completed. However, if the string is of an even length, the result will be reversed in the register. This requires us to push the length of the register (⒁) and check to see if it is even.
[⒂|&

If the register is of odd length, then we reverse the register and push it onto the stack (⒂). Otherwise, we simply push the register. -hd will then ensure that only the top item on the stack is printed.

Red, 52 bytes
func[a][append reverse extract next a 2 extract a 2]

Try it online!

J, 13 bytes
{~[:/:[:-/\#\

Try it online!
A J port of Bubbler's APL solution - don't forget to upvote his answer!
           #\  length of successive prefixes
        -/\    cumulative alternating difference
      [:       function composition (caps the previous two verbs as a fork)
    /:         grade up
  [:           caps the fork
{~             use the list to index into the input (arguments reversed)

Perl 5 +p, 30 bytes
$\=--$|%2?$\.$_:$_.$\for/./g}{

Try it online!

Vyxal r, 3 bytes
yṘJ

Uninterleave, reverse the second argument, merge b + a. Requires the r flag because there's no way to merge to my knowledge the other way around in one command.
Try it Online!
And flagless from @AaronMiller if the input is taken as a string:
Vyxal, 3 bytes
yṘp

Instead of J to merge, it prepends the element.
Try it Online!

3 bytes flagless

@AaronMiller that only works if you take the input as a string not a list, but I'll add it

From the question: "Given a string as an input (which can be any acceptable/convenient format in your language)"

Java (JDK), 60 bytes
a->{var r="";for(var c:a)r=r.length()%2<1?r+c:c+r;return r;}

Try it online!
Alternative with Streams (62 bytes)
s->{int[]x={0};return s.reduce("",(a,b)->x[0]++%2<1?a+b:b+a);}

Try it online!

Ruby, 42 bytes
f=->s,*w{s ?f[s[2..-1],s[1],*w,s[0]]:w*''}

Try it online!

PHP, 49 48 bytes
for(;$a=$argv[++$i];)$s=$i%2?$s.$a:$a.$s;echo$s;

Try it online!
Again, not a really great score for PHP..
EDIT: Thanks for @OlivierGrégoire for saving 1 byte

48 bytes

Icon, 62 bytes
procedure f(s)
t:=""
t[k:=|(0|1)\*s:k]:=pop(s)&\z
return t
end

Try it online!
Takes the input as a list of chars.
Icon, 66 bytes
procedure f(s)
t:=""
i:=1to*s&t[1-i%2:1-i%2]:=s[i]&\z
return t
end

Try it online!
Takes the input as a string.
procedure, return and end add a lot to the byte count :)
Icon's slice operator : can be used to insert substrings into strings, if the the two indices are equal. This s[1:1]:="a" prepends s with "a"; s[0:0]:="b" appends "b" to s. I start with an empty string t, scan the input string s and use the odd/even index i with the slice operator to prepend/append to t.

C# (.NET Core), 93 bytes
public static string P(this string a){int z=0;return a.Aggregate("",(x,y)=>z++%2>0?y+x:x+y);}

Try it online!

Japt -P, 7 6 5 bytes
I/O as a string.
ó ÔvÔ

Try it
ó ÔvÔ     :Implicit input of string    > "udlnuemp"
ó         :Uninterleave                > ["ulum","dnep"]
  Ô       :Reverse                     > ["dnep","ulum"]
   vÔ     :Reverse first element       > ["pend","ulum"]
          :Implicitly join and output  > "pendulum"

Zsh, 26 bytes
for x y;a=($y $a $x)
<<<$a

Try it online!
Input is a list of characters.

Retina, 20 bytes
*>^`.(.)?
$1
1,2,`.

Try it online! Link includes test suite. Explanation:
*>`

Execute this stage and immediately output the result without actually changing the working string.
^`

Before making the replacements, reverse their order.
.(.)?
$1

Keep only alternate characters.
1,2,`.

Delete alternate characters.
29 bytes as a reusable function:
,V,2,`
O^$`.((?=(..)*$))?
$#1

Try it online! Link includes test cases. Explanation:
,V,2,`

Reverse all the characters except alternate characters.
O^$`.((?=(..)*$))?
$#1

Sort all characters by the parity of their position from the end, and then reverse the result. This means that alternate characters end up reversed and sorted to the start, leaving the remaining characters at the end, although technically having been reversed twice.

Charcoal, 13 bytes
Ｆ²«Ｐ✂θιＬθ²←↷⁴

Try it online! Link is to verbose version of code. Explanation:
Ｆ²«

Loop over the even and alternate characters.
Ｐ✂θιＬθ²

Print the current set of characters.
←↷⁴

Prepare to print the alternate characters backwards.

Pip, 10 bytes
ORVDQUW:aa

Try it online!
-4 from DLosc.
Similar solution, 14 bytes
UW:a(RVa@1).@a

Try it online!

With solution 1, you can save a byte by keeping the unwoven halves in their original order: TIO. Solution 2, however, led to more golfing possibilities: TIO, 10 bytes.

Perl 5 -p, 26 bytes
s/(.)(.)/$\="$2$\$1";''/ge

Try it online!

Rockstar, 135 125 115 96 bytes
listen to S
cut S
X's 0
O's ""
while S
let X be not X
let O be X and O+roll S or roll S+O

say O

Try it here (Code will need to be pasted in)

Scala, 51 bytes
_./:(0,""){case(i->a,c)=>i+1->Seq(a+c,c+a)(i%2)}._2

Try it online

Factor, 47 bytes
[ dup <odds> ""reverse-as swap <evens> append ]

Try it online!
Explanation
It's a quotation (anonymous function) that takes a string from the data stack as input and leaves a string on the data stack as output. Assuming "udlnuemp" is on top of the data stack when this quotation is called...

dup Duplicate whatever's on top of the stack.
Stack: "udlnuemp" "udlnuemp"

<odds> Get the odd-indexed elements as a virtual sequence.
Stack: "udlnuemp" T{ odds f "udlnuemp" }

"" Push an empty string to the stack.
Stack: "udlnuemp" T{ odds f "udlnuemp" } ""

reverse-as Take a source sequence and an exemplar sequence, and create a new sequence where the source sequence is reversed, but with the type of the exemplar sequence.
Stack: "udlnuemp" "pend"

swap Swap the top two objects on the data stack.
Stack: "pend" "udlnuemp"

<evens> Get the even-indexed elements as a virtual sequence.
Stack: "pend" T{ evens f "udlnuemp" }

append Append two sequences. The result of append has the same type as the first argument.
Stack: "pendulum"

minigolf, 36 bytes
0,;i,unx2%!,,__a,n_nx2%,,__xo,;o_s,_

Attempt This Online!
Explanation
0,;        Start with an empty list
i,         Foreach item in input:
  u            Store list to acc
  n            Push curr. item
  x2%!,        If iteration index is even:
    ,_             drop TOS
  _            end
  a            Push acc
  ,n_          Dump acc onto stack
  n            Push curr. item
  x2%,         If iteration index is odd:
    ,_             drop TOS
  _            end
  xo           Iteration index + 1
  ,;o          Wrap last n items of stack into array
_            End foreach
s,_          (For some reason we have an extra implicit input,
              so swap it upwards and drop it)

Python 2, 25 bytes
lambda s:s[-1::-2]+s[::2]

Try it online!
Wrote this before I took a look at the submissions. The Python 3 answer is basically the same, but I improved the slicing to reverse the odd indices all in one.
But yeah, you can construct the pendulum encoding in two parts. First, the odd indices in reverse order. Second, the even indices in normal order.

Sadly, the first part doesn't get the odd indices, rather, it gets the negative odd indices. You can see why it fails for even-length strings.

Lua, 56 bytes
s=''(...):gsub('(.)(.?)',load'a,b=...s=b..s..a')print(s)

Try it online!


text:
Four distinct 8-bit integers
Submit a well-formed program or function with usual I/O rules which satisfy the input, output, and algorithm conditions below. Shortest submission (in bytes) wins. As always, standard loopholes are forbidden.
In short: Two distinct 8-bit integer inputs must produce two 8-bit integer outputs so that all four numbers are distinct, i.e., not equal.
Input Conditions
Two distinct 8-bit integers, a and b, both of which are in 8-bit signed (or unsigned at your discretion) format.
Output Conditions
Two 8-bit integers, c and d, which are in the same format as the input (signed or unsigned), such  that a, b, c, and d are distinct, i.e., no two of them are equal to each other.
Algorithm Conditions

The algorithm must halt for all possible valid inputs.

Valid inputs are those where a and b are distinct. When a and b are equal, the behaviour of the algorithm is unspecified.

The algorithm must be deterministic.

Running the algorithm with the same input must produce the same output.

The algorithm must satisfy the output conditions for all valid inputs.

Verification
There are two ways to verify your algorithm.

Brute force: explicitly check the program for all valid input combinations.
Prove/show, by analysis, that a clash is impossible (preferred).

FAQ

What if my programming language doesn't provide 8-bit integers?
What if my programming language doesn't support fixed-width integers?

Only the range of the outputs matter; internal computations may be in any precision.  If the outputs can be rounded/scaled to the required integral range, then the programming language is good to go.

Edits
Edit 1: Thank you for the submissions! I am glad to see so many creative solutions! Initially, I planned to restrict the algorithm to one-to-one mapping (i.e., invertible), however, decided against it to make the problem simpler. Looking at the enthusiastic response, I will consider submitting a second code golf with the one-to-one mapping requirement.

I would suggest explicitly allowing the deterministic output to be unordered, e.g. an input can produce [1,2] or [2,1] or a set that contains 1 and 2.

Just to be sure, 0s have to be taken into account right? The input may have one 0?

@JoKing sorry, without any disrespect, I do not think this is acceptable. The reason being that the original requirements of determinism are for output integers "c" and "d;" combining them into a set is only a convenience, which is allowed per the rules.

@RGS, yes, input range for 8-bit signed is [-128,127] and for 8-bit unsigned is [0,255].

Similar to https://codegolf.stackexchange.com/questions/139606/the-third-string

JavaScript (Node.js), 35 31 27 23 bytes
-4 bytes thanks to Arnauld and Kevin Cruijssen
-4 bytes thanks to xnor
a=>b=>[c=3^a&1^b&2,c^4]

Try it online!
Explanation:
Takes the flipped 1 bit of the first number, and adds the flipped 2 bit of the second number, guaranteeing a number different from both inputs in the 2 least significant bits. Outputs this number, and 4 added to this number

If you change the + to |, it looks like you can cut out the inner parens. Or better: Try it online!

Perl 6, 20 bytes
{grep(.none,^4)[^2]}

Try it online!
Outputs the first two numbers from the range 0 to 3 that aren't in the input.

brainfuck, 69 bytes
,+[->+>+>+<<<],[->>->-<<<]++>>>[[-]<<<->.>>]<+<+>[[-]<<->.>]<+<[->.<]

Try it online!
My solution takes the first input and counts it upwards and prints the first two numbers unless they are the second input.
So if the first input is A and the second input is B the output will be:
A+2, A+3 if B = A+1 or
A+1, A+3 if B = A+2 or
A+1, A+2 else
This initializes position 1,2,3 of the band as the first input incremented by 1
,[->>->-<<<]
This substracts the second input from positions 2 and 3.
++
Set position 0 to 2, counting the numbers still to print
The band now reads: (2) a+1 a-b+1 a-b+1
>>>[[-]<<<->.>>]
If position 3 is not 0, print out position 1 and decrement position 0
<+<+>
Increment the band in position 1 and 2
[[-]<<->.>]
If position 2 is not 0, print out position 1 and derement position 0
<+<[->.<]
Increment at position 1, Position 0 is now either 1 or 0. If it is 1 print position 1 one more time. ```

05AB1E, 9 5 bytes
∞IK2£

I/O as a pair of integers.
Try it online or verify some more test cases.
Explanation:
∞      # Push an infinite positive list [1,2,3,...]
 IK    # Remove the values of the input-pair
   2£  # Only leave the first two values
       # (after which the result is output implicitly)

Haskell, 32 bytes
a#b=take 2[i|i<-[1..],a/=i,b/=i]

Try it online! We pick the first two positive integers that aren't input numbers.

Charcoal, 27 10 bytes
Ｉ…⁻Ｅ⁴ιＥ²Ｎ²

Try it online! Link is to verbose version of code. Uses the same set difference algorithm as everyone else. Less boring 27-byte version actually tries to produce interesting outputs for all inputs:
ＮθＮηＩ﹪⁺÷¹²⁸⊕¬﹪⁻θη¹²⁸⟦θη⟧²⁵⁶

Try it online! Link is to verbose version of code. Takes unsigned integers. Explanation: Flips the top bits of the values, unless this would exchange them, in which case adds 64 (modulo 256) instead.

JavaScript (ES6),  32 27  26 bytes
Takes input as (x)(y).
x=>y=>[x^=k=y^x^1?1:2,y^k]

Try it online!

Octave, 28 22 bytes
@(x)setxor(1:4,x)(1:2)

Try it online!
Explanation
Anonymous function that outputs the first 2 entries from the sorted symmetric difference between [1 2 3 4] and the input.

Pyth, 5 bytes
>2-Uy

Try it online!
Explanation
    y # Repeat the input
   U  # Generate a length range: [0 .. 3]
  -   # Difference with implicit input
>2    # Slice out the last 2 items of the resulting list

You probably mean "repeat" the input, not "repeat twice"?

y is powerset, not repeat the input. Still length 4, which is what counts.

Python 3, 27 bytes
lambda s:[*{0,1,2,3}-s][:2]

Try it online! The input is a set s with the integers. We build the set {0, 1, 2, 3, 4, 5, 6, 7, 8} and then perform set subtraction to remove, from that set, any input numbers. We then convert to a list and extract two elements.
Thanks Surculose for saving me 2!

{0,1,2,3}-s should works

Wolfram Language (Mathematica), 32 bytes
port of @Jo King's answer
Complement[Range@4,{##}][[;;2]]&

Try it online!

C (gcc), 36 34 28 bytes
Saved 2 8 bytes thanks to ceilingcat!!!
f(x,y){x=(~y&2|~x&1)*257+4;}

Try it online!
Uses Paul Mutser's formula.
Returns the two 16-bit values in a 32-bit int since there are no tuples &c in C.

Japt, 8 bytes
Hõ kU ¯2

Try it

Bash + Core utilities, 29 bytes
seq 4|egrep -v $1\|$2|head -2

Try it online!
Input is passed in two arguments, and the output is printed to stdout.
This prints the first two positive integers that aren't either of the two arguments.

This seems to give only one number if passed in 1 and 2.

@xnor Thanks -- that was a dumb mistake.  It's fixed now (no scoring change).

Python 3.8, 31 29 bytes
Saved 2 bytes thanks to xnor!!!
lambda x,y:(k:=~x&1|~y&2,k+4)

Try it online!

The parens around the first entry aren't necessary.

@xnor Interesting - thanks! :-)

k:=(x|1)^(y|2) seems like a it could save bytes, but I don't a way to get rid of the parens.

Erlang (escript), 43 bytes
Outputs the first two numbers from the range 0 to 3 that aren't in the input.
f(A)->lists:sublist(lists:seq(0,3)--A,1,2).

Try it online!

W, 5 bytes
Takes input as a pair of integers.
%G?←√

Uncompressed:
4k     Range from 1 to 4
  at   Trim out all items that appear in the input
    2< Take the first two items of the output list.

Io, 46 bytes
Port of RGS's Python answer.
method(x,list(1,2,3,4)difference(x)slice(0,2))

Try it online!

Alchemist, 60 bytes
_->In_x+In_y+2n
n+x+y->Out_z+z+Out_" "
x+0y->z+3y
y+0x->z+3x

Try it online!
As with many answers here, prints the first two non-negative integers not in the input.  Input is unsigned, since Alchemist doesn't have signed numbers.
I similarly can't just let a variable "go negative" after it hits zero, so I just let an input value x also exclude x+4, x+8, and so on.  This has no effect on anything, provided both variables don't hit zero at the same time.  Fortunately, if they ever become the same, both outputs will happen before they hit zero.

Ruby, 22 bytes
->*a{([*6..9]-a)[0,2]}

Try it online!
Same method as almost everybody.


text:
Find how many ordered pairs of integers share only one digit
Task
Your task is to make the smallest function/program that can, when gives an number N, return/print:
the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23, where 2 appears both in 23 and in 12)
note - 1 and 11 count as having exactly one common digit, as 1 is a digit which appears in both of them, and it's the only one that appears in both of them.
You function/program should work for all n from 1 to 1000.
Test Cases
20 -> 63
40 -> 267
60 -> 575
80 -> 987
100 -> 1503
1000 -> 235431

Rules
This is a code golf so the lowest score in bytes wins. Good luck!

APL (Dyalog Extended or 18.0), 24 22 bytesSBCS
Full program.
≢⍸∘.(<∧1=∘≢∘∪∩⍥⍕)⍨1↓⍳⎕

Try it online!
⎕ prompt for N from the console
⍳ first N integers
1↓ drop the first one (0)
 ⍨ apply the following function using those integers as both left and right argument:
  ∘.(…) apply the following function between all combinations of left and right elements:
   ⍥⍕ stringify (make into character list) both arguments, then:
    ∩ find the intersection between the character lists
   ∪ find the Unique elements of that
   ∘ then:
    ≢ count that
   ∘ then:
    1= check if that is equal to 1
   ∧ and
   < the left argument is less than the right argument
⍸ find the ɩndices of the trues
≢ count them

the code doesn't work in tio, it errors.

@CommandMaster I hadn't filled in the test cases. Should be all good now.

05AB1E, 15 14 12 bytes
L¨2.Æʒ`ÃÙg}g

-2 bytes thanks to @Shaggy.
Try it online or verify all test cases.
Explanation:
L           # Push a list in the range [1, (implicit) input]
 ¨          # Remove the last value to make the range [1, input)
  2.Æ       # Get all non-duplicated combinations of size 2 of this list
     ʒ      # Filter this list of pairs by:
      `     #  Push them separated to the stack
       Ã    #  Only keep the digits of the first number which are also in the second
        Ù   #  Uniquify those remaining digits
         g  #  Get the length of the remaining digits (only 1 is truthy in 05AB1E)
     }g     # After the filter: get the amount of remaining items by taking the length
            # (which is output implicitly as result)

cool! I've found an answer in 05AB1E of 24 bytes

Does this approach offer any advantage? I know it's pretty bad right now...

Does 05AB1E not have a way to get combinations of a specified length?

@Shaggy .Æ should do that

@ExpiredData Well, you can remove the s, but apart from that it's still a byte longer I'm afraid.

@Shaggy Thanks for the -2. :)

J, 39 bytes
1#.[:,1=[:(</*([#@~.@-.-.)&":"0/)~1}.i.

Try it online!
Interestingly, almost exactly the same as Adam's APL answer, though I arrived at it independently.  A bit more verbose in J, though... ಥ_ಥ

Jelly, 12 bytes
ṖDŒcf/QLƊ€ċ1

A monadic Link accepting a non-negative integer which yields a non-negative integer.
Try it online!
How?
ṖDŒcf/QLƊ€ċ1 - Link: integer, N   e.g. 1000
Ṗ            - pop (implicit range)    [1,2,3,...,999]
 D           - to decimal (vectorises) [[1],[2],[3],...,[9,9,9]]
  Œc         - unordered pairs         [[[1],[2]],[[1],[3]],...,[[1],[1,9]],[[2],[3]],...,[[9,9,8],[9,9,9]]]
         €   - for each:                   e.g. [[2,5,2],[2,7,0]]
        Ɗ    -   last three links as a monad:
     /       -     reduce by:
    f        -       filter keep                [2,2]
      Q      -     de-duplicate                 [2]
       L     -     length                       1
           1 - literal one
          ċ  - count occurrences       235431

Python 2, 77 bytes
lambda n:sum(len(set(`a`)&set(`b`))==1for a in range(1,n)for b in range(1,a))

Try it online! Thanks to @SurculoseSputum for translating my Python 3 program into Python 2, helping me golf the v3 and creating a shorter one in Python 2.
Python 3.8 (pre-release), 99 79 bytes
lambda n:sum(len({*str(a)}&{*str(b)})==1for a in range(1,n)for b in range(1,a))

Try it online!

77 bytes

Ugh, I should learn some Python 2..... Thanks @SurculoseSputum!

Won't len(set(a)&set(b))==1 be true for, say, 22 and 202?

@Noodle9 yes it will, and that is what the OP means by "sharing a digit", 22 and 202 share the digit 2.

Ah, ok got it now.

JavaScript (ES6), 83 bytes
f=(a,b=--a)=>a?--b?!~-new Set((a+[,b]).match(/(.)(?=.*,.*\1)/g)).size+f(a,b):f(a):0

Try it online!
How?
To test how many distinct digits the integers \$a\$ and \$b\$ have in common, we concatenate them with a comma in between and apply the following regular expression:
/(.)(?=.*,.*\1)/g

 (.)              // a digit in the first integer
    (?=           // followed by:
       .*         //   some optional digits
         ,        //   a comma (the separator between the 2 integers)
          .*      //   some optional digits
            \1    //   the same digit in the 2nd integer
              )   // end of lookahead

We then turn all matches into a set and test whether its size is exactly \$1\$. For golfing reasons, we actually decrement the size and test whether the result is \$0\$:
!~-new Set(...).size

When nothing is matched, match() returns null rather than an empty array, which is usually painful to deal with if we want to apply some array method or property to the result. But we don't have to worry about that here because new Set(null) simply generates an empty set, which is what we want.

Non-recursive, 93 bytes
n=>{for(t=0;--n;)for(b=n;--b;)t+=new Set((n+[,b]).match(/(.)(?=.*,.*\1)/g)).size==1;return t}

Try it online!

Japt -x, 16 15 bytes
oì à2 Ërf â Ê¶1

Try it

Wolfram Language (Mathematica), 83 bytes
(t=0;Do[If[Tr[1^Intersection@@IntegerDigits@{i,j}]==1,t++],{i,#-1},{j,i+1,#-1}];t)&

Try it online!

Java 8, 166 156 bytes
n->{int r=0,a=n,b,i;for(;a-->2;)for(b=a;b-->1;){var s="";for(var t:(a+s).split(s))if((b+"").contains(t)&!s.contains(t))s+=t;r+=s.length()==1?1:0;}return r;}

Try it online.
Explanation:
n->{                    // Method with integer as both parameter and return-type
  int r=0,              //  Result-counter, starting at 0
      a=n,b,i;          //  Integers a,b,i
  for(;a-->2;)          //  Loop `a` in the range (n, 2]:
    for(b=a;b-->1;){    //   Inner loop `b` in the range (a, 1]:
      var s="";         //    Create an empty String
      for(var t:(a+s).split(s))
                        //    Loop over the digits of `a`:
        if((b+"").contains(t)
                        //     If `b` contains this digit
           &!s.contains(t))
                        //     and the String doesn't contain this digit yet:
          s+=t;         //      Append this digit to the String
      r+=               //    Increase the counter by:
         s.length()==1? //     If the length of the String is 1:
          1             //      Increment the counter by 1
         :              //     Else:
          0;}           //      Leave the counter the same by increasing with 0
  return r;}            //  After the loops, return the counter-integer as result

Charcoal, 25 bytes
ＩΣＥＮＬΦι∧λ⁼¹ＬΦχ∧№ＩιＩν№ＩλＩν

Try it online! Link is to verbose version of code. Explanation:
   Ｎ                       Input `n` as a number
  Ｅ                        Loop `0<=b<n`
      ι                    `b`
     Φ                     Loop `0<=a<n`
        λ                  `a`
       ∧                   Is non-zero and
           ＬΦχ             Count of digits where
               №ＩιＩν       Digit present in `b`
              ∧            And
                    №ＩλＩν  Digit present in `a`
         ⁼¹                Equals `1`
    Ｌ                      Number of matching values
 Σ                         Sum of numbers
Ｉ                          Cast to string for implicit print