Introduction
Classes have started! And so does the boredom. I decided to doodle in my notebook and started to draw some dots in (IMO) an aesthetically pleasing way. I came up with these numbers:
based on these conditions:
Given (n, m)
1) There must be n dots
2) All dots must lie on an m by m lattice
3) The position of the dots must minimize the spread* from the top left corner
4) The configuration of the dots must be diagonally symmetric as pictured:
*Spread (in this context) is defined as the sum of the distances from the top left dot position (whether or not there is a dot there). For example, the spread of the example above is 0 + 1 + 2 + 1 + √2 + 2 + 2√2 = 6 + 3√2
The Challenge
Come up with an algorithm using that uses natural numbers n and m (where it will always be that n <= m^2) to generate a configuration of dots that follow all the rules above.
Input can be received via STDIN, command-line argument, or function parameter.
Output the pattern to STDOUT or return a string with newlines. Any two different characters may be used in the output.
(e.g.
110
100
000
is the same as
**-
*--
---
Shortest Code in Bytes Wins
Example
STDIN: 6 3
STDOUT:
***
**_
*__
The Challenge has Ended!!!
After seven days I decided to declare the winner, but first some special awards!
Fastest code goes to... orlp with his submission in Pyth !
Slowest code goes to... orlp with his submission in Pyth !
Most straightforward code goes to... orlp with his submission in Pyth !
Most confusing code goes to... orlp with his submission in Pyth !
Longest Code goes to... orlp with his submission in Pyth !
And last but not least
Shortest code goes to......... orlp with his submission in Pyth !
Congratulations!
24 6
. \$\endgroup\$