My house is destroyed! Can you make me one?
Background
A House of I
I went on an adventure
Grabbed resources and making deeds
Like start to work on the materials
To build the shelter I need
It was a marvelous one
At least in the eyes of mine
And when the sun sets
I go inside
I went to sleep in comfort
Hoping to show it to comrades
Dreaming of dreams
In the hours that pass
Next day I wake up
I find myself in a pickle
"My house is gone, oh dear!"
Now I feel ill
I can't find a place to live
Then there I find thou
I have a simple request
"Can you make me a house?"
As some time pass by
You built such structure with potential
When you said it's made of code
You're who I'd call special
<Go to the edit page of this post for better formatting>
Challenge
Take input of a number that's $n > 2$ and use it to make a home for supposed character of the poem using the character of your choice. The building in use has a flat roof and walls. Shortest program wins!
Test Cases (#
for demo)
Input: 3
Output:
###
# #
# #
Input: 5
Output:
#####
# #
# #
# #
# #
Input: 10
Output:
##########
# #
# #
# #
# #
# #
# #
# #
# #
# #
Example program in Python 3.x
n = int(input())
for i in range(n):
print("#", end = '')
print("")
for i in range(n - 1):
print("#", end = '')
for j in range(n - 2):
print(" ", end = '')
print("#")
[jq] `--raw-output`, 32 bytes …
3y ago
Canvas, 9 7 bytes #*⌐⤢n↔n …
3y ago
[Ruby], 33 bytes ``` ->n{? …
3y ago
[Charcoal], 7 bytes GH↑ …
3y ago
Rockstar, 82 bytes list …
3y ago
JavaScript, 47 bytes …
3y ago
Japt `-R`, 11 10 bytes …
3y ago
Vyxal, 13 bytes ``` \#,‹(⇩ …
3y ago
[Python 3], 47 42 40 bytes …
3y ago
[C (clang)], 116 102 bytes …
3y ago
10 answers
Japt -R
, 11 10 bytes
ÆQ+ùUÉÃvçQ
ÆQ+ùUÉÃvçQ :Implicit input of integer U
Æ :Map the range [0,U)
Q : Quotation mark
+ : Append another
ù : Left padded with spaces to length
UÉ : U-1
à :End map
v :Modify first element
çQ : Replace all characters with a quotation mark
:Implicit output joined with newlines
0 comment threads
Ruby, 33 bytes
->n{?#*n+('
#'+' '*(n-2)+?#)*~-n}
Basically the same as moshi's python (developed parallelly).
jq --raw-output
, 32 bytes
jq is the language of the month, apparently. Here it is! Not sure if the --raw-output
flag really matters, someone let me know.
"#"*.+("
#"+" "*(.-2)+"#")*(.-1)
JavaScript, 47 bytes
n=>`0`.repeat(n)+(`
0`.padEnd(n--)+0).repeat(n)
My first pass used recursion before I realised I was over thinking things! First 51 byte version includes a leading newline, second 52 byte version was in case that wasn't allowed.
f=(n,x=n)=>x?f(n,--x)+`
0`.padEnd(n,` 0`[+!x])+0:``
f=(n,x=n)=>--x?f(n,x)+`
0`.padEnd(n)+0:`0`.repeat(n)
0 comment threads
Charcoal, 7 bytes
GH↑→↓N#
Link is to verbose version of code.
PolygonHollow
exactly fits this challenge.
Prints a polygon with sides in x, all with length y, and the z used for the sides, repeating from the origin. Polygon is not autoclosed or filled.
0 comment threads
Vyxal, 13 bytes
\#*,‹(⇩\#꘍ṘǏ,
\#*, # Print a line of #
‹( # n-1 times...
⇩\#꘍Ṙ # n-2 spaces before a hash
Ǐ, # Append a hash and print
2 comment threads