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 Gamer Meme Creator

Scala, 98 83 bytes Saved 15 bytes thanks to Shaggy! a=>t=>{val w=a.map(_.size).max (" "*(w-t.size>>1)+t)+:a:+" "*(w/2-5)+"BOTTOM TEXT"} Try it online! a is the ASCII art, t is th...

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

Answer
#3: Post edited by user avatar user‭ · 2021-08-03T22:28:05Z (over 3 years ago)
  • # Scala, 98 bytes
  • ```scala
  • a=>t=>{val w=a.map(_.size).max
  • (" "*(w-t.size>>1)+t)+:a:+" "*(w-11>>1)+"BOTTOM TEXT"mkString "\n"}
  • ```
  • [Try it online!](https://scastie.scala-lang.org/c2NXrP46R6CsDTkeHV7oPw)
  • `a` is the ASCII art, `t` is the string on top. `w` is the size of the longest line in the art, used for centering. A line `x` can be centered using `" "*(w-x.size>>1)+x` (no padding on the right side). We do that for both `t` and `BOTTOM TEXT`, then join on newlines.
  • # Scala, <s>98</s> 83 bytes
  • Saved 15 bytes thanks to Shaggy!
  • ```scala
  • a=>t=>{val w=a.map(_.size).max
  • (" "*(w-t.size>>1)+t)+:a:+" "*(w/2-5)+"BOTTOM TEXT"}
  • ```
  • [Try it online!](https://scastie.scala-lang.org/aP3iJji2RSqWPB2Z7Mlheg)
  • `a` is the ASCII art, `t` is the string on top. `w` is the size of the longest line in the art, used for centering. A line `x` can be centered using `" "*((w-x.size)/2)+x` (no padding on the right side). We do that for both `t` and `BOTTOM TEXT`, then join on newlines.
#2: Post edited by user avatar user‭ · 2021-08-01T19:06:13Z (over 3 years ago)
  • # Scala, 98 bytes
  • ```scala
  • a=>t=>{val w=a.map(_.size).max
  • (" "*(w-t.size>>1)+t)+:a:+" "*(w-11>>1)+"BOTTOM TEXT"mkString "\n"}
  • ```
  • [Try it online!](https://scastie.scala-lang.org/c2NXrP46R6CsDTkeHV7oPw)
  • # Scala, 98 bytes
  • ```scala
  • a=>t=>{val w=a.map(_.size).max
  • (" "*(w-t.size>>1)+t)+:a:+" "*(w-11>>1)+"BOTTOM TEXT"mkString "\n"}
  • ```
  • [Try it online!](https://scastie.scala-lang.org/c2NXrP46R6CsDTkeHV7oPw)
  • `a` is the ASCII art, `t` is the string on top. `w` is the size of the longest line in the art, used for centering. A line `x` can be centered using `" "*(w-x.size>>1)+x` (no padding on the right side). We do that for both `t` and `BOTTOM TEXT`, then join on newlines.
#1: Initial revision by user avatar user‭ · 2021-08-01T19:04:16Z (over 3 years ago)
# Scala, 98 bytes
```scala
a=>t=>{val w=a.map(_.size).max
(" "*(w-t.size>>1)+t)+:a:+" "*(w-11>>1)+"BOTTOM TEXT"mkString "\n"}
```
[Try it online!](https://scastie.scala-lang.org/c2NXrP46R6CsDTkeHV7oPw)