You’ve found Leonardo Da Vinci’s secret vault, secured by a series of combination locks. Fortunately, your treasure map has three codes: 1210, 3211000, and… hmm. The last one appears to be missing. Looks like you’re gonna have to figure it out on your own.
你發現了李奧納多 達文西的秘密庫房, 那裡安裝了一系列的 密碼鎖來確保安全。 幸運的是,你的寶藏圖上 有三個密碼: 1210、 3211000, 以及……。 顯然少了最後一個。 看來你得要靠自己找出來。
There’s something those first two numbers have in common: they’re what’s called autobiographical numbers. This is a special type of number whose structure describes itself. Each of an autobiographical number’s digits indicates how many times the digit corresponding to that position occurs within the number. The first digit indicates the quantity of zeroes, the second digit indicates the number of ones, the third digit the number of twos, and so on until the end.
頭兩組密碼有一些共通性: 它們是所謂的「自我描述數」。 這種數字類型很特殊, 它的結構能描述它自己本身。 自我描述數中的每一位數字 都表示次數,意即 該位數的位置號碼 在那個數中出現幾次。 第一位數表示 0 出現的次數, 第二位數表示 1 出現的次數, 第三位數表示 2 出現的次數, 以此類推到最後一位數。
The last lock takes a 10 digit number, and it just so happens that there’s exactly one ten-digit autobiographical number. What is it? Pause here if you want to figure it out for yourself! Answer in: 3 Answer in: 2 Answer in: 1
最後一個鎖的密碼是十位數的, 而且剛剛好 只有一個自我描述數是十位數的。 這個數字是什麼? 若你想要自己解解看, 請在此暫停! 答案即將公佈:3 答案即將公佈:2 答案即將公佈:1
Blindly trying different combinations would take forever. So let’s analyze the autobiographical numbers we already have to see what kinds of patterns we can find. By adding all the digits in 1210 together, we get 4 – the total number of digits. This makes sense since each individual digit tells us the number of times a specific digit occurs within the total. So the digits in our ten-digit autobiographical number must add up to ten.
盲目嘗試不同組合會要花上 不知道多久的時間。 所以,咱們來分析一下 我們已經有的自我描述數, 看看我們能找出什麼樣的模式。 把 1210 的每個位數的 數字都加在一起, 會得到 4 ——也就是位數的數目。 這是合理的,畢竟每一位數的數字 都告訴我們一個特定位數 出現的總次數。 所以,要找的十位數 自我描述數, 十個位數的數字加起來必須是 10。
This tells us another important thing – the number can’t have too many large digits. For example, if it included a 6 and a 7, then some digit would have to appear 6 times, and another digit 7 times– making more than 10 digits. We can conclude that there can be no more than one digit greater than 5 in the entire sequence. So out of the four digits 6, 7, 8, and 9, only one – if any-- will make the cut. And there will be zeroes in the positions corresponding to the numbers that aren’t used. So now we know that our number must contain at least three zeroes – which also means that the leading digit must be 3 or greater.
這就給了我們另一項重要資訊—— 這十位數的密碼中, 不會有很多個太大的數字。 比如, 若包含一個 6 和一個 7, 就表示有個數字出現 6 次, 還有另一個數字出現 7 次—— 這樣就不只十位數了。 我們可以得到一個結論: 整個數列中大於 5 的數字 不能超過一個。 所以, 若有 6、7、8 或 9 其中任一數字的話,只能有一個。 且對應到沒被使用之數字的 那些位置,都要填上 0。 現在我們知道,我們的密碼 應該有至少三個 0 —— 這也表示,第一位數 應該是 3 或更大的數字。
Now, while this first digit counts the number of zeroes, every digit after it counts how many times a particular non-zero digit occurs. If we add together all the digits besides the first one – and remember, zeroes don’t increase the sum – we get a count of how many non-zero digits appear in the sequence, including that leading digit. For example, if we try this with the first code, we get 2 plus 1 equals 3 digits. Now, if we subtract one, we have a count of how many non-zero digits there are after the first digit – two, in our example.
雖然第一位數的數字 表示 0 的數目, 這之後的每一位數數字都表示 一個特定的非 0 數字出現的次數。 如果我們把第一位以外的 所有位數數字加起來—— 別忘了,0 不會增加總和—— 我們得到的就是非 0 數字 出現在密碼中的次數, 包括第一位數。 比如,我們拿第一組密碼來試, 我們得到 2 + 1 = 3 位數。 如果我們減掉 1, 我們就能知道在第一位數之後 有多少個非 0 的位數—— 在我們的例子中,是 2 個。
Why go through all that? Well, we now know something important: the total quantity of non-zero digits that occur after the first digit is equal to the sum of these digits, minus one. And how can you get a distribution where the sum is exactly 1 greater than the number of non-zero positive integers being added together? The only way is for one of the addends to be a 2, and the rest 1s. How many 1s? Turns out there can only be two – any more would require additional digits like 3 or 4 to count them.
為什麼要做這些? 嗯,現在我們知道了 一項重要資訊: 在第一位數之後 有幾個位數是非 0 數字, 就等於這些位數的數字 加總再減掉 1。 你要如何讓加總總和剛好是 非 0 正整數的數字總和加上 1? 唯一的方式就是 讓其中一個加數是 2, 剩下的都是 1。 有幾個 1? 結果發現只能有 2 個—— 若超過 2 個,就會需要額外的 位數,比如 3 或 4,來計算它們。
So now we have the leading digit of 3 or greater counting the zeroes, a 2 counting the 1s, and two 1s – one to count the 2s and another to count the leading digit. And speaking of that, it’s time to find out what the leading digit is. Since we know that the 2 and the double 1s have a sum of 4, we can subtract that from 10 to get 6. Now it’s just a matter of putting them all in place: 6 zeroes, 2 ones, 1 two, 0 threes, 0 fours, 0 fives, 1 six, 0 sevens, 0 eights, and 0 nines.
所以,現在我們的第一位數 是 3 或以上,用來計算 0 的數目, 有一個 2 來計算 1 的數目, 還有 2 個 1 —— 分別計算 2 的數目, 以及第一位數的數目。 說到這個, 該是找出第一位數 是什麼的時候了。 我們知道 2 和 2 個 1 加起來是 4, 我們就能從 10 把它減掉,得到 6。 現在剩下的問題就是 要把它們都放對位置: 6 個 0、2 個 1、 1 個 2、沒有 3、 沒有 4、沒有 5、 1 個 6、沒有 7、 沒有 8、沒有 9。 安全箱打開了, 你在裡面發現了……
The safe swings open, and inside you find... Da Vinci’s long-lost autobiography.
失蹤已久的達文西自傳。