21
2
I got this challenge from Codingame and am curious about better solutions than mine:
Given a width via standard input draw a hollow square of '#' in given width and length.
Example:
5 results in
#####
# #
# #
# #
#####
I used python to solve this so i am particulary interested in other python code. But please feel free to post your solution in any language you want.
7What if input is 0 or 1? – Karl Napf – 2016-11-07T14:27:35.947
8Related, though this might be different enough to not be a dupe. – AdmBorkBork – 2016-11-07T14:31:20.200
3
Welcome to PPCG! For future questions, I encourage you to use the Sandbox where you can get meaningful feedback on a challenge before posting it to the main page.
– AdmBorkBork – 2016-11-07T14:31:59.147@KarlNapf Run his test code and see what the result is. – mbomb007 – 2016-11-07T14:32:04.263
@TimmyD Hardly necessary, in this case. – Shaun Wild – 2016-11-07T14:39:15.633
Partially related – Kevin Cruijssen – 2016-11-07T14:50:35.767
4Reading through the answers, I'm not convinced it's a dupe. Most of the answers here (golfing and regular languages) are roughly half the size of the answers on "Print N Squared." – AdmBorkBork – 2016-11-07T16:43:11.517
Does "via standard input" in "Given a width via standard input" mean that we have to read from stdin or that we can use any of PPCG's standard input methods?
– nimi – 2016-11-07T19:04:08.050@ElPedro The post has been reopened for the past several hours. – AdmBorkBork – 2016-11-07T20:18:34.917
Yes, and I left my code at work because I wrote it in my lunch break and now I have to wait until tomorrow to post by which time it may have been closed again. Just saying, if answers have already been posted and others may be working on an alternative solution is it right to close it and so waste their time? Just a question. Any opinions welcome. I'm not saying that I am right. – ElPedro – 2016-11-07T20:31:10.373
1This is absolutely a duplicate. Solutions from the other challenge can be trivially modified to be valid and competitive here. – Mego – 2016-11-08T10:42:21.927