views:

147

answers:

4

Is there a language agnostic algorithm to name tuples?

Specifically, I want the following function:

  1 => Single
  2 => Double
  3 => Triple
  4 => Quadruple
    ...
 10 => Decuple
    ...
100 => Centuple

First of all, is this human-language independent? For example, will that be understood in Spain and Russia?

Secondly, what is the most efficient way to generate this list?

Edit

Just to clarify:

  1. This is not for Tuples in the programming sense, but for a tournament system: Single-elimination, Double-elimination, and etc.

  2. I can do translations, I'm just wondering if there was an algorithm that would lend itself well to translations.

A: 

What about "Tuple of 10", etc?

Adrian
+1  A: 

The only language independent prefixes are going to be the SI ones, and even those aren't really truly language independent.

http://en.wikipedia.org/wiki/Si%5Funits

I'm pretty sure that 'tuple' notation is going to require translation for every language you want to use.

James
A: 

This is entirely language-dependent. One trick I like to use in this type of situation is to reword the terminology so it's language-independent. So here I might refactor the UI to read something more like "Number of Elimination Rounds: N" with a number instead of putting a dropdown with "Single", "Double", etc.

Even if you want to do this, I think for your application, if you have to type them all out by hand, it wouldn't be so bad. Are you really ever going to have a centuple-elimination tournament? ;)

Jon Seigel
Yes, I will have a centuple elimination tournament. Though, that specific type will be just for testing purposes. I am trying to leave this entirely up to whoever is consuming this library. If they want a Dodecuple-elimination tournament, I want that to be a valid option.
John Gietzen
Then I would advise implementing the API in such a way that the caller must provide a number as opposed to a name (the first suggestion in my answer).
Jon Seigel
+1  A: 

It sounds like you just want a function for converting from what's used in your system (1, 2, 3, etc) to a nice UI-friendly printable string. If you want it to work for non-English languages then you probably shouldn't have this function at all. Let the Spanish-speaker decide what a nice spanish user-friendly wording is.

If I were writing the function, I'd go to "Quadruple Elimination" only and past that just use "5x Elimination", "6x Elimination" instead. That seems nicer to read to me than some of the awkward sounding later tuple words.

There isn't a nice algorithm you could use for this, as it's not an algorithmic thing.

String[4] tupleWords = [ "", "Single", "Double", "Triple", "Quadruple" ];
String getTupleWord(int number) {
    if ( 1 <= number <= 4 ) { 
        return tupleWords[number];
    } else {
        return number+"x";
    }
}

is the best you could do.

Brian Schroth