Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Challenges

My house is destroyed! Can you make me one?

+3
−0

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

- Poem by Mark Giraffe

<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("#")

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Is a list of lines allowed as output? (4 comments)
White space? (2 comments)

10 answers

+2
−0

Canvas, 9 7 bytes

#*⌐⤢n↔n

-2 bytes thanks to @Razetime

Uh I don't really know how to use Canvas - what I think this does is create the vertical wall, then half the horizontal one, then concatneate and mirror them.

Try it here!

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

8 bytes: `#*#╴»×+│` (2 comments)
+2
−0

Ruby, 33 bytes

->n{?#*n+('
#'+' '*(n-2)+?#)*~-n}

Try it online!

Basically the same as moshi's python (developed parallelly).

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

General (1 comment)
+2
−0

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)

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

General (1 comment)
+1
−0

Charcoal, 7 bytes

GH↑→↓N#

Try it online!

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.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Rockstar, 82 bytes

listen to N
let N be-2
X's-1
say "##"+"#"*N
while N-X
say "#"+" "*N+"#"
let X be+1

Try it (code will need to be pasted in)

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 47 42 40 bytes

-2 bytes thanks to bastolski

lambda n:'#'*n+('\n#'+' '*(n-2)+'#')*~-n

Try it online!

Python's string multiplication is really useful.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

(n-1) --> ~-n for 40 bytes (1 comment)
+1
−0

JavaScript, 47 bytes

n=>`0`.repeat(n)+(`
0`.padEnd(n--)+0).repeat(n)

Try it online!

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:``

Try it online!

f=(n,x=n)=>--x?f(n,x)+`
0`.padEnd(n)+0:`0`.repeat(n)

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Vyxal, 13 bytes

\#*,‹(⇩\#꘍ṘǏ,

Try it Online!

\#*,          # Print a line of #
    ‹(        # n-1 times...
      ⇩\#꘍Ṙ   # n-2 spaces before a hash
           Ǐ, # Append a hash and print
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt -R, 11 10 bytes

ÆQ+ùUÉÃvçQ

Try it

Æ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
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+0
−0

C (clang), 116 102 bytes

j,k;f(i){for(j=i;j--;printf("#"));for(j=i-1;j--;printf("#"))for(k=i-2,printf("\n#");k--;printf(" "));}

Try it online!

Sometimes, it's better to use functions when you're not restricted from using it.

Golfed 14 bytes thanks to @Moshi's advice.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

102 bytes (1 comment)

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!