10
Create a function or program that makes a grid as close to an square as possible
- You will be given an integer N as input, whole numbers (1,2,3,25, etc)
- The output must be a perfect rectangular grid of N letters as close to a square as possible
- The (wannabe)square must consist of one of the the letters O or X as specified by user
Points:
- Hardcoded to only O or X: +1
- A param(0/1, true/false, something similar) to rotate output (like with 5 or 8): -10
- Design the square (use both O and X in some sort of pattern): -5
A pattern is considered valid if it contains both types of characters (where x/y-axis >= 3) and the pattern stays the same when flipped horizontally or vertically (exchanging Xs with Os is allowed)
Examples
INPUT: 4 INPUT: 5 INPUT: 8 INPUT: 9
OO OOOOO XXXX XOX
OO XXXX OXO
or rotated 90deg XOX
Examples which aren't allowed (not same length row or columns)
BAD RESULT: 5a BAD RESULT: 5b BAD RESULT: 8
OOO OO OOO
OO OO OOO
O OO
If possible please provide an online example.
Is a function enough, or do you want a full program? – John Dvorak – 2014-09-25T08:56:44.567
" Design the square ... in case of 9 change the center" -- under which exact circumstances is the pattern not a checkerboard? Can you provide an example? – John Dvorak – 2014-09-25T08:59:52.920
re the edit: do I read correctly that I get three points for doing
"xo"[i]
instead ofi
? That doesn't seem worth it. In general, all of your rewards seem kinda low. – John Dvorak – 2014-09-25T09:01:20.093"some sort of pattern" is kinda vague. Does it count if I replace the first 'x' with 'o'? – John Dvorak – 2014-09-25T09:02:12.697
Nice question. The only interesting bonus/penalty is the rotation one. Personally I would stick with one, hardcoded character (i.e. make the penalty the default) and eliminate all the bonuses / penalites except perhaps the rotation one. It's not a good idea to have too many bonuses or penalties. The important thing is to specify the main problem clearly. – Level River St – 2014-09-25T09:30:17.760
@steveverrill I don't consider them too many - just generally not worth it – John Dvorak – 2014-09-25T09:31:48.603
Wasn't sure about one of bonusses, changed it to the two now. I like the design one, a bit of creativity. – Martijn – 2014-09-25T09:32:29.820
I don't see any X in the examples. Really don't understand the X/O point. – edc65 – 2014-09-25T09:59:11.373
@edc65 I think the Pattern is meant like this: At least one of the characters in your output must be X and at least one must be O and your program must support the rotation-flag so that the pattern changes like you would rotate the grid – Falco – 2014-09-25T12:18:15.637
@Falco then put just a single X at top left, no change rotating (seriously, I'm going to try that) – edc65 – 2014-09-25T12:30:14.933
1 X amongst all O's isnt really a pattern is it? We're all smart people. – Martijn – 2014-09-25T12:38:05.050
@Martijn if it happens to be in the exact center, it's a valid pattern under the definition you have included. – John Dvorak – 2014-09-25T13:30:52.353
See, we're all smart ;) You're right. But one top left isn't – Martijn – 2014-09-25T13:36:04.017