Write a program to fabricate elaborate acronyms

-1

"Hey Bob, I need a new acronym. Something better than 'Automated Support System'. I need you to fabricate me an acronym!"

"Sure thing Joe! I'd love to fabricate an elaborate way to renovate, and not replicate something that you can tolerate."

"Alright Bob, make sure it can separate itself from the old acronym we need to terminate! It'll be great, or at least, that's just what I speculate."

Okay, apologies. I had a lot of fun writing that. Here's the challenge:

You are now Bob. You need to write a program that accepts a string of words from standard input:

This is an example string of words

The character encoding must be ASCII. Delimeters can be spaces and newlines only. From this string of words, it forms an acronym, which it shoots straight to standard output (or equivalent output log):

T.I.A.E.S.O.W.

The program must read the words, case-insensitive, and output the first letter of each word, capitalized, followed by a period.

This is code-golf. Shortest program wins. Go nuts!

Mason Watmough

Posted 2016-04-01T06:41:48.700

Reputation: 225

Question was closed 2016-04-01T07:45:54.943

This differs from the challenge marked as duplicate in that here there no stop words and the acronym includes dots. So I think this is not a duplicate – Luis Mendo – 2016-04-01T09:26:44.113

@LuisMendo I think almost all the answers could just have the word check parts removed, and then instead of flattening the list of characters have them be joined by periods. To me, those feel like trivial modification. – FryAmTheEggman – 2016-04-01T16:44:05.957

Answers

1

Pyth, 11 bytes

sm+hrd1\.cz

Straight forward split, append dots, uppercase and join.

orlp

Posted 2016-04-01T06:41:48.700

Reputation: 37 067

Great use of Pyth's "tokenizer" (?)! This is the shortest by far. – Mason Watmough – 2016-04-01T21:36:21.557

2

Jelly, 8 bytes

ŒtḟŒlp”.

Explanation:

ŒtḟŒlp”.
Œt       # Convert the string to Title Case (lowercases then uppercase beginnings of word)
   Œl    # And on the other side, convert the string to lowercase
  ḟ      # filter: remove the elements from the right side (lowercase) from the left side (Title Cased). Only leaves the initials
     p”. # Cartesian product with a dot.

Golfed down under the Pyth one, thanks Dennis and Fry!

Ven

Posted 2016-04-01T06:41:48.700

Reputation: 3 382

2

Retina, 23 bytes

Try it online!

(\S)\S+(\s|$)
$1.
T`l`L

Leaky Nun

Posted 2016-04-01T06:41:48.700

Reputation: 45 011

I think (.)\S+\s? is sufficient for the first stage. – Martin Ender – 2016-04-01T09:29:41.377

Dangerous, but I like it. – Leaky Nun – 2016-04-01T10:22:37.193

Not the shortest, but +1 for providing online example. – Mason Watmough – 2016-04-01T21:48:53.830

1

Python 2, 54 bytes

Pretty sure this can be optimized, but eh.

First golfing attempt! Woot!

lambda s:"".join([b[0].upper()+"."for b in s.split()])

Thanks to DenkerAffe for shaving off a whopping 22 bytes!

clismique

Posted 2016-04-01T06:41:48.700

Reputation: 6 600

split uses whtespaces on default, so you dont need to pass an argument to it. Also you should use list comprehension instead of a whole for loop which allows you to get everything in one line, so you can use a lambda: lambda s:"".join([b[0].upper()+"."for b in s.split()]) Didnt test it (pretty sure it works tho), but you should get the idea. – Denker – 2016-04-01T07:52:25.790

And some basic golfing techniques: for b in s.split(" "): instead of l=s.split(" ") and then for b in l – Leaky Nun – 2016-04-01T14:46:24.530

Sorry, guys. I wasn't on for a while. Thanks for the tips! – clismique – 2016-04-03T06:23:48.167

0

Pyth, 12 bytes

ss*hMcrz1d\.

ss*hMcrz1d\.
       z     # Input
      r 1    # Uppercase
     c   d   # Split by d (d=space)
   hM        # Map, tahe the "h"ead.
  *     \.   # Product with dot
ss           # Join twice

Ven

Posted 2016-04-01T06:41:48.700

Reputation: 3 382

0

Pylongolf2 (beta7+), 14 bytes

c| l1╨3♀~

Unfortunately I Pylongolf2 can't put a character between
all of the items in the stack so the output has no dots in it.

c          read input
 |         split by space (note the space after |)
   l1      take the first characters.
     ╨3    convert to uppercase
       ♀   pop the array
        ~  print everything

user47018

Posted 2016-04-01T06:41:48.700

Reputation: