10
Long time lurker first time poster here.
Write a program which takes 3 inputs: X, Y and Z.
- X = across (columns)
- Y = down (rows)
- Z = Location Marker
The program should then print a visual grid X across and Y down. This grid will can be made of any character except "+". Each 'location' is given an index number, counting up from 1 at coordinate 1, 1 across and then down until the end.
X and Y will always be at least 3, and Z will never be bigger than X * Y
.
Z will represent the location which is printed as a "+", on the location as well as 1 character left, right, up and down. For example:
+
+++
+
Finally, if the + characters would intercept the edges (top most, left most, right most and/or down most edge), then the + should bounce back along the same axis and overflow the other side.
Examples: Input = 5, 5, 13
-----
--+--
-+++-
--+--
-----
Input = 10, 10, 10
-------+++
---------+
---------+
----------
----------
----------
----------
----------
----------
----------
Input = 10, 10, 21
----------
+---------
+++-------
+---------
----------
----------
----------
----------
----------
----------
Edit : non square example 16,3,32
---------------+
-------------+++
---------------+
I think I've covered everything. There should be no limit to the input, but if your program requires, cap it off at 64 * 64.
Bonus point (can I do that?): Input Z should not be > X * Y, but if it is larger than Y * Z, then output the center + to the middle of the grid.
EDIT: Input Z cannot be greater than X * Y
Edit 2:. Made some changes to X and Y to hopefully be clearer
This is code golf, shortest code wins.
Welcome to Programming Puzzles and Code Golf! This is a nice challenge, but I recommend posting future challenges to the Sandbox where they can get feedback before being posted to the main site.
– betseg – 2016-12-02T05:09:56.093What is the "Bonus point" about? Does implementing that exact feature give an advantage to your byte-count? If it does, you should explicitly note how big of a bonus it is. (As a side note, bonuses in code-golf are generally discouraged)
– James – 2016-12-02T05:13:25.263@betseg - oops. Sorry, hopefully I can gain some interest having missed that important step. – Jake Harry – 2016-12-02T05:19:01.680
@DrMcMoylex - Noted, thanks, have removed the bonus now. – Jake Harry – 2016-12-02T05:19:20.153
You should explain how
– Luis Mendo – 2016-12-02T08:44:18.857Z
represents the location (1-based row-major it seems)X accross and Y down @luis – Jake Harry – 2016-12-02T09:00:20.260
2You shouldn't be accepting an answer in the first day of posting, I am fairly confident a MATL/Jelly/05AB1E golfer will see this and solve it in much less bytes than Python. I think most people tend to wait at least a week. – Kade – 2016-12-02T12:35:01.640
@kade. Thanks the rules made it sound like the answer you choose doesn't have to be the best one? – Jake Harry – 2016-12-02T22:07:43.037
@James yes I'm an all round stooge. First across, then down. And yes, it should be 10 rows and 10 columns – Jake Harry – 2016-12-04T02:18:33.470
@james I made some changes to the description. Is that clearer? – Jake Harry – 2016-12-04T02:22:50.517
@james That's the spirit! Sorry mate, my fault – Jake Harry – 2016-12-04T02:30:09.087
I am sad that there has been so few golf language attempts at this!! – Jake Harry – 2016-12-15T23:36:35.960