text:
Calculate the middle number of a row of the pascal triangle
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5

would return
20

Example 2:
4

would return
6

EDIT:
To be clear:
a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle.
b) if the number inputted is even then find the two middle numbers of the row on the pascal triangle and sum the 2 numbers.
The nth row is using zero-based indicies. For numbers other than zero, this is the row which has its second number as the number inputted into the function.

So nC(n/2) if n is even and 2(nC((n-1)/2)) if n is odd?

Very related.

@LeakyNun wait what's C in that context?

@Mayube binomial coefficient

Which built-in function may we not use?

@KSFT any, you can't actually write any code

Related.

Welcome on the site. I strongly recommend you to post your challenges in the Sandbox before posting the on main, in order to get feedbacks and help from the community to improve them.

@KSFT, I have removed that rule as it is unlikely for there to be a built-in function that does my challenge.

If the rows are 0-indexed (which is what I believe you are suggesting with "The nth row is using zero-based indicies") then it will be the odd numbered rows that have two middle entries. Note, however, that it is quite common to allow either 0 or 1 indexing in code-golf.

I don't see why this was closed; the OPs sequence is not the Catalan numbers.

@ChasBrown The Catalan numbers are very closely related to this sequence. Let C_n be the nth Catalan number, and G_n be the nth term of this sequence. G_n = (nCn/2) if n is even and G_n = 2(nC(n-1)/2) if n is odd (where aCb means a choose b, aka binomial coefficients). C_n = ((2n)Cn)/(n+1). Thus, C_2n = G_n/(2n+1) if n is even, and C_2n = 2(G_n)/(2n+1) if n is odd. The sequences are very closely related, and so any optimal solution to this challenge is likely to be very similar to an optimal solution for the Catalan numbers challenge.

@Mego Indeed they are closely related; but they are not so identical as 'Marked as duplicate' would imply. One might equally say that producing the Catalan numbers should be 'marked as a duplicate' of producing nCk, as they are also 'closely related'. IMHO, of course!

@ChasBrown I don't know that I would have voted to close this as a dupe of Catalan numbers, but given that my votes are binding due to my gold badge, and thus only one is needed to close or reopen a code golf question, I'm not going to unilaterally reopen it.

@Mego With great power comes great responsibility :). No worries!

Ohm, 6 bytes
½⌠Ddac

Try it online!
If the number is even it is you calculate (n n/2) if it is odd (n+1 (n+1)/2)
         Inplicit input
½        Half
 ⌠       Ceil
  D      Duplicate on stack
   d     x2
    a    Swap on stack
     c   Binomial

05AB1E, 7 5 bytes
Saved 2 bytes using the duplicate/swap technique from FrodCube's Ohm answer
;îxsc

Try it online!

Python 2, 88 81 80 79 74 72 bytes
Thanks to @JonathanAllen
import math
f=math.factorial
n=input()
print(n%2+1)*f(n)/f(n/2)/f(n-n/2)

Try it online!

No need for the int (saving 5), since division is integer division by default in Python 2, which means you can remove the assignment to k too and save another 2 with print(n%2+1)*f(n)/f(n/2)/f(n-n/2).

...and two more bytes removing the line k=n/2 and using the code I put in the last comment for the last line.

Jelly, 5 bytes
HĊµḤc

A monadic link, taking a (0-indexed) row and returning the middle number or the sum of the two middle numbers - equivalently the middle number of the row beneath).
Try it online!, or see the first 20 values in the test suite.
How?
HĊµḤc - Link: number v
H     - halve = v/2
 Ċ    - ceiling, i.e. (v + isOdd?(v)) / 2
  µ   - monadic chain separation, call that k
   Ḥ  - double k (this is n: v if v was even, or v+1 if v was odd)
    c - that choose k = nCk, the required result

R, 35 bytes
function(n)(1+n%%2)*choose(n,n%/%2)

An anonymous function.
Since odd rows need to be doubled, n%%2+1 is 2 when n is odd and 1 when nn is even. Then, I multiply by the appropriate binomial coefficient.
Try it online!

Python 2, 40 38 bytes
f=lambda n:n<1or(-n|1)*2*f(n-2)/(-n/2)

Try it online!

(4+2./(-n/2))*f(n-2) saves a few bytes.

Jelly, 8 bytes
c:2$×Ḃ‘$

Try it online!

Dyalog APL, 12 bytes
{k!2×k←⌈⍵÷2}

or
(⊢!2∘×)∘⌈÷∘2

Try it online!
How?
⍵÷2 - divide by 2
⌈ - ceiling
k← - assign to k
2× - double
k! - binomial with k


text:
Make a super acrostic
Background
Celebrating the release of Dyalog APL 16.0, where the solution to this problem is {⊢⌺(≢⍵)⊢⍵}Explanation
Task
Given a printable ASCII string of odd length n, make an n × n square with the string centered horizontally, duplicated to be centered vertically, and with acrostics of the same string in each row and column. Note that all but the centered strings will be cut off to keep the square's size n × n.
Explanation of your code will be much appreciated.
Rules

You may have trailing whitespace and newlines (this includes the lower-right triangle)
You may return a list of strings

Example using the string ABXCD:

n is 5. First we draw the two centered strings, one horizontal and one vertical:

┌─────┐
│  A  │
│  B  │
│ABXCD│
│  C  │
│  D  │
└─────┘

(5 × 5 bounding box added for clarity)
Then we place all the possible acrostics, horizontally and vertically:

       A
      AB
  ┌─────┐
  │  ABX│CD
  │ ABXC│D
  │ABXCD│
 A│BXCD │
AB│XCD  │
  └─────┘
   CD
   D

Finally, we return only what is inside the bounding box:

  ABX
 ABXC
ABXCD
BXCD
XCD

Test cases
World:
  Wor
 Worl
World
orld
rld

mississippi:
     missis
    mississ
   mississi
  mississip
 mississipp
mississippi
ississippi
ssissippi
sissippi
issippi
ssippi

Pneumonoultramicroscopicsilicovolcanoconiosis:
                      Pneumonoultramicroscopi
                     Pneumonoultramicroscopic
                    Pneumonoultramicroscopics
                   Pneumonoultramicroscopicsi
                  Pneumonoultramicroscopicsil
                 Pneumonoultramicroscopicsili
                Pneumonoultramicroscopicsilic
               Pneumonoultramicroscopicsilico
              Pneumonoultramicroscopicsilicov
             Pneumonoultramicroscopicsilicovo
            Pneumonoultramicroscopicsilicovol
           Pneumonoultramicroscopicsilicovolc
          Pneumonoultramicroscopicsilicovolca
         Pneumonoultramicroscopicsilicovolcan
        Pneumonoultramicroscopicsilicovolcano
       Pneumonoultramicroscopicsilicovolcanoc
      Pneumonoultramicroscopicsilicovolcanoco
     Pneumonoultramicroscopicsilicovolcanocon
    Pneumonoultramicroscopicsilicovolcanoconi
   Pneumonoultramicroscopicsilicovolcanoconio
  Pneumonoultramicroscopicsilicovolcanoconios
 Pneumonoultramicroscopicsilicovolcanoconiosi
Pneumonoultramicroscopicsilicovolcanoconiosis
neumonoultramicroscopicsilicovolcanoconiosis
eumonoultramicroscopicsilicovolcanoconiosis
umonoultramicroscopicsilicovolcanoconiosis
monoultramicroscopicsilicovolcanoconiosis
onoultramicroscopicsilicovolcanoconiosis
noultramicroscopicsilicovolcanoconiosis
oultramicroscopicsilicovolcanoconiosis
ultramicroscopicsilicovolcanoconiosis
ltramicroscopicsilicovolcanoconiosis
tramicroscopicsilicovolcanoconiosis
ramicroscopicsilicovolcanoconiosis
amicroscopicsilicovolcanoconiosis
microscopicsilicovolcanoconiosis
icroscopicsilicovolcanoconiosis
croscopicsilicovolcanoconiosis
roscopicsilicovolcanoconiosis
oscopicsilicovolcanoconiosis
scopicsilicovolcanoconiosis
copicsilicovolcanoconiosis
opicsilicovolcanoconiosis
picsilicovolcanoconiosis
icsilicovolcanoconiosis

Acknowledgements
Thanks to dzaima, Leaky Nun, Mr. Xcoder for everything but the very idea of this challenge.

Do the spaces-triange on the bottom right have to be included or not?

@flawr OP: may

Python 2, 60 bytes
n=input();l=len(n)
for i in range(l):print(l/2*' '+n)[i:l+i]

Try it online!

MATL, 8 bytes
nXyPGZ+c

Try it online!
Explanation
n    % Implicit input. Number of elements
Xy   % Identity matrix of that size
P    % Flip vertically
G    % Push input again
Z+   % 2D convolution, maintaining size
c    % Convert to char (char 0 is displayed as space). Implicitly display

Who thought that I would like this answer :D

@flawr Yes, who would have thought

Retina, 70 59 bytes
.
$.'$* $_$.`$* ¶
(?=((....))+)(?<-1>.)+(.*?)(?<-2>.)+¶
$3¶

Try it online! Edit: Saved 11 bytes with some help from @MartinEnder. Explanation: The first stage repeats the input once for each character, padding it appropriately on each line to get the shear. The last stage then removes 25% from each side to produce the desired result.

I think I had 59 earlier. Don't have time to dig up the details now, but essentially in the first stage I just padded the input with n/2 spaces left and right (using something like (..)+. --> $#1$* $&$#1$* with a trailing space) and then just did a !&\...where...matchesnexactlyn` characters.

Your approach can at least be shortened to 63: https://tio.run/##K0otycxL/P9fj0tFT11FS0ElXkUvAUgf2salmhCnYW@roKWhERMcE6ypqa2pYW@ja2inp6mtoadlD@YZgXgqXCrG//@H5xflpAAA

@MartinEnder Thanks, and I've golfed another 4 bytes off!

Do you need the second $*sp?

@CalculatorFeline Yes, I need all the lines to be the same length, so I can divide it by 4.

Java 8, 120 103 bytes
s->{int l=s.length(),i=l/2;for(;i-->0;s=" "+s+" ");for(;++i<l;System.out.println(s.substring(i,l+i)));}

-17 bytes thanks to @OlivierGrégoire.
Explanation:
Try it here.
s->{                      // Method with String parameter and no return-type
  int l=s.length(),       //  Length of the input-String
      i=l/2;              //  Temp index-integer (starting at halve the length floored)
  for(;i-->0;             //  Loop (1) from `l/2` to 0 (exclusive)
    s=" "+s+" "           //   Add spaces before and after the input-String
  );                      //  End of loop (1)
                          //  (If the input was "World", it is now "  World  ")
  for(;++i<l;             //  Loop (2) from 0 to `l` (exclusive)
    System.out.println(   //   Print:
      s.substring(i,      //    Substring of the modified input from `i`
                    l+i)  //    to `l+i` (exclusive)
    )                     //   End of print
  );                      //  End of loop (2)
}                         // End of method

i=l/2+1 and i-->1 and for(;i<l save a byte.

And... totally golfed: s->{int l=s.length(),i=l/2;while(i-->0)s=" "+s+" ";while(++i<l)System.out.println(s.substring(i,l+i));} (103 bytes). The only significant change is that the string with spaces is generated once and for all instead of "on the fly" (and of course the print instead of returning).

SWI Prolog, 234 bytes
h(_,0,_,_,[]).
h(T,N,S,L,[H|U]):-sub_string(T,S,L,_,H),M is N-1,A is S+1,h(T,M,A,L,U).
s(T,R):-string_length(T,L),findall('_',between(1,L,_),A),string_chars(B,A),
                   string_concat(B,T,C),string_concat(C,B,D),S is L-((L-1)/2),h(D,L,S,L,R).

Maybe try online here: http://swish.swi-prolog.org/p/hEKigfEl.pl
NB.

The last line is one long line, I added a linebreak and spaces here just to avoid horizontal scrollbar in this answer.
The question involves spaces for padding, but Swish online doesn't show them cleanly because of HTML rendering interactions, you have to view source in browser dev tools to check they are present (they are). I've changed the padding to be _ here, as it demonstrates it working and doesn't affect the byte count.

Examples running in Swish:

Approach, basically the first thing I could make work at all, and doubtless a skilled Prolog user could shorten it a lot:

Given a string of length L, the output will have L lines, and each line will be L characters long, so 'L' shows up a lot. Countdown from L to 0 for the number of lines, L for the substring length for each line.
Create a padding string of L spaces (underscores) long, add it to both ends of the input string, because that's a simple length which is definitely going to be enough padding.
Calculate a starting offset into this triple-length string and recurse, generating a substring each time, into a list of results.

Explained and commented code (might not run), read from superacrostic() down, then helper() main body, then helper() base case:
% helper function recursive base case,
% matches when counter is 0, other input has any values, and empty list 'output'.
helper(_,0,_,_,[]).

% helper function recursively generates substrings
% matching a padded input Text, a line Counter
% a substring starting Offset, a line Length,
% and an output list with a Head and a Tail
helper(Text, Counter, Offset, LineLength, [Head|Tail]):-

    sub_string(Text, Offset, LineLength, _, Head),    % The list Head matches
                                                      % a substring of Text starting
                                                      % from Offset, of LineLength chars
                                                      % and

    NextCounter is Counter-1,                         % decrement the Counter

    NextOffset is Offset+1,                           % increment the offset

    helper(Text, NextCounter, NextOffset, LineLength, Tail).  % Recurse for list Tail

% Result is a superacrostic for an input string Text, if
superacrostic(Text, Result):-
    string_length(Text, Length),                   % Length is length of input,
                                                   % Text = 'ABXCD', Length = 5
                                                   % and

    findall('_',between(1,Length,_),PaddingList),  % PaddingList is a list of padding
                                                   % chars Length items long,
                                                   % ['_', '_', '_', '_', '_']
                                                   % and

    string_chars(PaddingString, PaddingChars),     % PaddingString is the string from
                                                   % joining up that list of chars
                                                   % '_____'
                                                   % and

    string_concat(PaddingString, Text, Temp),      % Temp is Text input with a
                                                   % padding prefix
                                                   % Temp = '_____ABXCD'
                                                   % and

    string_concat(Temp, PaddingString, PaddedText), % PaddedText is Temp with
                                                    % a padded suffix
                                                    % Temp = '_____ABXCD_____'
                                                    % and

    S is Length - ((Length - 1) / 2),              % Starting offset S for the substring
                                                   % is just past the padding,
                                                   % then half the input length back
                                                   % '_____ABXCD_____'
                                                   %     |
                                                   % to start the first line,
                                                   % and

    helper(PaddedText, Length, S, Length, Result). % Result is the list generated from
                                                   % the helper function,

    % to recurse Length times for that many output rows, S starting offset,
    % Length linelength, and Result 'output'.

Haskell, 64 62 bytes
f s|l<-length s=take l$take l<$>scanr(:)""(([2,4..l]>>" ")++s)

Try it online!
How it works:
l<-length s               -- let l be the length of the input string

      ([2,4..l]>>" ")     -- take l/2 spaces and
                     ++s  -- append s
    scanr(:)""            -- make a list of the inits of the above string, e.g.
                          -- "  world" -> ["  world"," world","world","orld"...]
  take l <$>              -- take the first l chars of each string
take l                    -- and the first l strings

05AB1E, 11 bytes
g;úIvDIg£,À

Try it online!
Explanation
g;ú           # prepend len(input)/2 spaces to input
   Iv         # for each char of input do
     D        # duplicate current string
      Ig£     # take the first len(input) chars
         ,    # print
          À   # rotate the string to the left

JavaScript (ES6), 75 bytes

f=(s,k=1,l=s.length)=>k>l?'':(' '.repeat(l)+s).substr(l/2+k,l)+`
`+f(s,k+1)

console.log(f("World"))

72 bytes. Or 70 bytes if you want to go with ES8, like I did.

APL (Dyalog Unicode), 10 chars = 22 bytes
{⊢⌺(≢⍵)⊢⍵}

Try it online!
{…} anonymous function where the argument is represented by ⍵
 ⊢ provide the covered area when
 ⌺(…) sliding a stencil of size
  ≢ length of
  ⍵ the argument
 ⊢ on
 ⍵ the argument
The way this works is by letting each character form the middle of a string with the same length as the input, padding left or right as needed. Take e.g. ABXCD:
The string has five characters, so the stencil will have an "opening" that is five characters wide.
┌──↓──┐     stencil opening with middle marker
│  ABX│CD   let A be in the middle
 │ ABXC│D   then B
  │ABXCD|   etc.
  A|BXCD |
  AB|XCD  |
    └──↑──┘ final stencil position

PHP, 98 bytes
for(;~($a=$argn)[$i++];)$i&1?$t.=substr($a,$i/2)."
":$t=($s.=" ").substr($a,0,-$i/2)."
$t";echo$t;

Try it online!

PowerShell Core, 68 bytes
0..($L=($a="$args").Length-1)|%{-join(' '*($L/2)+$a)[($_..($_+$L))]}

Try it online!
Ungolfed explanation
# Input string ABXCD
# -> indexes  0,1,2,3,4  string indexing and num of output lines.
# -> Pad with half-len of spaces __ABXCD.
# -> sliding window array of chars:
# __ABXCD
# |    |       0..4
#  |    |      1..5
#   |    |     2..6
#    |    |    3..7   (selecting indexes past the end returns $nulls, no error)
#     |    |   4..8

# joining those chars into a line

$Text = "$args"                            # script args array to string.
$L    = $Text.Length - 1                   # useful number

$Offsets = 0..$L                           # range array 0,1,2,3,.. to last offset

$Offsets | ForEach-Object {                # Offsets doubles as number of output lines

    $LinePadding = ' ' * ($L / 2)          # lead padding string __
    $PaddedText  = $LinePadding + $Text    # -> __ABXCD

    $Chars = $_..($_+$L)                   # windows 0..4, then 1..5, then 2..6, etc.
    $Line  = $PaddedText[$Chars]           #_,_,A,B,X then _,A,B,X,C then A,B,X,C,D etc.

    -join $Line                            # __ABX  then _ABXC then ABXCD etc.

}

Care to ungolf the join to [($_..($_+$L))]?

@root short answer, the ( doesn't go with the join, it's doing -join  ($Padding + $Text)[0,1,2,3,4] to select several characters from a padded string for an output line, and joining those into a string to be a shorter way of doing .SubString(). and it's generating the padding in-place and the range of characters in-place. Full ungolf explanation added to my answer.

JavaScript (ES8), 66 63 62 bytes
Returns an array.
s=>[...s].map((_,x)=>s.padStart(l*1.5).substr(x,l),l=s.length)

Try it

o.innerText=(f=
s=>[...s].map((_,x)=>s.padStart(l*1.5).substr(x,l),l=s.length)
)(i.value="Pneumonoultramicroscopicsilicovolcanoconiosis").join`\n`;oninput=_=>o.innerText=f(i.value).join`\n`
<input id=i><pre id=o>

Explanation
s=>

Anonymous function taking the string as an argument via parameter s.
[...s]

Split the string to an array of individual characters.
l=s.length

Get the length of the string and assign it to variable l.
.map((_,x)=>                                        )

Map over the array, passing each element through a function, where x is the index of the current element.
s.padStart(l*1.5)

For each element, return the original string with spaces prepended until it's length is 1.5 times that of it's original length.
.substr(x,l)

Get the substring of length l beginning from the current element's index.

V, 14, 11 bytes
òlÙxHÄ$x>>ê

Try it online!
3 bytes saved thanks to @nmjmcman!
Hexdump:
00000000: f26c d978 48c4 2478 3e3e ea              .l.xH.$x>>.

Original approach (18 bytes):
ø..
Duu@"ñLÙxHÄ$x>

Explanation:
ò           " Recursively:
 l          "   Move one char to the right (this will break the loop if we move too far
  Ù         "   Duplicate this line down
   x        "   Delete the first character on this line
    H       "   Move to the first line
     Ä      "   Duplicate this line up
      $     "   Move to the end of this line
       x    "   And delete a character
        >>  "   Put one space at the beginning of this line
          ê "   And move to this column on the last line
            " (implicit) ò, end the loop.

Save a couple of bytes: Try it online!

@nmjcman101 Ah, that's genius! I totally forgot about ê. Thanks :)

Japt, 19 17 14 bytes
Saved 5 bytes thanks to @ETHproductions and @Shaggy
¬£iSp½*Ul¹tYUl

Test it online!
-R flag added to join with newlines (visibility purposes)
Explanation
¬£iSp½*Ul¹tYUl
                U = Implicit input
¬               Split the input into an array of chars
 £              Map; At each char:
  i               Insert:
   S                Space " "
    p               repeated(
     ½*Ul           .5 * U.length times
         ¹          )
          t        Substring(
           Y         Index,
            Ul       U.length)

There should be a much shorter way to generate Sp½*Ul, but I don't think there is one atm... BTW, you can usually change sXX+Y to tXY (s == .slice, t == .substr)

@ETHproductions Oh yeah, thanks!

16 bytes

Or, seeing as returning a array is permitted, 14 bytes.

Charcoal, 26 bytes
Ａ⁺¹÷Ｌθ²δＦδ⟦✂θι⁺ιδ⟧Ｆ∕θ²Ｃ¹±¹

Try it online! Link is to verbose version of code.

PowerShell, 133 119 bytes
$a="$args";$L=$a.Length;$m=($L+1)/2;$s=" "*($m-1)+$a+" "*($m-1);for($h=0;$h-lt$L;$h++){$r="";0..$L|%{$r+=$s[$_+$h]};$r}

Try it online!
Ungolfed
$a="$args"
$L=$a.Length                        # the length of the input
$m=($L + 1) / 2                     # the midpoint of the input
$s=" " * ($m-1) + $a + " " * ($m-1) # create a string using the input and padded on both sides with spaces

for($h=0;$h -lt $L;$h++) {          # the height, matching the length of the input
    $r=""                           # init/reset the output string

    0..$L | % {                     # number range to represent each character in the string
        $r+=$s[$_+$h]               # append the output string with the next character
    }

    $r                              # write the output
}

Nice answer! Welcome to the site. :)

Python 3, 68 bytes
a=input()
c=len(a)
b=a.center(c*2)
for i in range(c):print(b[i:i+c])

Try it online!

Jelly, 11 bytes
LH⁶ẋ;ṫJḣ€LY

Try it online!
How it works
LH⁶ẋ;ṫJḣ€LY   "ABXCD"
L             5
 H            2.5
  ⁶ẋ          "  "
    ;         "  ABXCD"
     ṫJ       ["  ABXCD"
               " ABXCD"
               "ABXCD"
               "BXCD"
               "XCD]
        ḣ€L   ["  ABX"
               " ABXC"
               "ABXCD"
               "BXCD"
               "XCD]
           Y  "  ABX
                ABXC
               ABXCD
               BXCD
               XCD"

Haskell, 86 70 bytes
This is (still) way too long, but thanks @bartavelle for reminding me that outputting a list of strings is acceptable too!
f s|m<-div(length s)2=take(2*m+1).(`drop`((*>)s" "++s))<$>[m+1..3*m+1]

Try it online!

I could only reach 82 : Try it online!

@bartavelle That doesn't look right. Your right side isn't chopped.

Yep I introduced a bug! You can gain a bit by dropping your concat : Try it online!

And with the chopping it's 84, making your approach better! Try it online!

And you can save a lot more, because you don't need to return a single string, lists of strings are OK too!

QBIC, 32 bytes
_L;|A=space$(a'\`2)+A[a|?_sA,b,a

Man, it's time for me to add space$ to QBIC...
Explanation
  ;             Read a cmd line parameter as A$
_L |            And take its length as 'a'
A=space$        Set A$ to a number of spaces
(a'\`2)           equal to its own length halved
+A                prepended to itself
[a|             FOR b= 1 to the length of A$
?_sA,b,a        Print a substring of our space-padded A$, starting at the b'th character, running for a chars

Sample run
Command line: acknowledgement
       acknowle
      acknowled
     acknowledg
    acknowledge
   acknowledgem
  acknowledgeme
 acknowledgemen
acknowledgement
cknowledgement
knowledgement
nowledgement
owledgement
wledgement
ledgement
edgement

Mathematica, 88 bytes
T=Table;Column@Reverse@T[T[" ",i]<>StringDrop[s=#,-i],{i,d=-⌊StringLength@s/2⌋,-d}]&

Python 2, 76 74 73 bytes
-1 thanks to @FelipeNardiBatista
Of course, not as short as the other Python answer, but it's worth trying a completely different method:
n=input();x=len(n)
for i in range(x):print((2*x-~i)*' '+n)[x+x/2:2*x+x/2]

Try it online! (with the 74 byte version)
This first generates the full String, and then slices it to fit the square.

Explanation

n=input();                                                  - takes input and assigns it to a variable n
          x=len(n)                                          - assigns the length of the input to a variable x
for i in range(x):                                          - iterates on the range 0...x, with a variable i
                   print                                    - outputs the result
                         ((2*x-i-1)*' '+n)                  - creates the "diamond" string
                                          [x+x/2:2*x+x/2]   - crops the string to fit the box

(2*x+~i) to save a byte

@FelipeNardiBatista Thanks.

Excel VBA, 68 Bytes
Golfed
Anonymous VBE immediate window function that takes input from cell [A1] and outputs to the VBE immediate window
l=[Len(A1)]:For i=Int(-l/2)+2To l/2+1:?Mid(Space(l-i)&[A1],l,l):Next

Ungolfed
Sub C(ByVal s As String)
    Let l = Len(s)
    For i = Int(-l / 2) + 2 To l / 2 + 1 Step 1
        Debug.Print Mid(Space(l - i) & s, l, l)
    Next i
End Sub

With the added functions in Excel since this question was posted, it's now shorter without VBA. This one is 64 bytes and basically implements your solution in a formula: =LET(L,LEN(A1),MID(REPT(" ",L-SEQUENCE(L,,INT(-L/2)+2))&A1,L,L))

J, 19 bytes
|.!.' '"{~2%~#\-#\.

Try it online!
Explanation
|.!.' '"{~2%~#\-#\.  Input: string S
             #\      Length of each prefix of S, [1, 2, ..., len(S)]
                #\.  Length of each suffix of S, [len(s), ..., 2, 1]
               -     Subtract elementwise
          2%~        Divide by 2
                     We now have a range [(1-len(S))/2, ..., -1, 0, 1, ..., (len(S)-1)/2]
       "{~           Use each value to operate on S
|.!.' '                Perform a shift while replacing characters with ' '

Works with '' as the replacement.

Perl 5, 53 + 1 (-n) = 54 bytes
$t=$"x(($\=y%%%c)/2).$_;say substr$t,$_,$\for 0..$\-1

Try it online!

Ruby -nl, 44 bytes
puts (0...c= ~/$/).map{$_.center(c*2)[_1,c]}

Attempt This Online!

Japt -R, 11 bytes
¬£îUûUÊÑ sY

Try it
¬£îUûUÊÑ sY     :Implicit input of string U
¬               :Split
 £              :Map each element at 0-based index Y
  î             :  Slice the following to the length of U
   Uû           :    Centre pad U with spaces to length
     UÊ         :      Length of U
       Ñ        :      Multiplied by 2
         sY     :    Slice from index Y
                :Implicit output joined with newlines

C# (.NET Core), 101 bytes
(a)=>{int L=a.Length,l=L/2;for(;l-->0;)a=" "+a+" ";for(;++l<L;)Console.WriteLine(a.Substring(l,L));};

Basically @KevinCruijssen's answer. Saves 2 bytes because string.Length doesn't need () and another 2 bytes because the second argument of string.Substring() is length rather than end Index, but then loses 2 bytes because Console.WriteLine() is longer. I had a more naive implementation, but it was about twice as long so...

jq, 41 39 bytes
(length/2*" "+.)[./""|keys[]:][:length]

Try it online!

source: Stack Exchange

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

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

sort: votes


text:
Am I divisible by double the sum of my digits?
Given a positive integer as input, your task is to output a truthy value if the number is divisible by the double of the sum of its digits, and a falsy value otherwise (OEIS A134516). In other words:
(sum_of_digits)*2 | number

Instead of truthy / falsy values for the true and false cases, you may instead specify any finite set of values for the true/false case, and their complement the other values. For a simple example, you may use 0 for the true case and all other numbers for the false case (or vice versa, if you like).

Standard input and output rules apply. Default Loopholes also apply.

You can take input as an integer or as the string representation of that integer.

This is code-golf, hence the shortest code in bytes wins!

I am new to PPCG, so I would like you to post an explanation if it's possible.

Test Cases

Input - Output - (Reason)

80  - Truthy - (16 divides 80)
100 - Truthy - (2 divides 100)
60  - Truthy - (12 divides 60)
18 - Truthy - (18 divides 18)
12 - Truthy - (6 divides 12)

4 - Falsy - (8 does not divide 4)
8 - Falsy - (16 does not divide 8)
16  - Falsy  - (14 does not divide 16)
21 - Falsy - (6 does not divide 21)
78  - Falsy  - (30 does not divide 78)
110 - Falsy - (4 does not dide 110)
111 - Falsy - (6 does not divide 111)
390 - Falsy  - (24 does not divide 390)

Good challenge, welcome to PPCG!

@Mayube Thanks, it is my second challenge, but the first one got closed :P

Are we allowed to take digits as a list of Integers?

@Henry No, that would be way too trivial

Would outputting 0 for true and any other number for false be allowed?

@Shaggy "The truthy / falsy values do not necessarily have to be constant, as long as for truthy you have a finite set of values, and their complement for the falsy ones." - so you have the set {0} for truthy and its complement,  Z \ {0} for false. Hence, I think it is allowed.

@Shaggy Sorry for the delay I answered: Yes, it is allowed.

Why does the truthy set have to be finite?

Indeed, the two sentences of "Instead of truthy / falsy values for the true and false cases, you may instead specify any finite set of values for the true case, and their complement for the falsy ones. For a simple example, you may use 0 for the true case and all other numbers for the false case (or vice versa, if you like)" seem to contradict each other (in particular, the "finite" and the "or vice versa").

@CalculatorFeline You can have the falsy set finite and its complement truthy

In my opinion, all calculate-able set should be accepted. (that is, there exists a Turing machine which, given an output, output True or False deterministically within a finite time.) For example, True = odd number, False = even number.

Neim, 3 bytes
ᚫ

Explanation:
      Implicitly convert to int array and sum the digits
 ᚫ     Double
     Is it a divisor of the input?

Try it online!
Detailed version

Umm...you should check if the input is a multiple of double the sum of the digits, not vice versa.

@EriktheOutgolfer What do you mean? I do check if the input is a multiple of double the sum of the digits. Perhaps I did not explain it correctly.

Neim needs to get even golfier - when submissions get too long, my browser starts to lag.

@Challenger5 I sincerely apologise for the lack of golfiness. I will try again next time. Again, sorry about that.

@Okx And I sincerely apologize for being too lazy to find a Neim answer that was a better demonstration of what I was talking about.

JavaScript (ES6), 31 29 27 bytes
Takes input as a string. Returns zero for truthy and non-zero for falsy.
n=>n%eval([...n+n].join`+`)

Commented
n => n % eval([...n + n].join`+`)
n =>                                   // take input string n  -> e.g. "80"
                  n + n                // double the input     -> "8080"
              [...     ]               // split                -> ["8", "0", "8", "0"]
                        .join`+`       // join with '+'        -> "8+0+8+0"
         eval(                  )      // evaluate as JS       -> 16
     n %                               // compute n % result   -> 80 % 16 -> 0

Test cases

let f =

n=>n%eval([...n+n].join`+`)

console.log('[Truthy]');
console.log(f("80"))
console.log(f("100"))
console.log(f("60"))
console.log(f("18"))
console.log(f("12"))

console.log('[Falsy]');
console.log(f("4"))
console.log(f("8"))
console.log(f("16"))
console.log(f("21"))
console.log(f("78"))
console.log(f("110"))
console.log(f("111"))
console.log(f("390"))

I've never seen the [...x] method of splitting before, is there a name for this specifically?

@JacobPersi This is the spread operator.

C#, 46 bytes
using System.Linq;n=>n%(n+"").Sum(c=>c-48)*2<1

Full/Formatted version:
using System;
using System.Linq;

class P
{
    static void Main()
    {
        Func<int, bool> f = n => n % (n + "").Sum(c => c - 48) * 2 < 1;

        Console.WriteLine(f(80));
        Console.WriteLine(f(100));
        Console.WriteLine(f(60));

        Console.WriteLine();

        Console.WriteLine(f(16));
        Console.WriteLine(f(78));
        Console.WriteLine(f(390));

        Console.ReadLine();
    }
}

x86-64 Machine Code, 24 bytes
6A 0A 5E 31 C9 89 F8 99 F7 F6 01 D1 85 C0 75 F7 8D 04 09 99 F7 F7 92 C3

The above code defines a function in 64-bit x86 machine code that determines whether the input value is divisible by double the sum of its digits. The function conforms to the System V AMD64 calling convention, so that it is callable from virtually any language, just as if it were a C function.
It takes a single parameter as input via the EDI register, as per the calling convention, which is the integer to test. (This is assumed to be a positive integer, consistent with the challenge rules, and is required for the CDQ instruction we use to work correctly.)
It returns its result in the EAX register, again, as per the calling convention. The result will be 0 if the input value was divisible by the sum of its digits, and non-zero otherwise. (Basically, an inverse Boolean, exactly like the example given in the challenge rules.)
Its C prototype would be:
int DivisibleByDoubleSumOfDigits(int value);

Here are the ungolfed assembly language instructions, annotated with a brief explanation of the purpose of each instruction:
; EDI == input value
DivisibleByDoubleSumOfDigits:
   push 10
   pop  rsi             ; ESI <= 10
   xor  ecx, ecx        ; ECX <= 0
   mov  eax, edi        ; EAX <= EDI (make copy of input)

SumDigits:
   cdq                  ; EDX <= 0
   div  esi             ; EDX:EAX / 10
   add  ecx, edx        ; ECX += remainder (EDX)
   test eax, eax
   jnz  SumDigits       ; loop while EAX != 0

   lea  eax, [rcx+rcx]  ; EAX <= (ECX * 2)
   cdq                  ; EDX <= 0
   div  edi             ; EDX:EAX / input
   xchg edx, eax        ; put remainder (EDX) in EAX
   ret                  ; return, with result in EAX

In the first block, we do some preliminary initialization of registers:

PUSH+POP instructions are used as a slow but short way to initialize ESI to 10. This is necessary because the DIV instruction on x86 requires a register operand. (There is no form that divides by an immediate value of, say, 10.)
XOR is used as a short and fast way to clear the ECX register. This register will serve as the "accumulator" inside of the upcoming loop.
Finally, a copy of the input value (from EDI) is made, and stored in EAX, which will be clobbered as we go through the loop.

Then, we start looping and summing the digits in the input value. This is based on the x86 DIV instruction, which divides EDX:EAX by its operand, and returns the quotient in EAX and the remainder in EDX. What we'll do here is divide the input value by 10, such that the remainder is the digit in the last place (which we'll add to our accumulator register, ECX), and the quotient is the remaining digits.

The CDQ instruction is a short way of setting EDX to 0. It actually sign-extends the value in EAX to EDX:EAX, which is what DIV uses as the dividend. We don't actually need sign-extension here, because the input value is unsigned, but CDQ is 1 byte, as opposed to using XOR to clear EDX, which would be 2 bytes.
Then we DIVide EDX:EAX by ESI (10).
The remainder (EDX) is added to the accumulator (ECX).
The EAX register (the quotient) is tested to see if it is equal to 0. If so, we have made it through all of the digits and we fall through. If not, we still have more digits to sum, so we go back to the top of the loop.

Finally, after the loop is finished, we implement number % ((sum_of_digits)*2):

The LEA instruction is used as a short way to multiply ECX by 2 (or, equivalently, add ECX to itself), and store the result in a different register (in this case, EAX).
(We could also have done add ecx, ecx+xchg ecx, eax; both are 3 bytes, but the LEA instruction is faster and more typical.)

Then, we do a CDQ again to prepare for division. Because EAX will be positive (i.e., unsigned), this has the effect of zeroing EDX, just as before.

Next is the division, this time dividing EDX:EAX by the input value (an unmolested copy of which still resides in EDI). This is equivalent to modulo, with the remainder in EDX. (The quotient is also put in EAX, but we don't need it.)

Finally, we XCHG (exchange) the contents of EAX and EDX. Normally, you would do a MOV here, but XCHG is only 1 byte (albeit slower). Because EDX contains the remainder after the division, it will be 0 if the value was evenly divisible or non-zero otherwise. Thus, when we RETurn, EAX (the result) is 0 if the input value was divisible by double the sum of its digits, or non-zero otherwise.

Hopefully that suffices for an explanation.
This isn't the shortest entry, but hey, it looks like it beats almost all of the non-golfing languages! :-)

Retina, 38 27 bytes
-11 bytes and fixed an error with the code thanks to @MartinEnder
$
$_¶$_
.+$|.
$*
^(.+)¶\1+$

Try it online!
Prints 1 if divisible, 0 otherwise
Explanation (hope I got this right)
$
$_¶$_

Appends the entire input, plus a newline, plus the input again
.+$|.
$*

Converts each match to unary (either the entire second line which is the original input, or each digit in the first line)
^(.+)¶\1+$

Check if the first line (the doubled digit sum) is a divisor of the second line

05AB1E, 5 4 bytes
-1 byte thanks to Okx
SO·Ö

Try it online!
You can also remove the last Ö to get 0 for truthy and something else for falsy resulting in only 3 bytes but to me that just doesn't seem to appropriately fit the definition.
Explanation
SO·Ö
SO    # Separate the digits and sum them
  ·   # Multiply the result by two
   Ö  # Is the input divisible by the result?

You can golf it to 4 bytes by replacing %_ with Ö.

This was exactly what I was about to post... lol

MATL, 7 bytes
tV!UsE\

Outputs 0 if divisible, positive integer otherwise. Specifically, it outputs the remainder of dividing the number by twice the sum of its digits.
Try it online!
Explanation
t   % Implicit input. Duplicate
V!U % Convert to string, transpose, convert to number: gives column vector of digits
s   % Sum
E   % Times 2
\   % Modulus. Implicit display

K (ngn/k), 15 14 bytes
{(2*+/10\x)!x}

Try it online!

0 is truthy

Tacit but no shorter: !/|1(2*+/10\)\

C89, 55 53 bytes
(Thanks to Steadybox!
s,t;f(x){for(t=x,s=0;t;t/=10)s+=t%10;return x%(s*2);}

It takes a single input, x, which is the value to test. It returns 0 if x is evenly divisible by double the sum of its digits, or non-zero otherwise.
Try it online!
Ungolfed:
/* int */ s, t;
/*int */ f(/* int */ x)
{
    for (t = x, s = 0; t /* != 0 */; t /= 10)
        s += (t % 10);
    return x % (s * 2);
}

As you can see, this takes advantage of C89's implicit-int rules. The global variables s and t are implicitly declared as ints. (They're also implicitly initialized to 0 because they are globals, but we can't take advantage of this if we want the function to be callable multiple times.)
Similarly, the function, f, takes a single parameter, x, which is implicitly an int, and it returns an int.
The code inside of the function is fairly straightforward, although the for loop will look awfully strange if you're unfamiliar with the syntax. Basically, a for loop header in C contains three parts:
for (initialization; loop condition; increment)

In the "initialization" section, we've initialized our global variables. This will run once, before the loop is entered.
In the "loop condition" section, we've specified on what condition the loop should continue. This much should be obvious.
In the "increment" section, we've basically put arbitrary code, since this will run at the end of every loop.
The larger purpose of the loop is to iterate through each digit in the input value, adding them to s. Finally, after the loop has finished, s is doubled and taken modulo x to see if it is evenly divisible. (A better, more detailed explanation of the logic here can be found in my other answer, on which this one is based.)
Human-readable version:
int f(int x)
{
    int temp = x;
    int sum  = 0;
    while (temp > 0)
    {
        sum  += temp % 10;
        temp /= 10;
    }
    return x % (sum * 2);
}

You can save two bytes, if you use t instead of t>0 as the loop condition.

Ah, of course! Good catch, @Steadybox. Not sure how I missed that, since testing against 0 is exactly what my asm implementation did, on which this answer was heavily based.

45

APL, 13 bytes
{⍵|⍨2×+/⍎¨⍕⍵}

Outputs 0 as a truthy value, and any other as falsy.

Japt, 7 4 bytes
Takes input as a string. Outputs 0 for true or a number greater than 0 for false, which, from other solutions, would appear to be valid. If not, let me know and I'll rollback.
%²¬x

Test it

Explanation
Implicit input of string U."390"
²

Repeat U twice."390390"
¬

Split to array of individual characters.["3","9","0","3","9","0"]
x

Reduce by summing, automatically casting each character to an integer in the process.24
%

Get the remainder of dividing U by the result, also automatically casting U to an integer in the process. Implicitly output the resulting integer.6 (=false)

Your explanations usually use up a lot of vertical space, which I feel isn't needed. Either way, it's your answer.

@Okx; I don't know how "usual" it can be when I only switched to this format a couple of days ago.

I liked the explanation format. Was easy to follow, especially for this problem, as it was a linear reduction and moved down the page like a math problem. Just my two cents.

This explaination format is a lot better than the usual format, especially for those who are not familiar with the languages. I wish other golfers using these golfing languages would do this too.

Brachylog, 8 bytes
ẹ+×₂;I×?

Try it online!
Explanation
ẹ+           Sum the digits
  ×₂         Double
    ;I×?     There is an integer I such that I×(double of the sum) = Input

Python 2, 34 32 bytes
-2 bytes thanks to @Rod
lambda n:n%sum(map(int,`n`)*2)<1

Try it online!

based on the example of "clearly distinguishable" provided in the question, I believe you can remove the <1.

Python 3, 35 bytes
lambda a:a%(sum(map(int,str(a)))*2)

Hello and welcome to the site.  You can remove some whitespace here.  Particularly around = and after the ) in int(c).  In addition since sum can take a generator as an argument you can remove the [..] inside it.  If you have any additional questions feel free to ping me.

int(c)for c in a could also be map(int,a), to save a few bytes.

This doesn't work - or rather, works backwards. Easily fixed with 4 extra bytes: lambda a:not a%(sum(map(int,str(a)))*2)

@osuka_ see bullet point one in the question description

Java (OpenJDK 8), 40 bytes
i->i%(i+"").chars().map(k->k*2-96).sum()

Try it online!
Returns 0 as truthy value and a value greater than 0 as falsy value.

Mathematica, 26 bytes
(2Tr@IntegerDigits@#)∣#&

No clue why ∣ has a higher precedence than multiplication...

PHP, 41 bytes
prints zero if divisible, positive integer otherwise.

<?=$argn%(2*array_sum(str_split($argn)));

Try it online!

You put the assignment in the header block. You might as well use $a=10, but you forgot to count that towards your byte count

@aross why should I count the input towards to my byte count. $argn is available with the -F (in this case) or -R option

Hm, interesting. I didn't know about -F. But that's not reflected in your TIO (does it support echoing from STDIN?).

@aross it works like your approach use only a file instead of code and the -Foption instead of -R http://php.net/manual/en/features.commandline.options.php If you found an better way to make the same in tio like in the commnd line let me know

Excel, 63 bytes
=MOD(A1,2*SUMPRODUCT(--MID(A1,ROW(OFFSET(A$1,,,LEN(A1))),1)))=0

Summing digits is the lengthy bit.

Perl 6, 19 bytes
{$_%%(2*.comb.sum)}

Try it online!

Husk, 9 8 bytes
Thanks to Leo for saving 1 byte.
Ṡ¦ȯ*2ṁis

Try it online!
Explanation
Ṡ¦ȯ         Test whether f(x) divides x, where f is the function obtained by
            composing the next 4 functions.
       s    Convert x to a string.
     ṁi     Convert each character to an integer and sum the result.
   *2       Double the result.

You can use ṁ to map and sum with a single command, saving one byte

Haskell, 38 37 42 bytes
Thanks to Zgarb for golfing off 1 byte
f x=read x`mod`foldr((+).(*2).read.pure)0x

Try it online!
Takes input as a string; returns 0 if divisible and nonzero otherwise.

(:[]) can be pure.

You will save 1 byte by replacing the lambda by function declaration

@bartavelle: Pretty sure it's a wash. Example?

You're right, it is the exact same length. Not sure how that crossed my mind :/

TI-BASIC, 27 26 21 bytes
-5 thanks to @Oki
:fPart(Ans/sum(2int(10fPart(Ans10^(~randIntNoRep(1,1+int(log(Ans

This is made trickier by the fact that there is no concise way to sum integer digits in TI-BASIC. Returns 0 for True, and a different number for False.
Explanation:
:fPart(Ans/sum(2int(10fPart(Ans10^(-randIntNoRep(1,1+int(log(Ans
                               10^(-randIntNoRep(1,1+int(log(Ans #Create a list of negative powers of ten, based off the length of the input, i.e. {1,0.1,0.01}
                            Ans                                  #Scalar multiply the input into the list
                    10fPart(                                     #Remove everything left of the decimal point and multiply by 10
               2int(                                             #Remove everything right of the decimal point and multiply by 2
           sum(                                                  #Sum the resulting list
       Ans/                                                      #Divide the input by the sum
:fPart(                                                          #Remove everything left of the decimal, implicit print

10^-randIntNoRep(1,1+int(log(Ans does the same as seq(10^(~A-1),A,0,log(Ans in fewer bytes as order doesnt matter (Assuming version 2.55MP)

Add++, 11 bytes
L,EDEs;A@%!

Try it online!
First time I've used either a Lambda or ; in an Add++ answer
How it works
L,   - Create a lambda function. Example argument; 172
  ED - Push the digits;   STACK = [[1 7 2]]
  Es - Stack-clean sum;   STACK = [10]
  ;  - Double;            STACK = [20]
  A  - Push the argument; STACK = [20 172]
  @% - Modulo;            STACK = [12]
  !  - Logical NOT;       STACK = [0]

Husk, 6 5 bytes
¦DΣd¹

Try it online!
-1 byte from Dominic Van Essen.
The existing answer doesn't use enough builtins, and Martin Ender is inactive, so I decided to post this.

5 bytes...

@DominicvanEssen thanks!

Zsh, 37 bytes
for ((;i++<19;a+=2*s[i]))s=$1;((s%a))

Try it online!
Outputs by exit code - 0 is falsey, 1 is truthy.
Explanation:
for ((;i++<19;a+=2*s[i]))s=$1;((s%a))    # i implicitly starts at 0
                         s=$1;           # set s to the input
for ((;                ))                # loop
          <19;                           #  while i is less than 19 (*)
       i++                               #  increment i
                   s[i]                  #  take the i'th character of s
                 2*                      #  doubled
              a+=                        #  add to a
                                s%a      # remainder of s divided by a
                              ((   ))    # output 0 if it's non-zero, 1 if it's zero

(*19 is the length of the maximum integer zsh can handle)

Swift, 53 46 bytes
Takes in a String or Substring representing an integer in [1, 255].
{UInt8($0)!%($0.utf8.reduce(0){$0+$1-48}*2)<1}

Try it online!
Type information not included, since it could be either:
let f: (String) -> Bool = {UInt8($0)!%($0.utf8.reduce(0){$0+$1-48}*2)<1}
let g: (Substring) -> Bool = {UInt8($0)!%($0.utf8.reduce(0){$0+$1-48}*2)<1}

Swift Character is... weird. It's not a single byte, like in C (that's CChar), but it's also not a single Unicode codepoint (that's Unicode.Scalar). Rather, it represents an extended grapheme cluster. This makes certain oprations substantially more painful, but others substantially easier. For this reason, I access the string's utf8 property (which is a collection of UInt8).
String and Substring are collections of Character; however, they also have a lot more shared functionality than e.g. [Character] because they conform to StringProtocol, and are in fact the only types that conform to it. I thought StringProtocol would work as the input type, but then the type checker times out.
For 49 bytes, here's a version that accepts integers in [1, 2^31 - 1] or [1, 2^63 - 1] depending on the machine:
{Int($0)!%($0.utf8.reduce(0){$0+Int($1)-48}*2)<1}

Explanation/Ungolfed
{ (number: String) -> Bool in
    return
        UInt8(number)! // Convert String to UInt8, force-unwrap optional
            % (
                number.utf8 // Convert String to byte array
                    .reduce(0) { (prevResult: UInt8, nextChar: Character) -> UInt8 in
                        return prevResult + nextChar - 48
                        // Convert ASCII to number by subtracting 48; sum the results
                    } * 2
            ) == 0 // convert number to boolean
}

Java (OpenJDK 8), 55 53 bytes
a->{int i=0,x=a;for(;x>0;x/=10)i+=x%10*2;return a%i;}

Try it online!
A return value of 0 means truthy, anything else means falsy.
Since my comment in Okx's answer made no ripple, I deleted it and posted it as this answer, golfed even a bit more.
Further golfing thanks to @KrzysztofCichocki and @Laikoni who rightfully showed me I needn't answer a truthy/falsy value, but any value as long as I describe the result.

You can remove the <1 part at the end, so the result will be 0 for true and >0 for false, which is accebtable, this will result in additional -2 bytes, so you answer coiuld be like 53 bytes.

@KrzysztofCichoki No I can't: this is Java. The only truthy value is true.

@OlivierGrégoire While this true if nothing else is specified, this challenge specifically states Instead of truthy / falsy values for the true and false cases, you may instead specify any finite set of values for the true/false case, and their complement the other values..

@KrzysztofCichocki and Laikoni Sorry I misread that part, I just fixed it! Thank you both :) Also, sorry for rejecting the edit which was actually appropriate in this case.

PHP, 44 bytes
for(;~$d=$argn[$i++];)$t+=2*$d;echo$argn%$t;

Run like this:
echo 80 | php -nR 'for(;~$d=$argn[$i++];)$t+=2*$d;echo$argn%$t;'

Explanation
Iterates over the digits to compute the total, then outputs the modulo like most answers.

Haskell, 35 34 bytes
f x=mod x$2*sum[read[c]|c<-show x]

Try it online!
Returns '0' in the true case, the remainder otherwise.
Haskell, pointfree edition by nimi, 34 bytes
mod<*>(2*).sum.map(read.pure).show

Try it online!

Same byte count if you go pointfree: mod<*>(2*).sum.map(read.pure).show

Looks good, I added it in my submission.

Mini-Flak, 296 292 bytes
({}((()[()]))){(({}[((((()()()){}){}){}){}])({}(((({})){}){}{}){})[({})])(({}({})))({}(({}[{}]))[{}])({}[({})](({}{})(({}({})))({}(({}[{}]))[{}])({}[({})]))[{}])(({}({})))({}(({}[{}]))[{}])({}[({})])}{}({}(((({}){})))[{}]){({}((({}[()]))([{(({})[{}])()}{}]()){{}{}(({}))(()[()])}{})[{}][()])}

Try it online!
The TIO link have more comments from me, so it is partially easier to read.
Truthy/Falsey: Truthy (divisible) if the second number is equal to the third number, falsy otherwise. So both the truthy and falsy set are infinite, but I suppose that should be allowed. +10 byte if that is not.
Note: Leading/trailing newlines/whitespaces are not allowed in input.

Braingolf, 13 12 bytes
VR.Mvd&+2*c%

Try it online!
Outputs 0 for truthy, any other number for falsey.
Explanation
VR.Mvd&+2*c%  Implicit input from command-line args
VR            Create stack2, return to stack1
  .M          Duplicate input to stack2
    vd        Switch to stack2, split into digits
      &+      Sum up all digits
        2*    Double
          c   Collapse stack2 back into stack1
           %  Modulus
              Implicit output of last item on stack

Java, 66 bytes
-1 byte thanks to Olivier
a->{int i=0;for(int b:(""+a).getBytes())i+=b-48;return a%(i*2)<1;}

Ungolfed & explanation:
a -> {
    int i = 0;

    for(int b : (""+a).getBytes()) { // Loop through each byte of the input converted to a string
        i += b-48; // Subtract 48 from the byte and add it to i
    }

    return a % (i*2) < 1 // Check if a % (i*2) is equal to one
    // I use <1 here for golfing, as the result of a modulus operation should never be less than 0
}

Use int instead of byte to save... a byte.

@OlivierGrégoire Thanks. Didn't notice that.

@Okx Need to change golfed code as well.

Your (golfed) code gives incorrect values for 110, 111. Probably the a%i*2 that's parsed as (a%i)*2 since modulus and multiplication have the same order.

@OlivierGrégoire Ah, that sucks.

Japt, 7 bytes
vUì x*2

Returns 1 for true, 0 for false
Try it online!
Explanation
vUì x*2
v        // Return 1 if the input is divisible by:
 Uì      //   Input split into a base-10 array
    x    //   Sum the array
     *2  //   While mapped by *2

I came up with a few other 7 byte solutions for this, too (although, I don't think this was one of them) - I'm convinced there's a shorter solution, though.

Haskell, 49 Bytes
f x=(==) 0.mod x.(*)2.sum.map(read.return).show$x

Usage
f 80

Try it online!

Tips: there is an extra space, return==pure, list comprehensions are often very compact : Try it online!

J, 15 bytes
0 indicates truthy, nonzero indicates falsy.
|~[:+/2#"."0@":

Explanation
        "."0@":  convert to list of digits
  [:+/2#         sum 2 copies of the list ([: forces monadic phrase)
|~               residue of sum divided by argument?

Very clever way to avoid parens or multiple @ or [:!

I debated posting this as my own answer, but it's not really different enough. |~2*1#.,.&.": for 13 bytes.

I get a 'domain error' for this on my J Qt IDE. (|~[:+/2#"."0@": 112)
Then for cole's code I get (|~2*1#.,.&.": 112)=0. :/ Possibly something wrong on my end.

Ohm, 5 bytes
D}Σd¥

Try it online!

tcl, 45
puts [expr 1>$n%(2*([join [split $n ""] +]))]

demo

You can replace 0== with 1>.

PowerShell, 39 bytes
($a="$args")%($a*2-replace'\B','+'|iex)

0 as Truthy output, any other number as Falsey.
PS D:\> D:\t.ps1 80
0

PS D:\> D:\t.ps1 81
9

It takes the args array as a string, does string multiplication to double all the digits, regex-replaces non-word-boundaries to make '8+0+8+0', eval's that to get the sum, and calculates a remainder of original/sum.

38 bytes by changing the replace to -replace'','+0', 80 would become +08+00+08+00+0

C# (.NET Core), 51 bytes
n=>{int l=n,k=0;for(;l>0;l/=10)k+=l%10;return n%k;}

Try it online!
0 for truthy, anything else for falsey.

Perl 5, 21 + 1 (-p) = 22 bytes
$_%=eval s/./+2*$&/rg

Try it online!

-1 byte: $_%=eval s//+2*/rg.0

Pyth - 12 Bytes
%sZ*2ssMscZ1

Explanation:
%       - implicitly print modulus of
 s      - parse int
  Z     - input
 *      - two times
  s    - sum of
   M   - map
    s  - parse int to
    c  - substrings
     Z - of input
     1 - of length 1

Ly, 10 bytes
nsS&+2*lf%

Try it online!
Ly is lucky enough to have a splitting built-in.
Returns 0 for truthy and a number greater than 0 for falsy.

Befunge-93, 34 bytes
p&::v>0g2*%.@
+19:_^#:/+91p00+g00%

Try it online!
Prints 0 for truthy, a different integer for falsey.

Brachylog, 7 bytes
f.&ẹj+∈

Try it online!
The predicate succeeds if the input is divisible by twice the sum of its digits, and fails otherwise. Run as a program, success prints true. and failure prints false..
This started off as a minor edit to Fatalize's answer, golfing a byte off by replacing +×₂ with j+, but as I was testing it I noticed that one or another of the updates he's made to the language in the last year and a half seems to have broken his solution on the case of 18, with I apparently being unable to assume the value of 1, so I ended up having to restructure it somewhat (fortunately without changing the byte count).
f.         The output variable is a list of the input's factors.
  &        And,
   ẹ       the digits of the input,
    j      all duplicated,
     +     sum up to
      ∈    a member of the output variable.

Runic Enchantments, 11 bytes
i:'+A2*%0=@

Try it online!
Explanation
i:             Read input, duplicate it
  '+A          Sum its digits
     2*        Multiply by 2
       %       Modulo input with digit sum
        0=     Compare to 0
          @    Print and terminate

Forth (gforth), 58 bytes
: f 0 over begin 10 /mod >r + r> ?dup 0= until 2* mod 0= ;

Try it online!
Code Explanation
: f           \ start a new word definition
  0 over      \ create an accumulator and copy the input above it on the stack
  begin       \ start an indefinite loop
    10 /mod   \ divide by 10 and get quotient and remainder
    >r + r>   \ add remainder to accumulator
    ?dup      \ duplicate the quotient if it's greater than 0
    0=        \ check if quotient is 0
  until       \ end the indefinite loop if it is
  2* mod      \ multiply result by 2, then modulo with input number
  0=          \ check if result is 0 (input is divisible by result)
;             \ end word definition

Keg+Reg, 11 bytes
Boring algorithm.
¿:;9%1+2*%

Finds the digital root of the top of the stack and then finds the remainder.
0 is a truthy value, any value that is not 0 is a falsy value. (Including ASCII characters)
Explanation (Syntactically invalid)
¿#         Integer input
 :#        Duplicate
  ;9%1+#   Digital Root Formula (1+(n-1)mod 9)
       2*%#Multiply by 2 and find the remainder

I believe everyone here used repetition/reduction but not an existing formula.

Vyxal, 3 bytes
∑dœ

Try it Online!
Compiles as:
stack.push(summate(stack.pop()))
stack.push(stack.pop() * 2)
lhs, rhs = stack.pop(2); stack.push(int((rhs % lhs) == 0))

Explained
∑dœ
∑   # Push the sum of the integers of the input
 d  # Double that sum
  œ # And push ((sum(input) * 2) % input) == 0

MathGolf, 3 bytes
Σ∞÷

Try it online.
Explanation:
Σ    # Get the digit-sum of the (implicit) input-integer
 ∞   # Double it
  ÷  # Check if the (implicit) input-integer is divisible by this value
     # (after which the entire stack is output implicitly as result)

Whitespace, 103 bytes
[S S S N
_Push_0][S N
S _Duplicate_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][N
S S N
_Create_Label_LOOP][S N
S _Duplicate][N
T   S S N
_If_0_Jump_to_Label_DONE][S N
S _Duplicate][S S S T   S T S N
_Push_10][T S T T   _Modulo][S T    S S T   S N
_Copy_0-based_2nd][T    S S S _Add][S N
T   _Swap_top_two][S S S T  S T S N
_Push_10][T S T S _Integer_divide][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_DONE][T   T   T   _Retrieve_input][S N
T   _Swap_top_two][S S S T  S N
_Push_2][T  S S N
_Multiply]{T    S T T   _Modulo][T  N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Outputs 0 as truthy or a positive integer as falsey.
Try it online (with raw spaces, tabs and new-lines only).
To output two distinct values (0 for truthy; 1 for falsey) it would be 128 bytes instead: try it online.
Explanation in pseudo-code:
Integer sum = 0
Integer input = STDIN as integer
Integer n = input
Start LOOP:
  If(n == 0):
    Jump to Label DONE
  Integer t = n modulo-10
  sum = sum + t
  n = n integer-divided by 10
  Go to next iteration of LOOP

DONE:
  sum = sum * 2
  Integer result = input % sum
  Print result as integer to STDOUT

Factor + math.text.utils math.unicode, 37 bytes
[ dup 1 digit-groups Σ 2 * mod 0 = ]

Try it online!
Explanation
                ! 12
dup             ! 12 12
1 digit-groups  ! 12 { 2 1 }
Σ               ! 12 3
2 *             ! 12 6
mod             ! 0
0 =             ! t

Vyxal, 3 bytes
∑dḊ

Try it Online!

C++, 121 bytes
#include<iostream>
main(){std::string n;int m=0;std::cin>>n;for(char i:n){m+=i-48;};std::cout<<((stoi(n)%(m*2)==0)?0:1);}

Try it online!
Explanation
#include<iostream>
main(){
  std::string n; int m = 0; // Initialize `n` (input) and `m` (sum)
  std::cin >> n; // Get input
  for(char i:n) // Loop through input to calculate the sum of digits
  {
    m+=i-48;
  };
  std::cout<<((stoi(n)%(m*2)==0)?0:1); // Output `0` if double the sum of digits is divisible by the number, else return `1`
}

109 bytes

Desmos, 62 bytes
f(n)=0^{mod(n,2mod(floor(n/10^{[0...floor(logn)]}),10).total)}

Try It Online!
Try It Online! - Prettified

Knight, 39 bytes
;=n!=p=sE P;Ws;=n+*2%s 10n=s/s 10O!%p n

Try it online!
Test Suite

Arturo, 21 bytes
$->n->n%2*∑digits n

Try it
Returns 0 for true or any other number for false.

Thunno 2, 3 bytes
SḌḊ

Explanation
SḌḊ   # implicit input
S     # sum the digits
 Ḍ    # double this number
  Ḋ   # input is divisible by this?
      # implicit output

Screenshot

Lua, 47 bytes
n=...a=0n:gsub('.',load'a=2*...+a')print(n%a<1)

Try it online!

R, 71 bytes
f=function(x)`if`(x%%(sum(floor(x/10^(0:(nchar(x)-1)))%%10)*2)==0,T,F)

Using floor(x/10^(0:(nchar(x)-1)))%%10 saves the usual hassle of converting to character and back.
> f(1)
[1] FALSE
> f(12)
[1] TRUE
> f(123456789)
[1] FALSE

R, 58 bytes
(a<-scan())%%(2*sum(strtoi(el(strsplit(paste(a),"")))))<1

a <- scan() stores user's input in variable a.
This variable is of type numeric. The paste function converts it into character for the strsplit function to separate its digits. el permits to use only the first element of the list created by strsplit.
The strtoi function converts then the digits back into numeric, for the function sum to, well, sum, before doubling the result.
To finish, divisibility of a with the double sum of its digits is tested by the ... %% ... < 1 part, outputing TRUE or FALSE.

Java, 53 bytes
a->{int i=0,c=a;for(;c>0;c/=10)i+=c%10*2;return a%i;}

0 true
>0 false

Welcome to PPCG!

Ruby, 25 bytes
->x{x%(x.digits.sum*2)<1}

Try it online!

LOGO, 24 bytes
[modulo ? 2*reduce "+ ?]

Try it online!
Only FMSLogo and its older version (MSWLogo) support ? in template-list; and only FMSLogo supports apply for infix operator +.
That is a template-list (equivalent of lambda function in other languages).
Return 0 for truthy and other values for falsy.
Usage:
pr invoke [modulo ? 2*reduce "+ ?] 100

(invoke calls the function, pr prints the result)
Explanation:
There is only one points need explaining: reduce. That is similar to fold in some other languages: reduce "f [1 2 3 4] calculate (f (f (f 1 2) 3) 4). In this case, reduce "+ ? calculate total of elements of digits in ?.
Numbers in LOGO is represented by word, so reduce, a library function can receive a word as its second parameter (while apply can't)

Alice, 16 bytes
/o. &
\i@h /+.+F

Try it online!
Prints twice the digit sum as the truthy result and 0 otherwise.
The code looks so painfully suboptimal with the two spaces and the repeated . and +, but I just can't figure out a more compact layout.
Explanation
/    Switch to Ordinal mode.
i    Read all input as a string.
.    Duplicate.
h    Split off the first character.
&    Fold the next command over the remaining characters (i.e. push each character
     in turn and then execute the command).
/    Switch back to Cardinal mode (not a command).
+    Add. This is folded over the characters, which implicitly converts them
     to the integer value they represent and adds them to the leading digit.
.+   Duplicate and add, to double the digit sum.
F    Test for divisibility. Gives 0 if the input is not divisible by twice its
     digit sum and the (positive/truthy) divisor otherwise.
\    Switch to Ordinal mode.
o    Implicitly convert the result to a string and print it.
@    Terminate the program.

Java 7, 197 133 126 bytes
First try Second try, fixed it, -9 characters on variable name, and changing it into function for the other subtraction with help of Olivier Grégoire
Changed boolean to int, now return 0 for true values, other number for falsy
int b(String a){int t=0;for(int i=0;i<a.length();i++){t+=Integer.parseInt(""+a.charAt(i));}return(Integer.parseInt(a)%(t*2));}

boolean a(String a){int t=0;for(int i=0;i<a.length();i++){t+=Integer.parseInt(""+a.charAt(i));}return(Integer.parseInt(a)%(t*2)==0);}

Ungolfed
int b(String a){
int t=0;for(int i=0;i<a.length();i++){
t+=Integer.parseInt(""+a.charAt(i));
}
return(Integer.parseInt(a)%(t*2));}

Hello and welcome to the golfing part of codegolf! First you can get a lot of tips from this thread to help you getting started. So let's golf, shall we? You're not forced to write full programs: you can write only a function, or if you use Java 8+, a lambda. Make sure to give short variable names and remove all your unneeded spaces (A { can be written as A{; String[] args as  String[]a). You can return results instead of printing. The code doesn't pass the test cases of the challenge, fixing it would be 1st.

Hello, which test case didn't it pass? About only a function, I have read other post that says you have to create full executable program, this includes imports if you use them, correct me if I'm wrong, thank you :)

Ah, I forgot to multiply it *2 sorry

Fixed and changed to a function, thank you

Pyth, 7 bytes
%QyssM`

Test it online! It returns 0 for truthy, a non null positive integer for falsy.
Explanations
       Q    # Implicit input Q
      `     # Convert the input to a string
    sM      # For each character in Q, convert to integer
   s        # Sum the resulting list
  y         # Multiply by two
%Q          # Perform the modulo with the input

><>, 26 bytes
000\~2*%n;
0(?\c%:{a*+}+i:

Try it online!
Output is 0 for truthy, non-0 for falsey.

Excel VBA, 72 Bytes
Anonymous VBE immediate window function that takes input from cell [A1] and outputs to the VBE immediate window
For i=1To[Len(A1)]:s=s+Int(Mid([A1],i,1)):Next:s=s*2:?Int([A1]/s)=[A1]/s

Element, 29 bytes
Here goes my first "real" codegolf attempt...
_2:x;2:$'0 z;[(z~+z;]x~z~2*%`

Outputs "0" if true, anything else if false.
Try it online!
Explanation:
_             push input into main stack
2:            pop number and push it twice
x;            store one of them as x
2:            pop again and push twice
$'            pop and get length, push it to control stack
0 z;          initiate accumulator "z" with value zero
[             for length of input number (loop start),
(             pop off first digit,
z~            retrieve "z",
+             add popped digit to it,
z;            store "z"  again
]             (end of looped statement)
x~            retrieve "x" (copy of original number)
z~            retrieve "z" (accumulated digit sum)
2*            double accumulated digit sum
%             modulus the digit sum and original number
`             pop result to output.

Jelly, 4 bytes
DSḤḍ

Try it online!
Explanation:
DSḤḍ Takes an integer as input.
D    Get digits (convert to base 10)
 S   Sum
  Ḥ  Unhalve (double)
   ḍ Check if y (the input itself) is divisible by x

@TheIOSCoder Added explanation.

Pari/GP, 24 bytes
n->!(n%(2*sumdigits(n)))

Try it online!

jq, 37 characters
.%(tostring/""|map(tonumber)|add*2)<1

Sample run:
bash-4.4$ jq '.%(tostring/""|map(tonumber)|add*2)<1' <<< '60'
true

bash-4.4$ jq '.%(tostring/""|map(tonumber)|add*2)<1' <<< '390'
false

Try on jp‣play

CJam, 11 10 bytes
1 byte saved thanks to @Challenger5
{_Ab:+2*%}

Anonymous block that takes the input from the stack and replaces it by the output, which is 0 if divisible or a positive integer otherwise.
Try it online! Or verify all test cases.
Explanation
{        }   e# Block
 _           e# Duplicate
  Ab         e# Convert to base 10. Gives an array of digits
    :+       e# Fold addition over array
      2*     e# Multiply by 2
        %    e# Modulus

You can replace s:~ with Ab (convert to base 10)

@Challenger5 Thanks! Edited

Bash + coreutils + bc, 46 bytes
yes $1%\(0`echo $1|sed 's/\(.\)/+\1*2/g'`\)|bc

Input via command line.  0 is truthy.
First I tried to loop through the characters of the input string, but bash loops are to big.  I ended up using sed to replace each character with an addition and multiplication, which then goes to bc. I saved a byte using yes instead of echo.

Perl 5, 27 bytes
$_%(2*eval join'+',split//)

Returns 0 for Truthy and non-zero for Falsy

Welcome on the site. Answers need to be either full programs or functions, while your answer is only a snippet. To make it a full program, you could add -p flag (cost 1 byte), and start with $_%=(2*...). Also, join'+',split// can be simplified to join'+',@F is you use -F  flag, or even better, s/./+$&/gr :)

Julia, 30 29 bytes
f(x)=x/2sum(digits(x)) in 0:x

saved a byte thanks to caird-coinheringaahing

This seems to fail for 60: Try it online!

you're right, the problem was order of operations. fixed it by saving a byte, thanks!

K (oK), 14 bytes
Solution:
(2*+/48!$x)!x:

Try it online!
Examples:
  (2*+/48!$x)!x:18
0
  (2*+/48!$x)!x:123
3
  (2*+/48!$x)!x:390
6

Explanation:
Evaluation is performed right-to-left, unfortunately modulo is b!a rather than a!b hence the need for brackets. Returns 0 for truthy, positive integer for falsey per spec.
(2*+/48!$x)!x: / the solution
            x: / store input in variable x
           !   / modulo right by the left ( e.g. 3!10 => 1, aka 10 mod 3 )
(         )    / the left
        $x     / string ($) input, 123 => "123"
     48!       / modulo with 48, "123" => 1 2 3
   +/          / sum over, +/1 2 3 => 6
 2*            / double, 6 => 12

Notes:

Prepend solution with ~ (not) to give a true/false result.

ARBLE, 33 bytes
nt(a%(sum(explode(""..a,"."))*2))

Try it online!

><>, 36 Bytes
Unlike the other ><> response, this takes the number itself as input as opposed to the digits. Of course, because of that it's a bit longer longer.
:&>:a%:}-\1-?\2*&$%n;
  \?)0:,a/l +<

Explanation:
:&

Duplicates input, stores a copy in the register.
  >:a%:}-\
  \?)0:,a/

Converts the number into its digits.
         \1-?\
         /l +<

Sum the digits
              2*&$%n;

Multiplies the digit sum by 2, and prints the original number modulo that sum. Output is, then, 0 for truthy and something else otherwise.

Deorst, 16 bytes
iE"E|miEH:+zE|%N

Try it online!
How it works
Implicitly inputs and outputs, example: 172
iE"              - To string;  STACK = ['172']
   E|            - Splat;      STACK = ['1' '7' '2']
     mi          - To integer; STACK = [1 7 2]
       EH        - Sum;        STACK = [10]
         :+      - Double;     STACK = [20]
           zE|   - Push input; STACK = [20 172]
              %N - Divides?    STACK = [0]

Clojure, 59 bytes
(fn[n](= 0(rem n(* 2(apply +(map #(-(int %)48)(str n)))))))

(defn sum-of-digits? [n]
  (let [ds (map #(- (int %) 48) (str n)) ; Stringify n, and parse each digit char of the string
        d-sum (* 2 (apply + ds))] ; Get the doubled sum
    (= 0 (rem n d-sum)))) ; Check if the remainder of (/ n sum) is 0

Scala, 54 32 bytes
Saved 22 bytes thanks to the comment of @user

Try it online!
n=>n.toInt%(n+n:\0)(_.asDigit+_)

You should be able to use a lambda here. Also, n.concat(n) can be replaced with (n+n). Lastly, folding is shorter than map+sum. 32 bytes: n=>n.toInt%(n+n:\0)(_.asDigit+_)

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


text:
Compute the inverse of an integer modulo 100000000003
The task is the following. Given  an integer x (such that x modulo 100000000003 is not equal to 0) presented to your code in any way you find convenient, output another integer y < 100000000003 so that (x * y) mod 100000000003 = 1.
You code must take less than 30 minutes to run on a standard desktop machine for any input x such that |x| < 2^40.
Test cases
Input: 400000001. Output: 65991902837
Input: 4000000001. Output: 68181818185
Input: 2. Output: 50000000002
Input: 50000000002. Output: 2.
Input: 1000000. Output: 33333300001
Restrictions
You may not use any libraries or builtin functions that perform modulo arithmetic (or this inverse operation).  This means you can't even do a % b without implementing % yourself. You can use all other non-modulo arithmetic builtin functions however.
Similar question
This is similar to this question although hopefully different enough to still be of interest.

So a-(a/b)*b is fine?

@immibis That looks fine.

tag: restricted code?

I notice you don't have any restriction that y<100000000003. I see at least one answer that could be shortened by dropping a final modulo...

@ØrjanJohansen I was definitely expecting y<100000000003.

What's special about 100000000003? (just wondering)

@Lembik In that case, could you mention that requirement that y<100000000003 in the question?

@NoOneIsHere It is the first twelve-digit prime number?

@JeppeStigNielsen It believe it is.

Do the restrictions disallow use of python's pow operator's 3rd argument? https://docs.python.org/3.3/library/functions.html#pow

@bendi Yes they do.

Pyth, 24 bytes
L-b*/bJ+3^T11Jy*uy^GT11Q

Test suite
This uses the fact that a^(p-2) mod p = a^-1 mod p.
First, I manually reimplement modulus, for the specific case of mod 100000000003. I use the formula a mod b = a - (a/b)*b, where / is floored division. I generate the modulus with 10^11 + 3, using the code +3^T11, then save it in J, then use this and the above formula to calculate b mod 100000000003 with -b*/bJ+3^T11J. This function is defined as y with L.
Next, I start with the input, then take it to the tenth power and reduce mod 100000000003, and repeat this 11 times. y^GT is the code executed in each step, and uy^GT11Q runs it 11 times starting with the input.
Now I have Q^(10^11) mod 10^11 + 3, and I want Q^(10^11 + 1) mod 10^11 + 3, so I multiply by the input with *, reduce it mod 100000000003 with y one last time, and output.

Very nice indeed!

I am guessing it's too late for me to tighten  up the test cases....

@Lembik I'd do it anyways, but opinions may vary. It's your challenge, make it work the way you want it to.

The way the question is written, it is possible you could drop the final reduction, although I asked for a clarification whether a result <100000000003 is required.

Haskell, 118 113 105 101 bytes
Inspired from this solution.
-12 from Ørjan Johansen
p=10^11+3
k b=((p-2)?b)b 1
r x=x-div x p*p
(e?b)s a|e==0=a|1<2=(div e 2?b$r$s*s)$last$a:[r$a*s|odd e]

Try it online!
Haskell, 48 bytes
A rewrite of this solution. While fast enough for the test vector, this solution is too slow for other inputs.
s x=until(\t->t-t`div`x*x==0)(+(10^11+3))1`div`x

Try it online!

Awesome! I like the exponentiation by squaring approach.

The shortest solution would be something like Try it online! but I don't think its performance is acceptable ...

(1) It's shorter to make g an operator (e?b)a s|... (2) If you switch a and s then you can make ! a non-operator and inline y into it. (3) You can get rid of the expensive where by a last trick, at the cost of duplicating z. Try it online!

Now those are nice tricks!

Oh, and |e==0=a gets rid of that pesky duplication.

Well spotted, updated the solution.

Brachylog, 22 bytes
∧10^₁₁+₃;İ≜N&;.×-₁~×N∧

Try it online!
This took about 10 minutes for 1000000 with a slightly different (and longer) version of the code which was exactly two times faster (checked only positive values of İ instead of both positive and negatives). Therefore this should take about 20 minutes to complete for that input.
Explanation
We simply describe that Input × Output  - 1 = 100000000003 × an integer, and let constraint arithmetic find Output for us.
∧10^₁₁+₃                   100000000003
        ;İ≜N               N = [100000000003, an integer (0, then 1, then -1, then 2, etc.)]
            &;.×           Input × Output…
                -₁         … - 1…
                  ~×N∧     … = the product of the elements of N

We technically do not need the explicit labeling ≜, however if we do not use it, ~× will not check the case N = [100000000003,1] (because it's often useless), meaning that this will be very slow for input 2 for example because it will need to find the second smallest integer instead of the first.

Wow, I never would have expected constraint arithmetic to pull that off. Awesome!

@isaacg The speed of this is unfortunately completely dependent on the value of İ, so this is still pretty slow for big products.

Updated the question. Does your code always take less than 30 minutes?

Python, 53 51 49 58 53 49 bytes
-2 bytes thanks to orlp
-2 bytes thanks to officialaimm
-4 bytes thanks to Felipe Nardi Batist
-3 bytes thanks to isaacg
-1 byte thanks to Ørjan Johansen
-2 bytes thanks to Federico Poloni
x=input()
t=1
while t-t/x*x:t+=3+10**11
print t/x

Try it Online!
It took me ~30 minutes to figure this one out.  My solution is to start with the first number that will mod to 1.  This number is 1. If its divisible by x, then y is that number divided by x. If not, add 10000000003 to this number to find the second number which mod 1000000003 will equal 1 and repeat.

The first number that will mod to 1 is 1...

@orlp lol thanks.  That saved me 2 bytes :)

Interesting, on TIO this is fast for all the test cases but a bit random keyboard banging gave me 421385994 which times out.

@ØrjanJohansen Good sleuthing.

Why not write b=3+10**11?

I really like this algorithm, but I can't upvote because of the unnecessary y=0, and more importantly the fact that both the input and output code are missing.

I have updated the question to make it clear it should not to be too slow for any input values. Apologies for the late change.

If you need b only once, why not hardcoding it?

The OP has relaxed the input/output requirements.  You can write a function that returns an integer, instead of actually printing.

@PeterCordes I think that would be 3 bytes longer.

Shouldn't the // be a /?

JavaScript (ES6), 153 143 141 bytes
Inspired by this answer from math.stackexchange.com.
A recursive function based on the Euclidean algorithm.
f=(n,d=(F=Math.floor,m=1e11+3,a=1,c=n,b=F(m/n),k=m-b*n,n>1))=>k>1&d?(e=F(c/k),a+=e*b,c-=e*k,f(n,c>1&&(e=F(k/c),k-=e*c,b+=e*a,1))):a+d*(m-a-b)

Modulo is implemented by computing:
quotient = Math.floor(a / b);
remainder = a - b * quotient;

Because the quotient is also needed, doing it that way does actually make some sense.
Test cases

let f =

f=(n,d=(F=Math.floor,m=1e11+3,a=1,c=n,b=F(m/n),k=m-b*n,n>1))=>k>1&d?(e=F(c/k),a+=e*b,c-=e*k,f(n,c>1&&(e=F(k/c),k-=e*c,b+=e*a,1))):a+d*(m-a-b)

console.log(f(2))
console.log(f(50000000002))
console.log(f(1000000))

You only need 64 bit flooring in the last occurence so you can replace the other ones with 0|x/y and remove the declaration

C++11 (GCC/Clang, Linux), 104 102 bytes
using T=__int128_t;T m=1e11+3;T f(T a,T r=1,T n=m-2){return n?f(a*a-a*a/m*m,n&1?r*a-r*a/m*m:r,n/2):r;}

https://ideone.com/gp41rW
Ungolfed, based on Euler's theorem and binary exponentation.
using T=__int128_t;
T m=1e11+3;
T f(T a,T r=1,T n=m-2){
    if(n){
        if(n & 1){
            return f(a * a - a * a / m * m, r * a - r * a / m * m, n / 2);
        }
        return f(a * a - a * a / m * m, r, n / 2);
    }
    return r;
}

ISO C++ only requires long to be at least 32-bit, so it can't necessarily hold 1e11 + 3.  It's 32-bit on x86-64 Windows.  long is a 64-bit type on x86-64 Linux (and other OSes that use the SystemV ABI), though.  So to be fully portable, you'd need to use long long, which is guaranteed to be at least 64-bit since C++11.

__int128_t doesn't seem to be standard C++, it seems to be a gcc extension, it would be cool if you'd state this as a language (C++11 + gcc).

This is not supposed to be a C++ experts site, I hoped no one will notice.

@PeterCordes Code golf doesn't need to be portable or even well-formed, it just needs to work on one implementation.

@aschepler: I know, which is why I said "you would need".  I thought it was useful to point out which platform it would/wouldn't work on, in case anyone tried it and ran into trouble.

Mathematica, 49 bytes
x/.FindInstance[x#==k(10^11+3)+1,{x,k},Integers]&

How long does this take to run?

Less than 0.001s on my computer (for case 2^40-1)

PHP, 71 bytes
for(;($r=bcdiv(bcadd(bcmul(++$i,1e11+3),1),$argn,9))!=$o=$r^0;);echo$o;

Testcases

Ruby, 58 bytes
Uses isaacg's application of Fermat's little theorem for now while I finish timing the brute-force solution.
->n,x=10**11+3{i=n;11.times{i**=10;i-=i/x*x};i*=n;i-i/x*x}

Current brute force version, which is 47 bytes but might be is too slow:
->n,x=10**11+3{(1..x).find{|i|i*=n;i-i/x*x==1}}

Try it online!


text:
Pad a matrix with its sums
Challenge:
Given a square input matrix \$A\$, pad the matrix with one row and one column on all four sides.

The value of each element in the top and bottom row should be the sum of the elements in each corresponding column.
The value of each element in the left and right column should be the sum of the elements in each corresponding row.
The value of the elements in the top left, and bottom right corner should be the sum of the elements on the diagonal
The value of the elements in the top right, and bottom left corner should be the sum of the elements in the anti-diagonal.

Example:
A =
1   5   3
3   2   4
2   5   5

Output:
 8    6   12   12    7
 9    1    5    3    9
 9    3    2    4    9
12    2    5    5   12
 7    6   12   12    8

Explanation:
The top left and bottom right elements are the sum of the diagonal \$1+2+5=8\$. The top right and bottom left elements are the sum of the anti-diagonal \$2+2+3=7\$.
The top and bottom row (except the corners) are the sum of each of the columns in \$A\$: \$1+3+2=6\$, \$5+2+5=12\$ and \$3+4+5=12\$. Similarly, the left and right column (except the corners) are the sum of each of the rows of \$A\$: \$1+5+3=9\$, \$3+2+4=9\$ and \$2+5+5=12\$.
Input:

A non-empty square matrix, with non-negative integers.
Optional format

Output:

The matrix padded as explained above
Optional format, but it must be the same as the input format

Test cases:
Use the submissions in this challenge if you want to convert the input format to a more suitable one (for instance [[1, 5],[0, 2]]).
0
----------------
0 0 0
0 0 0
0 0 0

1 5
0 2
----------------
3 1 7 5
6 1 5 6
2 0 2 2
5 1 7 3

17   24    1    8   15
23    5    7   14   16
 4    6   13   20   22
10   12   19   21    3
11   18   25    2    9
----------------
65   65   65   65   65   65   65
65   17   24    1    8   15   65
65   23    5    7   14   16   65
65    4    6   13   20   22   65
65   10   12   19   21    3   65
65   11   18   25    2    9   65
65   65   65   65   65   65   65

15    1    2   12
 4   10    9    7
 8    6    5   11
 3   13   14    0
----------------
30   30   30   30   30   30
30   15    1    2   12   30
30    4   10    9    7   30
30    8    6    5   11   30
30    3   13   14    0   30
30   30   30   30   30   30

This is code-golf, so the shortest solution in each language wins. Explanations are highly encouraged.

Is that to check magic squares?

Just checking is quite a bit easier, but it's indeed easy to see if a square is magic this way, yes :-)

Jelly, 27 bytes
,UŒDḢ$S$€,Ṛ$j€SW€jSẋ¥€2$j"$

Try it online!

I want to know how this works, please.

@ComradeSparklePony I don't know if I have time to write an explanation right now, sorry.

It's fine, don't worry.

Octave, 64 bytes
Thanks to Tom Carpenter for both saving 4 bytes, and correcting an error I had in the original code!
@(a)[b=(t=@trace)(a),c=sum(a),d=t(flip(a));z=sum(a,2),a,z;d,c,b]

Try it online!
Explanation:
@(a)                 % Anonymous function that takes the matrix 'a' as input
 [ ... ]             % Concatenate everything inside to a single matrix
  b=(t=@trace)(a),   % Clever trick by Tom Carpenter. Save a function handle
                     % for 't=trace', and call it with 'a' as input
                     % Save the result in the variable 'b'
  c=sum(a)           % Sum of all columns of 'a'
  d=t(flip(a));      % Save the trace of 'a' flipped as a variable 'd', while
                     % concatenating [b,c,d] horizontally at the same time, creating the
                     % first row of the output
  z=sum(a,2)         % The sum of each row of the input, and store it in a variable 'z'
  ,a,z;              % Concatenate it with 'a' and 'z' again, to create the middle part of the output
 d,c,b]              % Add [d,c,b] to complete the bottom row

Note, I wrote this long after I posted the challenge.

MATL, 27 26 bytes
,!tXswyv]GXds5L(PGPXds5L(P

Try it online! Or verify all test cases.
Explanation
,        % Do the following twice
  !      %   Tranpose. Takes input implititly in the first iteration
  t      %   Duplicate
  Xs     %   Row vector with the sum of each column
  wy     %   Push a copy to the bottom of the stack
  v      %   Concatenate stack vertically. This attaches the sum of
         %   each row (first iteration) and column (second), leaving
         %   the matrix with the correct orientation (transposed twice)
]        % End
G        % Push input again
Xds      % Column vector with the diagonal of the matrix. Sum of vector
5L(      % Write that into first and last entries of the result matrix
         % matrix; that is, its upper-left and lower-right corners
P        % Flip result matrix vertically
GP       % Push input matrix vertically flipped
Xds      % Diagonal, sum. Since the input has been vertically flipped,
         % this gives the sum of the anti-diagonal of the input.
5L(      % Write that into the upper-left and lower-right corners of
         % the verticallly flipped version of the result matrix
P        % Flip vertically again, to restore initial orientation
         % Implicitly display

Of course MATL is designed to work with matrices unlike Jelly. >_>

@EriktheOutgolfer But your answer has more euros!

Yeah it has euros dollars and yens...unfortunately that's not the winning criterion here. D:

Jelly, 26 bytes
ŒDµḊṖÑµ€1¦ŒḌU
S;;S
Ç€Zµ⁺ÑÑ

Try it online!
Looks surprisingly different from Erik's solution.
I finally managed to understand how ¦ works (by debugging through Jelly's code, lol). Too bad it requires a € to work with Ç in my case.
Explanation
The code uses three links. The first helper link pads a vector with its sum on both ends, the second helper link fixes two corners of the matrix and the main link calls these appropriately.
Ç€Zµ⁺ÑÑ    Main link. Argument: M (matrix)
Ç            Call the first helper link (pad row with sums)...
 €           ...on each row of the matrix.
  Z          Transpose, so that the second invocation uses the columns.
   µ         Begin a new monadic chain.
    ⁺        Repeat the previous chain (everything up to here).
     ÑÑ      Call the second helper link twice on the whole matrix.

S;;S    First helper link. Argument: v (1-dimensional list)
S         Sum the argument list.
 ;        Append the argument list to the sum.
  ;       Append...
   S      ...the sum of the argument list.

ŒDµḊṖÑµ€1¦ŒḌU    Second helper link. Argument: M (matrix)
ŒD                 Get the diagonals of the matrix, starting with the main diagonal.
  µ                Begin a new monadic chain.
      µ€           Perform the following actions on each diagonal...
        1¦         ...and keep the result for the first item (main diagonal):
   Ḋ                 Remove the first item (incorrect top corner).
    Ṗ                Remove the last item (incorrect bottom corner).
     Ñ               Call the first helper link on the diagonal to pad it with its sum.
          ŒḌ       Convert the diagonals back to the matrix.
            U      Reverse each row, so that consecutive calls fix the other corners.

APL (Dyalog), 37 bytes
(d,+⌿,d∘⌽)⍪(+/,⊢,+/)⍪d∘⌽,+⌿,d←+/1 1∘⍉

Try it online!
1 1∘⍉ diagonal (lit. collapse both axes into one)
d← store that function as d and apply it to the argument
+⌿ prepend the column sums
d∘⌽, prepend d applied to the reversed argument
(…)⍪ stack the following on top:
 +/,⊢,+/ row sums, the unmodified argument, row sums
(…)⍪ stack the following on top:
 d,+⌿,d∘⌽ applied to the argument, column sums, d applied to the reversed argument

Python 3, 155 bytes
This is the suggestion of @LeakyNun, which saves 54 bytes. I then golfed it myself a bit.
def f(m):l=len(m);r=range(l);s=sum;b=[s(m[i][i]for i in r)];c=[s(m[i][l+~i]for i in r)];d=[*map(s,zip(*m))];return[b+d+c,*[[s(a),*a,s(a)]for a in m],c+d+b]

Try it online!
Initial solution - Python 3, 216 bytes
def f(m):l=len(m);r,s=range(l),sum;a,b,c,d=s(m[i][i]for i in r),s(m[i][l-i-1]for i in r),[s(m[i][j]for j in r)for i in r],[s(m[i][j]for i in r)for j in r];print([[a]+d+[b]]+[[c[i]]+m[i]+[c[i]]for i in r]+[[b]+d+[a]])

Try it online!

162 bytes

@LeakyNun Thanks. Was just updating with ~190 bytes, this is much shorter :P

Python 2, 268 250 184 174 bytes
10 thanks to Stewie Griffin
from numpy import *
a,c,v,s=sum,trace,vstack,matrix(input())
l,r,d,e=a(s,0),a(s,1),c(s),c(fliplr(s))
print hstack((v(([[d]],r,[[e]])),v((l,s,l)),v(([[e]],r,[[d]])))).tolist()

Try it online!
Some explanations
The input is uploaded as a matrix. First the code computes the sum of each column and each row using numpy.sum. Then it computes the sum of the diagonal by numpy.trace. After this it obtains the other diagonal by making a left-right flip on the matrix. Finally, it uses numpy.vstack and numpy.hstack to glue the pieces together.

@StewieGriffin Ok, I just updated the code :)

I believe this works for 174 https://tio.run/##JY1LjsMgEET3PkUvYdSKAvnNLHwSxALZjoICNgJsTU7vKTyLbp7qier0qa9l1vv@zEukeY3pQz6mJVf66hwPvPVljVyzGybeSnXDuyt9dDX7X@HntFYhZRc488hT70Ths@T2KMmDKG09g08hg2WXsp8rvY4aITYhjBmtxWdjJmulZESBC4d/PNLDjs1KeapL8AUn990Y9WDSVybF9I19s0xGX5huTDCqmXvLAHcwjD5jdMsUSGnMDxIUXI4QoFCl0QAHZe0f

R, 129 bytes
pryr::f(t(matrix(c(d<-sum(diag(m)),c<-colSums(m),a<-sum(diag(m[(n<-nrow(m)):1,])),t(matrix(c(r<-rowSums(m),m,r),n)),a,c,d),n+2)))

An anonymous function that takes a square matrix as input. I'll post an explanation if there's interest.

PHP, 211 bytes
<?foreach($_GET as$l=>$r){$y=0;foreach($r as$k=>$c){$y+=$c;$x[$k]+=$c;$l-$k?:$d+=$c;($z=count($_GET))-1-$k-$l?:$h+=$c;}$o[]=[-1=>$y]+$r+[$z=>$y];}$o[]=[-1=>$h]+$x+[$z=>$d];print_r([-1=>[-1=>$d]+$x+[$z=>$h]]+$o);

Try it online!
Expanded
foreach($_GET as$l=>$r){
  $y=0; # sum for a row
  foreach($r as$k=>$c){
    $y+=$c; # add to sum for a row
    $x[$k]+=$c; # add to sum for a column and store in array
    $l-$k?:$d+=$c; # make the diagonal sum left to right
    ($z=count($_GET))-1-$k-$l?:$h+=$c; # make the diagonal sum right to left
  }
  $o[]=[-1=>$y]+$r+[$z=>$y]; # add to result array the actual row with sum of both sides
}
$o[]=[-1=>$h]+$x+[$z=>$d]; # add to result array the last array
print_r([-1=>[-1=>$d]+$x+[$z=>$h]]+$o); #output after adding the first array to the result array

Python 3, 125 bytes
from numpy import*
f=lambda m,t=trace,s=sum:c_[r_[t(m),s(m,1),t(m[::-1])],c_[s(m,0),m.T,s(m,0)].T,r_[t(m[::-1]),s(m,1),t(m)]]

Try it online!
Slightly ungolfed:
import numpy as np

def f_expanded(m):
    return np.c_[np.r_[np.trace(m), np.sum(m, 1), np.trace(m[::-1])],
                 np.c_[np.sum(m, 0), m.T, np.sum(m, 0)].T,
                 np.r_[np.trace(m[::-1]), np.sum(m, 1), np.trace(m)]]

This takes input formatted as a numpy array, then uses the np.c_ and np.r_ indexing tools to build a new array in one go. np.trace and np.sumare used to calculate the sums along the diagonals and everywhere else, respectively. T is used to take the transpose before and after concatenating the sums because it's shorter than making all the arrays 2-dimensional and using np.r_. m[::-1] saves bytes when compared to rot90(m) or fliplr(m) for finding the trace for the second diagonal.

Nice answer! Welcome to the site :)

Jelly, 24 19 bytes
,U$⁺Æṭj€SW€j§,"`j"Ɗ

Try it online!
I know there's already 2 Jelly answers, but this, I think, is fairly different from them both, and is shorter.
The Footer in the TIO link converts the inputs into 2D arrays, runs the above link over them then outputs them similar to the input format.
How it works
,U$⁺Æṭj€SW€j§,"`j"Ɗ - Main link. Takes a matrix A on the right
  $                 - Collect the previous two links:
 U                  -   Reverse each row of A
                        rev(A) = A with reversed rows
,                   -   Yield the pair [A, rev(A)]
   ⁺                - Do this again on [A, rev(a)]:
                      [A, rev(A)]U   -> [rev(A), A]
                      [A, rev(A)],U$ -> [[A, rev(A)], [rev(A), A]]

    Æṭ              - Take the trace of each.
                       This returns [[Tr(A), Tr(rev(A))], [Tr(rev(A)), Tr(A)]]
                       where Tr(·) returns the trace

        S           - Yield the sums of the columns of A
       €            - Over each pair in l:
      j             -   Insert the column sums between their elements
         W€         - Wrap each in an array
                  Ɗ - Group and run the previous commands on A:
            §       -   Yield the row sums of A
             ,"`    -   Pair each with itself
                 "  -   Zip the rows of A with the pairs of row sums
                j   -   Insert each row between each pair.
           j        - Insert the rows plus their sums in between the diagonal and column sums

JavaScript (ES6), 170 bytes
(a,m=g=>a.map((_,i)=>g(i)),s=x=>eval(x.join`+`))=>[[d=s(m(i=>a[i][i])),...c=m(i=>s(m(j=>a[j][i]))),g=s(m(i=>a[i][a.length-i-1]))],...a.map(b=>[r=s(b),...b,r]),[g,...c,d]]

Input and output is a 2D array of numbers.
Explained
(a,                             // input matrix: a
    m=g=>a.map((_,i)=>g(i)),    // helper func m: map by index
    s=x=>eval(x.join`+`)        // helper func s: array sum
) =>
[
    [
        d = s(m(i=>a[i][i])),           // diagonal sum: d
        ...c=m(i=>s(m(j=>a[j][i]))),    // column sums: c
        g = s(m(i=>a[i][a.length-i-1])) // antidiagonal sum: g
    ],
    ...a.map(b=>[r = s(b), ...b, r]),   // all rows with row sums on each end
    [g, ...c, d]                        // same as top row, with corners flipped
]

Test Snippet
Input/output has been formatted with newlines and tabs.

f=
(a,m=g=>a.map((_,i)=>g(i)),s=x=>eval(x.join`+`))=>[[d=s(m(i=>a[i][i])),...c=m(i=>s(m(j=>a[j][i]))),g=s(m(i=>a[i][a.length-i-1]))],...a.map(b=>[r=s(b),...b,r]),[g,...c,d]]

let tests=[[[0]],[[1,5],[0,2]],[[17,24,1,8,15],[23,5,7,14,16],[4,6,13,20,22],[10,12,19,21,3],[11,18,25,2,9]],[[15,1,2,12],[4,10,9,7],[8,6,5,11],[3,13,14,0]]];
<select id=S oninput="I.value=S.selectedIndex?tests[S.value-1].map(s=>s.join`\t`).join`\n`:''"><option>Tests<option>1<option>2<option>3<option>4</select> <button onclick="O.innerHTML=I.value.trim()?f(I.value.split`\n`.map(s=>s.trim().split(/\s+/g))).map(s=>s.join`\t`).join`\n`:''">Run</button>
<textarea rows=6 cols=50 id=I></textarea>

LOGO, 198 bytes
to g :v[:h reduce "+ :v]
op(se :h :v :h)
end
to f :s[:a reduce "+ map[item # ?]:s][:b reduce "+ map[item # reverse ?]:s][:c apply "map se "sum :s]
op `[[,:a ,@:c ,:b],@[map "g :s][,:b ,@:c ,:a]]
end

The function f takes in a matrix as a 2D list, then output the resulting matrix. g is helper function.

05AB1E, 38 bytes
ODŠζsζ€R€˜IÅ\OUIÅ/OVIÅ|ODXšYªsXªYšŠšsª

Try it online!
Input
A list of lists as a representation of a matrix.
Output
A list of lists as a representation of a matrix.
Explanation
ODŠζsζ€R€˜IÅ\OUIÅ/OVIÅ|ODXšYªsXªYšŠšsª
OD                                            Sum of rows and duplicate
  Š                                           Triple swap
   ζ                                          Zip arrays (to append to the rows)
    sζ                                        Swap and do the same (to prepend to the rows)
      €R€˜                                    Reverse each row and deep flat each row, making the new rows.
          IÅ\OU                               Get the diagonal of the input, sum it and save in variable X
               IÅ/OV                          Get the anti-diagonal of the input, sum it and save in variable Y
                    IÅ|OD                     Get the columns of the input, sum it and duplicate the sums vector.
                         Xš                   Prepend variable x
                           Yª                 Append variable y
                             sXªYš            Repeat for the second row, but now the prepend and append values are switched
                                  Ššsª        Append and Prepend the new rows (first and last)

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