2018年1月9日 星期二

Python: Hash a word

Python: Hash a word

Python Basic: Exercise-74 with Solution

Write a Python program to hash a word.
Sample Solution:-

soundex=[0,1,2,3,0,1,2,0,0,2,2,4,5,5,0,1,2,6,2,3,0,1,0,2,0,2]

word=input("Input the word be hashed: ")

word=word.upper()

coded=word[0]

for a in word[1:len(word)]:
    i=65-ord(a)
    coded=coded+str(soundex[i])
print() 
print("The coded word is: "+coded)
print()

========== RESTART: F:/Python_APSC/py-ex-basic-74.py =============
Input the word be hashed: abcdefghijklmnopqrstuvwxyz

The coded word is: A2020103262105542200210321

>>> 

沒有留言:

張貼留言

Node-Red --> MQTT --> Fuxa 開源碼網頁式圖控平台

Node-Red --> MQTT --> Fuxa      FUXA(一個開源的 Web HMI / SCADA 自動化監控軟體)的專案設定檔 。 這份設定檔完整定義了 HMI 監控畫面的 後端通訊(MQTT 連線、點位標籤) 與 前端網頁圖形介面(SVG 畫布...