[Question]
  [
Given a single positive odd integer as input, return a converging zigzag as a list of strings, list of lists of characters, or newline-separated string, in this form:
```
#
 #
  #
   #
    #
   #
  #
 #
  #
   #
  #
```
You can replace `#` with any consistent non-whitespace character. Trailing whitespace on each line is allowed and a trailing newline is allowed.
The zig-zag starts at column `1` and for each row moves right one column, until it reaches column `n` (where `n` is the input). Then, it moves left to `2`, then right to `n-1`, then left to `3`, with the two bounds converging in until the zigzag ends in the middle column (`(n+1)/2`).
# Test Cases
The example above is the test case for `5`.
The following are individual test cases:
```
3
#
 #
  #
 #
```
```
7
#
 #
  #
   #
    #
     #
      #
     #
    #
   #
  #
 #
  #
   #
    #
     #
    #
   #
  #
   #
    #
   #
```
```
1
#
```
  
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 89 bytes
```
f(n,a,b){puts("0");for(a=n;--a>n/2;)for(b=n-2*a;b<=2*a-n;)printf(" %*d\n",a-abs(b++),0);}
```
[Try it online!](https://tio.run/##JY1BCsIwEEWvIgFhpkmwZuNiOp7EzSQSmYVjaeuqePZocPXh8R6/xEcprVWwICHjPr@3FdzokOprAWGjGOVqp0TYQWaLaRDKE/8mGuG8qG0V3OE43G/mgkTJK2TvMYxIn6b0FDXAvefKZ9KJL6SeE1ZQDP9D19Uv "C (gcc) – Try It Online")
Works by analyzing the sequence of number of spaces as (for n=7):
```
          0
1 2 3 4 5 6 5 4 3 2 1
    2 3 4 5 4 3 2
        3 4 3
```
And for n=3:
```
  0
1 2 1
```
We can see that the middle number (`a` in the code) runs from [n-1, n/2). Then, the difference between the first number and the middle number is:
```
a  n  b  2a-n
-------------
6  7  5  5
5  7  3  3
4  7  1  1
2  3  1  1
```
So, if we have `b` going through [-(2a-n), 2a-n], `a-abs(b)` will give us the desired sequence. This is essentially what the code does.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~10~~ 8 bytes
```
ＦＮ«↗ι‖»/
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBwzOvoLTErzQ3KbVIQ1NToZqLM6AoM69Ewyq0ICgzPaNERyFT05qLMyg1LSc1uUQDyK7lgqhQ0lfStP7/3/S/btl/3eIcAA "Charcoal – Try It Online") Link is to verbose version of code. Edit: Saved 2 bytes thanks to @dzaima for pointing out that I don't have to use `#`s.
[Answer]
# [Python 2](https://docs.python.org/2/), 78 bytes
```
l=range(1,input())
print 8
for i in l:
 for i in l:print' '*i+'8'
 l=l[-2::-1]
```
[Try it online!](https://tio.run/##K6gsycjPM/r/P8e2KDEvPVXDUCczr6C0RENTk6ugKDOvRMGCKy2/SCFTITNPIceKSwGJA5ZXV1DXytRWt1DnUsixzYnWNbKy0jWM/f/fHAA "Python 2 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
ṖṖṚ$ÐĿẎ0;⁶ẋp1Y
```
[Try it online!](https://tio.run/##y0rNyan8///hzmlgNEvl8IQj@x/u6jOwftS47eGu7gLDyP///5sDAA "Jelly – Try It Online")
Full program.
Uses `1`.
-1 thanks to [Jonathan Allan](https://codegolf.stackexchange.com/users/53748/jonathan-allan).  
-1 thanks to [Jonathan Allan](https://codegolf.stackexchange.com/users/53748/jonathan-allan).
[Answer]
# [Haskell](https://www.haskell.org/), 72 bytes
```
g[]=[]
g a=a++g(reverse$init a)
r="#":map(' ':)r
("#":).g.tail.(`take`r)
```
[Try it online!](https://tio.run/##FcqxCoQwDADQ3a8oXsEEodNNQr/iRimYIfSCtUga/f2Kb35/ajuX0nteU1zTkB1FmucMyjdrYy9VzBEOGsfPuBx0wuSmBbUfJDWel/1M/VWLVG4e4E0YcjCSEmAz2nlTxG9/AA "Haskell – Try It Online")
We define an infinite list `r` being the diagonal of `#`s starting from the upper left hand corner.
We then define a function `g` which does the brunt of the work. `g` will take a list and repeatedly reverse it and remove its first element until the list is empty, then concatenate the result of each action.
Our main function here is a point-free function. This function starts by taking `n` elements from the infinite list `r`, it then chops of the first element and applies `g`. Last we have to add a `#` back to the beginning, this is because the specs for the question are a little weird, I'm not sure why the first diagonal is always one longer than it should be but, it is, so we have to add a a `#`.
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGL), 19 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
┘.»∫«I╝:±jk+jl0;±Iž
```
[Try it Here!](https://dzaima.github.io/SOGLOnline/?code=JXUyNTE4LiVCQiV1MjIyQiVBQkkldTI1NUQlM0ElQjFqaytqbDAlM0IlQjFJJXUwMTdF,inputs=Nw__)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 22 bytes
```
i8ë<LZFD¨R})˜0¸ìε8sú}»
```
[Try it online!](https://tio.run/##ASkA1v8wNWFiMWX//2k4w6s8TFpGRMKoUn0py5wwwrjDrM61OHPDun3Cu///MQ "05AB1E – Try It Online")
Uses `8`.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
```
LN71SΛ
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fx8/cMPjc7P//LQE "05AB1E – Try It Online")
```
     Λ     use the canvas function with
L          a range list [1 .. input] as lengths for each path 
 N         a "0" as character to be printed 
           (N is the index variable used by loops. If there was no loop yet, its
           default value is 0. By using N, I avoid an extra space between 0 and 71)
  71S      and the directions 7 and 1 (NW and NE), that alternate automatically until
           the range list is finished.
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 29 bytes
```
ri,(;_,{_);W%}*]e_0\+Sf*8f+N*
```
[Try it online!](https://tio.run/##S85KzP3/vyhTR8M6Xqc6XtM6XLVWKzY13iBGOzhNyyJN20/r/39zAA "CJam – Try It Online")
Uses `8`.
[Answer]
# Pyth, 23 bytes
```
8JStQKdVQjbm+*\ d8J=_PJ
```
[Try it here.](http://pyth.herokuapp.com/?code=8JStQKdVQjbm%2B%2a%5C+d8J%3D_PJ&input=7&debug=0)
[Answer]
## JavaScript, 127 bytes
Calculates the goal (`g`) to get to. When this goal is reached, turn around to the next goal. Also uses a trick to avoid using `Math.round()` by adding `0.5` to every uneven number.
```
f=n=>{c=0;for(i=0;i<n;i++){m=i/2;g=i%2==0?n-m:m+1.5;while(c!=g){c>g?c--:c++;console.log(' '.repeat(c-1)+'#'+' '.repeat(n-c))}}}
```
```
f=n=>{c=0;for(i=0;i<n;i++){m=i/2;g=i%2==0?n-m:m+1.5;while(c!=g){c>g?c--:c++;console.log(' '.repeat(c-1)+'#'+' '.repeat(n-c))}}}
f(5);
```
[Answer]
## Haskell, 74 bytes
```
f[x]=[x]
f s=s++tail(f$reverse$tail s)
g n=f[(' '<$[2..x])++"#"|x<-[1..n]]
```
[Try it online!](https://tio.run/##fYmxCsIwGAb3PsVHDbQlGKgOLs0buDmGDAGTGox/JUklg@8e6wt0OLjjHiY9bQi1OlW03GgckkycZ@ND71i0HxuTZf9EGpoZJJ3qO3QTUychih44bw/tt0xHNQpBWteX8QSJ@9IAeK/5luOVwLBS8GTTZjPGnXfeeZf6Aw "Haskell – Try It Online")
How it works:
```
    [(' '<$[2..x])++"#"|x<-[1..n]]     -- build the first diagonal, e.g. for n=3:
                                         -- ["#", " #", "  #"]
  f                                      -- call f, which is
f s = s ++                               -- the input list, followed by
           tail                          -- all but the first element of
                f                        -- a recursive call with
                  reverse                -- the reverse of
                          tail s         -- all but the first element of the input 
                                         -- list
f[x]=[x]                                 -- base case: stop if the input list a
                                         -- singleton list
```
Each recursive call to `f` appends the next diagonal.
[Answer]
## [Husk](https://github.com/barbuz/Husk), 19 bytes
```
mo`:'#R' ∫`Ṙ¢e1_1tṫ
```
[Try it online!](https://tio.run/##ASQA2/9odXNr//9tb2A6JyNSJyDiiKtg4bmYwqJlMV8xdOG5q////zU "Husk – Try It Online")
## Explanation
This feels a bit clunky.
```
mo`:'#R' ∫`Ṙ¢e1_1tṫ  Input is n (e.g. 5)
                  ṫ  Range from input to 1: [5,4,3,2,1]
                 t   Drop first element: [4,3,2,1]
             e1_1    The list [1,-1]
            ¢        repeated infinitely: [1,-1,1,-1,..
          `Ṙ         Clone with respect to the list above: [1,1,1,1,-1,-1,-1,1,1,-1]
         ∫           Cumulative sum: [0,1,2,3,4,3,2,1,2,3,2]
mo                   For each element k (e.g. 3) do this:
      R'             Repeat space k times: "   "
  `:'#               Append '#': "   #"
                     Print implicitly separated by linefeeds.
```
[Answer]
# [Python 3](https://docs.python.org/3/), 82 bytes
```
def z(n):l=range(1,n);print(8);exec("[print(' '*i+'8')for i in l];l=l[-2::-1];"*n)
```
[Try it online!](https://tio.run/##JcpBCoMwEADAryxesqvmED1UEnyJeCgadSGsIaRQ/XxK8Tgw8crHKX0pq9/gRiEbxvSW3aNphVxMLBkHcv7rF6ymxwpUzY0aFG1nAgYWCLMLY5h0Z602s6tqoXLjP7PET0YiKq8f "Python 3 – Try It Online")
[Answer]
# [Retina](https://github.com/m-ender/retina), 71 bytes
```
.+
$* 
^
:>
 $
:
;{*T`:<>`_#
( ) >(:)|( )<
$1<$2$3
(:)( )<|>( )
$2$1$3>
```
[Try it online!](https://tio.run/##K0otycxL/P9fT5tLRUuBK47Lyo5LQYXLisu6WiskwcrGLiFemUtDQVPBTsNKswbIsOFSMbRRMVIx5gIKgPg1dkCSCyhiqGJs9/@/KQA "Retina – Try It Online") Explanation: The first three stages convert the input into the form `:> :` where the number of characters between the `:`s is the input number. The last two stages then bounce the `>` (or `<`, when moving leftward) between the `:`s. The fourth stage loops the bounce, printing the required parts of the string each time. The `;` stops the string from being printed after the loop.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 16 bytes
```
Î<L¤FÂ¦})˜Ôð×X«»
```
[Try it online!](https://tio.run/##ASUA2v8wNWFiMWX//8OOPEzCpEbDgsKmfSnLnMOUw7DDl1jCq8K7//80 "05AB1E – Try It Online")
**Explanation**
```
Î<L               # push 0 and range [1 ... input-1]
   ¤              # get the last element of the list
    F             # that many times do
     Â            # bifurcate
      ¦           # remove the head
       })˜        # end loop and wrap in flattened list
          Ô       # remove consecutive duplicates
           ð×     # repeat space a number of times corresponding to each number in the list
             X«   # append 1 to each
               »  # join on newline
```
[Answer]
# K (Kona), 27 bytes
```
`0:{|x$"#"}'1,,/{1_|x}\-2-!
```
Produces the underlying numeric sequence by repeatedly reversing and dropping the head of a vector until empty.
[Answer]
# PHP, 65 bytes
```
<?while(--$n||$n=$d=--$argn)echo str_pad("X
",2+$x-=$d&1?:-1);?>X
```
Run as pipe with `-nF` or [test it online](http://sandbox.onlinephpfunctions.com/code/87819fa945312260b87327f04aed3616254391c5).
**explanation:**
first iteration: `$n` is `NULL`, so `--$n` has no effect and evaluates to `NULL`  
--> set `$n` and `$d` to pre-decremented argument  
1. increment `$x` for even `$d`, decrement for odd `$d`  
2. print `X`, a newline and `$x` spaces
further iterations: decrement `$n`; when it hits `0`, reset `$n` (and `$d`) to pre-decremented argument
finale: print one more `X`.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 31 bytes
```
Ç+V ç +QÃê ¯-2 c´U?ß´UVÄ :Vç +Q
```
Recursive solution that returns an array of lines.
[Try it online!](https://codepen.io/justinm53/full/NvKjZr?code=xytWIOcgK1HD6iCvLTIgY7RVP9+0VVbEIDpW5yArUQ==&inputs=MQ==,Mw==,NQ==,Nw==,OQ==,MTE=,MTM=&flags=LVI=) using the `-R` flag to join output with newlines.
[Answer]
# Python 2, ~~159~~ ~~145~~ ~~141~~ 136 bytes
```
print"".join([" "*p+"#\n"for p in(lambda l:[sum(l[:i])for i in range(len(l))])(sum([i*[1-i%2*2]for i in range(input())[::-1]],[])+[1])])
```
There has already been quite nice Python versions to this problem but I thought I'd still post my awful one-liner. (Without semicolons though!)
Edit: 14 bytes down, using sum instead of double list comprehension
Edit: Just noticed in python 2 you can use input instead of raw\_input.
I've always just used the latter.
[Answer]
# Mathematica, ~~142~~ 102 bytes (independent)
This solution has a mathy flavor:
`UnitVector[#,1-Sum[(-1)^Floor[#+1/2-Sqrt[9/4+#*#-#-2x]],{x,k}]]~Table~{k,0,#(#-1)/2}/.{0->" ",1->"X"}&`
This basically calculates which segment we're in (by inverting the triangular number function) and then moving left or right by adding a power of -1.
You can test it on the [Wolfram Code Sandbox](http://sandbox.open.wolframcloud.com) by pasting code like `UnitVector[#,1-Sum[(-1)^Floor[#+1/2-Sqrt[9/4+#*#-#-2x]],{x,k}]]~Table~{k,0,#(#-1)/2}/.{0->" ",1->"X"}&@6//MatrixForm` and pressing Shift+Enter or Numpad Enter or clicking Gear->"Evaluate Cell".
---
This happens to be the same length as my original incorrect port of [Erik's Python 2 solution](https://codegolf.stackexchange.com/a/135080/41105) (This port gives the output for an input one higher):
`(Print[X];l=Range@#;Do[Do[Print[StringRepeat[" ",l[[j]]]<>"X"],{j,Length@l}];l=l[[-2;;1;;-1]],{i,#}])&`
]