15
1
The famous C64 basic one liner
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
prints a maze of slashes and backslashes.
\\/\\\//\/\////\\/\/
\/\///\\///////\//\/
/\\\//\//\////\\//\\
\////\//\//\/\\\\\\/
/\/\\///\\\\/\\\\/\\
\/\//\\\\\\//\/\////
/\//\\///\/\///\////
\/\\\//\\/\\\//\\/\/
//////\\/\\/\/\/\///
\\/\/\\////\/\/\\/\/
Read in such maze made of diagonal walls from stdin and print out the same maze with horizontal and vertical walls consisting of the wall character "#"
For example the small maze
/\\
\\/
///
translates to
#####
# #
# # # #
# # # #
##### # # #
# #
#########
#####
To be precise, each isolated wall segment has the length of five characters, adjacent wall segments share a corner. Moving a character to the right/left/top/down in the matrix of slashes and backslashes corresponds to a diagonal translation by 2 characters in vertical and 2 characters in horizontal direction in the #-matrix.
Another output example would probably be useful. And I expect the title should be "one liner". – Calvin's Hobbies – 2015-09-25T00:06:23.453
Will the input maze always be a rectangle? Could you should a larger example so we can see the spacing? – xnor – 2015-09-25T00:06:31.393
2Welcome to Programming Puzzles & Code Golf Stack Exchange! Great first challenge, but a few things: can input/output be something other than STDIN/STDOUT (ex. as a function argument and return value)? Can lines be separated via a character other than newlines? – Doorknob – 2015-09-25T00:08:07.240
The input will be an n times m rectangle. – mschauer – 2015-09-25T00:08:31.627
2Using stdin and stdout is obligatory if possible, otherwise "the closest equivalent." Are there reasons to weaken the newline-assumption? – mschauer – 2015-09-25T00:13:32.143
1
Related: http://codegolf.stackexchange.com/q/37390/194 , http://codegolf.stackexchange.com/q/21730/194
– Peter Taylor – 2015-09-25T06:26:52.113@PeterTaylor: Bonus, but not obligatory: handle ' ' (space) to procure a general slash image inverter. – mschauer – 2015-09-25T09:49:50.220
Is trailing whitespace (newlines and/or spaces) allowed in the output? – Zgarb – 2015-09-25T18:09:04.023
@zgarb: yes xxxxxxxxx – mschauer – 2015-09-25T18:23:12.937
@codegolf.stackexchange: Why am I not allowed to be concise? Why is there a minimum length of a comment - in this very place? – mschauer – 2015-09-25T19:30:07.837
Ok, how about preceding whitespace? – Zgarb – 2015-09-25T19:53:41.437
At most 5 preceding whitespace in front of the lower left corner of the original picture, no preceding newline. – mschauer – 2015-09-25T20:43:17.487
reasons to weaken the newline-assumption: in JavaScript inside a browser console, I can get input (stdin like) using
prompt
. Butprompt
does not manage multiline input well – edc65 – 2015-09-26T23:25:54.667You can save some memory by re-writing the program as follows
0 PRINTCHR$(205.5+RND(1));:GOTO
– Shaun Bebbers – 2017-01-26T12:00:46.167