Last active
          August 7, 2019 22:34 
        
      - 
      
- 
        Save Ratismal/43cb2075de479794a373cbcbea7fb948 to your computer and use it in GitHub Desktop. 
    converts a snowflake into a hastebin-like token
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const data = [ | |
| "12345", | |
| "12346", | |
| "22346", | |
| "21345" | |
| ] | |
| const output = []; | |
| const consonants = [ | |
| 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z' | |
| ]; | |
| const vowels = [ | |
| 'a', 'e', 'i', 'o', 'u', 'y' | |
| ]; | |
| for (const id of data) { | |
| const parts = id.split('').map(Number); | |
| let flake = []; | |
| for (let i = 0; i < parts.length; i++) { | |
| if (i % 2 === 0) { | |
| // consonant | |
| let seed; | |
| if (i === 0) seed = parts[i] + parts[i + 1]; | |
| else seed = parts[i] + parts[i - 1]; | |
| seed = seed % consonants.length; | |
| flake.push(consonants[seed]); | |
| } else { | |
| // vowel | |
| let seed = (parts[i] + parts[i - 1]) % vowels.length; | |
| flake.push(vowels[seed]); | |
| } | |
| } | |
| output.push(flake.join('')); | |
| } | |
| console.log(output.map((o, i) => data[i].padStart(22, ' ') + ' => ' + o).join('\n')); | |
| /* | |
| 12345 => fohem | |
| 12346 => fohen | |
| 22346 => guhen | |
| 21345 => fogem | |
| */ | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment