11
2
Spring has recently arrived, and it is almost the time when flowers start to sprout. So I want you to help them grow.
Your task:
Given two numbers, m
, and n
, output m
flowers randomly placed on an n*n
grid.
A single flower looks like this:
&
|
A flower's position is defined by where its &
is. When randomly placing two flowers, no two can be in the same place. If one flower's &
overlaps another flower's |
, display the &
. The bottom row of flowers may not contain any &
.
Input can be as a number or a string, through any of the standard methods.
Output can be a list of strings, each string representing one row of the grid, or a delimited string following the same guideline as the list. Standard methods of output. Trailing whatevers are allowed, and you can use tabs to separate your flowers. Note that every grid must be completely filled, with spaces or something.
Note that the input will always be valid, you will always be able to legally fit the m
flowers into the n
by n
grid.
Test cases:
Since only very tight test cases can be guaranteed, due to the whole "random placement" bit, that will be the only kind of test case with an answer provided. But I will try all submissions online to make sure that they are valid using some test cases too.
Input for the test cases is given in the form m, n
.
Input: 2, 2
Output:
&&
||
--------------
Input: 6, 3
Output:
&&&
&&&
|||
Note that the newline after the word Output:
in the test cases is optional.
Other test cases:
- 1, 10
- 0, 100
- 5, 8
- 6, 3
Code golf so shortest code wins!
Thank you to ComradeSparklePony for making this challenge and posting it in the Secret Santa's gift box!. Sandbox post
2When you say "randomly", does every possible outcome need to have equal probability? – xnor – 2017-04-22T06:26:31.380