Hackthissite Programming 第1關心得
題目網址:https://www.hackthissite.org/missions/prog/1/ 本關重點:字串處理、搜尋 題目:Unscramble the words 原始單字清單 You have to find the original (unscrambled) words, which were randomly taken from a wordlist. This level is about unscrambling words. Find the original (unscrambled) words, which were randomly taken from a wordlist. Send a comma separated list of the original words, in the same order as in the list below. You have 30 seconds time to send the solution. List of scrambled words: tsreaeh erxotp rtoatrc pdazoh abomob stieccl ruconyt sbownr kmfcue swleov (重新排列的十個單字) 題目會先給你一千多個單字的題庫,每個單字之間以換行字元隔開。接著會要求你在30秒之內把重新排列過的其中10個單字(如題)找出來,最後以逗點方式隔開答案。 整理單字題庫的字元數 和ASCII碼, 一千多個單字,解題時間卻只有30秒,如果逐個字元比對,平均7個字元長度的10個重新排列單字需要 (1000+500+250+125+62+31+15)*字元比對*7*10,再加上暫存題庫的空間。我想可能不是個有效率的方法。因此我們先將題庫整理一下,列出所有單字的字元數和ascii碼然後以相同順序儲存到暫存陣列。依序進行字元數比對、ascii比對、逐字元比對,我估計計算時間可以減少為 (1000*字元長度比對+200*acii碼比對+5*字元比對*7)*10。