3
\$\begingroup\$

Task

Write a function to generate names of aliens and their worlds, so that the output is of the form:

Greetings Earthfolk, I am ____ of the planet _____.

"Rules"

Best space-sounding-ness to code length wins.

The more diversity the better.

Dictionaries/look-up tables count towards code length.

Random number generators definitely allowed, other libraries less so.

Provide examples of the output.

\$\endgroup\$
3
  • 8
    \$\begingroup\$ Your question in the current form leaves too much room for interpretation. Especially for code-golf much depends on strict and specific rules. What kind of names are allowed? E.g. "I am X of the planet X" sounds perfect alien for me. How do you quantitatively measure "space-sounding-ness to code"? If you can update your question to meet these requirements I am happy to remove my -1. \$\endgroup\$
    – Howard
    Apr 11, 2013 at 6:15
  • 2
    \$\begingroup\$ Krang demands that you give to Krang the source code that Krang demands that you give to Krang. \$\endgroup\$ Apr 23, 2013 at 13:07
  • 1
    \$\begingroup\$ I can see why the q. is closed but it has yielded some creative and funny responses. :P \$\endgroup\$
    – roblogic
    Dec 20, 2022 at 13:03

7 Answers 7

25
\$\begingroup\$

APL (72)

Not entirely serious, but I couldn't resist. The names are generated from a subset of the APL charset. The names are between 5 and 14 characters long.

{'Greetings Earthfolk, I am'⍺'of the planet'⍵}/{⎕AV[186+{?25}¨⍳4+?9]}¨⍬⍬

Example output:

Greetings Earthfolk, I am  ⌹⍒|⍟∩⊤∩⍉⊂⊥⌽  of the planet  ∩⌹⍱⍎∪≢⊂∩  
Greetings Earthfolk, I am  ⍕≡|⍕⍋!⍟⌹  of the planet  ⊂⊤⊤⌽⍟⊖⍱⊤⊤⍟⊥  
Greetings Earthfolk, I am  ≢⍉⊂⍫⊂  of the planet  ⍋⌽!⍟⍉⊂∪≢
\$\endgroup\$
3
  • 4
    \$\begingroup\$ This is the most alien-looking thing I have ever seen. And I mean the program, not the output. \$\endgroup\$
    – user7486
    May 2, 2013 at 7:24
  • 4
    \$\begingroup\$ The output seems oddly appropriate. \$\endgroup\$
    – Kaz Dragon
    May 3, 2013 at 11:43
  • \$\begingroup\$ Save 2 bytes: {⎕AV[186+{?25}¨⍳4+?9]}{⎕AV[186+?25/⍨4+?9]} \$\endgroup\$
    – Adám
    Jun 2, 2016 at 12:00
12
\$\begingroup\$

Perl, 51 characters

print"Greetings Earthfolk, I am ~ of the planet ~."

The aliens communicate using a special space language that is not translatable in human text or speech. It is customary to use the character ~ to represent any word in the aliens' native tongue. Thus this answer is very space-sounding and also contains a great deal of diversity, which, unfortunately, is not able to be adequately represented using a standard character set.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ You could use one of the astral planes in unicode. They're, after all, called "astral". \$\endgroup\$ Apr 11, 2013 at 15:43
10
\$\begingroup\$

GolfScript, 85 characters

26,{97+}%{9,{;..,rand=}%@@}2*;;"Greetings Earthfolk, I am "\+" of the planet "+\+"."+

(online test version)

Greetings Earthfolk, I am mfevurnoh of the planet pclqvbpcu.
Greetings Earthfolk, I am niuzigmuu of the planet wdkosibdb.
Greetings Earthfolk, I am tvihxsxhd of the planet depkxwcto.

Pclqvbpcuans and wdkosibdbeans apologise for having chosen such a difficult name for us to pronounce for their planet. Tvihxsxhd's first parent also apologises for the double "x" in tvihxsxhd's name. He said he would never expect their child to travel to Earth.

longer version, but more pronounceable names:

GolfScript, 105 characters

"aeiouy".26,{97+}%\-{5,{;..,rand=2$.,rand=}%@@}2*;;"Greetings Earthfolk, I am "\+" of the planet "+\+"."+

(online test version)

Sample output:

Greetings Earthfolk, I am nirexahuji of the planet hulabasesa.
Greetings Earthfolk, I am xepozidylo of the planet wuxasidape.
Greetings Earthfolk, I am jypakivixy of the planet lutegujyxo.

For those who are claiming that they wrote us a letter, not spoke to us (and thus capitalisation is important), this can be fixed in as few as six characters:

26,{97+}%{9,{;..,rand=}%(32-\+@@}2*;;"Greetings Earthfolk, I am "\+" of the planet "+\+"."+

(test)

"aeiouy".26,{97+}%\-{5,{;..,rand=2$.,rand=}%(32-\+@@}2*;;"Greetings Earthfolk, I am "\+" of the planet "+\+"."+

(test)

\$\endgroup\$
5
\$\begingroup\$

Javascript

golfed ( 186 bytes )

function f(){for(c=[],b=0;new Date%30+2>b;)c[++b]=String.fromCharCode(Math.random()*25|0+(b<2?65:97));return c.join('')}alert('Greetings Earthfolk, I am '+f()+' of the planet '+f()+'.')

Example Output:

Greetings Earthfolk, I am Kugwegoysuseq of the planet Esagqwsakeges.
Greetings Earthfolk, I am Ui of the planet Oq.
Greetings Earthfolk, I am Qeuseoswwusk of the planet Gsyuemaeqqwa.
Greetings Earthfolk, I am Usyssacemsiiokk of the planet Mgscemkaooaggku.
Greetings Earthfolk, I am Egugskkgmk of the planet Ecakmkayys.

Keep in mind without the bulky text in the output, the function alone is 121 bytes.

Also the names and the planet names are the same character len so I can save a few characters and use new Date%30+2 however if this is an issue just run them a ~hundred ms apart.

\$\endgroup\$
1
  • \$\begingroup\$ Nice, that's the kind of solution I was hoping for :) \$\endgroup\$
    – Lucas
    Apr 29, 2013 at 17:35
3
\$\begingroup\$

PHP - 283 with line breaks.

Here's my code for alien sounding words. My goal was to make it sound like a legitimate language without difficult pronunciation. The apostrophe's suffix the preceding letter with the 'yeh' sound (e.g. GYEH, DYEH, FYEH, etc.). All vowels are of the long-vowel sound, with the exception of A and E, which are short. Granted, this sounds like a single language rather than many diverse languages, but I don't care.

<?$a=$z="";function w(){$k=array("B","D","F","G","J","K","L","M","N","P","T","V","W","Z");$v=array("A","E","O","U","'");return$k[rand(0,13)].$v[rand(0,4)];}for($i=0;$i<rand(3,8);$i++){$a.=w();}for($i=0;$i<rand(3,8);$i++){$z.=w();}echo"Greetings Earthfolk, I am $a of the planet $z.";

Here's the ungolfed version:

<?php

$a=$z="";

function rk() {
    $k = array("B","D","F","G","J","K","L","M","N","P","T","V","W","Z");
    return $k[rand(0,13)];
}
function rv() {
    $v = array("A","E","O","U","'");
    return $v[rand(0,4)];
}
function rp() { return rk().rv(); }

for ($i=0; $i < rand(3,8); $i++) { $a .= rp(); }
for ($i=0; $i < rand(3,8); $i++) { $z .= rp(); }

echo "Greetings Earthfolk, I am $a of the planet $z.";

?>

Sample outputs:

  • Greetings Earthfolk, I am NEMEWEJU of the planet N'VUMELULOFU.
  • Greetings Earthfolk, I am FUM'FELE of the planet WUW'JEDUG'GELA.
  • Greetings Earthfolk, I am ZUDEWEGUPOGE of the planet LUNOT'ZEJALOTU.
  • Greetings Earthfolk, I am M'DOMAMO of the planet WUWAGUBU.
\$\endgroup\$
3
  • 7
    \$\begingroup\$ Most of those wouldn't look out of place in a Nigerian 419 scam email. :P \$\endgroup\$
    – marinus
    Apr 28, 2013 at 9:54
  • \$\begingroup\$ Haha, Maybe I should randomly output between 200-500 words and email them to random people and see what happens? I wonder what Google translate would auto recognize this as... \$\endgroup\$ Apr 29, 2013 at 12:36
  • \$\begingroup\$ You should golf it a bit. Remove whitespace, use one-character variable names... \$\endgroup\$ Apr 29, 2013 at 13:22
3
\$\begingroup\$

Python Code :

This code will generate random words of random length .

from random import *;t=range;l=map(chr,t(97,123));k=m="";r=randint
for i in t(r(1,100)):k+=l[r(0,25)]
for i in t(r(1,100)):m+=l[r(0,25)]
print "Greetings Earthfolk, I am",k," of the planet",m

Sample output:

Greetings Earthfolk, I am ixpygrfoswpkby  of the planet kanhkcg
Greetings Earthfolk, I am ijojukgjfxcbdt  of the planet zvllqgtqihkxy
Greetings Earthfolk, I am svbwsgrwgedfshw  of the planet inepzkdzerbkscy
Greetings Earthfolk, I am srixnnlqendbnbcqbghpdfotvxhfjidpdypzhkoddtbfhbjneaagnxtfqlbikfmrfrjwkwjoordvmks  of the planet qxyrvaxwnktqffbwcloeznkzuhkwzbwusksaychspjedtvrwxzjeoxtymrgfhqelqrwhquxrlvjbnbghiml

The last one is most "aliener" among the random outputs :D ..

We can even shorten the code more by adding the restriction of having the length of the planet's and alien's name of same length

from random import *;t=range;l=map(chr,t(97,123));k=m="";r=randint
for i in t(r(1,100)):k+=l[r(0,25)];m+=l[r(0,25)]
print "Greetings Earthfolk, I am",k," of the planet",m

Sample outputs :

Greetings Earthfolk, I am grtmsmjxbcvfcqfrvnmxuburprkgofstzemaflrbwtxabpdmmkhohntmvgkwcntjhefvrbcuzbdkrrgbxgsbwkrevi  of the planet mzuykipozdfhzalajaarqlrcoebmalrmfdvevieldqmuojwsfjbcfxdwwxakilcpwprdyedzplhxyafstcbpwdfzor
Greetings Earthfolk, I am rltfsxhaiybpqthmkwprepkchbeprxnkiaoyaujwehgsbafxwikenohviyxnj  of the planet qdgoyjqcwlopfgciethfqfaffhloqbmjkkonwutabozgbmzpyrsftiunucnse
Greetings Earthfolk, I am ynyhetukywsfgllbzejrmqygbzerhbrnorflri  of the planet qgihkeymaujjgltgzaeyfhnbqyzjtlpsnpnmbl
\$\endgroup\$
3
  • \$\begingroup\$ Note this is, in part, a code golf. Four-space indentation is such a waste of characters. I'm also wondering if k="";m="" could be replaced by k=m="" \$\endgroup\$ Apr 23, 2013 at 20:11
  • \$\begingroup\$ Thanks for pointing that out.. I have removed the unnecessary code. \$\endgroup\$ Apr 24, 2013 at 2:30
  • 2
    \$\begingroup\$ I'd hate to have to address a letter to one of those planets. \$\endgroup\$
    – user7486
    May 2, 2013 at 7:25
1
\$\begingroup\$

Lua, 211

m,c=math.random,("").char print(((" "):rep(9):gsub(".",function()return c(("aeiouy"):byte(m(1,6)))end):gsub(".-",function()return c(m(97,122))end):gsub("^.......","Greetings Earthfolk, I am %1 of the planet ")))

Greetings Earthfolk, I am toqujor of the planet aeilywyvuief

Greetings Earthfolk, I am kyvirux of the planet ymofoyyxidyw

Greetings Earthfolk, I am hooikoe of the planet exucedimetez

Greetings Earthfolk, I am dytudiu of the planet ueitebeyoben

Greetings Earthfolk, I am denecub of the planet ufolyvooutab

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.