Skip to main content
Further improvements
Source Link
Scott
  • 237
  • 2
  • 8

Javascript (ES6), 407 400 366 360360 353 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(new RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+c+[.split``..c].reverse().map(b=>(d=s.indexOf(b),"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[d+8])).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")),  //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c+[.split``..c].reverse()  //Split this cut into each character, and read it backwards .map((b,d)=>( //Translate each character d=s.indexOf(b), //Save where this character appears in the mapping "A"<=b&&"z">=b //If the character is a-zA-Z ?s[d+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[d+8])) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 
  • Thanks to Dendrobium for shaving off 6-6 bytes!
  • Thanks to the Closure Compiler for shaving off 34-34 bytes!
  • Thanks to ןnɟuɐɯɹɐןoɯ for -7 bytes!

Javascript (ES6), 407 400 366 360 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(new RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+c.split``.reverse().map(b=>(d=s.indexOf(b),"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[d+8])).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map((b,d)=>( //Translate each character d=s.indexOf(b), //Save where this character appears in the mapping "A"<=b&&"z">=b //If the character is a-zA-Z ?s[d+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[d+8])) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 
  • Thanks to Dendrobium for shaving off 6 bytes!
  • Thanks to the Closure Compiler for shaving off 34 bytes!

Javascript (ES6), 407 400 366 360 353 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+[...c].reverse().map(b=>(d=s.indexOf(b),"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[d+8])).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(RegExp(`.{1,${w}}`,"g")),  //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +[...c].reverse()  //Split this cut into each character, and read it backwards .map((b,d)=>( //Translate each character d=s.indexOf(b), //Save where this character appears in the mapping "A"<=b&&"z">=b //If the character is a-zA-Z ?s[d+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[d+8])) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 
  • Thanks to Dendrobium for -6 bytes!
  • Thanks to the Closure Compiler for -34 bytes!
  • Thanks to ןnɟuɐɯɹɐןoɯ for -7 bytes!
More savings
Source Link
Scott
  • 237
  • 2
  • 8

Javascript (ES6), 407 400 366366 360 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(new RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+c.split``.reverse().map(b=>"A"<=b&&"z">=b?s[sb=>(d=s.indexOf(b)+26],"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[s.indexOf(bs[d+8])+8]).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map(b=>(b,d)=>( //Translate each character  d=s.indexOf(b),  //TranslateSave eachwhere this character appears in the mapping "A"<=b&&"z">=b //If the character is a-zA-Z ?s[s.indexOf(b)+26]s[d+26]  //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[s.indexOf(bs[d+8])+8])  //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 

Javascript (ES6), 407 400 366 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(new RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+c.split``.reverse().map(b=>"A"<=b&&"z">=b?s[s.indexOf(b)+26]:" "==b?b:s[s.indexOf(b)+8]).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map(b=> //Translate each character "A"<=b&&"z">=b //If the character is a-zA-Z ?s[s.indexOf(b)+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[s.indexOf(b)+8]) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 

Javascript (ES6), 407 400 366 360 bytes

s=`ABCDEFGHIJKLMNOPQRSTUVWXYZ∀qƆpƎℲפHIſʞ˥WNOԀQɹS┴∩ΛMX⅄Zabcdefghijklmnopqrstuvwxyzɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz&_?!"'.,⅋‾¿¡„,˙'`,f=(i,w)=>(i=i.match(new RegExp(`.{1,${w}}`,"g")),i.map((c,x)=>x%2?" ".repeat(w-c.length)+c.split``.reverse().map(b=>(d=s.indexOf(b),"A"<=b&&"z">=b?s[d+26]:" "==b?b:s[d+8])).join``:c).join` `) let input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel libero arcu. Nunc dictum elementum lectus nec aliquet. Donec dolor nunc, sodales at dolor rhoncus, hendrerit scelerisque purus. Pellentesque vel sagittis libero, et rutrum leo. Nullam vulputate enim et massa dictum, vitae venenatis augue lobortis. Fusce sollicitudin ultrices consequat. Vestibulum quis nunc non tortor eleifend facilisis. In at nunc elit. Aliquam pellentesque, lectus quis aliquam posuere, quam lectus sagittis metus, ut auctor sem quam a neque. Integer rhoncus lobortis nisl. Pellentesque mi dui, laoreet in metus quis, mollis accumsan est. Nunc dignissim tortor ac eleifend tempus. Ut ut tellus aliquam, luctus nulla quis, consectetur nunc. Suspendisse viverra molestie condimentum. Curabitur et hendrerit augue."; console.log(f(input, 50));
s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map((b,d)=>( //Translate each character  d=s.indexOf(b),  //Save where this character appears in the mapping "A"<=b&&"z">=b //If the character is a-zA-Z ?s[d+26]  //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[d+8]))  //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 
Added explanation
Source Link
Scott
  • 237
  • 2
  • 8

###Explanation

s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map(b=> //Translate each character "A"<=b&&"z">=b //If the character is a-zA-Z ?s[s.indexOf(b)+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[s.indexOf(b)+8]) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 

###Explanation

s=`A∀ .. ZZaɐ .. &⅋ ..`, //Character translation "map" f=(i,w)=> //Create a function named "f" that takes an (i)nput string and (w)idth ( //Implicitly return i=i.match(new RegExp(`.{1,${w}}`,"g")), //Cut string into arrays every w-th match of anything i.map((c,x)=> //Loop through each element in array by (c)ut at inde(x) x%2 //If the index is odd ?" ".repeat(w-c.length) //Output spaces for padding +c.split``.reverse() //Split this cut into each character, and read it backwards .map(b=> //Translate each character "A"<=b&&"z">=b //If the character is a-zA-Z ?s[s.indexOf(b)+26] //Print the flipped character by looking 26 characters ahead of where this character is found :" "==b //Else, if it's a space ?b //Output the space :s[s.indexOf(b)+8]) //Else, print the flipped punctuation character (only 8 of these) .join`` //Join everything back into a continuous string :c //Else just output the whole cut ).join` `) //Finally join each cut by a newline 
No longer using if/else!
Source Link
Scott
  • 237
  • 2
  • 8
Loading
Removed unnecessary space
Source Link
Scott
  • 237
  • 2
  • 8
Loading
Source Link
Scott
  • 237
  • 2
  • 8
Loading