[Question]
  [
# Twisting Words!
Given a string and a positive integer. You must twist the string, back and forth.
### Example Input / Output
Input
```
Programming Puzzles & Code Golf
4
```
Output
```
Prog
mmar
ing 
zzuP
les 
oC &
de G
 flo
```
## Input
The input can be taken in through STDIN, or function argument. The input will consist of a string and a positive integer, *n*. The integer will determine the length of each twisted line.
The string is twisted back-and-forth. An input of `HELLO, WORLD!` and 5 would look like:
![HELLO, WORLD!](https://i.stack.imgur.com/6K9vq.png)
## Output
The output will be the twisted text. It may not any trailing whitespace. If the input string length is not divisible be the line length, add a space until the line is filled:
An example of this:
Input
```
Hello, World!
5
```
Output (Note the whitespace at the very end)
```
Hello
roW ,
ld!  
```
  
[Answer]
# Pyth, ~~19~~ 15
```
VPc+z*dQQ_W~!ZN
```
Pre-pads the string, then reverses each other line as it prints it. The padding is equal to the size of the box, but the last line after chopping up the input is discarded.
[Try it here](https://pyth.herokuapp.com/?code=VPc%2Bz*dQQ_W%7E!ZN&input=Programming+Puzzles+%26+Code+Gol%0A4&debug=0)
[Answer]
## Python 2, 60
```
s,n=input()
d=1
while s:print(s+n*' ')[:n][::d];s=s[n:];d=-d
```
Takes `n` characters at a time from the from of `s`, printing them with a direction `d` that alternates between `1` and `-1`. For spacing on the last line, `s` is padded with `n` spaces at the end before it is chopped, which only affects it when it has fewer than `n` characters remaining.
A recursive solution would save a char (59) except that it leaves a trailing newline, which is not allowed.
```
f=lambda s,n,d=1:s and(s+n*' ')[:n][::d]+"\n"+f(s[n:],n,-d) 
```
[Answer]
# CJam, 19 bytes
```
q~1$S*+/W<{(N@Wf%}h
```
Input example:
```
5 "Hello, World!"
```
### Explanations
```
q~         e# Input n and the string.
1$S*+      e# Append n spaces to the string.
/W<        e# Split by each n characters, and remove the last chunk.
{          e# While the array of chunks isn't empty:
    (N     e# Extract the first chunk and push a newline.
    @Wf%   e# Reverse every chunk left in the array.
}h
```
[Answer]
## [Snowman 1.0.1](https://github.com/KeyboardFire/snowman-lang/releases/tag/v1.0.1-beta), 91 bytes
```
{vg10vg|sB*#.'aGal'NdE'aaAaL|al!*+#5nS" "'aR'!#aCwR|.aC2aG:0aa|sP"
"sP'NdE|1aA.aNsP"
"sP;aE
```
Or all on one line (for aesthetics, or more specifically, anti-aesthetics), at the cost of 2 bytes:
```
{vg10vg|sB*#.'aGal'NdE'aaAaL|al!*+#5nS" "'aR'!#aCwR|.aC2aG:0aa|sP10wRsP'NdE|1aA.aNsP10wRsP;aE
```
This is way too short, for Snowman. (It's probably the shortest it can get, though; I worked on golfing this for a pretty long time.)
This has one caveat: it will exit with an error (but still produce the correct output) 50% of the time, when the last line is *not* reversed. (This is because I use `ag` to group the array elements in groups of two so that I can reverse every other one, but I don't check whether the last element has both expected elements, so it'll try to access a nonexistent element if there are an odd number of lines.)
Ungolfed / explanation:
```
{vg10vg|sB*#      // get input, convert second string to number and store
.'aG              // split string into groups of n chars
al'NdE'aaAaL      // take out the last element of the array
|al!*+#5nS" "'aR  // subtract its length from 5, repeat that many spaces
'!#aCwR|.aC       // concat spaces to last el. and that back to the array
2aG               // split in groups of 2, so we can reverse every other string
// for each sub-group in the array of groups...
:
    0aa|sP10wRsP         // print the first element as is
    'NdE|1aA.aNsP10wRsP  // print the second element, reversed
;aE
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~83~~ 75 bytes
```
(id!)
(f![])_=[]
(f!l)n=f(take n$l++cycle" ")++'\n':((f.reverse)!drop n l)n
```
Simple `chunksOf` implementation with take and drop, applying an even or odd number of reverses to the output as we go.
Thanks to @BMO for five bytes and @ØrjanJohansen for three bytes!
[Try it online!](https://tio.run/##FcuxCsIwEADQ3a@4hmITgk5OQiYH14JjWySkl1p6TUISBfvxRt3e8h46LUhUsuoLn8dK7LitukHcVTf8ScIpy7NeEFxNUpq3IWTAhJRN75oz5/YY8YUxoajG6AM4@J2y6tmBgvDMtxyhhgysjX6Kel1nN0H73DbCBHu4@BHh6skyOJWPsaSnVA4mhC8 "Haskell – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 22 15 13 bytes
```
]`|."1@(]\)~-
```
*-2 bytes thanks to xash*
Note the above solution requires J901, which allows you to apply cyclic gerunds using the rank `"` conjuntion. TIO uses an older version, so to run this one you have to download J.
However, my previous solution of 15 bytes will work on TIO:
## 15 bytes
```
([]`|.\[:,]\)~-
```
[Try it online!](https://tio.run/##VcxBC4IwGIDhu7/iQ8lt4b4SOo2SkVCXCOk6F0apGdrA6GKyv76CunR4Tw@8N@cjqWAlgEAEcxCfOEJ62G0cVboYMVci0jmz3DFvv0agSugwKeiIYcJmuPRjJqnOLf9xgzIYUeqjUP4cYv2nXH6f@oVWTWmCcmID5nnl@WqAZL2p@1PXNfcasucwtOUDQkjNpYStaSsCFSzcGw "J – Try It Online")
Finally, another 15 byte alternative, thanks to @Marshall and based on a trick from @ngn, is:
```
([:|.@]/\]\)~-
```
[Answer]
# [Stuck](http://kade-robertson.github.io/stuck/), ~~42~~ ~~41~~ ~~40~~ 38 Bytes
This is a wee bit too long, probably will try to golf more!
```
tg;_lu_@%u;-_0G<*' *+0GKE"];2%;Y_Y?p":
```
Input should be like `"string"|n`.
Explanation:
```
tg                 # Take input, place each item on stack, save the int to variable stack                                        
;_l                # Swap the top two items, duplicate the string and obtain length
u_@%               # Rotate to the left, duplicate, rotate right and take mod
u;-                # Rotate left, swap the top two and subtract from each other
_0G<*              # duplicate this value, check if less than stored int and multiply
' *+               # Push space onto stack n times, append to starting string
0GKE               # Split this string into segments, and enumerate
"];2%;Y_Y?p":      # For each segment, determine if should be reversed, and print
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 19 bytes
```
{↑⊢∘⌽\↓↑⍵⊆⍨⌈⍺÷⍨⍳≢⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P/FR24TqR20TH3UtetQx41HP3phHbZNB/N6tj7raHvWueNTT8ah31@HtIGbv5kedi4Aytf//mygkKqgHFOWnFyXm5mbmpSsElFZV5aQWK6gpOOenpCq45@ekqXOZglR5pObk5OsohOcX5aQoqgMA "APL (Dyalog Unicode) – Try It Online")
Took the `⊢∘⌽\` trick from [ngn's brilliant answer to the boustrophedonise challenge](https://codegolf.stackexchange.com/a/150153/41805).
After realising that my submission breaks for lines with leading newlines, I have added two more bytes. Below is the older submission.
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 17 bytes
```
{↑⊢∘⌽\⍵⊆⍨⌈⍺÷⍨⍳≢⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P/FR24TqR20TH3UtetQx41HP3phHvVsfdbU96l3xqKfjUe@uw9tBzN7NjzoXAWVq//83VUhUUPdIzcnJ11EIzy/KSVFUBwA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# Perl, 87 bytes
```
sub f{$_=@_[0].$"x(@_[1]-1);$a.=(($i++&1?reverse$1:$1).$/)while/(.{@_[1]})/g;chop$a;$a}
```
Old version (prints a trailing newline):
```
sub f{$_=@_[0].$"x(@_[1]-1);print(($i++&1?reverse$1:$1).$/)while/(.{@_[1]})/g}
```
String is passed as a function argument with no trailing newline. Call like this:
```
$_=<>;chomp;print f($_,5);
```
[Answer]
## Mumps, 86 bytes
```
R I,S,! S P=$L(I),$P(I," ",P)=P F Q=1:S:P S F=$E(I,Q,Q+S-1),P='P W $S('P:F,1:$RE(F)),!
```
Although it could be 2 bytes shorter if you remove the first ',!' characters in the R statement (read from STDIN); that adds a carriage return between the input and output. If that wasn't there, the output is technically correct, but the first line would appear appended to the input string. *[[ The standard Mumps terminal that I use has no local echo. ]]*   As it sits, here's the test:
```
R I,S,! S P=$L(I),$P(I," ",P)=P F Q=1:S:P S F=$E(I,Q,Q+S-1),P='P W $S('P:F,1:$RE(F)),!
ABCDEFGHIJKLMNOPQRSTUVWXYZ1236
ABCDEF
LKJIHG
MNOPQR
XWVUTS
YZ123 
```
Also note, there's actually a carriage return / Enter keypress between the '123' and the '6' at the end of the input. *[[ The local echo thing again. ]]*
If anyone's interested I can describe what's going on with the code; but I do realize there's not a ton of Mumps enthusiasts out there... :-)
[Answer]
## PowerShell, 102 Bytes
```
param($s,$i)$l=$s.Length;$s+' '*($i%$l)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$l..0]-join''))[$r]}
```
Invoked as follows (if saved to file `CodeGolf55051.ps1`)
```
.\CodeGolf55051.ps1 -s '1234567890' -i 4
```
---
## Previous Attempts
(longer or invalid)
**PowerShell, 110 Bytes**
```
param($s,$i)$l=$s.Length;$s+' '*(($i-$l%$i)%$i)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$l..0]-join''))[$r]}
```
**PowerShell, 111 Bytes**
```
param($s,$i)$s+' '*(($i-$s.Length%$i)%$i)-split"(.{$i})"|?{$_}|%{$r=-not$r;@($_,($_[$_.length..0]-join''))[$r]}
```
**Explanation**
```
param($s,$i)                         #Take input text (s) and column width (i)
$s                                   #take the user entered string
+ ' ' * (($i - $s.Length % $i) % $i) #add the least number of spaces required to make its length divisible by i
-split"(.{$i})"                      #break it into chunks of i characters in length
| ?{$_}                              #skip any blank lines created in the process
| %{                                 #for each line
    $r = -not $r;                    #    toggle a boolean value
    @(                               #    define an array
        $_                           #    index 0 = the string going forwards
        ,($_[$_.length..0] -join '') #    index 1 = the string reversed (by taking each character from the last to the first, then joining them)
    )[$r]                            #    if our boolean value is false take the forward string (index 0), if true take the backwards one (index 1)
}                                    #next
```
**PowerShell, 180 Bytes**
```
param($s,$i)$x="`${0}|{1}|`${2}";$w=$x;1..$i|%{$w=$w-f$_,$x,($i+$_)};$w=$w-replace'\||\${.*}';$r=$w-replace'\$\d+','(.)?';$s+' '*($i-$s.Length%$i)-replace$r,$w-split"(.{$i})"|?{$_}
```
**PowerShell, 196 Bytes**
```
param($s,$i)$x="{0}|{1}|{2}";$w=$x;1..$i|%{$w=$w-f$_,$x,($i+$_)};$w=$w-replace'(\d+)','$$$1'-replace'\||{.*}';$r=$w-replace'\$\d+','(.)?';$s+' '*($i-$s.Length%$i)-replace$r,$w-split"(.{$i})"|?{$_}
```
**Explanation**
```
param ($s, $i)                      #Take input text (s) and column width (i)
$x = "{0}|{1}|{2}"                  #Define string format which takes 3 entries and pipe delimits them
$w = $x                             #initialise our replacement regex with this format
1..$i | %{                          #for 1 to the specified column width
    $w = $w -f $_, $x, ($i + $_)    #update the regex 1|{...}|5, 1|2|{...}|6|5, etc
}                                   #resulting in w = 1|2|3|4|{...}|8|7|6|5
$w = $w -replace '(\d+)', '$$$1'    #now prefix the numbers with a dollar (so they're regex replacement variables)
        -replace '\||{.*}'          #and remove the delimiters and superfluous `{...}` left from our middle insertion routine
$r = $w -replace '\$\d+', '(.)?'    #then create the match pattern by replacing the variables with optional single character captures
$s                                  #now take the user entered string
    + ' ' * ($i - $s.Length % $i)   #add the least number of spaces required to make its length divisible by i
    -replace $r, $w                 #perform a replacement using the regex match and replace patterns created above
    -split "(.{$i})"                #then split the string into blocks of length i
    | ?{$_}                         #removing any blank lines created in the process
```
(`{...}` in the above comments is actually `{0}|{1}|{2}`; I put `{...}` for improved readability.
**Powershell, 120 Bytes**
(invalid)
```
param($s,$i)$s + ' ' * ($i-$s.Length%$i) -replace '(.{4})?(.)(.)(.)(.)',"`$1`n`$5`$4`$3`$2`n" -split "`n" | ?{$_ -ne ""}
```
[Answer]
## [Perl 5](https://www.perl.org/), 51 bytes
```
$_.=$"x(($-=<>)-1);say--$|?$_:~~reverse for/.{$-}/g
```
[Try it online!](https://tio.run/##BcHBCoJAEADQu1@xxRIKzaqQF8s6dKhL4K2jCI4ijDsyW1FWfnrbeyMKZd7ryhR6@QxDDcVuH0EabV39AtCfg67yeRZ8oDhULUts3hq@ced9KdxJPQy97VR5nyZCp1bqyA2qE1MbbIIzEvFaXVmoWQTZj8dbz9Z5sOThkpkkTf4 "Perl 5 – Try It Online")
[Answer]
## Clojure, 83 bytes, 87 bytes, 79 bytes
```
(fn[n s](map #(apply str(% %2))(cycle[#(or %)reverse])(partition n n(repeat\ )s))))
```
several corrections after comments below, thank you [Ørjan](https://codegolf.stackexchange.com/users/66041/%C3%98rjan-johansen).
[Try it online!](https://tio.run/##LY3LTsMwEEX3@YpLqiBbgg2CL2ABy@5YpF1YzqSYjh@MnUrtzwe7YWZ3z9wzluPPIrSuaqIZvgPUHMaAfFTeJOyUSYmvyEXUgOFFa2WvlmncqSgYtNCFJNNRq2SkuOJiQF0llMiUA3TWdbqu2QPsN9kz7vb2iKlgFMoLFyhfe1m3vJIpZvrFyC4QtoMNVJQkoOX/3k35in4v8STGexdO2C@3G1PGI97jRPiIPPe6q1UXCgf0z/dp0VZ/Q/9JzPEJX1F4eqhkXf8A)
Clojure seems often sadly absent from code golfing answers. It certainly can not compete in byte length with golfing languages, but I think the total absence is somewhat unwarranted.
Explanation: 
* in-data, two arguments a number and a string
* start by running clojure built-in function [partition](https://clojuredocs.org/clojure.core/partition) on string `s` chunking it into a sequence of lists of characters where the lists have length `n`. The last chunk will be padded with spaces to length `n` using the "pad collection" returned from `(repeat " ")` which returns an infinite lazy sequence of spaces
* we then call [map](https://clojuredocs.org/clojure.core/map) with three arguments:
	+ an anonymous function (the `#(..)`)
	+ an infinite alternating lazy sequence of functions `#(or %)` which functions like the [identity](https://clojuredocs.org/clojure.core/identity) function and [reverse](https://clojuredocs.org/clojure.core/reverse) (i.e. `[#(or %) reverse #(or %) reverse ...]`) as returned by [cycle](https://clojuredocs.org/clojure.core/cycle).
	+ the chunked up lazy sequence of lists returned by partition.
* finally the [anonymous function](https://clojure.org/guides/learn/functions#_anonymous_function_syntax) `#(apply ...)`:
	+ calls either `identity` or `reverse` alternatingly on a chunk. This is done via the `(% %2)` expression which calls the function sent in as the first argument to the anonymous function [i.e. `identity` or `reverse`] using the second argument [i.e. the chunk] to the anonymous function as the argument to the call.
	+ calls `(apply str ...)` to convert the list of characters into a string
* the outer function returns a lazy sequence of strings
one trick we use here is that a lot of clojure functions like `map` take an arbitrary number of collections as args, i.e. `(map f coll1 coll2 coll3 ...)` where the function f just needs to accept as many arguments as there are collections. In this case we send in two collections, a collection of alternating function references and the chunked up string. 
[Answer]
# Python 3, ~~110~~ ~~108~~ ~~107~~ 103 bytes
```
def a(s,n):l=len(s)//n+1;s+=' '*(len(s)-l);print('\n'.join([s[x*n:n*x+n][::(-1)**x]for x in range(l)]))
```
(looking at other answers), with `rjust`: ~~95~~ ~~93~~ ~~92~~ 90 bytes
```
def a(s,n):print('\n'.join([s[x*n:n*x+n][::(-1)**x].rjust(n)for x in range(len(s)//n+1)]))
```
[Answer]
# Haskell, 108 bytes
```
(#)=splitAt
s!n=let(a,t)=n#s;(b,u)=n#t in a:reverse b:(u!n)
s%n=unlines$takeWhile(any(>' '))$(s++cycle" ")!n
```
That's sort of long, jeez. Here it is in action:
```
*Main> putStrLn $ "Programming Puzzles & Code Golf" % 4
Prog
mmar
ing
zzuP
les
oC &
de G
 flo
```
[Answer]
# Python 2, 109 bytes
Had to add padding with spaces for the last line to be correct.
[**Try it here**](http://ideone.com/54nKxW)
```
I,c=input()
I+=(c-len(I)%c)*" "
L=[]
i=0
while I:s=I[:c];L+=[[s,s[::-1]][i%2]];i+=1;I=I[c:]
print"\n".join(L)
```
[Answer]
# Lua, ~~91~~ ~~88~~ ~~88~~ ~~84~~ ~~83~~ 82 bytes
Old version:
```
a=arg for i=1,#a[1],a[2]do s=a[1]:sub(i,i+a[2]-1)print(d and s:reverse()or s)d=not d end
```
New version:
```
arg[1]:gsub((".?"):rep(arg[2]),function(s)print(d and s:reverse()or s)d=not d end)
```
[Answer]
# O, 60 bytes
```
z""/rlJ(Q/{n:x;Q({+}dxe{`}{}?p}drQJQ%-{' }dJQ/e{r}{}?Q({o}dp
```
My very first O program, and a long one at that!
[Live demo.](http://o-lang.herokuapp.com/link/code=z%22%22%2FrlJ(Q%2F%7Bn%3Ax%3BQ(%7B%2B%7Ddxe%7B%60%7D%7B%7D%3Fp%7DdrQJQ%25-%7B%27+%7DdJQ%2Fe%7Br%7D%7B%7D%3FQ(%7Bo%7Ddp&input=Programming+Puzzles+%26+Code+Golf%0A4)
[Answer]
# Q, ~~64~~ 56 bytes
```
{c::neg y;-1(til(#)l){$[x mod 2;c$(|:)y;y]}'l:y cut x;}
```
* `{}` is a function that should be called as `{}[x;y]`.
	+ `x` will be the string.
	+ `y` will be the length of the resulting lines.
Test:
```
{c::neg y;-1(til(#)l){$[x mod 2;c$(|:)y;y]}'l:y cut x;}["Programming Puzzles & Code Golf";4]
Prog
mmar
ing
zzuP
les
oC &
de G
 flo
```
**edit**: Used shorter functions as inspired by the other [q answer by @tmartin](https://codegolf.stackexchange.com/a/55119/21697)
[Answer]
# Python 2, 82 75 bytes
```
s,n=input()
k=0
while k<=len(s):print s[k:k+n].ljust(n)[::1-2*(k/n%2)];k+=n
```
I couldn't comment on @willem but I made his code smaller.
[Try here](http://ideone.com/jpDwEF)
[Try here](http://ideone.com/Qu5l6r)
[Answer]
# Perl, 72 bytes
```
perl -p0e's/\n(.*)/$"x($1-$-[0]%$1)/e;s/.{$1}/($i++%2?reverse$&:$&)."\n"/ge;chop'
```
70 bytes, plus 2 bytes for `-p0`.
Demo:
```
$ echo -en 'Hello, World!\n5' | perl -p0e's/\n(.*)/$"x($1-$-[0]%$1)/e;s/.{$1}/($i++%2?reverse$&:$&)."\n"/ge;chop'
Hello
roW ,
ld!  $
```
Note that the input read from STDIN cannot end with a newline (that would cost 2 extra bytes).
Explanation:
```
perl -p0e'  # Read from STDIN, splitting on null bytes,
            # and print $_ automatically at the end
    s/
        \n(.*)  # Replace everything after first newline,
                # capturing wrap length in $1...
     /
        $"x($1-$-[0]%$1)  # ...with spaces until the total length of $_ is
                          # a multiple of $1 (i.e. right-pad with spaces)
     /e;
    s/
        .{$1}  # Replace series of $1 contiguous chars...
     /
        ($i++%2?reverse$&:$&)."\n"  # ...alternately with themselves or in
                                    # reverse, with a trailing newline
     /ge;
    chop'  # Remove final newline
```
[Answer]
# JavaScript ES6, 123 bytes
```
var t=(s,n)=>{for(var d=1,i=0,o='',l=s.length;i<l;i++){o+=d?s[i]:s[i-i%n+n-1-i%n]||' ';if(i%n==n-1){d=!d;o+='\n'}}return o}
```
Call with `t(input_string, twist_length)`, which returns the output string.
[Answer]
# Python 3, 64 bytes
[Try Online](https://tio.run/##BcGxCsMgEADQvV9xZCgKtlCyXXDqkDW7OAgxicWcwTPU5ufte8evbIn61ma/gBOsSFX9kniD7xaiB8YjByqCDZJ95s/JRZA0iNXKgTUbQjtU/ajNiW7Kac1u3wOtMJ3XFT3DHd5p9jCmuHQKetnaHw)
```
def a(s,n,x=1):
 while s:print(s[:n].rjust(n)[::x]);s=s[n:];x=-x
a('Programming Puzzles & Code Golf',4)
```
Step 1: Print the first n bytes of the string (flag = 1 so normal order)
Step 2: Trim the string by n bytes
Step 3: Flip the flag to -1
Repeat the process until string is empty
Note that flag flips to +1 and -1. When it goes to -1, it prints in reverse order
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
òV ËzEÑÃù
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=8lYgy3pF0cP5&input=IlByb2dyYW1taW5nIFB1enpsZXMgJiBDb2RlIEdvbGYiCjQ)
[Answer]
## PHP, 135 bytes
Takes two command-line arguments as shown with `$argv`.
```
<? foreach($a=str_split($s=$argv[1],$n=$argv[2])as$k=>&$v)$v=$k%2?$v:strrev($v);echo implode("\n",$a).str_repeat(' ',$n-strlen($s)%$n);
```
[Answer]
## CoffeeScript, 131 bytes
This seems too long.
```
f=(s,n,r=l=s.length,i=0,z='')->(t=s[i...i+=n].split '';t=t.reverse()if r=!r;z+=t.join('')+(i<l&&'\n'||' '.repeat n-l%n))while i<l;z
```
[Answer]
# Julia, 104 bytes
```
f(s,n)=(L=length(s);L+=L÷n;j=0;for i=1:n:L-n+1 x=rpad(s,L)[i:i+n-1];println(j%2<1?x:reverse(x));j+=1end)
```
Ungolfed:
```
function f(s::String, n::Int)
    L = length(s) + length(s) ÷ n
    j = 0
    for i = 1:n:L-n+1
        x = rpad(s, L)[i:i+n-1]
        println(j % 2 == 0 ? x : reverse(x))
        j += 1
    end
end
```
[Answer]
# Python 3, 101 bytes
```
t,x=eval(input())
print("\n".join([t[c:c+x].ljust(x)[::1-2*(int(c/x)%2)] for c in range(0,len(t),x)]))
```
[Try it here](http://ideone.com/6Oxrqj "Try it here")
[Answer]
# q, 46
```
{-1@neg[y]$@[a;(&)(til(#)a:y cut x)mod 2;|:];}
```
.
```
q){-1@neg[y]$@[a;(&)(til(#)a:y cut x)mod 2;|:];}["Programming Puzzles & Code Golf";4]
Prog
mmar
ing
zzuP
les
oC &
de G
 flo
```
[Answer]
# Coffeescript, 151 bytes
```
f=(s,n)->r="";d=n;i=0;_="\n";u=" ";l=s.length;(d--and(r+=s[i]or u;++i)or(r+=_;r+=s[c]or u for c in[i+n-1..i];i+=d=n;r+=_ if i<l))while i<(l/n+1>>0)*n;r
```
Too much =(
]