text:
Making Squared Words
The Challenge
Your task is to create a program that takes any given string input, and outputs the input in a squared format. Empty strings should return an empty string.
Examples
Given the input:
golf

Your program should output:
golf
o  l
l  o
flog

Input:
123

Output:
123
2 2
321

Input:
a

Output:
a

Input:
Hello, world!

Output (notice the space between the , and w - the gap is not just a newline):
Hello, world!
e           d
l           l
l           r
o           o
,           w

w           ,
o           o
r           l
l           l
d           e
!dlrow ,olleH

Scoring
This is code-golf, so the shortest answer in each language wins.

@DJMcMayhem Yes, my apologies I had forgotten to add that.

No worries, just double checking. Nice first challenge BTW! Welcome to the site :)

@SpookyGengar Would you add a test case for a one-letter input?

@musicman523 don't I already have one? The third example involving just the letter 'a'.

Is empty string allowed to output to STDERR? (aka can I error out for null input)

@SpookyGengar my bad, I'm blind apparently

Ooh, this gave me an idea I have forgotten a while ago.

Do you accept the input itself as a part of the output? As in - the program doesn't output the the top line? That's the design of this answer: https://codegolf.stackexchange.com/a/133927/71498 and I'm looking for confirmation before I retract my downvote.

Do you accept the output as a list of (meta-approved) strings that do not have newline characters? Some solutions (e.g. Haskell) are already doing things that way, but I wanted to check.

Charcoal, 7 5 bytes
θ‖Ｏ↙↘

Try it online! Link is to verbose version of code. Edit: Saved 2 bytes thanks to @CarlosAlejo. Explanation:
θ       Print the input string, making the top row
 ‖Ｏ     Reflect with overlap...
   ↙    ... down and left, to create the left side
    ↘   ... down and right, to create the bottom and right sides

(Multiple directions to the Reflect command run consecutively rather than simultaneously.)

Wow, jesus, I still think Charcoal was the coolest esolang idea.

You can save two bytes if you just print the input string and reflect it downleftwards and downrightwards: θ‖Ｂ↙↘. Try it online!

Now that I think of it, maybe I should have used ReflectOverlap instead of ReflectButterfly to avoid flipping characters. :-)

This is one of the rare cases where a golfed answer in an esoteric language is easier to read and understand than the full ungolfed versions of popular general purpose languages.

Your answer here also works for 4 bytes.

You really just crafted this programming language for this challenge, didn't you?

@arminb I didn't create this language, although I have contributed some bug fixes.

MATL, 20 16 11 bytes
otYTO6Lt&(c

Try it at MATL online!
EDIT: The code works in release 20.2.1, which predates the challenge. The link uses that release. (In 20.2.2 the code would be shorter, but it postdates the challenge).
Explanation
o     % Implicitly input a string. Convert chars to ASCII codes
t     % Duplicate
YT    % 2-input Toeplitz matrix
O     % Push 0
6L    % Push predefined literal [2, -1+1j]. When used as an index, this is
      % interpreted as 2:end-1 (indexing is 1-based)
t     % Duplicate
&(    % 4-input assignment indexing. This writes 0 at the square formed by
      % rows 2:end-1 and columns 2:end-1
c     % Convert to char. Char 0 is shown as space. Implicitly display

Very impressive! :) Is it possible to remove the blank line at the bottom of every output, or is that needed for functionality?

@SpookyGengar It's a very common request to allow a single trailing newline.

@SpookyGengar Thanks! MATL always displays a trailing newline. As Jonathan says, that's usually allowed

@LuisMendo You learn something new everyday. :) Thanks for the submission - definitely the best so far!

Jelly,  29 22  17 bytes
Charcoal will trounce+d this score...
J⁶ẋa0,1¦"ṚṚ;$ṖŒḌY

A monadic link taking and returning a lists of characters; or a full program printing the result.
Try it online!
How?
J⁶ẋa0,1¦"ṚṚ;$ṖŒḌY - Link: list of characters, w     e.g. "whole"
 ⁶                - literal space character              ' '
J                 - range(length(w))                     [1,2,3,4,5]
  ẋ               - repeat                               [" ","  ","   ","    ","     "]
         Ṛ        - reverse w                            "elohw"
        "         - zip with:
       ¦          -   sparse application of:
   a              -     and (vectorises)
    0,1           -     to indexes: [0,1] (last and 1st) ["e","ll","o o","h  h","w   w"]
            $     - last two links as a monad:
          Ṛ       -   reverse                            ["w   w","h  h","o o","ll","e"]
           ;      -   concatenate                        ["w   w","h  h","o o","ll","e","e","ll","o o","h  h","w   w"]
             Ṗ    - pop (remove last entry)              ["w   w","h  h","o o","ll","e","e","ll","o o","h  h"]
              ŒḌ  - reconstruct matrix from diagonals    ["whole","h   l","o   o","l   h","elohw"]
                Y - join with newlines                   "whole\nh   l\no   o\nl   h\nelohw"
                  - if running as a full program implicit print

Very cool! So far the shortest solution, but does not work with single-character inputs, and strings consisting of numbers i.e. '123'.

Ah I will have to handle the single character edge case, yes. It does work with digit-character strings, the program input really should be quoted, like 'Hello', "Spooky's", "123", etc. (Python is used to interpret input).

@SpookyGengar - fixed it up for the 1-character case.

Nice length reduction!

You're right about Charcoal.

@LuisMendo thanks, three different approaches used rather than just plain glfng.

@JonathanAllan Same as my answer then, haha

@LuisMendo Yeah a similar approach for sure!

Octave, 40 bytes
@(s,t=toeplitz(s),u=t(x=2:end-1,x)=32)t;

Try it online!
It is my answer but posted after @Luis MATL answer

Very nice answer. Btw: your code crashed the GNU Octave development branch 4.3.1 (b481a9baeb61) and is now part of the test suite :-) http://hg.savannah.gnu.org/hgweb/octave/rev/c94e9509461b

@Andy Thanks and welcome to codegolf! I glad if it can help improving Octave project!

Haskell, 84 78 bytes
f s@(_:x)|_:y<-r x=s:[a:(y>>" ")++[b]|(a,b)<-zip x y]++[r s];f s=[s]
r=reverse

Try it online!  Usage: f "test". Returns a list of lines.
Edit: -6 bytes thanks to dianne!

you can save a few bytes by using the pattern guard as a guard and defining a synonym for reverse;  r=reverse;f s@(_:x)|_:y<-r x=s:[a:(y>>" ")++[b]|(a,b)<-zip x y]++[r s];f s=[s] is 78 bytes.

C, 109 bytes
i,j;f(char*s){for(i=j=printf("%s\n",s)-2;1[++s];)printf("%c%*c\n",*s,i,s[j-=2]);for(;*s*~i--;)putchar(*s--);}

Try it online!
Noteworthy tricks:

Instead of wasting bytes on strlen, we simply grab the length of the string while simultaneously printing the first line:
i=j=printf("%s\n",s)-2

This works because printf returns the number of bytes written.
For the middle lines, we need to loop over the string but exclude both the first and last character. This is achieved with the condition
1[++s]

(which is shorter than (++s)[1]), which skips the first character due to the ++'s being in the condition and skips the last one by stopping when the character past the current character is '\0' (rather than stopping at '\0').
In the body of the first loop,
printf("%c%*c\n",*s,i,s[j-=2])

we print the current character, then the appropriate "mirrored" character (keeping track with j, which does go into the negatives, resulting in the odd situation of indexing into a string with a negative number) padded to a length of i with spaces (where i is conveniently strlen(s) - 1).
The reversed printing on the last line is pretty straightforward; the only trick is the *s*~i--, which is the shortest way to get i+2 iterations of the loop body (which doesn't depend on i; all i is used for is to count). The funky *s* part makes sure the loop doesn't run if *s is '\0', which happens on length-1 input.

Python 3, 88 bytes
w=input();p=print;l=len(w)-2
[p(w[n+1]+' '*l+w[l-n])for n in range(l)]
l+1and p(w[::-1])

Welcome to PPCG!

Welcome to the site as well! I believe that l+1 and could be rewritten as l+1and to save a byte.

@WheatWizard edited - thanks! I was surprised that worked...

It will work except for the case of 0or, where python fails to parse because 0o is an octal prefix.

When I run this, it doesn't seem to print the top line...
https://tio.run/##FcoxCsQgEAXQPqeYLk7EwqRL8CRiEVh3Iww/gxhkT@@yr376bdeNbYweCvRphg8NWgvaIUEyTGe3TlFNj7A@2ZnmRWyP4pD4fVcCFVA98clGOE1i/YkX/f@@O594jHblHw

@CotyJohnathanSaxman the solution re-uses inputted word as first line (i.e. try copy-pasting into .py file and run from terminal and you'll see). You could add "p(w);" before the "l=len(..." to obtain what you're looking for.

Python 2, 89 81 88 86 bytes
i=input();n=k=len(i)-2
print i
exec'print i[~k]+" "*n+i[k];k-=1;'*n
if~k:print i[::-1]

Try it online!

Same failure for length 1 strings that mine had.

@StepHen fixed it and golfed further :D

R, 113 bytes
function(s){n=length(s<-strsplit(s,'')[[1]])
m=matrix(' ',n,n)
m[n,n:1]=m[,1]=m[1,]=m[n:1,n]=s
write(m,'',n,,'')}

Try it online!

My answer to the dupe challenge is shorter -- what a difference a year can make!

05AB1E, 17 16 15 19 bytes
ÂDÂø¦¨Dgú€Ás)˜»Igi¨

Try it online!
Explanation
Example with input = golf
ÂDÂ                  # bifurcate, duplicate, bifurcate
                     # STACK: 'golf', 'flog', 'flog', 'golf'
   ø                 # zip the top 2 items
                     # STACK: 'golf', 'flog', ['fg', 'lo', 'ol', 'gf']
    ¦¨               # remove the first and last element
                     # STACK: 'golf', 'flog', ['lo', 'ol']
      Dg             # get the length of the list
                     # STACK: 'golf', 'flog', ['lo', 'ol'], 2
        ú            # prepend that many spaces to each element
                     # STACK: 'golf', 'flog', ['  lo', '  ol']
         €Á          # rotate each right
                     # STACK: 'golf', 'flog', ['o  l', 'l  o']
           s         # swap the top 2 items
                     # STACK: 'golf', ['o  l', 'l  o'], 'flog'
            )˜       # wrap in a flattened list
                     # STACK: ['golf', 'o  l', 'l  o', 'flog']
              »      # join on newline
               Igi¨  # if input is length 1, remove last char

The fix for 1-letter input was quite expensive.
I feel like a different approach might be better now.

Python 2, 99 88 bytes
-4 bytes thanks to musicman523.
lambda s:s[1:]and[s]+[s[i]+' '*(len(s)-2)+s[~i]for i in range(1,len(s)-1)]+[s[::-1]]or s

Try it online!
Returns a list of strings.

Close! The output is not exactly what I am asking for.

89 bytes by moving s and s[::-1] into the join

This doesn't quite work for length-1 strings

Just to note, all the issues have been fixed.

Swift 3, 215 199 bytes
let s=readLine()!,c=s.characters,r:[Character]=c.reversed(),b=c.count
print(s)
if b>1{for i in 0..<b-2{print("\(r.reversed()[i+1])\(String.init(repeating:" ",count:b-2))\(r[i+1])")};print(String(r))}

Try it online

APL, 58 bytes
{(' ',⍵)[x+(x←∘.{((c-1)=⍺⌈⍵)∨0=⍺⌊⍵}⍨r)×o⌊⌽⊖o←∘.⌈⍨r←⍳c←≢⍵]}

With ⎕IO←0.
Try it online!
How?
c←≢⍵ - length of the string
r←⍳ - range
o←∘.⌈⍨ - outer product with minimum
123
223
333

o⌊⌽⊖ - minimalize with itself turned 180o
123  ⌊  333  =  123
223  ⌊  322  =  222
333  ⌊  321  =  321

× - multiply with
x←∘....⍨r - outer product of the range with
    ((c-1)=⍺⌈⍵)∨0=⍺⌊⍵ - the frame of the matrix
111  ×  123  =  123
101  ×  222  =  202
111  ×  321  =  321

x+ - add the frame
111  +  123  =  234
101  +  202  =  303
111  +  321  =  432

(' ',⍵)[...] - get by index from the string concatenated to space

Can ⍉⊖⍉⊖ be ⌽⊖?

Mathematica, 128 bytes
(c=Column;g=Length[x=Characters@#]-1;If[g==0,#,c@{#,c@Table[""<>{x[[i]],""<>Table[" ",g-1],x[[-i]]},{i,2,g}],StringReverse@#}])&

C, 96 bytes
i,l;f(char*s){for(i=l=puts(s)-2;--i;)printf("%c%*c\n",s[l-i],l,s[i]);for(;l+1;)putchar(s[l--]);}

Bonus version (122 bytes):
x,y,i,l;f(char*s){for(i=l=puts(s)-1;++i<l*-~l;putchar(x==l?10:x%~-l*(y%~-l)?32:s[(x*y?l+l-2-x-y:x+y)%l]))x=i%-~l,y=i/-~l;}

JavaScript (ES8), 108 112 bytes

let f =

s=>(n=s.length)<2?s:(r=[...s].reverse()).slice(1,-1).reduce((a,v,i)=>a+`
`+s[i+1].padEnd(n-1)+v,s)+`
`+r.join``

o.innerHTML = f("hello folks!")

Less golphed
s=>
   (n=s.length) < 2 ?    // record and check length
   s :                   // s has 0 or 1 char, else
   (r=[...s].reverse())  // reverse characters,
   .slice(1,-1)          // exclude 1st and last
   .reduce((a,v,i)=>     // append inner lines
      a +'\n' +s[i+1].padEnd(n-1) + v
    ,s)                  // to first line
    + '\n' +r.join("")   // append characters reversed

Thanks to Justin Mariner for saving lots of bytes, which then all got used up adding the zero or single character check needed to comply with the challenge. You get that :-(

You can save 7 bytes by making the second line \+s[i+1].padEnd(s.length-1)+v,s)+`and by usingr.join```.

Thanks @JustinMariner for the tips about String.prototype.padStart and tagged template literals. I needed that to help keeping the addition of the length check to a minimum :-)

Your spacing is one character too short now; you can fix that and save a couple more by doing (n=s.length-1)?(r=<...>+r.join\`:sand usingpadEnd(n). If the length is 1, length-1is0` (false).

@JustinMariner spacing is fixed, but I've kept the length test - as I understand it, both zero length strings and strings of one character return themselves without either carriage return or repetition of the string.

padEnd is ES2017.

@Neil thanks, a new standard to read!

PHP, 118 bytes
echo $s=$argv[1];$l=strlen($r=strrev($s))-1;for($i=$l-1;$l&&$i;)echo "\n".str_pad($r[$i],$l).$s[$i].(--$i?"":"\n$r");

Try it online!
echo $s = $argv[1];
$l = strlen($r = strrev($s)) - 1;

for ($i = $l - 1; $l && $i;)
    echo "\n" . str_pad($r[$i], $l) . $s[$i] . (--$i ? "" : "\n$r");

Vyxal, 16 10 bytes
∞∞?L2460ø∧

Try it Online!
-6 bytes by porting 05AB1E thanks to emanresu

osabie port = 10

Japt -R, 14 10 bytes
Knew there had to be a shorter way!
¬hU ÆÔÃÕÆÔ

Try it
¬hU ÆÔÃÕÆÔ     :Implicit input of string U
¬              :Split
 hU            :Replace first element with U
    Æ          :Modify last element
     Ô         :  U reversed
      Ã        :End modify
       Õ       :Transpose
        ÆÔ     :As above
               :Implicit output joined with newlines

Python 3, 122 bytes
i=input();l=len(i)
if l!=1:
    print(i)
    for I in range(1,l-1): print(i[I]+" "*(l-2)+i[l-I-1])
    print(i[::-1])
else:print(i)

Attempt This Online!

Welcome to Code Golf, and nice answer!

J, 28 23 bytes
|._1}]0}|.,.~<:@#{."1,.

Try it online!

,. Columnize the input:
g
o
l
f

<:@#{."1 Take "input length - 1" elements from each row, with space fills.  I'll show the spaces filled with . for clarity:
g..
o..
l..
f..

|.,.~ Zip with the reverse:
g..f
o..l
l..o
f..g

]0} Replace first row with input:
golf
o..l
l..o
f..g

|._1} Replace last row with input reversed:
golf
o..l
l..o
flog

05AB1E, 8 bytes
gIûûŽ9¦Λ

Try it online or verify all test cases.
Explanation:
g    # Push the length of the (implicit) input
I    # Push the input itself
 û   # Palindromize it
  û  # And palindromize that again
Ž9¦  # Push compressed integer 2460
Λ    # Use the Canvas builtin with those three options
     # (after which the result is output immediately implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž9¦ is 2460.
As for some additional information about the Canvas builtin Λ:
It takes 3 arguments to draw an ASCII shape:

Length of the lines we want to draw
Character/string to draw
The direction to draw in, where each digit represents a certain direction:

7   0   1
  ↖ ↑ ↗
6 ← X → 2
  ↙ ↓ ↘
5   4   3

gIûûŽ9¦ creates the following Canvas arguments:

Length: the length of the input (e.g. 4 for input "abcd")
Characters: the double palindromized input (e.g. "abcdcbabcdcba" for input "abcd")
Directions: [2,4,6,0], which translates to \$[→,↓,←,↑]\$

Because we only have a single length, the directions are leading here.
Step 1: Draw 4 characters ("abcd") in direction 2 (\$→\$):
abcd

Step 2: Draw 4-1 characters ("cba") in direction 4 (\$↓\$):
abcd
   c
   b
   a

Step 3: Draw 4-1 characters ("bcd") in direction 6 (\$←\$):
abcd
   c
   b
dcba

Step 4: Draw 4-1 characters ("cba") in direction 0 (\$↑\$):
abcd
b  c
c  b
dcba

See this 05AB1E tip of mine for an in-depth explanation of the Canvas builtin.

Python 3, 85 bytes
Using the input for the top row :)
a=input()
b=len(a)
for i in range(b-2):print(a[1+i]+" "*(b-2)+a[-2-i])
print(a[::-1])

Are you sure this gives a correct answer?

Retina, 106 bytes
..+
$&¶$&
O$^`.(?=.*$)

\G.
$&$%'¶
r`.\G
¶$%`$&
+`(.+)¶¶((.*¶)*).(.*)
¶¶$1$4$2
T`p` `(?<=.¶.).*(?=.¶.)
G`.

Try it online! Explanation:
..+
$&¶$&

If there are at least two characters, duplicate the input.
O$^`.(?=.*$)

Reverse the duplicate.
\G.
$&$%'¶
r`.\G
¶$%`$&

Turn the strings into triangles. The top triangle starts with the input and removes the first character each time, while the bottom triangle starts with the first letter of the reversed input and adds a character each time.
+`(.+)¶¶((.*¶)*).(.*)
¶¶$1$4$2

Join the triangles together, overlapping so that the last character forms the / diagonal.
T`p` `(?<=.¶.).*(?=.¶.)

Change all the characters to spaces, if they are at least one character away from the end on every side.
G`.

Delete any left-over blank lines.

Lua, 104 bytes
print(s);for a=2,#s-1 do print(s:sub(a,a)..(" "):rep(#s-2)..s:sub(#s-a+1,#s-a+1)) end;print(s:reverse())

Try it online!

but you only used p once...

True... gonna change that.

JavaScript (ES2017), 87 bytes
s=>[...s].reverse(l=s.length-1).map((c,i,z)=>i?l-i?s[i].padEnd(l)+c:z.join``:s).join`
`

ES6 version: 93 bytes
s=>[...s].reverse(l=s.length-1).map((c,i,z)=>i?l-i?s[i]+' '.repeat(l-1)+c:z.join``:s).join`
`

Less golfed
s => (
  l = s.length-1,
  [...s].reverse().map( // scan string backwards
     (c, i, z) =>
     i != 0 // check if top row
     ? l-i != 0 // check if bottom row
       ? s[i].padEnd(l) + c // any middle row
       : z.join`` // bottom row: string reversed
     :s // top row: original string
  ).join`\n`
)

F=
s=>[...s].reverse(l=s.length-1).map((c,i,z)=>i?l-i?s[i].padEnd(l)+c:z.join``:s).join`
`

function update() {
  O.textContent = F(I.value)
}

update()
<input id=I value='Hello, world!' oninput='update()'>

padEnd is ES2017.

@Neil thank you I'll change my heading

You can save a byte on your ES6 version by using l+~i, this avoids having to subtract 1 twice instead you can subtract 2 once.

@Neil it should be l-~-i

I was thinking of s=>[...s].reverse(l=s.length).map((c,i,z)=>i?l+~i?s[i]+' '.repeat(l-2)+c:z.join``:s).join`\n`  but s=>[...s].reverse(l=s.length-2).map((c,i,z)=>i?i+~l?s[i]+' '.repeat(l)+c:z.join``:s).join`\n`  also works.

C# (.NET Core), 179 161 bytes
-18 bytes thanks to TheLethalCoder
using System.Linq;
s=>{int l=s.Length-1,i=1;var d=s.Reverse().ToArray();while(i<l)s+="\n"+s[i]+new string(' ',l-1)+d[i++];if(l>1)s+="\n"+new string(d);return s;};

Try it online!
I'm not sure about the rules, if this is needed to byte count or not:
using System.Linq;

Someone please correct me about this.
Ungolfed:
s =>
{
    int l = s.Length - 1, i = 1;
    var d = s.Reverse().ToArray();
    while (i < l)
        s += "\n" + s[i] + new string(' ', l - 1) + d[i++];
    if (l > 1)
        s += "\n" + new string(d);
    return s;
};

Hello and welcome to PPCG! You are using Linq so you should include the using into your byte count. As you are using Linq ToCharArray() can be just ToArray(), do you really need it before the Reverse() though? As you are using String you either need to fully qualify it or include the using, however, this can be easily fixed by changing it too string. The if might be shorter as a ternary like s+=l>1?if code:"";. You can remove the i++ from the loop and post increment it at d[i++].

Initialise i with l like int l=s.Length-1,i=1;. And I think that might be it!

@TheLethalCoder thank you! I added your suggestions to the code. A few notes: I totally forgot that string does in fact have IEnumerable; String instead of string was a Java residue that I still fight with, ternary was in fact exactly as long suprisingly; and after your changes I changed for(;expr;) to while(expr) since it looks nicer and is the same byte count. Thank you again.

No worries! Ternaries sometimes are but usually come out shorter so is always worth trying them.

Java, 191 bytes
(s)->{PrintStream o=System.out;int l=s.lenght();o.println(s);for(int i=0;i<l;i++){o.printf("%"+"s%"+(l-1)+"s%n",s.charAt(i),s.charAt(l-1-i));for(int i=0;i<l;i++){o.print(s.charAt(l-1-i));}}};

(s) can be just s. The loops with single lines inside can have their curly braces removed. You could return instead of printing if that will save you any bytes. You use int i in both loops, I can't tell if they're in different scopes but worth pointing out. Initialising like variables together usually saves bytes. for(int i=0;i<l;i++){o.print(s.charAt(l-1-i));} -> for(int i=0;i<l;){o.print(s.charAt(l-1-i++));}. You don't need the trailing semi colon.

Thanks for pointing out ;) (not very familiar with Golfing). Will Optimize it later!

Python 2, 100 bytes
lambda a:'\n'.join([a]+(len(a)>1)*([a[i]+(len(a)-2)*' '+a[~i]for i in range(1,len(a)-1)]+[a[::-1]]))

Try it online!

Mathematica, 138 91 bytes
(b=Outer[" "&,#,#];Do[l={{1,k},{k,1}};b=ReplacePart[b,Join[l,-l]->#[[k]]],{k,Length@#}];b)&

You can try it online with by pasting the following at the Wolfram Cloud Sandbox and clicking "evaluate cell" or hitting Shift+Enter or Numpad Enter:
(b=Outer[" "&,#,#];Do[l={{1,k},{k,1}};b=ReplacePart[b,Join[l,-l]->#[[k]]],{k,Length@#}];b)&@{"g","o","l","f","y"}//MatrixForm

Python 3, 106 bytes
A functional version...
w=input();p=print;l=len(w)-2
def f(k):p(w[k]+' '*l+w[-k-1]);l-k>0and f(k+1)
l<0 or f(1)or l<1or p(w[::-1])

><> (Fish) - 153 bytes
l:>:?v;l$-[r:or].
-$/-$>$: ?vao~1-l1
  ^1vv?(2:<
 1^\:>$:&05&60. >$:&04&60.
o 1^\l3-=?v$:2(?^:l3-=?v$' '
 $^/$-3l:$<   /1-$-3l:$<
   \-1+&05&60.\+&04&60.

Try it
Make sure the initial stack setting is set to "chars", occasinally it bugs out and switches itself to numbers.
Summary

The blue bar at the top l$-[r:or] prints the n-th letter. The rest of the code is mostly branches leading to &04&60. that jump to the nth letter printer.


text:
Make a Word Art

No, not that thing in powerpoint

You will be given a string, and a 2D array of boolean values. The 2D array will represent a picture.
You will be creating art out of it.
Let me show you how.
The steps to art
First, you create a square which fits the 2d array, with the string.
Like if the string is 'PPCG', and the picture is 4x3, the square should be like this.
PPCG
PCGP
CGPP
GPPC

Now in the square, erase all characters which the corresponding boolean is 0, or the corresponding boolean doesn't exist.
Let me show you. If the 2D array is
1001
0110
1001

And the square is same to the above (above this one), the result should be like:
P  G
 CG
C  P

Now output the result.
Test data is not made yet. Will add ASAP.
Rules

General code-golf rules apply, including loopholes.

Related. I'm sure there was one that created the squares like above too but I can't find it.

It would help if you use 'ABCD' or something( with non-repeating chars) instead of 'PPCG' in the example... The two 'P's are really confusing to get a clear picture...

If the string is ABC can the input array be [[1,0],[1,0],[1,0]] or must the inner arrays be 3 in length?

@TheLethalCoder The array size isn't determined by the string. In fact the square is determined by the array size.

@SIGSEGV So is it guaranteed the array will be non-empty and not larger than the string?

@TheLethalCoder The square must expand as the array does.

I mean the input array, If the input string is 2 in length is it guaranteed the input array will be at most 2 x 2?

@TheLethalCoder no.

@SIGSEGV So what happens in the case of the string AB and array [[1,1,1][1,1,1][1,1,1]]?

May we take the boolean array as a String instead (10100101 instead of [[1,0,1,0],[0,1,0,1]]?

And I honestly think it would be more interesting if one should not expand the square if the array is larger, and it would guaranteed that the length of the array is the same as the String's length.

Does the "direction" we shift the characters to create the square matter? For example, given PPCG, could the square be PPCG,GPPC,CGPP,PCGP?

Test data is not made yet. Will add ASAP. -> why didn't you just Sandbox this until you had test data?

C#, 168 bytes
s=>a=>{var r=new string[a.Length];for(int i=0,j;i<a.Length;++i)for(j=0;j<a[i].Length;++j)r[i]+=a[i][j]>48?(s.Substring(i,s.Length-i)+s.Substring(0,i))[j]:' ';return r;}

Works for the example in the question, not entirely sure how it will hold up against future test cases as the spec isn't fully clear.
Try it online!

Can't Substring(0, i) be Substring(0,i)?

@Mr.Xcoder Yeah, just me forgetting to remove all spaces, thanks!

Mathematica, 74 bytes
(z=Characters@#;Grid[Table[RotateLeft[z,i],{i,0,Length@#2-1}]#2/.0->" "])&

input

["PPCG", {{1, 0, 0, 1}, {0, 1, 1, 0}, {1, 0, 0, 1}}]

works for test case.will update if things get "clearer"...

Python 3, 95 79 74 bytes
-2 bytes thanks to @Mr.Xcoder
lambda s,b,e=enumerate:[[b*(2*s)[k+i]or' 'for k,b in e(v)]for i,v in e(b)]

Try it online!

Your function is not recursive, why did you add f=?

@Mr.Xcoder thanks for noticing

source: Stack Exchange

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

sort: votes


text:
Generate an Acronym
This is similar to Making an acronym, but there are several key differences, including the method of fetching the acronym, and this challenge including flexible output.
Task
Given a string (list of chars/length 1 strings is allowed) containing only printable ASCII, output all capital letters in the input that are either preceded by a space or a dash, or are the first character in the input. Empty string is undefined behavior.
Test Cases:
Output may be in the format of "TEST", ["T","E","S","T"], or whatever else works for you.
Self-contained Underwater Breathing Apparatus
SUBA

a Programming Language
PL

NATO Atlantic TREATY Organization
NATO

DEFCON 2
D

hello, world!

light-Emitting dioDe
E

What Does the Fox Say?
WDFS

3D mov-Ies
I

laugh-Out Lou-D
OLD

Best friends FOREVE-r
BF

--

<space>

--  --a -  - --

--  -- -  - -- A
A

Step-Hen@Gmail-Mail Mail.CoM m
SHMM

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

Sandbox

Can we take input as a list of Strings (list of characters)?

@Mr.Xcoder yes.

Could you add a test case that includes some letters separated by one or more characters that aren't letters, numbers, spaces or dashes. An e-mail address, for example: My-Name@Some-Domain.TLD.

@Shaggy added, thanks.

V, 7 bytes
ÍÕü¼À!õ

Try it online!
Here is a hexdump to prove the byte count:
00000000: cdd5 fcbc c021 f5                        .....!.

Explanation:
Í       " Search and replace all occurrences on all lines:
        " (Search for)
 Õ      "   A non-uppercase letter [^A-Z]
  ü     "   OR
      õ "   An uppercase letter
    À!  "   Not preceded by...
   ¼    "   A word-boundary
        " (implicitly) And replace it with:
        "   Nothing

This is short all thanks to V's wonderful regex compression.

That's pretty short 0.o

@StepHen Why thank you! I think this is pretty close to optimal. :)

What do you mean by a word boundary? The question seems to suggest that only space and - are allowed.

R, 66 63 bytes
function(s)(s=substr(strsplit(s,' |-')[[1]],1,1))[s%in%LETTERS]

Try it online!
-3 bytes thanks to Scarabee
An anonymous function; returns the acronym as a vector c("N","A","T","O") which is implicitly printed.
For once, this isn't too bad in R! splits on - or (space), takes the first element of each of those, and then returns whichever ones are capitals (LETTERS is an R builtin with the capital letters), in order.

I think you can save a few bytes: function(s)(s=substr(strsplit(s,' |-')[[1]],1,1))[s%in%LETTERS]

@Scarabee thank you. sorry it took 2 years to update.

Python 2, 59 56 bytes
-3 bytes thanks to Lynn

lambda s:[b for a,b in zip(' '+s,s)if'@'<b<'['>a in' -']

Try it online!

I borrowed your trick '@'<b<'[', very nice solution +1

Don’t forget about comparison chaining! '@'<b<'['>a in' -' saves 3 bytes.

Javascript 21 bytes
Takes a string input and outputs an array of strings containing the acronym characters
x=>x.match(/\b[A-Z]/g)

Explanation
It's just a global regex match for word-boundary followed by a capital letter.

Dyalog APL, 29 23 bytes
Bonus test case: A Programming Language (APL).
'(?<=^| |-)[A-Z]'⎕S'&'⊢

Returns an array of chars (shows as space seperated on TIO).
Try it online!

Older post, 29 bytes
{(⎕AV~⎕A)~⍨'(\w)\w+'⎕R'\1'⊢⍵}

Try it online!
How?
'(\w)\w+'⎕R - replace each cluster of alphabetic chars
    '\1' - with its first character
~⍨ - remove every char
    (⎕AV~⎕A) - that is not an ASCII uppercase

Retina, 21 17 bytes
!`(?<=^| |-)[A-Z]

Try it online!
Explanation
Outputs the matches of the regex (?<=^| |-)[A-Z] in the input, one per line (!).

Julia 0.6.0 (57 bytes)
s=split(s,r" |-");for w∈s isupper(w[1])&&print(w[1])end

Explanation:
This is my first code-golf. Pretty straight forward. Split the words, print 1rst upper letter of each.
Probably easy to do better using regex but I am new to this

Welcome to PPCG! I'm out of votes right now, I'll upvote this later.

@StepHen I've gotchoo covered. :P

C#, 84 78 bytes
using System.Linq;s=>s.Where((c,i)=>c>64&c<91&(i>0?s[i-1]==32|s[i-1]==45:1>0))

Saved 6 bytes thanks to @jkelm.
Try it online!
Full/Formatted Version:
using System.Collections.Generic;
using System.Linq;

class P
{
    static void Main()
    {
        System.Func<string, IEnumerable<char>> f = s => s.Where((c, i) => c > 64 & c < 91 & (i > 0 ? s[i-1] == 32 | s[i-1] == 45: 1 > 0));

        System.Console.WriteLine(string.Concat(f("Self-contained Underwater Breathing Apparatus")));
        System.Console.WriteLine(string.Concat(f("a Programming Language")));
        System.Console.WriteLine(string.Concat(f("NATO Atlantic TREATY Organization")));
        System.Console.WriteLine(string.Concat(f("DEFCON 2")));
        System.Console.WriteLine(string.Concat(f("hello, world!")));
        System.Console.WriteLine(string.Concat(f("light-Emitting dioDe")));
        System.Console.WriteLine(string.Concat(f("What Does the Fox Say?")));
        System.Console.WriteLine(string.Concat(f("3D mov-Ies")));
        System.Console.WriteLine(string.Concat(f("laugh-Out Lou-D")));
        System.Console.WriteLine(string.Concat(f("Best friends FOREVE-r")));
        System.Console.WriteLine(string.Concat(f(" ")));
        System.Console.WriteLine(string.Concat(f("--  --a -  - --")));
        System.Console.WriteLine(string.Concat(f("--  -- -  - -- A")));

        System.Console.ReadLine();
    }
}

Why do you have to include using System.Linq in the byte count if using System.Collections.Generic is exempt? Is there some consensus on which using's are countable?

@DaveParsons using System.Linq; is needed for the Linq code in my answer. However, IEnumerbale<char> is not part of the answer and that is the part of the code that needs using System.Collections.Generic; to compile.

makes sense; thanks for clarification.

You could save a few bytes by checking uppercase using the chars as ints. c>64&c<91 should net you 6 bytes.

@jkelm Nice :) I always forget about that trick!

No problem. You need every little thing you can get to be competitive in C# apparently. I have been avoiding Linq because of the using bloat, but it appears that didn't stop you :)

@jkelm It's always a toss up because of the using but with Linq you can usually have an implicit return which ends up saving bytes so you lose less than you might think.

Can't you replace s[i-1]==32|s[i-1]==45 with s[--i]==32|s[i]==45 ?

Python, 53 bytes
import re
lambda s:re.findall("(?<=[ -])[A-Z]"," "+s)

Try it online!
A simple regular expression with a lookahead for space or dash.  Rather than matching the start, prepend a space.

Edited in a TIO link with MrXCoder's test suite.

Thanks @StepHen -- you beat me to it and saved me the effort

50

C# (.NET Core), 108 bytes
n=>{var j="";n=' '+n;for(int i=0;++i<n.Length;)if(" -".IndexOf(n[i-1])>=0&n[i]>64&n[i]<91)j+=n[i];return j;}

Try it online!

Haven't checked but changing the if to a ternary might save you bytes. This starts at index 2 instead of 1, just change int i=1 to int i=0 to fix it.  Other than that I don't think there's much more you can do here.

A ternary wouldn't help here, as it would be the same byte count as an if statement. However, you are correct in that I need to change the initial i value

I wasn't entirely sure but they usually come out shorter so it is always worth a check.

05AB1E, 11 bytes
'-ð‡ð¡ζнAuÃ

Try it online!

Japt, 19 16 14 bytes
-2 bytes thanks to Shaggy
f/^| |-)\A/ mÌ

Try it online!

Since you're using v2, I think you can change "(^| |-)%A" to /^| |-)\A/ to save a byte

mf\A -> mÌ to save 2 bytes.

Perl 5, 25 bytes
24 bytes code + 1 for -n.
Annoying that grep -P support variable length look-behind but Perl doesn't :(.
print/(?:^| |-)([A-Z])/g

-1 byte thanks to @Dada!
Try it online! - includes -l to run all tests at once.

You can do extremely way much so better: Try it online! ;-)

@Dada Hah! Of course... I'm out ATM but I'll update when I get back. Thanks! I'm quite disappointed I couldn't get s/// or $_= to negate the print...

Yeah, I was looking for a single s/// to solve this but it's not obvious... I'm at work, maybe I'll give it another try later!

Swift 5, 110 bytes
-5 thanks to Cœur
import UIKit
func f(s:[String]){for i in zip(s,[" "]+s){if i.0.isUppercase()&&"- ".contains(i.1){print(i.0)}}}

Detailed Explanation

import Foundation - Imports the module Foundation that is vital for zip(), the main piece of this code.

func f(s:[String]){...} - Creates a function with a parameter s, that is a list of Strings, representing the characters of the input.

for i in zip(s,[" "]+s){...} - Iterates with i through the zip of the input and the input with a space added in the beginning, which is very helpful for getting the previous character in the String.

if - Checks whether:

i.0==i.0.uppercased() - The current character is uppercase,

&&"- ".contains(i.1) - and If the previous character is a space or a dash.

If the above conditions are met, then:

print(i.0) - The character is printed, because it is part of the acronym.

-5 with import UIKit instead of import Foundation.

Jelly,  11  10 bytes
-1 byte thanks to Erik the Outgolfer (Ḳ splits at spaces >_<)
⁾- yḲḢ€fØA

A monadic link taking and returning lists of characters.
As a full program accepts a string and prints the result.
Try it online! or see a test suite.
How?
⁾- yḲḢ€fØA - Link: list of characters, x       e.g. "Pro-Am Code-golf Association"
   y       - translate x with:
⁾-         -   literal list of characters ['-',' '] "Pro Am Code golf Association"
    Ḳ      - split at spaces               ["Pro","Am","Code","golf","Association"]
     Ḣ€    - head each (1st character of each)      "PACgA"
        ØA - yield uppercase alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
       f   - filter keep                            "PACA"
           - if running as a full program: implicit print

Umm, why not use Ḳ instead of ṣ⁶?

Heh, because I forgot about it. Thanks!

MATL, 19 bytes
'- 'X{&Yb'^[A-Z]'XX

Try it online!

Brachylog, 25 23 22 bytes
,Ṣ↻s₂ᶠ{h∈" -"&t.∧Ạụ∋}ˢ

Try it online!
(-2 bytes thanks to @Fatalize.)
,Ṣ↻                      % prepend a space to input
   s₂ᶠ                   % get all substrings of length 2 from that, to get prefix-character pairs
      {              }ˢ  % get the successful outputs from this predicate:
       h∈" -"              % the prefix is - or space
               &t.∧        % then the character is the output of this predicate if:
                  Ạụ∋        % the alphabet uppercased contains the character

You can use Ṣ instead of " " to save two bytes

PowerShell, 43 bytes
''+($args|sls '(?<=^| |-)[A-Z]'-a -ca|% m*)

Try it online!
Unrolled:
''+($args|select-string '(?<=^| |-)[A-Z]' -allmatches -caseSensitive|% matches)

Python 3, 67 bytes
lambda x:[c[0]for c in x.replace("-"," ").split()if c[0].isupper()]

Try it online!

Bash (grep), 29 28 bytes
grep -oP'(?<=^| |-)[A-Z]' a

A port of my python answer but because pgrep supports variable length lookbehinds it's noticeably shorter (even accounting for the overhead of python).  Stick the test cases in a file called a, output is 1 character per line.
-1 Thanks to Neil

^| |- might be a shorter test?

@Neil that works here, thanks.  Missed it because it doesn't work in Python

Pyth, 12 bytes
@rG1hMcXz\-d

Test suite here.

Python 3, 73 70 bytes
lambda n:[n[x]for x in range(len(n))if'@'<n[x]<'['and(' '+n)[x]in' -']

Try it online!

Explanation

lambda n: - Creates an anonymous lambda-function with a String parameter n.

n[x] - Gets the character of n at index x.

for x in range(len(n)) - Iterates from 0 to the length of n, naming the variable x.

if - Checks:

'@'<n[x]<'[' - If the character is uppercase,

and(' '+n)[x]in' -' - And if it is preceded by a space or a dash in the String formed by a space and n.

Is it bad that I read that as i supper, and I have no idea why?

@TheLethalCoder It's .isupper(), I have no idea what you read :p

JavaScript (SpiderMonkey), 62 bytes
n=s=>(""+s.match(/([ -]|^)[A-Z]/g)).replace(/[ \-,]|null/g,"")

Try it online!

Pyth, 12 bytes
Created one year after the initial answer.
rI#1hMcXQ\-d

Try it online!
Pyth, 21 bytes
Initial answer.
:+dQ"(?<=[ -])[A-Z]"1

Try it online!

-|  is one byte less than [ -]

@ATaco That does not seem to work

Pyth, 15 16 bytes
@rG1<R1:w"[ -]"3

Test suite

QuadS, 17 bytes
(?<=^| |-)[A-Z]
&

Try it online!

Lua, 79 75 bytes
for i=1,#t do for i in(" "..t[i]):gmatch"[%-| ]%u"do print(i:sub(2))end end
Try it!
I stuck a print() before the final end in the try it version because otherwise it's a mess. This program perfectly adheres to the requirements of I/O and matching, but without that extra new line it's pretty hard to read.
Input is given in the form of a table of number:string , number incrementing by 1 each time and starting at 1.
Explanation:
It for loops through a gmatch of each input string. The gmatch search is as follows:
[%-| ] - Group, search for a - or a space
%u - Search for an uppercase character
Then for each match, it prints it out minus the preceding dash or space
Edit: Golfed 4 bytes by removing the declaration of 'a' and adding the space to the input inside the for loop in, as well as changing the sub input to just 2 rather than 2,2 (which produce equivalent results)

C++, 168 bytes
#include<string>
auto a=[](auto&s){auto r=s.substr(0,1);if(r[0]<65||r[0]>90)r="";for(int i=1;i<s.size();++i)if(s[i]>64&&s[i]<91&&(s[i-1]==32||s[i-1]==45))r+=s[i];s=r;};

Output done via the parameter

Would it be possible to completely remove #include<string> and assume the argument s is a std::string?

RProgN 2, 18 bytes
`-` rû#ùr.'[a-z]'-

Explained
`-` rû#ùr.'[a-z]'-
`-`                     # Push "-" literal, and " " literal.
    r                   # replace, Replaces all "-"s with " "s.
     û                  # Split, defaultly by spaces.
      #ù                # Push the head function literally.
        r               # Replace each element of the split string by the head function, which gets each first character.
         .              # Concatenate, which collapses the stack back to a string.
          '[a-z]'-      # Push the string "[a-z]" literally, then remove it from the string underneith, giving us our output.

Try it online!

PHP, 62 bytes
for(;~$c=$argn[$i++];$p=$c!="-"&$c!=" ")$c<A|$c>Z|$p?:print$c;

Run as pipe with -nR or try it online.
other solutions:
foreach(preg_split("#[ -]#",$argn)as$s)$s[0]>Z|$s<A?:print$s[0];  # 64 bytes
preg_match_all("#(?<=\s|-)[A-Z]#"," $argn",$m);echo join($m[0]);  # 64 bytes
preg_match_all("#(?<=\s|-)\p{Lu}#"," $argn",$m);echo join($m[0]); # 65 bytes

Ruby, 55 30 29 + 1 = 56 31 30 bytes
Run with -e flag (+1)
p (?-+$_).scan(/[ -]([A-Z])/)

Explanation: this is much easier as a regex if there's a hyphen in the beginning to match
Note: this returns a 2d list of characters like [["S"], ["U"], ["B"], ["A"]], which should be fine because

Output may be in the format of "TEST", ["T","E","S","T"], or whatever else works for you.

Use a negative lookbehind regex to save 3 bytes.

JavaScript, 49 bytes
s=>(s.match(/(^| |-)[A-Z]/g)||[]).map(x=>x[1]||x)

Try it online

Japt, 6 bytes
Outputs an array of characters, or the empty array.
f"%b%A

Try it

SNOBOL4 (CSNOBOL4), 86 bytes
	S =' ' INPUT
S	S ANY(' -') ANY(&UCASE) . X REM . S	:F(O)
	O =O X	:(S)
O	OUTPUT =O
END

Try it online!
	S =' ' INPUT					;* prepend a space
S	S ANY(' -') ANY(&UCASE) . X REM . S	:F(O)	;* find an initial
	O =O X	:(S)					;* add to output string
O	OUTPUT =O					;* print
END

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

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


text:
N-Queens Puzzle
(Despite 60+ questions tagged chess, we don't have a simple n-queens challenge.)
In chess, the N-Queens Puzzle is described as follows: Given an n x n chessboard and n queens, arrange the queens onto the chessboard so that no two queens are threatening each other. Below is an example solution for n = 8, borrowed from Wikipedia.

Or, in ASCII rendering:
xxxQxxxx
xxxxxxQx
xxQxxxxx
xxxxxxxQ
xQxxxxxx
xxxxQxxx
Qxxxxxxx
xxxxxQxx

The challenge here will be to take input n and output an ASCII representation of a solution to the n-Queens puzzle. Since there are more than one possible solution (e.g., at the least, a rotation or reflection), your code only needs to output any valid solution.
Input
A single positive integer n with n >= 4 in any convenient format. (n=2 and n=3 have no solutions, and n=1 is trivial, so those are excluded)
Output
The resulting ASCII representation of a solution to the N-queens puzzle, as outlined above. You may choose any two distinct ASCII values to represent blank spaces and queens. Again, this can be output in any suitable format (single string, a list of strings, a character array, etc.).
Rules

Leading or trailing newlines or whitespace are all optional, as well as whitespace between characters, so long as the characters themselves line up correctly.
You can either use an algorithm to calculate the possible positions, or use the explicit "stair-step" style of solution, whichever is golfier for your code.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples
n=4
xQxx
xxxQ
Qxxx
xxQx

n=7
xxQxxxx
xxxxxxQ
xQxxxxx
xxxQxxx
xxxxxQx
Qxxxxxx
xxxxQxx

n=10
xxxxQxxxxx
xxxxxxxxxQ
xxxQxxxxxx
xxxxxxxxQx
xxQxxxxxxx
xxxxxxxQxx
xQxxxxxxxx
xxxxxxQxxx
Qxxxxxxxxx
xxxxxQxxxx

Related.

Could you give testcases for odd inputs?

@Cowsquack Added n=7 example

@KeyuGan Neither of those have the [tag:code-golf] tag, so I don’t think they’re even candidate dupes

Could we output an array of number instead of an array of characters?

@KeyuGan Something like the MATL answer? Yeah, that's fine.

@AdmBorkBork was "You can either use an algorithm to calculate the possible positions, or use the explicit "stair-step" style of solution, whichever is golfier for your code."  meant to exclude non-deterministic solutions such as loop-with-random-permute&check?

@JonathanAllan No such exclusion was intended, so long as the program finishes in finite time with probability one (as standard for all submissions).

Are one of these the relevant oeis sequence?

@programmer5000 The first result, A000170, is the relevant problem in that it tells how many solutions exist, but none of OEIS gives the actual board positions, which is what this question is asking.

C, 114 bytes
Q(n,o,y){o=n%2;n-=o;for(y=0;y<n+o;++y)printf("%*c\n",y<n?o+n-(n+y%(n/2)*2+(n%6?y<n/2?n/2-1:2-n/2:y<n/2))%n:0,81);}

Directly prints a solution in O(1) time.

It's not clear to me how it can be O(1) with a loop repeating n times. How can all of those calculations always be done in constant time?

@poi830 I mean O(1) computation time per row to determine the position of the queen.

couldn't you save a few by making a new variable for n/2?

Suggest n-=o=n%2;for(y=n+o;y--;) instead of o=n%2;n-=o;for(y=0;y<n+o;++y)

MATL, 33 32 27 bytes
`x,GZ@]1Z?tt!P!,w&TXds]h1>a

Try it online!
Semi-brute force, non-determistic approach:

Generate a random permutation of row positions
Generate a random permutation of column positions
Check that no queens share a diagonal or anti-diagonal
Repeat if necessary.

The obtained solution is random. If you run the code again you may get a different valid configuration. Running time is also random, but the longest test case (n = 10) finishes in about 30 seconds in TIO most of the time.

I'm not sure this counts as a solution, given that it doesn't always give the correct answer.

@junkmail Huh? There is no such thing as the correct answer, as there a several solutions (as stated by the challenge). The code always gives a correct answer, just not the same every time

It's theoretically possible for the program to run arbitrarily many times and still fail to give an answer.

@junkmail But it finishes in finite time with probability one

Hmm, I read "You can either use an algorithm to calculate the possible positions, or use the explicit "stair-step" style of solution, whichever is golfier for your code." as excluding this approach, but I wasn't sure and forgot to ask. I have now. EDIT: the approach has been approved by OP.

@JonathanAllan Thanks for helping clarify this

The problem with generating random permutations is that you are probably relying on a pseudorandom generator to do it. And that pseudorandom generator will ultimately just cycle through a finite sequence. So it could, in fact, simply run forever. The cycle would be very long though.

@JamesHollis I disagree. That could make some permutations more likely than others, but it wouldn't prevent any permutation from appearing. So the solution would eventually be reached. And in addition, assuming the random generator is ideal is usually accepted

Befunge, 122 bytes
&::2%-v>2*00g++00g%00g\-\00g\`*4>8#4*#<,#-:#1_$55+"Q",,:#v_@
/2p00:<^%g01\+*+1*!!%6g00-2g01\**!!%6g00-g012!:`\g01:::-1<p01

Try it online!
This is more or less based on the C solution by orlp.
Explanation

 Read the number of queens, q, from stdin and calculate two variables for later use: n = q - q%2, and hn = n/2
 Start the main loop, iterating r, the row number, from q down to 0, decrementing at the start of the loop, so the first r is q minus 1.
 Calculate the offset of the queen in each row with the following formula:
offset = (n - (
  (hn <= r) * (2 - hn) * !!(n % 6) +
  (hn > r) * ((hn - 2) * !!(n % 6) + 1) +
  (y % hn * 2) + n
) % n) * (n > r)

 Output offset space characters to indent the queen's position for the current row, plus one additional space just because it makes the output loop easier.
 Output the Q for the queen, followed by a newline to move to the next row.
 Test if r is zero, in which case we've reached the end of the board and can exit, otherwise we repeat the main loop again.

Mathematica, 103 108 110 117 bytes
-5 bytes for DuplicateFreeQ -> E!=##&@@@
-7 bytes for ReplacePart[Array[],] -> SparseArray[]
SparseArray[Thread@#&@@Select[Permutations@Range@#~Tuples~2,And@@(E!=##&@@@{#-#2,+##})&@@#&]->1,{#,#}]&

Return a 2D-array. It takes 2.76s to calculate f[6] and 135s for f[7]. (In the current version, - becomes 0 and Q to 1.

The algorithm is similar to MATL answer but here the code is completely brute-force.

C - 222 bytes
v,i,j,k,l,s,a[99];main(){for(scanf("%d",&s);*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&&(!k&&!!printf(2+"\n\n%c"-(!l<<!j)," #Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&&v&&v-i+j&&v+i-j))&&!(l%=s),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i]);}

The code is not mine, but from the IOCCC. I hope I'm not breaking any rules. Also, this displays all solutions for N between 4 and 99. I'll try to get a TIO link later.

As this code isn't yours, could you convert it into a Community Wiki? (just click the button below the editing window that says "Community Wiki")

Hi QuaerendoInvenietis and welcome to PPCG. As it's currently written, this doesn't seem to take a particular number as input and output only that solution.

Retina, 136 bytes
.+
$*

$_;$`Q¶
( +)\1( ?);
:$1;
:( +);\1\1
$1$1
:((   )+);( *)
 $1$1% $3$3
: ( +);( \1)?( *)
 $1 $1%$#2$* $#2$* $#2$* $1$3$3
( +)%\1?

Try it online! Port of @orlp's excellent C answer. Explanation:
.+
$*

Convert to unary, using spaces (there is a space after the *).
$_;$`Q¶

Create N rows with N spaces, a ;, then 0..N-1 spaces, then a Q. The remaining stages apply to all rows.
( +)\1( ?);
:$1;

Integer divide N by 2. (Also wrap the result in :; to make it easier to anchor patterns.)
:( +);\1\1
$1$1

If the loop index equals N/2*2, then just leave that many spaces.
:((   )+);( *)
 $1$1% $3$3

If N/2 is a multiple of 3, then take double the loop index plus one, modulo N/2*2+1.
: ( +);( \1)?( *)
 $1 $1%$#2$* $#2$* $#2$* $1$3$3

Otherwise, take double the loop index plus (N/2-1) plus an extra 3 in the bottom half of the board, modulo N/2*2.
( +)%\1?

Actually perform the modulo operation.

Python 3, 204 189 bytes
import itertools as p
n=int(input())
r=range(n)
b='.'*(n-1)+'Q'
for c in p.permutations(r):
 if len(set((x*z+c[x],z)for x in r for z in[1,-1]))==n+n:[print(*(b[x:]+b[:x]))for x in c];break

Brute force search through all permutations. I could remove the * and print the list comprehensions, but they look awful.
Output:
10
Q . . . . . . . . .
. . Q . . . . . . .
. . . . . Q . . . .
. . . . . . . Q . .
. . . . . . . . . Q
. . . . Q . . . . .
. . . . . . . . Q .
. Q . . . . . . . .
. . . Q . . . . . .
. . . . . . Q . . .

Slightly ungolfed:
import itertools as p
n=int(input())
r=range(n)
b='.'*(n-1)+'Q'
for c in p.permutations(r):
    if len(set( (x*z+c[x],z) for x in r for z in[1,-1] )) == n+n:
        [print(*(b[x:] + b[:x])) for x in c]
        break

Jelly, 24 21 bytes
,JŒc€IF€An/PC
ẊÇ¿=þRG

Try it online!
Assuming each queen are placed on separate rows, we only need to find the column indices to place each queen at to avoid conflicts, which can be found by generating a random permutation of [1, 2, ..., n] and testing it.
Explanation
,JŒc€IF€An/PC  Helper. Input: permutation of [1, 2, ..., n]
 J             Enumerate indices, obtains [1, 2, ..., n]
,              Join
  Œc€          Find all pairs in each
     I         Calculate the difference of each pair
      F€       Flatten each
        A      Absolute value
               (We now have the distance in column between each queen and
                the distance in rows between each queen. If they are unequal,
                the queens do not conflict with each other)
         n/    Reduce using not-equals
           P   Product, returns 1 only if they are all unequal
            C  Complement
               Returns 1 when there is a conflict, else 0

ẊÇ¿=þRG  Main.  Input: n
Ẋ        Shuffle (When given an integer, it will shuffle [1, 2, ..., n])
 Ç¿      While the helper returns 1, continue shuffling
     R   Range, gets [1, 2, ..., n]
   =þ    Equality table (Generates the board as a matrix)
      G  Pretty-print the matrix

Can't you use Œc€ instead of œc€2 for -1?

Charcoal, 44 bytes
Ｎθ≔÷θ²ηＥθ◧Q⊕⎇⁼ι⊗ηι⎇﹪η³﹪⁺⁺⊗ι⊖η×³¬‹ιη⊗η﹪⊕⊗ι⊕⊗η

Try it online! Link is to verbose version of code. Another port of @orlp's excellent C answer.

APL (Dyalog Unicode), 18 bytesSBCS
Full program prompting for n from stdin. Prints space-separated solution to stdout using · for empty squares and ⍟ for Queens.
⎕CY'dfns'
⊃queens⎕

Try it online!
⎕CY'dfns' Copy the "dfns" library
⎕ get input from stdin
queens find all truly unique Queens' solutions (no reflections or rotations)
⊃ pick the first solution

Haskell, 145 bytes
The obvious brute force approach:
b=1>0
t[]=b
t(q:r)=all(/=q)r&&foldr(\(a,b)->(abs(q-b)/=a&&))b(zip[1..]r)&&t r
q n|y<-[1..n]=(\q->(' '<$[1..q])++"Q")<$>[x|x<-mapM(\_->y)y,t x]!!0

Try it online!

J, 49 bytes
i.=/0({(1-.@e.,)@(([:(=#\){.|@-}.)\."1)#])!A.&i.]

Try it online!
Brute force by testing all permutations of length n.

Swift 5.9, 251 bytes
let f={n->[[Bool]] in
var q=[(Int,Int)](),z=0..<n
func d(_ r:Int){for c in z{if q.allSatisfy{(x,y)in !(x==r||y==c||abs(x-r)==abs(y-c))}{q+=[(r,c)]
d(r+1)
if q.count==n{break}
q.removeLast()}}}
d(0)
return z.map{r in z.map{c in q.contains{$0==(r,c)}}}}

The brute-force approach. I think.
This closure returns a 2D Array of Bools. true means there's a queen there; false means that there's nothing there.

Uiua, 29 characters
≡(+@@=⇡)⧻.-1∵⟨⌈÷2-|-⌊÷2⟩◿2.⇡.

Apparently any grid output is enough:
≡(=⇡)⧻.∵⟨-1⌈÷2-|-⌈÷2⟩◿2.⇡.

Try it here!


text:
Collapse Adjacent Duplicates
Challenge
Given a list of integers, return the list of these integers after repeatedly removing all pairs of adjacent equal items.
Note that if you have an odd-length run of equal numbers, one of them will remain, not being part of a pair.
Example:
[0, 0, 0, 1, 2, 4, 4, 2, 1, 1, 0]

First, you should remove 0, 0, 4, 4, and 1, 1 to get:
[0, 1, 2, 2, 0]

Now, you should remove 2, 2:
[0, 1, 0]

And this is the final result.
Test Cases
[] -> []
[1] -> [1]
[1, 1] -> []
[1, 2] -> [1, 2]
[11, 11, 11] -> [11]
[1, 22, 1] -> [1, 22, 1]
[-31, 46, -31, 46] -> [-31, 46, -31, 46]
[1, 0, 0, 1] -> []
[5, 3, 10, 10, 5] -> [5, 3, 5]
[5, 3, 3, 3, 5] -> [5, 3, 5]
[0, -2, 4, 4, -2, 0] -> []
[0, 2, -14, -14, 2, 0, -1] -> [-1]
[0, 0, 0, 1, 2, 4, 4, 2, 1, 1, 0] -> [0, 1, 0]
[3, 5, 4, 4, 8, 26, 26, 8, 5] -> [3]
[-89, 89, -87, -8, 8, 88] -> [-89, 89, -87, -8, 8, 88]

Scoring
This is code-golf, so the shortest answer in each language wins!

Sandbox for those who can see deleted posts

It doesn't matter, they are all equal. The meaning of this phrase is that [14, 14, 14] collapses to [14]

Misread the challenge, sorry. Thought you had to remove all pairs of numbers increasing by 1 (1,2, 11,12, etc.)

Can we take input as a delimited string?

@Shaggy Yes you may

Thanks :) In that case, would trailing or leading spaces be acceptable in the output?

Yes, both are fine

Could you add a test case such as -89,89,-87,-8,-88? Both my (unposted) Japt solution and Fry's Retina solution fail there, outputting --87,8.

Jelly, 10 bytes
Œgœ^/€FµÐL

Try it online!
How it works
Œgœ^/€FµÐL  Main link. Argument: A (array)

       µ    Combine all links to the left into a chain.
Œg              Group all adjacent equal items.
    /€          Reduce each group by...
  œ^                symmetric multiset difference.
                In each step, this maps ([], n) to [n] and ([n], n) to [], so the
                group is left with a single item if its length is odd, and no items
                at all if its length if even.
      F         Flatten the resulting array of singleton and empty arrays.
        ÐL  Apply the chain until the results are no longer unique. Return the last
            unique result.

Using Ẏ instead of F would make you support lists in your list too.

No, œ^ relies on integer-to-array promotion here. Since 1D arrays don't get promoted to 2D arrays, it won't work for anything except an array of numbers.

Heh...I mean you could've just used ŒgWẎ$œ^/$€ẎµÐL...oh wait that's too naive. :P

Mathematica 29 bytes
This repeatedly removes pairs of equal adjacent elements, a_,a_ until there are none left.
#//.{b___,a_,a_,c___}:>{b,c}&

Retina, 17 15 bytes
+m`^(.+)¶\1$¶?

Try it online!
Saved 2 bytes thanks to Neil and Martin!
Replaces each pair of numbers with nothing. This process loops until no changes are made.

Worked up an identical solution in Japt before spotting this. Unfortunately, we both fail on inputs such as -89 89 -87 -88 -88, which outputs --87.

@Shaggy Thanks, I corrected it by adding a boundary check and using _ to denote negatives, as is common in some languages.

I've since discovered that this'll also fail on _89 89 _87 _8 _88, outputting _89 89 _87 8. Sorry :\

@Shaggy Don't be sorry! Thanks for finding the problem!  I added another boundary check to fix that case.

Nicely done :) Do you mind me posting my Japt solution seeing as it's now extremely derivative of this?

You could save 2 bytes by requiring a newline-delimited list.

@Shaggy Go ahead!

@Neil I only see how to save 1 (\S -> .). As far as I can tell the rest is the same?

@FryAmTheEggman Not sure whether that's what Neil meant but you could then also use m to turn the \bs into ^ and $.

If you take input as a space-separated list (with a trailing space) on a single line, you can do the same thing as my sed solution in 13 bytes (or maybe fewer, since I don't really know Retina).

@Jordan Thanks, but this answer was specifically written to handle what I would think is a "list" in Retina: some tokens separated by a consistent separation token, perhaps being bookended by another token. Using trailing whitespace as a requirement feels like its not really in the spirit of a list. In any case, feel free to post that as a separate answer!

Python 2, 57 bytes
r=[]
for x in input():r+=x,;r[-2:]*=r[-2:-1]!=[x]
print r

Try it online!
Iteratively constructs the output list by appending the next element, then chopping off the end if the appending element equals the one before it. Checking the second-to-last element r[-2:-1]!=[x] turns out awkward because it's possible the list has length only 1.

Awesome answer, well done :)

Jelly, 15 bytes
Œr;ṪḂ$$€x/€FµÐL

Try it online!
Explanation
Œr;ṪḂ$$€x/€FµÐL  Main Link
Œr               Run-length encode
  ;              Concatenate (?)
       €         For each element
   ṪḂ$$          Is the last element odd?
          €      For each element    // Non-breaking alternative
        x/       Reduce by repeating // for run-length decode
           F     Flatten
            µ    (New monadic link)
             ÐL  Repeat until results are no longer unique

-1 byte thanks to miles, and fixed :)

@FryAmTheEggman Fixed; thanks!

I'm not sure if throwing an error and leaving the output empty counts as a correct solution. You program throws ValueError: not enough values to unpack (expected 2, got 0) for test case [1,2,2,1]. Also note that empty output is different from [] and 2 is different from [2].

13 bytes with Œr;ṪḂ$$€ŒṙµÐL. To avoid the error, replace Œṙ with x/€F since run-length decode is throwing an error when given an empty list. To see the output as a list, tacking ŒṘ will show it.

@ThePirateBay Jelly's representation of an empty list is - empty, of one item - just that item, and of multiple items - a bracketed and comma separated list. The submission is of a link (function) not a full program (much like a lambda would be in Python) - to see a more "normal" view place ÇŒṘ in the footer to call the last link (Ç) and print a Python representation (ŒṘ). The error might not be acceptable however.

@JonathanAllan. Ok, I realized that Jelly's string representation of a list is acceptable. The main point of my first comment is to mention that the error is thrown when the list become empty.

@miles Thanks. That fixes the error and saves a byte. :)

JavaScript (ES6), 54 53 bytes
Saved 1 byte thanks to @ThePirateBay
f=a=>1/a.find(q=>q==a[++i],i=-2)?f(a,a.splice(i,2)):a

Naive recursive solution, may be improvable.

You can check current and previous element instead of current and next one, so you can replace i=0 with i=-2 and i-1 with i which is -1 byte in total.

@guest44851 Thanks, but... wouldn't that mean I'd need to change it to i+1? (I tried this before with moving the ++ as well and couldn't figure it out, though I only had about a minute to do so)

You can see that it works properly.

@ThePirateBay By golly, you're right! But how?

MATL, 7 bytes
t"Y'oY"

For some of the test cases where the result is empty the program exits with an error, but in any case it produces the correct (empty) output.
Try it online! Or verify the test cases with non-empty output.
Explanation
t     % Implicit input. Duplicate
"     % For each (i.e. do as many times as input size)
  Y'  %   Run-length encode. Gives array of values and array of run lengths
  o   %   Parity, element-wise. Reduces run-lengths to either 0 or 1
  Y"  %   Run-length decode. Gives array of values appearing 0 or 1 times;
      %   that is, removes pairs of consecutive values
      % Implicit end. Implicit display

Consider input
0 0 0 1 2 4 4 2 1 1 0

Each iteration removes pairs of consecutive pairs. The first iteration reduces the array to
0 1 2 2 0

The two values 2 that are now adjacent were not adjacent in the initial array. That's why a second iteration is needed, which gives:
0 1 0

Further iterations will leave this unchanged. The number of required iterations is upper-bounded by the input size.
An empty intermediate result causes the run-length decoding function (Y") to error in the current version of the language; but the ouput is empty as required.

Could you add an explanation? I'd like to understand how you beat me so soundly. :P

@Dennis Sure! I had forgotten. Done :-)

Ah, RLE pushes two arrays. That's useful.

x86 Machine Code (32-bit protected mode), 36 bytes
52
8B 12
8D 44 91 FC
8B F9
8D 71 04
3B F0
77 10
A7
75 F9
83 EF 04
4A
4A
A5
3B F8
75 FB
97
EB E7
58
89 10
C3

The above bytes of machine code define a function that takes an array as input, collapses adjacent duplicates in-place, and returns to the caller without returning a result. It follows the __fastcall calling convention, passing the two parameters in the ECX and EDX registers, respectively.
The first parameter (ECX) is a pointer to the first element in the array of 32-bit integers (if the array is empty, it can point anywhere in memory). The second parameter (EDX) is a pointer to a 32-bit integer that contains the length of the array.
The function will modify the elements of the array in-place, if necessary, and also update the length to indicate the new length of the collapsed array. This is a bit of an unusual method for taking input and returning output, but you really have no other choice in assembly language. As in C, arrays are actually represented in the language as a pointer to the first element and a length. The only thing a bit weird here is taking the length by reference, but if we didn't do that, there would be no way to shorten the array. The code would work fine, but the output would contain garbage, because the caller wouldn't know where to stop printing elements from the collapsed array.
Ungolfed assembly mnemonics:
; void __fastcall CollapseAdjacentDuplicates(int * ptrArray, int * ptrLength);
; ECX = ptrArray              ; ECX = fixed ptr to first element
; EDX = ptrLength
   push  edx                  ; save pointer to the length
   mov   edx, [edx]           ; EDX = actual length of the array
   lea   eax, [ecx+edx*4-4]   ; EAX = fixed ptr to last element

FindAdjacentPairs:
   mov   edi, ecx             ; EDI = ptr to element A
   lea   esi, [ecx+4]         ; ESI = ptr to element B
FindNext:
   cmp   esi, eax             ; is ptr to element B at end?
   ja    Finished             ; if we've reached the end, we're finished
   cmpsd                      ; compare DWORDs at ESI and EDI, set flags, and increment both by 4
   jne   FindNext             ; keep looping if this is not a pair

; Found an adjacent pair, so remove it from the array.
   sub   edi, 4               ; undo increment of EDI so it points at element A
   dec   edx                  ; decrease length of the array by 2
   dec   edx                  ;  (two 1-byte DECs are shorter than one 3-byte SUB)
RemoveAdjacentPair:
   movsd                      ; move DWORD at ESI to EDI, and increment both by 4
   cmp   edi, eax             ; have we reached the end?
   jne   RemoveAdjacentPair   ; keep going until we've reached the end
   xchg  eax, edi             ; set new end by updating fixed ptr to last element
   jmp   FindAdjacentPairs    ; restart search for adjacent pairs from beginning

Finished:
   pop   eax                  ; retrieve pointer to the length
   mov   [eax], edx           ; update length for caller
   ret

The implementation was inspired by my C++11 answer, but meticulously rewritten in assembly, optimizing for size. Assembly is a much better golfing language. :-)
Note: Because this code uses the string instructions, is does assume that the direction flag is clear (DF == 0). This is a reasonable assumption in most operating environments, as the ABI typically requires that DF is clear. If this cannot be guaranteed, then a 1-byte CLD instruction (0xFC) needs to be inserted at the top of the code.
It also, as noted, assumes 32-bit protected mode—specifically, a "flat" memory model, where the extra segment (ES) is the same as the data segment (DS).

Python 2, 73 bytes
Since I do not have enough reputation to comment:
I just changed @officialaimm 's answer to use r!=[] instead of len(r) to save a byte.
Very clever solution to you, @officialaimm !
r=[]                            # create list that will hold final results. A new list is important because it needs to be removable.
for i in input():
 if r!=[]and r[-1]==i:r.pop()   # Ensure that we have at least 1 char added to the list (r!=[])... or that the last character of our final result isn't the current character being scanned. If that is, well, remove it from the final list because we do not want it anymore
 else:r+=[i]                    # Shorthand for r.append(i). This adds i to the final result
print r

Try it online!
It is, again, way too late... why am I even still up?

Python, 60 58 bytes
f=lambda a:a and(a[:1]+f(a[1:]))[2*(a[:1]==f(a[1:])[:1]):]

Try it online!

[a[0]] is a[:1]

@xnor So it is. Thanks!

Japt, 34 bytes
ó¥ k_l vÃ®ò k_l É}Ãc
ó¥ l ¥Ul ?U:ß

Recursively removes pairs of equal numbers until none exist.
Try it online! with the -Q flag to format the output array.
Run all test cases using my WIP CodePen.

Jelly, 12 bytes
ŒgṁLḂ$$€ẎµÐL

A monadic link taking and returning lists of numbers.
Try it online! or see a test suite
How?
ŒgṁLḂ$$€ẎµÐL - Link: list
         µÐL - perform the chain to the left until no changes occur:
Œg           -   group runs (yield a list of lists of non-zero-length equal runs)
      $€     -   last two links as a monad for €ach run:
     $       -     last two links as a monad:
   L         -       length (of the run)
    Ḃ        -       modulo 2 (1 if odd, 0 if even)
  ṁ          -     mould (the run) like (1 or 0) (yields a list of length 1 or 0 lists)
        Ẏ    -   tighten (make the list of lists into a single list)

ṁLḂ$$€ is equivalent to ḣLḂ$$€ which is equivalent to ṫḊ¿€3$ which you can replace with ṫḊ¿€3 here to form a dyad/nilad pair.

That does not work with, for example, an input with a run of length 4. What is the input to the dequeue at each iteration of the while loop?

You are supposed to be left with a list with 0 or 1 elements. If len(x) == 1, then Ḋ will return [] while if len(x) == 0 Ḋ will return 0, both being falsy values. The input to Ḋ is of course the current value, and ṫ will have the current value as left argument and 3 as the right. If len(x) == 4, then it would be the same as ṫ3ṫ3 or ṫ5 leaving you with [].

I can see what it is supposed to do, but is x in your description there really the current value? Try this out for size.

To be honest I do not know if that is the code or a bug :)

E.g. for [3, 3, 3, 3], since Ḋ returns [3, 3, 3] which is truthy, the next value would be [3, 3]. Since Ḋ now returns [3] which is still truthy, next value is [] Since Ḋ now returns 0, a falsy value, [] is our final result.

Btw this shouldn't be happening.

Let us continue this discussion in chat.

Batch, 133 bytes
@set s=.
:l
@if "%1"=="%2" (shift/1)else set s=%s% %1
@shift/1
@if not "%1"=="" goto l
@if not "%s:~2%"=="%*" %0%s:~1%
@echo(%*

I set s to . because Batch gets confused if there are only duplicates. I also have to use shift/1 so that I can use %0%s:~1% to set the argument list to the new array and loop.

I have to ask ... why? Good answer ... but why?

@Zacharý Because it's there.

@Zacharý In part, a good reason to golf in non-golfing languages is because this might actually be useful. No one is going to fire up a Jelly interpreter in real life to do this, but they might need to do it in a batch file!

Oh. that makes sense.

Python 2, 74 70 66 bytes

Thanks @SteamyRoot for 4 bytes: r instead of len(r) is enough to check emptiness of the list/stack.
Thanks @ovs for 4 bytes: better if condition [i]==r[-1:]

Python 2, 66 bytes
r=[]
for i in input():
 if[i]==r[-1:]:r.pop()
 else:r+=[i]
print r

Try it online!

If the purpose of len(r) is just to check whether or not the list is empty, you should be able to replace it by just r, I think?

66 bytes

@ovs Thanks a lot, that is awesome! (y)

Alternative 66 bytes long version, though only requiring three lines.

05AB1E, 15 bytes
[γʒgÉ}€нÐγ‚€gË#

Try it online!
Explanation
[γʒgÉ}€нÐγ‚€gË#
[               # Start infinite loop
 γ              # Group Array into consecutive equal elements
  ʒgÉ}          # Keep the subarrays with an uneven amount of elements
      €н        # Keep only the first element of each subarray
        Ð       # Triplicate the result on the stack
         γ      # Group the top element into consecutive equal elements
          ‚     # Wrap the top two items of the stack in an array
           €g   # Get the length of each subarray
             Ë# # Break if they are equal
                # Implicit print

05AB1E, 13 bytes
[DγʒgÉ}€нDŠQ#

Try it online!
Explanation:
[DγʒgÉ}€нDŠQ# Implicit input
[             Start infinite loop
 D            Duplicate
  γ           Split into chunks of equal elements
   ʒ  }       Filter by
    g           Length
     É          Odd? (0=falsy 1=truthy)
       €      Foreach command
        н     Head
         D    Duplicate
          Š   Push c, a, b
           Q  Equal? (0=falsy 1=truthy)
            # Break if true (i.e. equal to 1)

Haskell, 33 bytes
a!(b:c)|a==b=c
a!b=a:b
foldr(!)[]

Try it online!

Husk, 9 bytes
ωoṁ?I↓2εg

Try it online!
A bit shorter than Zgarb's existing answer.
Explanation
ωoṁ?I↓2εg
ωo        apply the following till a fixed point:
        g group adjacent values
   ?   ε  if the group is a singleton list
    I     leave as is
     ↓2   otherwise drop 2 elements
  ṁ       concatenate the results of that

PHP, 81 bytes
    function f(&$a){for($i=count($a);--$i;)$a[$i]-$a[$i-1]||array_splice($a,$i-1,2);}

function, call by reference or try it online.
fails for empty input; insert $i&& or $a&& before --$i to fix.

V, 10 bytes
òÍ¨.«©î±î*

Try it online!
Compressed Regex: :%s/\(.\+\)\n\1\n*.  The optional newline is so that it works at the end of the file also.  If I assume that there is a newline after the end it would be 8 bytes... but that seems like a stretch

R, 57 54 bytes
l=rle(scan());while(any(x<-!l$l%%2))l=rle(l$v[!x]);l$v

Try it online!
uses a run-length encoding to remove pairs.

dc, 84 78 bytes
[L.ly1-dsy0<A]sA[LtLtS.ly1+sy]sP[dStrdStr!=Pz1<O]sO[0syzdsz1<Oly0<Azlz>M]dsMxf

Try it online!
Unpacking it a bit, out of order in some attempt at clarity:

[0syzdsz1<Olydsx0<Alx1+lz>M]dsMxf The main macro M resets counter y to 0, retrieves the number of items on the stack, stores this in register z, then runs macro O if there are at least two items on the stack. Once O finishes, it loads counter y and copies it into register x before checking to make sure y is nonzero (meaning stack . has data). If this is the case, it runs macro A. Finally it checks whether the original stack size is larger than the current stack size and reruns itself if so. Once it has finished, it prints the stack with f.
[dStrdStr!=Pz1<O]sO Macro O temporarily stores the top two items on the stack into stack t. It then compares the top two items and runs macro P if they are not equal. Finally it checks whether or not there are at least two items on the stack, and runs itself if so.
[LtLtS.ly1+sy]sP Macro P takes the two items from stack t, pushes the top one back onto the main stack, and pushes the following one onto stack .. It then increments counter y.
[L.ly1-dsy0<A]sA Macro A takes stack . and turns it back into the primary stack. It does that, decrementing counter y until there's nothing left to push.

Edited for explanation, and to golf off 6 bytes as I was needlessly storing the size of the stack.

C++11, 161 bytes
#include<vector>
#include<algorithm>
using V=std::vector<int>;void f(V&v){V::iterator i;while((i=std::adjacent_find(v.begin(),v.end()))!=v.end())v.erase(i,i+2);}

The above code defines a function, f, that takes a std::vector<int> by reference, modifies it in place to collapse adjacent duplicates according to the specification, and then returns.
Try it online!
Before I checked the byte count, I thought this was pretty svelte code. Over 150 bytes is, however, not so good! Either I'm not very good at golfing, or C++ is not a very good golfing language…
Ungolfed:
#include <vector>
#include <algorithm>

using V = std::vector<int>;

void f(V& v)
{
   V::iterator i;

   // Use std::adjacent_find to search the entire vector for adjacent duplicate elements.
   // If an adjacent pair is found, this returns an iterator to the first element of the
   // pair so that we can erase it. Otherwise, it returns v.end(), and we stop.
   while ((i=std::adjacent_find(v.begin(), v.end())) != v.end())
   {
        v.erase(i, i+2);   // erase this adjacent pair
   }
}

C++ isn't the best golfing language. Nice use of std::adjacent_find! I wonder if you implemented this function yourself if it would be shorter, since you can remove #include <algorithm> as well

@musicman523 My first attempt did implement it by hand, although I used a little bit different algorithm. I was adapting the implementation of std::unique to do what I needed. But it takes a lot of code to do all the logic, and when I happened across std::adjacent_find, it was pretty obvious that that was a winner in terms of code size.

Husk, 10 bytes
ωoṁS↑o%2Lg

Try it online!
Explanation
ωoṁS↑o%2Lg
ω           Repeat until fixed point
 o          the following two functions:
         g   a) group adjacent elements
  ṁ          b) map over groups and concatenate:
        L     length of group
     o%2      mod 2
   S↑         take that many elements of group

Clojure, 100 bytes
#(loop[i % j[]](if(= i j)i(recur(mapcat(fn[p](repeat(mod(count p)2)(last p)))(partition-by + i))i)))

Not sure if this is the shortest possible.

Bash, 82 bytes
cat>b
while cat b>a
perl -pe 's/(\d+) \1( |$)//g' a>b
! diff a b>c
do :
done
cat a

There's probably a way out of all those cats, but I don't know it.

PHP, 74 bytes
function c(&$a){foreach($a as$k=>$v)$a[$k+1]===$v&&array_splice($a,$k,2);}

Function c calls by reference to reduce array. Try it online.
Interestingly this works in Php5.6 but not 7.

J, 38 bytes
;@(<@($~2|#)/.~0+/\@,}.~:}:)^:(0<#)^:_

Try it online!

GNU sed, 19 + 1 = 20 bytes
+1 byte for -r flag.
:
s/\b(\S+ )\1//g
t

Try it online!

Pyth, 10 bytes
Bit late to the party.
ueMf%hT2r8

Test Suite.

Japt -h, 11 bytes
£=òÎ®ò l1Ãc

Try it or run all test cases
£=òÎ®ò l1Ãc     :Implicit input of array U
£               :Map
 =              :  Reassign to U
  ò             :  Partition between elements where
   Î            :    The sign of their difference is truthy (not zero)
    ®           :  Map
     ò          :    Partitions of length 2
       l1       :    Filter elements of length 1
         Ã      :  End map
          c     :  Flatten
                :Implicit output of last element


text:
Challenge: Multiplication of integers a by b without multiplication symbols
This challenge is as follows.
(Uhoh no! Now everyone is going to use reciprocal division. Now all the answers are going to look the same and lose originality, ugh!)
Given two integers multiply them, ... but you can't use the multiplication symbols "*" and "x". As you probably know multiplication is just an extension of successive additions, so this challenge is definitely feasible, as for instance the product of 8 and 5 is five sums of 8 or eight sums of 5:
8 * 5 = 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5, & also ...
= 8 + 8 + 8 + 8 + 8
= 40
Restrictions/Conditions:
1) The two numbers are allowed to be any two integers.
2) The calculation should work on both positive and negative integers.
3) The multiplication product should be correct no matter the order in which the two integer factors are presented.
4) You cannot import any installable modules/libraries not native to the base functions of your programming language.
5) There is no need to worry about expanding the scope of either of the integer sizes as it is highly unlikely that either of the integers would overload your system memory.
6) You cannot use either of the operators "*" or "x" as multiplication operators.
7) In case anybody asks, this is multiplication in base 10, exclusively.
8) New Restriction: One multiplication function/operators are now banned. Sorry Jonathon. Creating a new operator is fine, but using any built in one function multiplication operators are banned.
Desired output is the following:
a x b=c

Again, "x" here is not to be used as an operator, just a character.
So if a is 5 and b is 8, then c should be 40, and vice-versa.
This is code-golf, so the shortest code in bytes wins!
Good luck!
Finally, if you could give a brief description of how your program works,
everyone will appreciate that, I'm sure. Thanks.

Possible duplicates

No, it is not a duplicate because in the other challenge the winning condition was the fastest program to calculate the product of two integers. In my question, the winning condition is the least amount of bytes. In the other question that links, addition operators were not allowed. Addition is allowed in my challenge.

Related.

Do X without Y in one of our things to avoid when writing challenges. The reason is primarily that elaborating a spec that doesn't essentially boil down to a worst abuse of the rules contest is very difficult, as evidenced by the answers that simply divide by the multiplicative inverse.

'built in one function multiplication operators are banned' : so an operator that takes a vector and returns the product of its elements would be banned?

That's correct.

J, 2 bytes
%%

x * y = x / (1 / y)
%%  Input: x (LHS), y (RHS)
 %  Reciprocal of y
%   Divide x by 1/y

Also, multiplication is addition after log, then computing the power using base e.
5  bytes
+&.^.

x * y = e^(log(x * y)) = e^(log(x) + log(y))
+&.^.  Input: x (LHS), y (RHS)
 & ^.  Natural log of x and y
+      Add them
 &.^.  Apply inverse of natural log to the sum
       NB. e^sum

0 == 0 (%%) 0 It does work @JonathanAllan

Also, 4 bytes: 1#.#

Well it works in Jelly as anything divided by inf is 0...

What it really does work with zeroes!? Huh, if that's true then it looks like you are winning!

Jelly, 12 3 bytes
Uh turns out this works - port of Mile's J answer
İ÷@

A dyadic link taking the two integers
Try it online!
How?
İ÷@ - Link: a, b
İ   - inverse a (i.e. 1/a - note: if a is 0 this yields inf)
 ÷@ - divide with reversed arguments (if a was 0, this is b divided by inf, which yields 0)

...which sure beats this:
Aẋ/SN¹⁸ṠSỊ¤?

A monadic link taking a list of the two integers and returning their product.
How?
Aẋ/SN¹⁸ṠSỊ¤? - Link: list [a, b]    e.g. [-7, -3]     [3, -7]          [7, 3]    or [3, 0]
A            - absolute values           [ 7,  3]     [3,  7]          [7, 3]       [3, 0]
 ẋ/          - reduce by repetition      [ 7, 7, 7]   [3,3,3,3,3,3,3]  [7, 7, 7]    []
   S         - sum                        21           21               21           0
           ? - if:
          ¤  -   nilad followed by link(s) as a nilad:
      ⁸      -     chain's left argument [-7, -3]     [3, -7]          [7, 3]       [3, 0]
       Ṡ     -     sign                  [-1, -1]     [1, -1]          [1, 1]       [1, 0]
        S    -     sum                    -2           0                2            1
         Ị   -     abs(v) <= 1?            0           1                0            1
    N        - then: negate                           -21                  negate(0)=0
     ¹       - else: do nothing           21                            21

Python 2, 31 bytes
lambda x,y:y and x/(1/float(y))

Try it online!
Old approach was longer, but then I remembered Math!:
Python 2, 49 bytes
lambda x,y:sum([x,-x][y<0]for i in range(abs(y)))

Try it online!

What happens if y is 0?

For the second one I think you can remove the space after [y<0]

For the 30 byter add y and  to cater for when y is 0 and the division errors. Also I think it's acceptable to return the float (get rid of int()) since the result will still be correct. Finally move to Python 3 and do away with the float() Try It Online! for 24 bytes.

Fixed divide by 0 error (thx Jonathon Allan; and 1byte saved in longer version (thx Conor O'Brien )

If you want to stick to Python 2 you can use 1./y to save six bytes.

y and x/y**-1 for 24 bytes in python 2

Ly, 17 bytes
n1-<ns>[<l+>1-]<u

A more difficult golf than I imagined...

R, 20 bytes
function(a,b)a/(1/b)

in R, a/Inf is 0. Moreover, in the R, we can actually see define * to be this operation instead of .Primitive("*") which is the standard multiplication operator. The TIO link shows the old and new values and demonstrates that we can use our new * operator as the infix multiplication operator.
Try it online!
3 Bytes:
%*%

the matrix multiplication operator. Implicitly converts numbers into matrices, so it returns a 1x1 matrix as a result, but that's stored as a length-1 vector in R, just like a single number is.
OR
%o%

Which is an alias for outer(x,y,'*') which also computes the correct value for numbers.

Brainfuck, 32 bytes
,>,[-<[->>+>+<<<]>>[-<<+>>]<]>>.

,>, take ascii input and put it in the first and second cells

[-  until the second cell is zero

    <[->>+>+<<<]> move the first cell value into the third and fourth cells

    >[-<<+>>]<    move the third cell to the first one again

] end loop. This layers the first value onto the fourth cell,
  as many times as the value in the second cell (= product of 1st & 2nd)

>>. print the fourth cell

Forth, 7 bytes ( But it's a cheat. )
: m * ; ( Renaming it is still using it. )

use:
10 11 m . 110  ok

Forth, 37 bytes ( the suggested loop )
: c 0 swap 0 ?do over + loop . drop ;

Use:
2 2 c  4  ok
0 0 c 0  ok
0 1 c 0  ok
1 0 c 0  ok
1 1 c 1  ok
1 2 c 2  ok
2 1 c 2  ok
1001 2002 c 2004002  ok

JavaScript (ES7), 14 bytes
(x,y)=>x/y**-1

Don't use '*'  .

@0x45 I'm not using *, I'm using **, which is a different operator.

Save a byte with currying.

Japt, 4 bytes
/VpJ

Test it

Explanation
Same as Neil's JS solution; divides (/) the first integer (U, implicit) by the second integer (V) raised to the power (p) of -1 (J).


text:
The bouncing sequence
Let us define a sequence.  We will say that \$a(n)\$ is the smallest number, \$x\$, that has the following properties:

\$x\$ and \$n\$ are co-prime (they share no factor)
\$x\$ does not appear earlier in the sequence
\$|n - x| > 1\$

Unlike most sequences the domain and range of our sequence are the integers greater than 1.

Let us calculate the first couple of terms.
\$a(2)\$, must be at least 4, but 4 and 2 share a factor of 2 so \$a(2)\$ must be 5.
\$a(3)\$, must be at least 5 but 5 is taken by \$a(2)\$, so it is at least 6, but 6 shares a factor with 3 so it must be at least 7, 7 fulfills all three requirements thus \$a(3)=7\$.
\$a(4)\$

2 Shares a factor
3 Too close
4 Too close
5 Too close
6 Shares a factor
7 Taken by a(3)
8 Shares a factor
9 is good

\$a(5)\$

2 is good

Task
In this challenge you are to write a program that takes a number greater than 1 and returns \$a(n)\$.
This is a code-golf question so answers will be scored in bytes, with fewer bytes being better.
Test Cases
Here are the first couple terms of the sequence (They are of course 2 indexed):
5,7,9,2,11,3,13,4,17,6,19,8,23,22,21,10,25,12,27,16,15,14

Bonus Fun fact
As proven by Robert Israel on Math.se (link) this sequence is its own inverse, that means that \$a(a(n)) = n\$ for all n.
OEIS
After asking this question I submitted this sequence to the OEIS and after a few days it was added.
OEIS A290151

How many values did you compute? (Talking about the bonus)

@SocraticPhoenix I've been doing it by hand so only the ones shown in the test cases.  I'm currently debugging a program to check larger values.

As am I... it's not working right now though, my indexing is off (edit:) aand now it's working... the first 1000 are safe xD

Do you know an upper bound for a(x)?  E.g. a(x) < u*x for some u. Btw the first few million values are safe.

@nimi I do not know of an upper bound.

a = {1, 5}; Do[k = 2; While[Nand[CoprimeQ[n, k], ! MemberQ[a, k], Abs[n - k] >= 2], k++]; AppendTo[a, k], {n, 3, 96}]; Rest@ a (* Michael De Vlieger, Jul 21 2017 *) - Wow, they're fast, you'd think it'd take longer to post AND implement a sequence for them.

Haskell, 61 bytes
f n=[i|i<-[2..],gcd i n<2,all((/=i).f)[2..n-1],abs(n-i)>1]!!0

Try it online!
I'm fairly new to Haskell, so any golfing tips are appeciated.
Thanks to Wheat Wizard for 2 bytes and nimi for 4 bytes
Explanation:
f n=[i|i<-[2..],gcd i n<2,all((/=i).f)[2..n-1],abs(n-i)>1]!!0
f n=                                                          -- define a function f :: Int -> Int
    [i|i<-[2..],                                              -- out of positive integers greater than two
                gcd i n<2,                                    -- gcd of i and n is 1
                          all((/=i).f)[2..n-1],               -- i isn't already in the sequence
                                               abs(n-i)>1]    -- and |n-i| > 1
                                                          !!0 -- take the first element

Alice, 42 bytes
/oi
\1@/2-&whq&[]w].q-H.t*n$K.qG?*h$KW.!kq

Try it online!
Explanation
/oi
\1@/.........

This is a standard template for programs that take a number as input, and output a number, modified to place a 1 on the stack below the input number.
The main part of the program places each number k in slot a(k) on the tape.  The inner loop computes a(k), and the outer loop iterates over k until a(n) is computed.
1       push 1
i       take input
2-&w    repeat n-1 times (push return address n-2 times)
h       increment current value of k
q&[     return tape to position 0
]       move right to position 1
w       push return address to start inner loop
]       move to next tape position
.q-     subtract tape position from k
H       absolute value
.t*     multiply by this amount minus 1
n$K     if zero (i.e., |k-x| = 0 or 1), return to start of inner loop
.qG     GCD(k, x)
?       current value of tape at position: -1 if x is available, or something positive otherwise
*       multiply
h$K     if not -1, return to start of inner loop
W       pop return address without jumping (end inner loop)
.!      store k at position a(k)
k       end outer loop
q       get tape position, which is a(n)
o       output
@       terminate

Mathematica, 111 bytes
(s={};Table[m=2;While[m<3#,If[CoprimeQ[i,m]&&FreeQ[s,m]&&Abs[i-m]>1,s~AppendTo~m;m=3#];m++],{i,2,#}];s[[#-1]])&

Try it online!  2..23 (range mode)
Try it online! or 150 (distinct values)

VB.NET (.NET 4.5), 222 bytes
Function A(n)
Dim s=New List(Of Long)
For i=2To n
Dim c=2
While Math.Abs(i-c)<2Or g(c,i)>1Or s.Contains(c)
c+=1
End While
s.Add(c)
Next
Return s.Last
End Function
Function g(a, b)
Return If(b=0,a,g(b,a Mod b))
End Function

I had to roll your own GCD. I also couldn't figure out how to get it to not be an entire function.
GCD is always >= 1, so only need to ignore 1
Took out short-circuiting in the golf because it's shorter
Un-golfed
Function Answer(n As Integer) As Integer
    Dim seqeunce As New List(Of Integer)
    For i As Integer = 2 To n
        Dim counter As Integer = 2
        ' took out short-circuiting in the golf because it's shorter
        ' GCD is always >= 1, so only need to ignore 1
        While Math.Abs(i - counter) < 2 OrElse GCD(counter, i) > 1 OrElse seqeunce.Contains(counter)
            counter += 1
        End While
        seqeunce.Add(counter)
    Next
    Return seqeunce.Last
End Function

' roll your own GCD
Function GCD(a, b)
    Return If(b = 0, a, GCD(b, a Mod b))
End Function

It blows my mind that .NET doesn't have a GCD built in outside of the BigInteger class.

Japt, 33 bytes (non-competing?)†
ò2 rÈc_aY >1«XøZ «Yk øZk}a+2}[] o

Try it online!
† I fixed a bug in the Japt Interpreter while working on this solution. This meta post
 from a year ago deems this answer non-competing, but this newer meta post is pushing for more freedom in this. Regardless, I spent too much time on this to scrap it.

05AB1E, 26 bytes
2IŸεDU°2Ÿ¯KʒX¿}ʒXα1›}θDˆ}θ

Try it online or output the first \$n\$ terms as list. (NOTE: ° is obviously extremely slow, so replaced with T* in the TIO links (\$10*n\$ instead of \$10^n\$).)
Explanation:
2IŸ               # Create a list in the range [2, input]
   ε              # Map each value `y` to:
    DU            #  Store a copy of `y` in variable `X`
    °2Ÿ           #  Create a list in the range [10**`y`,2]
       ¯K         #  Remove all values already in the global_array
       ʒX¿}       #  Only keep values with a greatest common divider of 1 with `X`
       ʒXα1›}     #  Only keep values with an absolute difference larger than 1 with `X`
             θ    #  After these filters: keep the last (the smallest) element
              Dˆ  #  And add a copy of it to the global_array
   }θ             # After the map: only leave the last value
                  # (and output the result implicitly)

Husk, 22 bytes
!¡λḟ§&oε⌋o>1≠→L¹`-N);1

Try it online!

Japt, 21 bytes
It pains me to have to invoke a function without a shortcut - can't remember the last time I had to, if ever - but it worked out shorter than any other method I could come up with.
@W{WjY «ZøW ©ÓWaY}a}g

Try it

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