Hacker News new | ask | show | jobs
by meric 4067 days ago
The first solution that came into my mind, type using strokes.

Here is a list of 11 strokes:

http://www.121chineselessons.com/wp-content/uploads/2012/02/...

Every word's strokes has a pre-determined "correct" order.

Once you list out the word's strokes, there are only a a couple of possibilities of characters left.

A blog post on `Chinese Python`. http://reganmian.net/blog/2008/11/21/chinese-python-translat...

1 comments

Unfortunately, Chinese Python maps English words to 2-character Chinese words, so the translation requires spaces between the Chinese words. So

    while running:
      guess = int(raw_input('Enter integer: '))
      if guess == number:
        print 'Congratulations'
        running = False
      elif guess < number:
        print 'No, higher'
      else:
        print 'No, lower'
translates to

    當 運行:
      猜測 = 整數(輸入('輸入數字: '))
      如果 猜測 == 數字:
        印出 '恭喜'
        運行 = 假
      假使 猜測 < 數字:
        印出 '錯了, 再大'
      否則:
        印出 '錯了, 再小'
But if we map English words in programming to single Chinese characters, we wouldn't need spaces, so perhaps

    當運:
      猜=整(輸('輸入數字: '))
      如猜==數:
        印'恭喜'
        運=假
      否如猜<數:
        印'錯了, 再大'
      否:
        印'錯了, 再小'
And if we made the syntax more C-like to fully make use of the spaceless syntax

    當運{
      猜=整(輸('輸入數字: '))
      如猜==數{印'恭喜';運=假}
      否如猜<數{印'錯了, 再大'}
      否{印'錯了, 再小'}
    }
One could program on one's smartphone screen on the train!
You can use semi-colons in Python to put multiple lines in one line, as well as inline blocks next to the colon. So, you can remove the braces, too. Added parenthesis for python 3.

    當運:
      猜=整(輸('輸入數字: '))
      如猜==數:印('恭喜');運=假;
      否如猜<數:印('錯了, 再大');
      否:印('錯了, 再小')