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

66%
+2 −0
Challenges In The Jailhouse Now

C (gcc), 119 118 116 115 bytes #define p(x,y,z) printf(i^1?i^c?#z:#y:#x) i,j;f(c){for(i=1;i<=c;p(╗\n,╝\n,╣\n),i++)for(j=p(╔,╚,╠);j++<c;)p(╦,╩,╬);} Try it online! Function solution. I...

posted 3y ago by Lundin‭  ·  edited 3y ago by Lundin‭

Answer
#11: Post edited by user avatar Lundin‭ · 2021-08-26T16:25:11Z (about 3 years ago)
  • # [C (gcc)], <strike>119 118 116</strike> 115 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗\n,╝\n,╣\n),i++)for(j=p(╔,╚,╠);j++<c;)p(╦,╩,╬);}
  • [Try it online!][TIO-kssrhvra]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssrhvra]: https://tio.run/##HYrfCoIwGMXvfYrBbvaxeSF0EU7xRUSQ5eSTWmJB/sG3SIIgCIIg6Kl8kNb04pwf/M5RfqmUtXRXaDQFqVkrOtEDqRs0Z80wCxLMVEL7kHYhbcFDUUnNFAz62DCMA4lRrGTN5umWGjFPj7VfqQGBnMPyquJlvjp9d3mCrDiPlITFvp35uHxBjvaQo2EweIRotgG5cus42p/S@7w8Wf/yBw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], <strike>119 118 116</strike> 115 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗\n,╝\n,╣\n),i++)for(j=p(╔,╚,╠);j++<c;)p(╦,╩,╬);}
  • [Try it online!][TIO-kssrhvra]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssrhvra]: https://tio.run/##HYrfCoIwGMXvfYrBbvaxeSF0EU7xRUSQ5eSTWmJB/sG3SIIgCIIg6Kl8kNb04pwf/M5RfqmUtXRXaDQFqVkrOtEDqRs0Z80wCxLMVEL7kHYhbcFDUUnNFAz62DCMA4lRrGTN5umWGjFPj7VfqQGBnMPyquJlvjp9d3mCrDiPlITFvp35uHxBjvaQo2EweIRotgG5cus42p/S@7w8Wf/yBw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • EDIT:
  • Recursive version which currently landed at exactly 115 bytes too...
  • #define p(x,y,z) printf(i^1?i^c?#z:#x:#y);
  • c,j;f(i){for(c=c?c:i,j=p(╔,╚,╠)j++<c;)p(╦,╩,╬)p(╗\n,╝\n,╣\n)--i?f(i):0;}
#10: Post edited by user avatar Lundin‭ · 2021-08-26T10:07:48Z (about 3 years ago)
  • # [C (gcc)], <strike>119 118</strike> 116 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=p(╔,╚,╠);j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssrd7un]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssrd7un]: https://tio.run/##HYrfCoIwGMXvfYrBbvbhvBC6CKf4IiLIcvKNWmJB/sG3SIIgCIIg6Kl8kNb04pwf/M6RQSWltXRXKjQlqVnLO94DqRs0Z8UwD1PMZUr7iHYRbcFDroViEgZ1bBgmocA4kaJm83TLDJ@nx9qvzABH34flpZNlvjp9d3mC0LEU2o2Lfjv1cfmCGO2hQMNg8AhRbANi5dZxtD@p9kV1ssHlDw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], <strike>119 118 116</strike> 115 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=p(╔,╚,╠);j++<c;)p(╦,╩,╬);}
  • [Try it online!][TIO-kssrhvra]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssrhvra]: https://tio.run/##HYrfCoIwGMXvfYrBbvaxeSF0EU7xRUSQ5eSTWmJB/sG3SIIgCIIg6Kl8kNb04pwf/M5RfqmUtXRXaDQFqVkrOtEDqRs0Z80wCxLMVEL7kHYhbcFDUUnNFAz62DCMA4lRrGTN5umWGjFPj7VfqQGBnMPyquJlvjp9d3mCrDiPlITFvp35uHxBjvaQo2EweIRotgG5cus42p/S@7w8Wf/yBw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#9: Post edited by user avatar Lundin‭ · 2021-08-26T10:05:09Z (about 3 years ago)
Oh hey, printf happens to return 3 in this case. This is some truly evil code... :)
  • # [C (gcc)], <strike>119</strike> 118 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=3,p(╔,╚,╠);j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssr6wok]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssr6wok]: https://tio.run/##HYrfCoIwGMXvfYrBbvbhvJC6CJf4IiLIcvKNWmJB/sG3SIIgCIIg6Kl8kNb04pwfnN@RQSmltXRXKDQFqVjDW94BqWo0Z8UwCxPMZEK7iLYRbcBDroViEnp1rBnGocBtLEXFpvGWGj6Nj6VfqQGOvg/zS8crPh@uTtxdniD0Vgrt9Dy/3fRx@YIY7CFHw6D3CFFsDWLhxnGwP6n2eXmyweUP "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], <strike>119 118</strike> 116 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=p(╔,╚,╠);j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssrd7un]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssrd7un]: https://tio.run/##HYrfCoIwGMXvfYrBbvbhvBC6CKf4IiLIcvKNWmJB/sG3SIIgCIIg6Kl8kNb04pwf/M6RQSWltXRXKjQlqVnLO94DqRs0Z8UwD1PMZUr7iHYRbcFDroViEgZ1bBgmocA4kaJm83TLDJ@nx9qvzABH34flpZNlvjp9d3mC0LEU2o2Lfjv1cfmCGO2hQMNg8AhRbANi5dZxtD@p9kV1ssHlDw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#8: Post edited by user avatar Lundin‭ · 2021-08-26T09:59:49Z (about 3 years ago)
Move the first print to the first condition of inner for loop. Lose && but adds a ,
  • # [C (gcc)], 119 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-ksspc60b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ksspc60b]: https://tio.run/##HYtdCoJAFIXfXcXAgMzF8UHqIRzFjYggkyNXahIL8gd3kQRBEARB0KpcSNPYwzkfH5wj/VJKY@i2UKgLUrOWd7wHUjeoT4phFiSYyYT2Ie1C2oKDvBKKSRjUoWEYBwKjWLpuzebpwufpZvMAseg11Vbu/36mGjh6HiyvKl6JKpKisr4MX3bwtvmAGM0@R81gcAhRbA3iz43laL5S7fLyaPzzDw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], <strike>119</strike> 118 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c;p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=3,p(╔,╚,╠);j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssr6wok]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssr6wok]: https://tio.run/##HYrfCoIwGMXvfYrBbvbhvJC6CJf4IiLIcvKNWmJB/sG3SIIgCIIg6Kl8kNb04pwfnN@RQSmltXRXKDQFqVjDW94BqWo0Z8UwCxPMZEK7iLYRbcBDroViEnp1rBnGocBtLEXFpvGWGj6Nj6VfqQGOvg/zS8crPh@uTtxdniD0Vgrt9Dy/3fRx@YIY7CFHw6D3CFFsDWLhxnGwP6n2eXmyweUP "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#7: Post edited by user avatar Lundin‭ · 2021-08-26T09:07:03Z (about 3 years ago)
  • # [C (gcc)], <strike>126</strike> 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], 119 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf(i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-ksspc60b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ksspc60b]: https://tio.run/##HYtdCoJAFIXfXcXAgMzF8UHqIRzFjYggkyNXahIL8gd3kQRBEARB0KpcSNPYwzkfH5wj/VJKY@i2UKgLUrOWd7wHUjeoT4phFiSYyYT2Ie1C2oKDvBKKSRjUoWEYBwKjWLpuzebpwufpZvMAseg11Vbu/36mGjh6HiyvKl6JKpKisr4MX3bwtvmAGM0@R81gcAhRbA3iz43laL5S7fLyaPzzDw "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#6: Post edited by user avatar Lundin‭ · 2021-08-26T09:06:07Z (about 3 years ago)
  • # [C (gcc)], 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], <strike>126</strike> 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#5: Post edited by user avatar Lundin‭ · 2021-08-26T09:05:45Z (about 3 years ago)
  • # [C (gcc)], 124 bytes <strike>126</strike>
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#4: Post edited by user avatar Lundin‭ · 2021-08-26T09:05:32Z (about 3 years ago)
  • # [C (gcc)], 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], 124 bytes <strike>126</strike>
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#3: Post edited by user avatar Lundin‭ · 2021-08-26T09:05:18Z (about 3 years ago)
  • # [C (gcc)], 124 <strike>126</strike> bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], 124 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#2: Post edited by user avatar Lundin‭ · 2021-08-26T09:05:02Z (about 3 years ago)
  • # [C (gcc)], 126 bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=0;j<c-3;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-ksson86j]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-ksson86j]: https://tio.run/##HYtRCoJAGITfO8XiUuyPKyT1EK7SRUSIzZV/qU0qSBNvUQRBEARB0Kk8SNvqw8zwDTMyKKS0lq5zhSYnJat4zc9Ayj2ao2Le@OBxzMIlZnJJzxGtI1rBCLkWiklo1G7PMAkFxomcTErWXS@8u96dniB6vKXGwWPwV2qAo@9D/9LJVOhYBjOhXdNP327ycfqCaO12hYZBMyJEsTmIIRcuW/uTarMqDjY4/QE "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
  • # [C (gcc)], 124 <strike>126</strike> bytes
  • <!-- language-all: lang-c -->
  • #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
  • i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗
  • ,╝
  • ,╣
  • ),i++)for(j=3;j<c;j++)p(╦,╩,╬);}
  • [Try it online!][TIO-kssp9e7b]
  • [C (gcc)]: https://gcc.gnu.org/
  • [TIO-kssp9e7b]: https://tio.run/##HYtdCoJAFIXfXYUkyVwcH6QewlHciAgyOXKlJtEgf3AXSRAEQRAErcqFNI0@nPPxwTnczTlXytpnAmVmlqShLe3ALCuUZ0FW63pFMfEiTHhkdb7V@lYDBtKCCcKhF6eKYOgxDEJu2yWZxiudxrvOE9ist1hqeSz9iiVQdByYX0W4YUXAWaF9Hr714KPzBTaoY4qSQG@YpiBbYAt3moP6cXFI81q5lz8 "C (gcc) – Try It Online"
  • Function solution.
  • I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.
#1: Initial revision by user avatar Lundin‭ · 2021-08-26T08:56:38Z (about 3 years ago)
# [C (gcc)], 126 bytes

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

    #define p(x,y,z) printf("%s",i^1?i^c?#z:#y:#x)
    i,j;f(c){for(i=1;i<=c&&p(╔,╚,╠);p(╗\n,╝\n,╣\n),i++)for(j=0;j<c-3;j++)p(╦,╩,╬);}

[Try it online!][TIO-ksson86j]

[C (gcc)]: https://gcc.gnu.org/
[TIO-ksson86j]: https://tio.run/##HYtRCoJAGITfO8XiUuyPKyT1EK7SRUSIzZV/qU0qSBNvUQRBEARB0Kk8SNvqw8zwDTMyKKS0lq5zhSYnJat4zc9Ayj2ao2Le@OBxzMIlZnJJzxGtI1rBCLkWiklo1G7PMAkFxomcTErWXS@8u96dniB6vKXGwWPwV2qAo@9D/9LJVOhYBjOhXdNP327ycfqCaO12hYZBMyJEsTmIIRcuW/uTarMqDjY4/QE "C (gcc) – Try It Online"

Function solution. 

I started with a recursive solution but it didn't work out well... though I'm still convinced that this can be shaved down quite a bit with recursion.