Hidden sentences in the license plates

12

2

Introduction:

Inspired by both Perfect License Plates and How many points does my license plate give?

Just like in the challenges above, me and my little brother had a game of our own with license plates as kids. We tried to create (random/funny) sentences with the (numbers and) letters of the license plates.

For example, I can still remember the license plate of our old car from over ten years ago, because of the silly sentence we had created with it:

71-NN-BT
71 Nare Nonnen Bijten Tijgers   [Dutch for: 71 Nasty Nuns Biting Tigers]

Input:

  • A license plate, which for the sake of this challenge will always start with two digits [0-9], followed by four uppercase letters [A-Z].
  • Three fixed lists (see below): consisting of Dutch plural nouns; Dutch adjectives; and Dutch verbs.

Output:

Using the list of Dutch plural nouns, adjectives and verbs below as input, create a random Dutch sentence with the given license plate using the following rules:

  • Start with the numbers, followed by a space;
  • And the four letters should either be used in the pattern adjective noun verb noun or noun verb adjective noun (50/50 random).
    This would mean that the sentence mentioned earlier ("Nare Nonnen Bijten Tijgers" / "Nasty Nuns Biting Tigers") is in the pattern adjective noun verb noun, and this alternative sentence "Nonnen Negeren Blote Theekopjes" / "Nuns Ignoring Naked Teacups" is in the pattern noun verb adjective noun).

Lists of words

Formatted pastebin thanks to @Arnauld.

Nouns:

Aanbeelden [Anvils]
Aardbeien [Strawberries]
Apen [Monkeys]
Appels [Apples]
Auto's [Cars]
Bananen [Bananas]
Bessen [Berries]
Bloemen [Flowers]
Bomen [Trees]
Bijen [Bees]
Cadeaus [Presents]
Cavia's [Guinea pigs]
Cheerleaders [Cheerleaders]
Circusdieren [Circus animals]
Citroenen [Limons]
Dinosaurussen [Dinosaurs]
Dieren [Animals]
Documenten [Documents]
Doctoren [Doctors]
Dolfijnen [Dolphins]
E-mails [Emails]
Edelstenen [Gemstones]
Eekhoorns [Squirles]
Enqûetes [Enquetes]
Ezels [Donkeys]
Fabrieken [Factories]
Fietsen [Bicycles]
Flessen [Bottles]
Fontijnen [Fountains]
Foto's [Photographs]
Giraffen [Girafs]
Glazen [Glasses]
Gummen [Erasers]
Guppy's [Guppies]
Gymschoenen [Gym shoes]
Haaien [Sharks]
Homo's [Gay men]
Honden [Dogs]
Hoofden [Heads]
Horloges [Watches]
Idioten [Idiots]
Idolen [Idols]
IJsklontjes [Ice cubes]
Illusies [Illusions]
Imperia [Empires]
Jassen [Jackets]
Jokers [Jokers]
Jongleurs [Jugglers]
Jurken [Dresses]
Juwelen [Jewels]
Kabels [Cables]
Katten [Cats]
Kauwgomballen [Gum-balls]
Knoppen [Buttons]
Konijnen [Rabbits]
Leesboeken [Reading books]
Leeuwen [Lions]
Legercommandanten [Commander-in-chieves]
Lesbies [Lesbians]
Lummels [Oafs]
Maagden [Virgins]
Mannen [Men]
Mensen [People]
Mieren [Ants]
Muren [Walls]
Neuzen [Noses]
Nieuwkomers [Novices]
Nonnen [Nuns]
Noten [Nuts]
Nummerborden [License plates]
Oceanen [Oceans]
Ogen [Eyes]
Olifanten [Elephants]
Oren [Ears]
Orkanen [Huricanes]
PC's [PCs]
Pizza's [Pizzas]
Politieagenten [Police officers]
Postbezorgers [Mail men]
Potloden [Pencils]
Quads [ATVs]
Quaggamosselen [Quagga mussels]
Querulanten [Querulants]
Quiëtisten [Quietists]
Quizzen [Quizzes]
Radio's [Radios]
Ramen [Windows]
Regiseuren [Film directors]
Rekenmachines [Calculators]
Relschoppers [Hooligans]
Schepen [Ships]
Slakken [Snails]
Slangen [Snakes]
Stegosaurussen [Stegosauruses]
Stoelen [Chairs]
T-rexen [T-rexes]
Tafels [Tables]
Theekopjes [Teacups]
Tijgers [Tigers]
Tovenaars [Wizards]
Uien [Unions]
Uilen [Owls]
Universa [Universes]
Universiteiten [Universities]
USB-sticks [USB-sticks]
Vliegtuigen [Planes]
Vrachtwagens [Trucks]
Vrienden [Friends]
Vrouwen [Women]
Vulkanen [Vulcanos]
Walvissen [Whales]
Wespen [Wasps]
Wormen [Worms]
Worstelaars [Wrestlers]
Wortels [Carrots]
X-assen [X-axes]
X-chromosomen [X-chromosomes]
Xenonlampen [Xenon lamps]
Xylofonen [Xylophones]
Xylofonisten [Xylophonists]
Y-assen [Y-axes]
Y-chromosomen [Y-chromosomes]
Yoghurtdranken [Yugurt drinks]
Yogaleraren [Yoga teachers]
Yogaleraressen [Female yoga teachers]
Zeeën [Seas]
Zeehonden [Seals]
Zeepbellen [Soap bubbles]
Zwanen [Swans]
ZZP'ers [Freelancers]

Verbs:
X has some duplicated verbs, because there aren't enough verbs starting with an X in Dutch..

Accepteren [Accepting]
Activeren [Activating]
Amputeren [Amputating]
Amuseren [Amuzing]
Assisteren [Assisting]
Bakken [Baking]
Bedreigen [Threatening]
Bellen [Calling]
Bevruchten [Fertilizing/Impregnating]
Bijten [Biting]
Castreren [Castrating]
Categoriseren [Categorizing]
Centrifugeren [Centrifuging]
Claimen [Claiming]
Coachen [Coaching]
Dagvaardigen [Prosecuting]
Daten [Dating]
Degraderen [Downgrading]
Dienen [Serving]
Dwarsbomen [Thwarting]
Electroniseren [Eletronizing]
Eren [Show respect for]
Erven [Inherit]
Eten [Eating]
Exploderen [Blow up]
Factureren [Invoicing]
Fokken [Breeding]
Föhnen [Blow-drying]
Fotographeren [Photographing]
Frituren [Frying]
Gooien [Throwing]
Graderen [Grading]
Grijpen [Grabbing]
Groeperen [Making groups of]
Groeten [Greeting]
Hacken [Hacking]
Hallucineren [Hallucinating]
Haten [Hating]
Helpen [Helping]
Huren [Renting]
Importeren [Importing]
Inspireren [Inspiring]
Ironiseren [Ridiculing]
Irriteren [Irritating/Annoying]
Isoleren [Isolating]
Jagen op [Hunting on]
Jatten [Stealing]
Jennen [Teasing]
Jongleren met [Juggling with]
Justeren [Adjusting]
Klonen [Cloning]
Koken [Cooking]
Kopen [Buying]
Kraken [Cracking]
Kussen [Kissing]
Labelen [Labeling]
Leasen [Leasing]
Lonken [Ogling]
Loven [Praising]
Lusten [Having a taste for]
Maken [Creating]
Martelen [Torturing]
Merken [Labeling]
Meten [Measuring]
Mollen [Breaking]
Negeren [Ignoring]
Neuken [Having sex with]
Neutraliseren [Neutralizing]
Normaliseren [Normalizing]
Notificeren [Notifying]
Observeren [Observing]
Oliën [Oiling]
Ontbloten [Denuding]
Ontsmetten [Disinfecting]
Ordenen [Sorting]
Penetreren [Penetrating]
Pesten [Bullying]
Plagen [Teasing]
Porren [Poking]
Produceren [Producing]
Quadrilleren met [Quadrille-dancing with]
Quadrupleren [Quadrupling]
Queruleren over [Grumbling about]
Quoteren [Giving a rating to]
Quotiseren [Distributing]
Raadplegen [Consulting]
Redden [Saving]
Reinigen [Cleaning]
Ruilen [Trading]
Roken [Smoking]
Schieten [Shooting]
Schoppen [Kicking]
Schudden [Shaking/Shuffling]
Slaan [Hitting]
Stoppen [Stopping]
Tackelen [Assaulting]
Telen [Cultivating]
Tellen [Counting]
Temperen [Tempering]
Torpederen [Torpedo-ing]
Unificeren [Uniformising]
Unlocken [Unlocking]
Upgraden [Updrading]
Urineren [Urinating]
Utiliseren [Making use of]
Verbinden [Binding]
Verjagen [Scaring away]
Verkopen [Selling]
Vermoorden [Killing]
Verwijderen [Deleting]
Wassen [Washing]
Wekken [Awakening]
Wijzigen [Modifying]
Wreken [Avenging]
Wurgen [Strangling]
Xeroxen [Photocopying]
Xoipen [Sending over the internet]
Xeroxen [Photocopying]
Xoipen [Sending over the internet]
X-en [X-ing]
Yammeren [Yammering]
Yellen [Cheerleading]
Yielding [Calculating percentages of]
YouTube-streamen [YouTube-streaming]
Youtuben [YouTubing]
Zegenen [Blessing]
Zieken [Nagging]
Zien [Seeing]
Zoeken [Searching]
Zoenen [Making out with]

Adjectives:

Abstracte [Abstract]
Achterlijke [Morron]
Afrikaanse [African]
Amerikaanse [American]
Angstaanjagende [Scary]
Baby [Baby]
Blauwe [Blue]
Blote [Naked]
Boze [Angry]
Broze [Fragile]
Charmante [Charming]
Chinese [Chinese]
Chocolade [Chocolade]
Coole [Cool]
Corrupte [Corrupt]
Dagdromende [Daydreaming]
Dansende [Dancing]
Dikke [Fat]
Dode [Dead]
Dunne [Skinny]
Echte [Real]
Effectieve [Effective]
Elektrische [Electronic]
Enorme [Enormous]
Europese [European]
Felle [Bright]
Fictieve [Fictive]
Fietsende [Cycling]
Fluisterende [Whispering]
Fluitende [Whistling]
Gele [Yellow]
Glow-in-the-dark [Glow-in-the-dark]
Grijze [Grey]
Groene [Green]
Grote [Big]
Harige [Hairy]
Harde [Hard]
Homosexuele [Gay]
Horde [Troop of]
Hyperactieve [Hyperactive]
Idiote [Idiotic]
IJzere [Iron]
IJzige [Frosty]
Instelbare [Adjustable]
Ivoren [Ivory]
Jaloerse [Jealous]
Jammerende [Whining]
Japanse [Japanese]
Jokkende [Fibbing]
Jonge [Young]
Kale [Bald]
Kapotte [Broken]
Kleine [Little]
Knappe [Handsome]
Koude [Cold]
Lelijke [Ugly]
Lege [Empty]
Levende [Living]
Lopende [Walking]
Luie [Lazy]
Maffe [Weird]
Massieve [Massive]
Middeleeuwse [Medieval]
Milde [Mellow]
Mythische [Mythical]
Naakte [Naked]
Nachtelijke [Nocturnal]
Nare [Nasty]
Nucleaire [Nuclear]
Normale [Normal]
Ongelovige [Infidel]
Oranje [Orange]
Oude [Old]
Overheerdende [Prevailing]
Oxiderende [Oxidizing]
Paarse [Purple]
Platte [Flat]
Pratende [Talking]
Piraten [Pirate]
Puzzelende [Puzzling]
Quiteense [Female resident of the city of Quito]
Quad-rijdende [ATV-driving]
Quasi [Quasi]
Queue-stotende [(Billiard) cue thumping]
Quiche-etende [Quiche-eating]
Rennende [Running]
Rode [Red]
Romantische [Romantic]
Ronde [Round]
Roze [Pink]
Saaie [Boring]
Schattige [Cute]
Scherpe [Sharp]
Springende [Jumping]
Stoffige [Dusty]
Tongzoenende [French kissing]
Transformerende [Transforming]
Transparente [Transparent]
Treiterende [Tormenting]
Triomferende [Victorious]
Ultieme [Supreme]
Unieke [Unique]
Uniseks [Unisex]
Uiteenlopende [Various]
Uitmuntende [Outstanding]
Vage [Vague]
Verdrietige [Sad]
Vierkante [Square]
Vliegende [Flying]
Vrolijke [Jolly]
Warme [Warm]
Waterige [Aquatic]
Wijze [Wise]
Witte [White]
Wraakzuchtige [Vindicitive]
Xenofobische [Xenophobic]
Xhosa-sprekende [Xhosa-speaking]
XTC-verslaafde [XTC-addicted]
XXX [XXX]
Xylofoonspelende [Xylophone-playing]
Yahoo-zoekende [Yahoe-searching]
Yammerende [Yammering]
Yellende [Cheerleading]
YouTube-streamende [YouTube-streaming]
Youtubende [YouTubing]
Zachte [Soft]
Zingende [Singing]
Zwarte [Black]
Zwemmende [Swimming]
Zwevende [Floating]

Challenge rules:

  • You aren't allowed to use the same random noun twice in one sentence.
  • You have to take the license plate input either as string or array/list of characters. You can choose to input without delimiter however, so all these are valid input-formats: NN-CC-CC; NN CC CC; NN CCCC; NNCCCC; N N C C C C; etc.
  • The list of words can be in any reasonable format. Can be three separate lists; maps with the first letters as keys; one or multiple separate text files to read from; all possible. (You are allowed to take the input with or without the English translations added, as long as you output the Dutch sentence.)
  • Output can be printing to STDOUT or returning a string.
  • The lists above and the resulting sentences will only be in Dutch (with optionally the English translations added behind every word / the entire sentence).
    NOTE: The original idea was to have the lists being part of the code, and @JonathanAllan suggested to use just Dutch instead of English, since there are quite a few languages with build-in English libraries. Later in the Sandbox, this switched to having the lists as input, and since I was already halfway through finishing the lists, I kept them Dutch. I've still added the English translations of each word in the list, so you can easily translate what your random output means.
  • Because all the nouns are plural, we can assume the numbers will be in the range 02-99.
  • The numbers 02-09 may be outputted with or without leading zero.
  • You are allowed to take the input license plate as lowercase instead of uppercase.

General rules:

  • This is , so shortest answer in bytes wins.
    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
  • Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
  • Default Loopholes are forbidden.
  • If possible, please add a link with a test for your code.
  • Also, please add an explanation if necessary.

Some possible test cases (but feel free to use your own as well).

71-NN-BT
80-XW-IK
13-UU-EF
12-AA-AA
99-ZX-YW
73-TH-QQ
04-DJ-IO

What are some of your favorite random sentences?

Kevin Cruijssen

Posted 2017-09-15T11:24:29.600

Reputation: 67 575

Somehow I can't believe those are the lists of words you used to use... – Neil – 2017-09-15T11:47:19.303

@Neil As a kid in the past you mean? You're probably right. X would always result in something with xylophones, since it was the only word with an X I knew as a kid. But when I created this list earlier this week I wanted to have 5 words of each letter for each noun, verb and adjective for the sake of this challenge (which was pretty hard to accomplish for some letters..) Some of those words with a Q or X I had never even heard of.. And some words would be inappropriate to know as a < 12 y.o. kid. :) – Kevin Cruijssen – 2017-09-15T11:59:44.613

Answers

3

Jelly,  37  35 bytes

ṙ2X¤;⁸ṪW¤i’¥Ðḟ"⁹ṫ3¤ŒpŒQẠ$ÐfXK⁹ḣ2¤,K

A dyadic link taking a list of lists (of lists of characters): [[verbs],[adjectives],[nouns]] on the left and the numberplate (format = NNCCCC) on the right and returning a list of characters.

Try it online!

How?

ṙ2X¤;⁸ṪW¤i’¥Ðḟ"⁹ṫ3¤ŒpŒQẠ$ÐfXK⁹ḣ2¤,K - Link: list of lists of lists, words; list, plate
   ¤                                - nilad followed by link(s) as a nilad:
 2                                  -   literal two
  X                                 -   random integer in [1,z] -------- gets 1 or 2
ṙ                                   - rotate left by - words [v,a,n] -> [a,n,v] or [n,v,a]
        ¤                           - nilad followed by link(s) as a nilad:
     ⁸                              -   chain's left argument, words
      Ṫ                             -   tail - get the nouns
       W                            -   wrap in a list
    ;                               - concatenate - add another noun list to the end
                                    - (call this allWordLists) - either [a,n,v,n] or [n,v,a,n])
                  ¤                 - nilad followed by link(s) as a nilad:
               ⁹                    -   chain's right argument, plate
                 3                  -   literal three
                ṫ                   -   tail from index - get the four letters
                                    - (call this letters)
              "                     - zip with the dyadic operation:
            Ðḟ                      -   filter discard if:
           ¥                        -     last two links as a dyad:
         i                          -       first index of (a letter in a word in a wordList in allWordLists)
          ’                         -       decrement (if not found i yields 0, so this result is only 0 when the first index is the head of the list)
                                    - ...this gives us a list of lists of words beginning with the appropriate letters ordered either as [a,v,n,n] or [n,v,a,n]
                   Œp               - Cartesian product of the filtered lists
                         Ðf         - filter keep if:
                        $           -   last two links as a monad:
                     ŒQ             -     distinct sieve (1s at 1st occurrences, 0s elsewhere)
                       Ạ            -     all truthy - i.e. all distinct?
                           X        - random choice from the resulting list - get one four word choice
                            K       - join with spaces
                                ¤   - nilad followed by link(s) as a nilad:
                             ⁹      -   chain's right argument, plate
                               2    -   literal two
                              ḣ     -   head to index - get the two digits
                                 ,  - pair
                                  K - join with a space

Jonathan Allan

Posted 2017-09-15T11:24:29.600

Reputation: 67 804

5

Perl 5, 89 bytes

88 bytes code + 1 for -p.

Requires the numberplate to be in the format ## A A A A and the lists need to be formatted like ("A","B",...). If this is pushing the limits of acceptable, please let me know.

@$_=eval<>for n,v,a;s!\pL!(grep/^$&/,@{(rand>.5?(a,n,v,n):(n,v,a,n))[$-++]})[rand 5]!egi

Try it online!

Dom Hastings

Posted 2017-09-15T11:24:29.600

Reputation: 16 415

3

JavaScript (ES6), 124 120 118 bytes

Takes input in currying syntax (s)(a) where s is a string in "NNCCCC" format and a is the array of arrays of words [nouns, verbs, adj].

s=>a=>s.replace(/\D/g,c=>' '+(g=a=>a.sort(R)[0][0]==c?a.shift(i/=4):g(a))(a[i&3]),i=(R=_=>Math.random()-.5)()<0?18:36)

Test cases

let f =

s=>a=>s.replace(/\D/g,c=>' '+(g=a=>a.sort(R)[0][0]==c?a.shift(i/=4):g(a))(a[i&3]),i=(R=_=>Math.random()-.5)()<0?18:36)

const NOUNS = ["Aanbeelden","Aardbeien","Apen","Appels","Auto's","Bananen","Bessen","Bloemen","Bomen","Bijen","Cadeaus","Cavia's","Cheerleaders","Circusdieren","Citroenen","Dinosaurussen","Dieren","Documenten","Doctoren","Dolfijnen","E-mails","Edelstenen","Eekhoorns","Enqûetes","Ezels","Fabrieken","Fietsen","Flessen","Fontijnen","Foto's","G-spots","Giraffen","Glazen","Gymschoenen","Gummen","Haaien","Homo's","Honden","Hoofden","Horloges","Idioten","Idolen","IJsklontjes","Illusies","Imperia","Jassen","Jokers","Jongleurs","Jurken","Juwelen","Kabels","Katten","Kauwgomballen","Knoppen","Konijnen","Leesboeken","Leeuwen","Legercommandanten","Lesbies","Lummels","Maagden","Mannen","Mensen","Mieren","Muren","Neuzen","Nieuwkomers","Nonnen","Noten","Nummerborden","Oceanen","Ogen","Olifanten","Oren","Orkanen","PC's","Pizza's","Politieagenten","Postbezorgers","Potloden","Quads","Quaggamosselen","Querulanten","Quiëtisten","Quizzen","Radio's","Ramen","Regiseuren","Rekenmachines","Relschoppers","Schepen","Slakken","Slangen","Stegosaurussen","Stoelen","T-rexen","Tafels","Theekopjes","Tijgers","Tovenaars","Uien","Uilen","Universa","Universiteiten","USB-sticks","Vliegtuigen","Vrachtwagens","Vrienden","Vrouwen","Vulkanen","Walvissen","Wespen","Wormen","Worstelaars","Wortels","X-assen","X-chromosomen","Xenonlampen","Xylofonen","Xylofonisten","Y-assen","Y-chromosomen","Yoghurtdranken","Yogaleraren","Yogaleraressen","Zeeën","Zeehonden","Zeepbellen","Zwanen","ZZP'ers"];
const VERBS = ["Accepteren","Activeren","Amputeren","Amuseren","Assisteren","Bakken","Bedreigen","Bellen","Bevruchten","Bijten","Castreren","Categoriseren","Centrifugeren","Claimen","Coachen","Dagvaardigen","Daten","Degraderen","Dienen","Dwarsbomen","Electroniseren","Eren","Erven","Eten","Exploderen","Factureren","Fokken","Föhnen","Fotographeren","Frituren","Gooien","Graderen","Grijpen","Groeperen","Groeten","Hacken","Hallucineren","Haten","Helpen","Huren","Importeren","Inspireren","Intelligente","Irriteren","Isoleren","Jagen op","Jatten","Jennen","Jongleren met","Justeren","Klonen","Koken","Kopen","Kraken","Kussen","Labelen","Leasen","Lonken","Loven","Lusten","Maken","Martelen","Merken","Meten","Mollen","Negeren","Neuken","Neutraliseren","Normaliseren","Notificeren","Observeren","Oliën","Ontbloten","Ontsmetten","Ordenen","Penetreren","Pesten","Plagen","Porren","Produceren","Quadrilleren met","Quadrupleren","Queruleren over","Quoteren","Quotiseren","Raadplegen","Redden","Reinigen","Ruilen","Roken","Schieten","Schoppen","Schudden","Slaan","Stoppen","Tackelen","Telen","Tellen","Temperen","Torpederen","Unificeren","Unlocken","Upgraden","Urineren","Utiliseren","Verbinden","Verjagen","Verkopen","Vermoorden","Verwijderen","Wassen","Wekken","Wijzigen","Wreken","Wurgen","Xeroxen","Xoipen","Xeroxen","Xoipen","X-en","Yammeren","Yellen","Yielding","YouTube-streamen","Youtuben","Zegenen","Zieken","Zien","Zoeken","Zoenen"];
const ADJECTIVES = ["Abstracte","Achterlijke","Afrikaanse","Amerikaanse","Angstaanjagende","Baby","Blauwe","Blote","Boze","Broze","Charmante","Chinese","Chocolade","Coole","Corrupte","Dagdromende","Dansende","Dikke","Dode","Dunne","Echte","Effectieve","Elektrische","Enorme","Europese","Felle","Fictieve","Fietsende","Fluisterende","Fluitende","Gele","Glow-in-the-dark","Grijze","Groene","Grote","Harige","Harde","Homosexuele","Horde","Hyperactieve","Idiote","IJzere","IJzige","Instelbare","Ivoren","Jaloerse","Jammerende","Japanse","Jokkende","Jonge","Kale","Kapotte","Kleine","Knappe","Koude","Lelijke","Lege","Levende","Lopende","Luie","Maffe","Massieve","Middeleeuwse","Milde","Mythische","Naakte","Nachtelijke","Nare","Nucleaire","Normale","Ongelovige","Oranje","Oude","Overheerdende","Oxiderende","Paarse","Platte","Pratende","Piraten","Puzzelende","Quiteense","Quad-rijdende","Quasi","Queue-stotende","Quiche-etende","Rennende","Rode","Romantische","Ronde","Roze","Saaie","Schattige","Scherpe","Springende","Stoffige","Tongzoenende","Transformerende","Transparente","Treiterende","Triomferende","Ultieme","Unieke","Uniseks","Uiteenlopende","Uitmuntende","Vage","Verdrietige","Vierkante","Vliegende","Vrolijke","Warme","Waterige","Wijze","Witte","Wraakzuchtige","Xenofobische","Xhosa-sprekende","XTC-verslaafde","XXX","Xylofoonspelende","Yahoo-zoekende","Yammerende","Yellende","YouTube-streamende","Youtubende","Zachte","Zingende","Zwarte","Zwemmende","Zwevende"];

console.log(f("71NNBT")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("80XWIK")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("13UUEF")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("12AAAA")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("99ZXYW")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("73THQQ")([NOUNS, VERBS, ADJECTIVES]))
console.log(f("04DJIO")([NOUNS, VERBS, ADJECTIVES]))

How?

The sequences of lists to pick the words from are stored as bitmasks, in reverse order:

Noun, Verb, Adjective, Noun --> 0, 1, 2, 0 --> 00 01 10 00 --[reverse]--> 00100100 --> 36
Adjective, Noun, Verb, Noun --> 2, 0, 1, 0 --> 10 00 01 00 --[reverse]--> 00010010 --> 18

That's why i is randomly initialized to either 18 or 36.

s => a =>                           // given 's' and 'a'
  s.replace(                        // replace in 's'
    /\D/g, c =>                     // each non-digit character 'c' with:
    ' ' + (                         // a space followed by
      g = a =>                      // a word picked from the list 'a'
        a.sort(R)                   //   shuffle the list
        [0][0] == c ?               //   if the 1st char. of the 1st word is matching 'c':
          a.shift(i /= 4)           //     return this word (removing it from the list)
                                    //     and discard the 2 least significant bits of 'i'
        :                           //   else:
          g(a)                      //     try again with a recursive call
    )(a[i & 3]),                    // initial call to g() with the next list
    i = (                           // initialize 'i', using:
      R = _ => Math.random() - 0.5  //   R(): returns a random float in [-0,5, 0.5)
    )() < 0 ? 18 : 36               // to either 18 or 36 (see above)
  )                                 // end of replace()

Arnauld

Posted 2017-09-15T11:24:29.600

Reputation: 111 334

3

Excel, 382 353 bytes

=D1&E1&" "&IF(RAND()>0.5,INDIRECT("C"&INT((CODE(F1)-64.8+RAND())*5))&" "&INDIRECT("A"&INT((CODE(G1)-64.8+RAND())*5))&" "&INDIRECT("B"&INT((CODE(H1)-64.8+RAND())*5)),INDIRECT("A"&INT((CODE(F1)-64.8+RAND())*5))&" "&INDIRECT("B"&INT((CODE(G1)-64.8+RAND())*5))&" "&INDIRECT("C"&INT((CODE(H1)-64.8+RAND())*5)))&" "&INDIRECT("A"&INT((CODE(I1)-64.8+RAND())*5))

Three lists in A, B and C respectively. Numberplate characters in D1 -to- I1. Formula in any other cell.

Golfing:

  • Last word will always be NOUN,

  • -14 bytes replacing ADDRESS with "A"&INT()

  • -14 bytes arithmetic(CODE(F1)-65)*5+RAND()*5+1 with (CODE(F1)-64.8+RAND())*5

Wernisch

Posted 2017-09-15T11:24:29.600

Reputation: 2 534

2

Java (OpenJDK 8), 535 314 304 297 382 bytes

import java.util.*;
L->N->V->A->{int c=((int)(Math.random()*8))%2,i=0,f;String[]a=new String[4],b[]={A,N,V,N,N,V,A,N};for(;i<4;i++){List<String>p=new ArrayList();for(f=0;f<b[i+c*4].length;f++)if(b[i+c*4][f].charAt(0)==L.charAt(i+2)&&(i<3|!b[i+c*4][f].equals(a[1-c])))p.add(b[i+c*4][f]);a[i]=p.get((int)(Math.random()*p.size()));}System.out.print(L.substring(0,2)+" "+L.join(" ",a));}

Try it online!

Roberto Graham

Posted 2017-09-15T11:24:29.600

Reputation: 1 305

You can still golf some more things: L->N->V->A-> can be (L,N,V,A)->; int j=i can be j=i when you add ,j to the other ints; the space j< 3 can be removed; some of those || can be | and && can be &; (c<0?!s.equals(a[1]):!s.equals(a[0])) can be !s.equals(c<0?a[1]:a[0]). Apart from that it looks like a great answer now that it's golfed from 535 to 314. :) – Kevin Cruijssen – 2017-09-15T13:04:08.887

@Giuseppe I've fixed the previous problem but I can't deal with -xxx-, it's non-competing now – Roberto Graham – 2017-09-15T13:49:38.733

It seems to work now after your last edit. :) Now that it's working, let's get to some more golfing: TryItOnline: 365 bytes. Short summary of the changes: int variables inside for-loop; ArrayList to Stack; L->N->V->A-> to (L,N,V,A)->; removed parenthesis around (int)(Math.random()*8); Added int t to replace 4x i+c*4; && to &.

– Kevin Cruijssen – 2017-09-18T09:26:32.680

1Love heart code <3 – Roman Gräf – 2017-09-19T09:16:43.770

1

Python 3, 82 bytes

def f(l,d):print(l[:2],*map(lambda i,j:d[i][j].pop(),{'anvn','nvan'}.pop(),l[2:]))

Try it online!

Function taking a string l for the license plate and a dictionary d containing dictionaries with nouns, verbs and adjectives. These must be labeled 'n', 'v' and 'a', respectively.

In each of these dictionaries, the words are grouped and labeled by their first letter. Each key then contains a set of words. By using the set.pop() method to generate output, the chosen words are both random and non-duplicate.

Jitse

Posted 2017-09-15T11:24:29.600

Reputation: 3 566

Oh, I like the set.pop() approach! Very nice. :) I'm not entirely sure if the input method of the lists you've used is valid according to the meta though. It now looks like a snipper instead of program/function taking the lists as input(s)/argument(s). Regardless, nice answer. – Kevin Cruijssen – 2019-08-16T13:10:19.403

@KevinCruijssen You are right concerning the input, this is indeed just a snippet. I'll update my code. – Jitse – 2019-08-16T13:19:22.993

0

C#, 245 bytes

Random r=new Random();var a1=a[r.Next(0,a.Length)];var n1=n[r.Next(0,n.Length)];var n2=n[r.Next(0,n.Length)];var v1=v[r.Next(0,v.Length)];var m=r.Next(0,2)==0;Console.WriteLine($"{r.Next(0,10)}{r.Next(0,10)} {m?a1:n1} {m?n1:v1} {m?v1:a1} {n2}");

Surely not the shortest but it was fun to do so idc xD
Same code uncompacted (272 bytes):

Random r=new Random();
var a1 = a[r.Next(0, a.Length)];
var n1 = n[r.Next(0, n.Length)];
var n2 = n[r.Next(0, n.Length)];
var v1 = v[r.Next(0, v.Length)];
var m = r.Next(0, 2)==0;
Console.WriteLine($"{r.Next(0,10)}{r.Next(0,10)} {m?a1:n1} {m?n1:v1} {m?v1:a1} {n2}");

canttalkjustcode

Posted 2017-09-15T11:24:29.600

Reputation: 131

Currently is not a full program. Will do that tomorrow – canttalkjustcode – 2019-08-20T02:07:14.867