[Question]
  [
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed:
```
                                         26
                                       25  27                                      .
         10                          24      28                                  .
        9  11                      23          29                              .
 2     8     12                  22              30                          44
1 3   7        13              21                  31                      43
   4 6           14          20                      32                  42
    5              15      19                          33              41
                     16  18                              34          40
                       17                                  35      39
                                                             36  38
                                                               37
```
So, if N is `1` the output is
```
1
```
If N is `2`, the output is
```
 2
1
```
If N is `3` the output is
```
 2
1 3
```
If N is `4` the output is
```
 2
1 3
   4
```
If N is `10` the output is
```
         10
        9
 2     8
1 3   7
   4 6
    5
```
If N is `19` the output is
```
         10
        9  11
 2     8     12
1 3   7        13
   4 6           14
    5              15      19
                     16  18
                       17
```
and so on.
# Notes
* Each peak or trough of the zigzag reaches its point one more line away from the line with the `1` on it than the previous peak or trough.
* N is not limited to `44`. The zigzag grows in the same pattern and larger N should be supported.
* Numbers with multiple digits should only "touch" at their corners, as depicted. Make sure this works when N is `100` and above.
* There should be no empty (or space only) lines in the output except one optional trailing newline.
* Any line may have any amount of trailing spaces.
# Scoring
The shortest code in bytes wins. Tiebreaker is earlier answer.
  
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), ~~41~~ ~~37~~ 29 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
RDµḌ’½Ċ-*_\x©L€Ṣ.ị®ạ€⁶ẋj"FZj⁷
```
[Try it online!](http://jelly.tryitonline.net/#code=UkTCteG4jOKAmcK9xIotKl9ceMKpTOKCrOG5oi7hu4vCruG6oeKCrOKBtuG6i2oiRlpq4oG3&input=&args=NDQ)
### How it works
```
RDµḌ’½Ċ-*_\x©L€Ṣ.ị®ạ€⁶ẋj"FZj⁷  Main link. Argument: n (integer)
R                              Range; yield [1, ..., n].
 D                             Decimal; yield A =: [[1], ..., [1, 0], ...].
  µ                            Begin a new, monadic chain. Argument: A
   Ḍ                           Undecimal; convert back to falt range.
    ’                          Decrement to yield [0, ..., n-1].
     ½Ċ                        Take the square root and round up (ceil).
       -*                      Elevate -1 to each rounded square root.
         _\                    Cumulatively reduce by subtraction.
                               This yields [1, 2, 1, 0, -1, 0, ...], i.e., the
                               vertical positions of the digits in A.
             L€                Compute the length of each list in A.
           x                   Repeat the nth position l times, where l is the
                               nth length.
            ©                  Copy the result to the register.
               Ṣ               Sort.
                .ị             At-index 0.5; yield the last and first element,
                               which correspond to the highest and lowest position.
                  ạ€®          Take the absolute difference of each position in the
                               register and the extrema.
                               This yields the number of spaces above and below
                               the integers in r as a list of pairs.
                     ⁶ẋ        Replace each difference with that many spaces.
                         F     Flatten the list A.
                       j"      Join the nth pair of strings of spacing, separating
                               by the nth digit in flat A.
                          Z    Zip/transpose the result.
                           j⁷  Join, separating by linefeeds.
```
[Answer]
# PHP, ~~211~~ ~~177~~ ~~164~~ 163 bytes
Predict the peaks with `$n` and increase the array dynamically in either direction, using `($x, $y)` output cursor. 
Numbers are aligned with `str_pad()` and the final output is the `implode()` of that array of strings (`$g`).
```
for($x=0,$d=-1,$h=$n=2,$y=$a=1;$a<=$argv[1];$y+=$d){$g[$y]=str_pad($g[$y],$x).$a;$x+=strlen($a);if($a++==$n){$h+=2;$n+=$h-1;$d*=-1;}}ksort($g);echo implode(~õ,$g);
```
## [Test it online!](http://sandbox.onlinephpfunctions.com/code/a8ca8a253713c3e241570f710f8ed8f76f75d507)
Update: removed 34 bytes by getting rid of the unneeded array\_pad().
Update2: followed @insertusernamehere's advice to shorten it a bit more.
Update3: followed @Lynn's advice to save one more byte with ~õ which imposes the use of LATIN-1 charset. (not available in online PHP emulator so not included there)
[Answer]
# Pyth, ~~60~~ ~~53~~ ~~52~~ ~~46~~ ~~42~~ ~~39~~ ~~38~~ ~~36~~ ~~34~~ ~~32~~ 31 bytes
39: It is now on par with [the bug-fixed version of Jelly](https://codegolf.stackexchange.com/a/82866/48934), and I have out-golfed Dennis' competing version!
38: I have out-golfed Dennis!
36: I have out-golfed Dennis again!
34: Even lower than his bug-fixed version!
31: 32 -> 31 thanks to Dennis.
```
~~[[email protected]](/cdn-cgi/l/email-protection)++\*]\*dl`hkabhSK`hk\*]\*dl`hkabeSKKd~~
~~[[email protected]](/cdn-cgi/l/email-protection)\*]\*dl`hkhaeSKhSKabhSKhkKd~~
~~J1K.u+N=J\_WsI@Y2JtQZ=-RhSKKjsM.t.eX\*]\*dl`hkheSKbhkKd~~
~~J1K.u+N=J\_WsI@Y2JtQQj-#dsMC.eX\*]\*dl`hkheSKbhkK~~
~~J1j-#dsMC.eX\*]\*dl`hkyQ+Qbhkm=+Z=J\_WsI@td2J~~
~~J1j-#dsMCmX\*]\*;l`hdyQ+Q=+Z=J\_WsI@td2Jhd~~
~~J1j-#dsMCmX\*]\*;l`hdyQ+Q=+Z=J\_WsI@td2Jh~~
~~J1j-#dsMCmX\*]\*;l`hdyQ+Q=+Z=@\_BJsI@td2h~~
~~j-#dsMCmX\*]\*;l`hdyQ+Q=+Zsty%s@td2 2h~~
~~j-#dsMCmX\*]\*;l`hdyQ+Q=+Z@\_B1.E@d2h~~
~~JQj-#dsMCmX\*]\*;l`hdyQ=+J@\_B1.E@d2h~~
~~JyQj-#dsMCmX\*]\*;l`hdJ=+Q@\_B1.E@d2h~~
~~j-#dsMCmX\*]\*;l`hdyQ=+Q@\_B1.E@d2h~~
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h
```
[Try it online!](http://pyth.herokuapp.com/?code=j-%23dsMCmX%2a%5D%2a%3Bl%60hdyQ%3D%2BQ%40_B1.E%40d2h&input=44&debug=0)
## How it works
```
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h      input: Q
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2hdQ    implicit filling arguments
       m                        Q    for each number d from 0 to Q-1:
                           @d2           yield the square root of d.
                         .E              yield its ceiling.
                      ^_1                raise -1 to that power. this
                                         yields the desired direction.
                   =+Q                   increment Q by this amount.
               hd                        yield d+1.
              `                          yield its string representation.
             l                           yield its length.
           *;                            repeat " " for that number of times
          ]                              yield a list containing the string above.
         *       yQ                      repeat the list for Q*2 times.
                                         the Q has changed, but Q*2 is
                                         an overshoot that is high
                                         enough, so we don't have to
                                         worry about it.
        X                                in that list, replace the
                                         element with index being the
                                         number generated above
                              hd         with d+1.
      C                              transpose the resulting array.
    sM                               flatten each element.
 -#d                                 remove lines containing only spaces.
                                     (filter on truthiness of set difference with space)
j                                    join by newlines.
```
[Answer]
# MATLAB, 148 bytes
```
n=input('');k=fix(n^.5);m=0;w=1;d=-1;for l=1:n;s=num2str(l);m(k+1,w:w+nnz(s)-1)=s;w=w+nnz(s);k=k+d;d=d*(-1)^(l^.5==fix(l^.5));end;[m(any(m,2),:),'']
```
Note that the spaces are missing in Octave, as MATLAB prints the the character indexed with `0` as a space, while octave does just omit that character.
Explanation:
```
n=input('');
k=fix(n^.5);                    %caculate starting height
m=0;w=1;d=-1;                   %initialize counters and output matrix
for l=1:n;
    s=num2str(l);
    m(k+1,w:w+nnz(s)-1)=s;      %insert current index as a string
    w=w+nnz(s);                 %current horizontal position
    k=k+d;                      %current vertical position
    d=d*(-1)^(l^.5==fix(l^.5)); %if we reached a square number, change direction
end
[m(any(m,2),:),'']              %delete all zero rows
```
[Answer]
## Haskell, ~~144~~ 142 bytes
```
g n|k<-take n$scanl(+)0$[1..]>>= \x->(-1)^x<$[2..2*x]=unlines[[1..n]>>= \x->show x#(k!!(x-1)==y)|y<-[minimum k..maximum k]]
s#g|g=s|1<2=' '<$s
```
Usage example:
```
*Main> putStr $ g 19
         10                  
        9  11                
 2     8     12              
1 3   7        13            
   4 6           14          
    5              15      19
                     16  18  
                       17    
```
How it works:
```
s#g|g=s|1<2=' '<$s              -- # is a helper function that expects a string s
                                -- and a boolean g. It returns s if g is True, else
                                -- as many spaces as there a characters in s 
k<-take n$                      -- bind k to the first n elements of
 [1..]>>= \x->(-1)^x<$[2..2*x]  -- 2*x-1 copies of (-1)^x for each x in [1,2,3,...]
                                -- i.e. [-1, 1,1,1, -1,-1,-1,-1,-1, 1,1,1,1,1,1,1..]
 scanl(+)0                      -- build partial sums, starting with 0
                                -- i.e. [0,-1,0,1,2,1,0,-1,-2,-3,-2,-1...]
                                -- -> k is the list of y coordinates for the
                                --    numbers 1,2,3,...
 [  |y<-[minimum k..maximum k]] -- for all y coordinates in k 
      \x->show x#(k!!(x-1)==y)  -- map the # function
  [1..n]>>=                     -- over [1..n] (the x coordinates)
                                -- where # is called with
                                --  s -> a string representation of x 
                                --  g -> True if k at index x equals the current y
unlines                         -- join with newlines
```
Edit: Thanks @Lynn for two bytes!
[Answer]
## JavaScript (ES6), 213 bytes
```
with(Math)n=>(a=[...Array(n)].map((_,i)=>n-=1+sqrt(--i)&1||-1).map((e,_,a)=>e-min(...a))).map((e,i)=>r[e][i]=++i,r=[...Array(1+max(...a))].map(_=>a.map((_,i)=>` `.repeat(1+log10(++i)))))&&r.map(a=>a.join``).join`\n`
```
Where `\n` represents a literal newline character. Explanation:
```
with(Math)                          Bring functions into scope
 n=>                                Accepts one parameter
  (a=                               Intermediate result variable
   [...Array(n)].map(               For each number 0..n-1
    (_,i)=>n-=                      Accumulate index for each number
     1+sqrt(--i)&1||-1              Calculate the direction
    ).map((e,_,a)=>e-min(...a))     Scale the smallest index to zero
  ).map((e,i)=>r[e][i]=++i,         Overwrite the padding with 1..n
   r=[...Array(1+max(...a))].map(   Calculate number of lines
    _=>a.map((_,i)=>                For each number 1..n
     ` `.repeat(1+log10(++i)))))    Calculate the padding needed
  &&r.map(a=>a.join``).join`\n`     Join everything together
```
To shorten `pow(-1,ceil(sqrt(i)))` I rewrite it as `sqrt(i-1)&1||-1` however this doesn't work for `i=0` so to fix that I add 1 but this then flips the sign of the result which is why I end up with `n-=`.
[Answer]
# Python 2, 137 bytes
```
l={}
i=x=y=n=v=0
exec"v+=1;l[y]=l.get(y,'').ljust(x)+`v`;x+=len(`v`);i=-~i%-~n;y+=n%4-1;n+=2>>i*2;"*input()
for k in sorted(l):print l[k]
```
View the output on [ideone](http://ideone.com/6kjoAR).
]