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
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges My house is destroyed! Can you make me one?

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 yo...

posted 3y ago by General Sebast1an‭  ·  edited 3y ago by General Sebast1an‭

Answer
#2: Post edited by user avatar General Sebast1an‭ · 2021-09-06T01:06:25Z (over 3 years ago)
  • # [C (clang)], 116 bytes
  • <!-- language-all: lang-c -->
  • j,k;f(i){for(j=0;j<i;printf("#"),j++);for(j=0;j<i-1;j++){printf("\n#");for(k=0;k<i-2;printf(" "),k++);printf("#");}}
  • [Try it online!][TIO-kt7vsxgm]
  • Sometimes, it's better to use functions when you're not restricted from using it.
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-kt7vsxgm]: https://tio.run/##S9ZNzknMS///P0sn2zpNI1OzOi2/SCPL1sA6yybTuqAoM68kTUNJWUlTJ0tbW9MaSVLX0BokVA1TE5MHVAVWkA1UkA1UYATXrwDUnw3Sj2SgdW3t/9zEzDwNzWouzjQNU6BkaUkxyBygHEjEHEjV/gcA "C (clang) – Try It Online"
  • # [C (clang)], <s>116</s> 102 bytes
  • <!-- language-all: lang-c -->
  • 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!][TIO-kt7xzb3b]
  • Sometimes, it's better to use functions when you're not restricted from using it.
  • Golfed 14 bytes thanks to [**@Moshi**](https://codegolf.codidact.com/users/53196)'s [advice](https://codegolf.codidact.com/comments/thread/4396#comment-13402).
  • [C (clang)]: http://clang.llvm.org/
  • [TIO-kt7xzb3b]: https://tio.run/##S9ZNzknMS///P0sn2zpNI1OzOi2/SCPLNtM6S1fXuqAoM68kTUNJWUlT0xoqoWuIIQWSyQbKGOnARGPygOLW2UjqFEBG1P7PTczM09Cs5uJM0zDVtC4oLSkGKQaqBYmYY4gYGgDp2v8A "C (clang) – Try It Online"
#1: Initial revision by user avatar General Sebast1an‭ · 2021-09-06T00:04:42Z (over 3 years ago)
# [C (clang)], 116 bytes

<!-- language-all: lang-c -->

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

[Try it online!][TIO-kt7vsxgm]

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

[C (clang)]: http://clang.llvm.org/
[TIO-kt7vsxgm]: https://tio.run/##S9ZNzknMS///P0sn2zpNI1OzOi2/SCPL1sA6yybTuqAoM68kTUNJWUlTJ0tbW9MaSVLX0BokVA1TE5MHVAVWkA1UkA1UYATXrwDUnw3Sj2SgdW3t/9zEzDwNzWouzjQNU6BkaUkxyBygHEjEHEjV/gcA "C (clang) – Try It Online"