Created
          December 5, 2013 21:05 
        
      - 
      
- 
        Save nasser/7813877 to your computer and use it in GitHub Desktop. 
    Prints out numbers who's value is the same as the length of their spelled out form in a given language.
  
        
  
    
      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
    
  
  
    
  | require 'json' | |
| require 'open-uri' | |
| require 'numbers_in_words' | |
| require 'numbers_in_words/duck_punch' | |
| class Numeric | |
| def to_words language | |
| if language == 'en' | |
| self.in_words | |
| else | |
| url = "http://translate.google.com/translate_a/t?client=t&tl=#{language}&hl=en&ie=UTF-8&oe=UTF-8&uptl=#{language}&alttl=en&q=#{URI.escape(self.in_words)}" | |
| json = open(url).read.gsub /,+/, "," # wtf google | |
| JSON.parse(json).first.first.first | |
| end | |
| end | |
| end | |
| language = ARGV.first | |
| 100.times { |i| words = i.to_words language; puts words if words.length == i } | 
      
      
  Author
  
  
        
      
            nasser
  
      
      
      commented 
        Dec 5, 2013 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment