解題語言不限Java
- Advent of Code Day 1 逆向驗證碼
- Advent of Code Day 2 損壞校驗和
- Advent of Code Day 3 螺旋內(nèi)存
- Advent of Code Day 4 高熵密碼
- Advevnt of Code Day 5 曲折的蹦床迷宮
- Advent of Code Day 6 內(nèi)存重分配
- Advent of Code Day 7 遞歸馬戲團(tuán)
- Advent of Code Day 8 注冊表愛好者
- Advent of Code Day 9 流處理
- Advent of Code Day 10 結(jié)哈希
- Advent of Code Day 11 六邊形迷宮
題目內(nèi)容
As you walk through the door, a glowing humanoid shape yells in your direction. "You there! Your state appears to be idle. Come help us repair the corruption in this spreadsheet - if we take another millisecond, we'll have to display an hourglass cursor!"
當(dāng)你通過門的時候伊履,一個人形的火焰對你大喊“你來幫我們修復(fù)這個表格嗎徽龟。如果我們用一毫秒來恢復(fù)這個表格上岗,我們必須要一個滴漏光標(biāo)”
The spreadsheet consists of rows of apparently-random numbers. To make sure the recovery process is on the right track, they need you to calculate the spreadsheet's checksum. For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences.
這個表格是由隨機數(shù)字組成的。為了保證恢復(fù)過程順利進(jìn)行描融,要計算這個表格的校驗和吕喘。校驗和是每一行最大和最小值得差值的和。
5 1 9 5
7 5 3
2 4 6 8
The first row's largest and smallest values are 9 and 1, and their difference is 8.
第一行最大的數(shù)字是9
亚铁,最小的是1
,所以差值是8
The second row's largest and smallest values are 7 and 3, and their difference is 4.
第二行最大的數(shù)字是7
螟加,最小的是3
徘溢,所以差值是4
The third row's difference is 6.
第三行的差值是6
In this example, the spreadsheet's checksum would be 8 + 4 + 6 = 18.
在這個例子里,電子表格的校驗和是8+4+6=18
解題思路
將輸入復(fù)制到文件
在讀取循環(huán)中捆探,同時計算單行數(shù)據(jù)的最大值和最小值
計算差值并加到buff里