1
\$\begingroup\$

This should be easy: given an arbitrary string, your program will give it a name.

Requirements

Your program will accept an input of a UTF8 string, and output a string representing the input's "name", how you define this name is arbitrary, but it must comply with some conditions.

I/O Ranges

The input will at most be 382 UTF 8 characters long (making the input space 1112064^382 long). Don't ask me why this number, it was random. Your program must support all of them. Consider not forcing you to deal with arbitrary input size an act of mercy.

You can use any character set to build your output space. ASCII, Unicode, only Wingdings characters, etc. all are fair game. This output space must be smaller than the input space (easy enough), and name collisions must be uniformly distributed (every name will refer to roughly the same number of input strings, ~1% fluctuation is the max. accepted difference).

Yes I'm asking you to build a watered down hash function. Just in case you're wondering.

Name collisions must be sufficiently rare that it does not happen in everyday use. 1 in \$2^{100}\$ sounds reasonable enough a limit. This forces your output space to be at least 7540 bits long (the input space is a little larger than \$2^{7640}\$). (I tried cheating my own challenge by only outputting 0 and 1, you are not allowed to cheat like I did).

Conditions

  1. Name collisions must be rare enough (see above) and must not be, by any method, deliberately generated. This is similar to hash collisions.

  2. Name space must be smaller that input space (whats the point of having a name longer than the string)

  3. Your program must be deterministic. Same string must be assigned the same name every time.

Winning

The program with a name of at most 10 characters long and pronounceable (edit: since someone pointed out pronounceable is hard to define, this condition is now changed to <=10 characters of the same spoken language) wins. If this win condition is not met, scoring is lowest byte wins as usual.

The same language above means any one of the languages that people use. If one language uses some characters from another, that is fine as long as it is within normal use. (French uses English characters, for example) Mixing different language's characters that are not within formal use is not allowed (e.g. Korean characters and English alphabets)

Also give your program's name in the answer, even though it is unlikely to be <=10 characters and/or unpronounceable. I am curious what your program is called.

\$\endgroup\$
  • 4
    \$\begingroup\$ Intriguing idea, but I think it could benefit from some sandbox time. E.g. define "pronounceable". The special name-win condition is unnecessary and just pushes solutions to recognise themselves and return a short name. \$\endgroup\$ – Adám Feb 10 at 9:25
  • \$\begingroup\$ For those who want to ask there is an objective and definite ruling of whether something is pronouncable. docs.microsoft.com/en-us/previous-versions/office/developer/… \$\endgroup\$ – user92017 Feb 10 at 9:26
  • 2
    \$\begingroup\$ 1) You didn't link to that 2) Even that page doesn't specify rules for this, so 3) One would have to do trial-and-error 4) It requires platform-specific software. \$\endgroup\$ – Adám Feb 10 at 9:28
  • \$\begingroup\$ A "Coordinated Universal Time" string‽ \$\endgroup\$ – Adám Feb 10 at 9:30
  • 6
    \$\begingroup\$ Please define "characters of the same language". \$\endgroup\$ – Adám Feb 10 at 9:32
2
\$\begingroup\$

05AB1E, 2 bytes

₂∍

Try it online!


Explanation

 ₂                - 26
  ∍               - Extend/shorten to this length

Extend will repeat the string until it is length 26, shorten will remove chars from the right until it is length 26.

This means that some strings will be slightly more likely (the repeated ones since ab, abab, ababab, ababababab etc all produce ababababababababababababab, but it will fall within the 1%, since these cases of collision only occur for strings below length 26.


05AB1E, 8 bytes (Winning)

HSAsèJ₆∍

Try it online!

Program's name: faegdahbbafaegdahbbafaegdahbbafaegda


Explanation

HSAsèJ          - Convert it to a string of the first 10 letters of the english alphabet
      ₆∍        - Extend shorten to base 36 (10^36 > 2^100)        

Can definitely be shorter, but why bother. It wins.

\$\endgroup\$
  • 2
    \$\begingroup\$ Yeah but that's the same as any other substring amount @KevinCruijssen call it the base rate \$\endgroup\$ – Expired Data Feb 10 at 11:37
  • \$\begingroup\$ Put it this way.. the worst case is a single repeated character, there are 26 + base amount that produce this. Since 26 is clearly less than 1% of the number of suffixes of length 356 it's within the 1%... @KevinCruijssen \$\endgroup\$ – Expired Data Feb 10 at 11:41

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