In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such as:
- Stupid Brick Teeth
- Sussy Baka Training
- Shady Blue Tourists
- Seriously Big Toes
- Silly Bear Topics
- Salacious Bacon Tripod
- Syringed Baby Toys
- Schadenfreude Bringing Trains
- Several Belated Tanks
- Slightly Better Tiet (because piet doesn't start with a T)
As you can see, the meaning of "sbt" changes each time, and the words used are never repeated. Today's challenge is to generalise this to a block of text.
Challenge
Your task is to replace all instances of an acronym in a large block of text with a different meaning each time. To do so, you'll be given a string representing the haystack text and the acronym to change, as well as a list of words starting with each letter in the acronym.
For the acronym "sbt", you'll receive: the large text to change, the acronym, a list of words starting with "s", a list of words starting with "b" and a list of words starting with "t".
To each occurrence of the acronym, replace it with a uniformly randomly chosen word from each word list. To make sure the same set of words aren't used twice, one a word is chosen from a list, it can't be used again.
Worked Example
Given the following text:
I think it might be possible to make an sbt wrapper to allow it to be
used without a shell. That means that instead of having to launch the
sbt console each time, you'll be able to use sbt commands straight
from the command line.
The acronym "sbt"
and the following word lists:
["stupid", "sussy", "shady", "seriously", "silly", "salacious", "syringed", "several", "schadenfreude", "slightly"]
["brick", "baka", "blue", "big", "bear", "bacon", "baby", "bringing", "belated", "better"]
["teeth", "training", "tourists", "toes", "topics", "tripod", "toys", "trains", "tanks", "tiet"]
Valid outputs might include:
I think it might be possible to make an salacious bacon tripod wrapper to
allow it to be used without a shell. That means that instead of having to
launch the several big teeth console each time, you'll be able to use silly
blue toys commands straight from the command line.
I think it might be possible to make an stupid bear training wrapper to
allow it to be used without a shell. That means that instead of having to
launch the schadenfreude brick topics console each time, you'll be able to
syringed baka tripod sbt commands straight from the command line.
I think it might be possible to make an sussy baka toes wrapper to
allow it to be used without a shell. That means that instead of having to
launch the stupid brick teeth console each time, you'll be able to use
salacious baby topics commands straight from the command line.
Note that the above paragraphs have been line-wrapped for formatting reasons. They would otherwise be on a single line.
Rules
- Only acronyms surrounded by spaces or EOF should be replaced. That means that
"sbt"
in something like"whomsbted"
should not be replaced with an expanded meaning."sbt."
shouldn't be expanded either. But"sbt"
at the start or end of the long text should be replaced. - Acronyms will only contain distinct letters.
- The acronym will be case-sensitive. If the acronym is
"sbt"
, only"sbt"
should be placed, not"SbT"
,"sbT"
,"SBT"
and other variations. - Inputs can be taken in any reasonable and convenient format.
- Inputs can be taken in any order.
- Output can be given in any reasonable and convenient format.
- Each word in expanded meanings should have an equal chance of being included given it hasn't already been used. This can be achieved by removing the chosen word from the word list.
- None of the inputs will be empty.
- You can assume that the word lists will have at least as many words as there are occurrences of the acronym in the large text. They may be different lengths to each other though.
Test Cases
Format:
text
acronym
word lists
---
possible output
"I think it might be possible to make an sbt wrapper to allow it to be used without a shell. That means that instead of having to launch the sbt console each time, you'll be able to use sbt commands straight from the command line."
"sbt"
["stupid", "sussy", "shady", "seriously", "silly", "salacious", "syringed", "several", "schadenfreude"]
["brick", "baka", "blue", "big", "bear", "bacon", "baby", "bringing", "belated"]
["teeth", "training", "tourists", "toes", "topics", "tripod", "toys", "trains", "tanks"]
---
"I think it might be possible to make an salacious bacon tripod wrapper to allow it to be used without a shell. That means that instead of having to launch the several big teeth console each time, you'll be able to use silly blue toys commands straight from the command line."
"y'all ever just see a meme and rofl so hard that you rofl into a sharp object and rofl harder?"
"rofl"
["rinse", "rake", "randomise", "risky"]
["original", "orderly", "optimal", "omega"]
["flower", "flatten", "filibuster", "foxes"]
["linguistics", "legacies", "landings", "loses"]
---
"y'all ever just see a meme and rinse orderly flower landings so hard that you rake original filibuster loses into a sharp object and risky optimal flatten legacies harder?"
"Keg is a golfing language created by lyxal in 2018. Not to be confused with an actual beer keg, Keg is an acronym that stands for Keyboard Golfed. That's ironic, because Keg is horrible at golfing."
"Keg"
["Kaleidoscopes", "Keyboard", "King"]
["energetically", "eagerly", "entertains", "enrage"]
["goombas", "ginger", "google", "grams", "good"]
---
"Keyboard entertains ginger is a golfing language created by lyxal in 2018. Not to be confused with an actual beer keg, King eagerly grams is an acronym that stands for Keyboard Golfed. That's ironic, because Kaleidoscopes enrage goombas is horrible at golfing."
This is code-golf, so the answer with the lowest boring young train egg count in each language wins.
Update: Turns out jokes about acronymised software tools aren't as unique as I thought - npm seems to have been doing it for ages on their website. Rip lol