Skip to main content
1 of 2
user avatar
user avatar

#Pyth, 32 bytes

J1VQ=JhtS[06+J-qNbqNd;?qJ1\N?JJ1

Uses space and newline for down and up.

Explanation

J1VQ=JhtS[06+J-qNbqNd;?qJ1\N?JJ1
J1                                 Initialize J to 1
  VQ                 ;             For each character in the input
            +J-qNbqNd              Increment or decrement J
      htS[06                       Get the middle sorted value of [0,6,J]
    =J                             Assign it to J
                      ?qJ1\N?JJ1   Change 1 to 'N' and 0 to 1

There's almost certainly a better way to do the incrementing and the output.

user48543