# Underground geek rock band names

We have a group of stealthy computer-savvy geeks who are also musicians with a very subversive element to their songs that the authorities in their totalitarian country just can't stand, and are itching to show up at one of the concerts, fire off rubber bullets and tear gas at the audience, and arrest the band members and as may other fans as their paddy vans can carry and "disappear" them.

However, the authorities are a bit slow to act, and will only show up to the second concert held under the same band name (case, accent and whitespace-length insensitive). They are also not very tech-savvy, so can't reverse-engineer the decoder (see later). Since they are working from memory, they'll forget a name after five years, so a repeat after that time won't attract their attention.

One of these tech-savvy band members comes up with an algorithm that - given the date of a concert - generates a (hopefully) unique cool-sounding and pronounceable band name using the latin alphabet (A-Z) plus Space. They also create a decoder that they distribute to fans, which, given a band name and a date, returns some output indicating that this is indeed a code-generated name of our subversive band, or some other output indicating that the band name entered is that of some other band (or a sting set up by the authorities to catch fans they want to arrest).

The decoder does not output any valid names, as the authorities are just tech-savvy enough themselves to obtain a copy and use that to generate possible names if it can output them, but don't have time to check all the names of the hundreds of other bands that appear and disappear (sometimes with their assistance) from time to time against it.

Your Task:

Produce these two complementary pieces of code - the name generator and the name checker.

As this is a popularity contest, we're looking for cool-sounding, pronounceable band names for the English-speaking world, not random unpronounceable text. Any programming language is OK, as the fans are all very tech-savvy like us. Please provide a sample of the cool names your generator generates.

If it can be shown that an algorithm produces a duplicate for any two dates in a 5-calendar-year period, then that will be considered a disqualification. (Disqualification is a far better fate than what the authorities would do to them).

• What's the point of requesting a separate decoder? All it should be is a call to the encoder followed by an equality check. And you can't be serious about wanting a list of 260 names. No-one's going to want to verify their distinctiveness without using a computer program anyway, so why not just write your own test framework? – Peter Taylor Oct 30 '14 at 8:04
• @PeterTaylor, I've edited the question to show why a decoder is needed. As to a list of names, you're right, I can check myself, so just a few to demonstrate the "cool" factor will suffice. – Monty Wild Oct 31 '14 at 1:38

# Pyth

Encoder:

Jf-\'T'jdm@JdjswlJ


Takes two arguments: a dictionary on one line, and the date, in DDMMYYYY form on the next.

Filters out words with apostrophes from the dictionary, then converts the current date into a number with base equal to the dictionary length, and then chooses words from the filtered dictionary with indexes of the digits, and prints them out, space separated.

Today's result:

\$ pyth -c "Jf-\'T'jdm@JdjswlJ" <<< '/usr/share/dict/words
30102014'
Annam pals


Future results:

31102014
Antarctica economical

01112014
Abernathy carousels

02112014
Acadia unsnarled

03112014
Actaeon oversimplifying

04112014
Adela dugouts

0511204
Adolph Maude


To decode, run the date through the program and see if the output matches the name given. I'm not going to list any more band names, but from how the program works it should be clear there are no repeats.

### Encoder

{18+65}%


Expects input in the form YYYYMMDD. Online demo

### Decoder

n/~{18+65}%=


Expects input in the form

BANDNAME
YYYYMMDD


Online demo

I'm not going to post a list of 260 names because a) that would be a complete waste of space; b) it's easy to convince yourself that the encoder is an injection.

• Fails on cool-sounding, in my opinion. – isaacg Oct 30 '14 at 15:38
• And pronounceable? – Bill Woodger Oct 30 '14 at 16:36
• @BillWoodger, if you can pronounce taramasalata I don't think you should have problems with any of these names. English phonotactics isn't overly restrictive. – Peter Taylor Oct 30 '14 at 16:38
• Ah. G(r)eek rock band. I suppose I tied "pronounceable" to being actual words. Nicely fineses the need for a dictionary. – Bill Woodger Oct 30 '14 at 17:05

# Python 3

## Generator

This generates shorter names so they seem a little less obscure.

import string

date = input()
vowels = 'aeiou'
name = ''
consonants = ''.join(i for i in string.ascii_lowercase if not i in vowels)
for i in range(0,len(date),2):
name += vowels[int(date[i])%len(vowels)]+consonants[int(date[i])%len(consonants)]
print(name)


### Example

Input:  30102014
Output: ofecidec


## Validator

Just performs the above and compares the result with the supplied name.

import string

date, name = input().split(',')
vowels = 'aeiou'
tname = ''
consonants = ''.join(i for i in string.ascii_lowercase if not i in vowels)
for i in range(0,len(date),2):
tname += vowels[int(date[i])%len(vowels)]+consonants[int(date[i])%len(consonants)]
print(tname == name)


### Examples

Input:  30102014,ofecidec
Output: True

Input:  30102014,ofocidoc
Output: False


Input should be in the format:

DDMMYYYY,NAME


# Javascript

Since the authorities forget names after 5 years, we can leave the millennium, century, and decade digits out of the year. We can also use day of year (DoY). This program accepts input in the form of YDoY

## Encoder

The encoder converts the base 10 date to a base 26 string, then shifts it over 10 characters to remove any numbers. Then we add vowels, spaces, and capitalization to make the words look like english.

function encodeName(date){
var alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
var vowels = 'aeiou';
var rebased = date.toString(26);
var shifted = '';
var name = '';
for(var c in rebased){
var i = alphabet.indexOf(rebased[c]);
shifted += alphabet.substring(i+10, i+11)
}
for(var a in shifted)
name += a%2 == 0 ? shifted[a].toUpperCase() + vowels[a%vowels.length] : shifted[a] + ' ';

return name.trim();
}


## Decoder

function decodeName(name){
var alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
var vowels = 'aeiou';
var stripped = '';
var shifted = '';

for(var n in name)
stripped += vowels.indexOf(name[n]) >= 0 || name[n] == ' ' ? '' : name[n].toLowerCase();

for(var n in stripped)
shifted += alphabet[alphabet.indexOf(stripped[n])-10];

return parseInt(shifted, 26);
}


## Examples

function encodeName(b){b=b.toString(26);var a="",d="",c;for(c in b)var f="0123456789abcdefghijklmnopqrstuvwxyz".indexOf(b[c]),a=a+"0123456789abcdefghijklmnopqrstuvwxyz".substring(f+10,f+11);for(var e in a)d+=0==e%2?a[e].toUpperCase()+"aeiou"[e%5]:a[e]+" ";return d.trim()}
function decodeName(b){var a="",d="",c;for(c in b)a+=0<="aeiou".indexOf(b[c])||" "==b[c]?"":b[c].toLowerCase();for(c in a)d+="0123456789abcdefghijklmnopqrstuvwxyz"["0123456789abcdefghijklmnopqrstuvwxyz".indexOf(a[c])-10];return parseInt(d,26)};

var date = 1003;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 9123;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 3333;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 2321;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));
var date = 0345;
alert(encodeName(date) + ' -- ' + decodeName(encodeName(date)));

• 0345 is an octal number. – Peter Taylor Oct 30 '14 at 16:19