解題語(yǔ)言不限Java
- Advent of Code Day 1 逆向驗(yàn)證碼
- Advent of Code Day 2 損壞校驗(yàn)和
- 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 注冊(cè)表愛(ài)好者
- Advent of Code Day 9 流處理
- Advent of Code Day 10 結(jié)哈希
- Advent of Code Day 11 六邊形迷宮
題目?jī)?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)你通過(guò)門(mén)的時(shí)候,一個(gè)人形的火焰對(duì)你大喊“你來(lái)幫我們修復(fù)這個(gè)表格嗎。如果我們用一毫秒來(lái)恢復(fù)這個(gè)表格,我們必須要一個(gè)滴漏光標(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.
這個(gè)表格是由隨機(jī)數(shù)字組成的。為了保證恢復(fù)過(guò)程順利進(jìn)行,要計(jì)算這個(gè)表格的校驗(yàn)和。校驗(yà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.
在這個(gè)例子里,電子表格的校驗(yàn)和是8+4+6=18
解題思路
將輸入復(fù)制到文件
在讀取循環(huán)中,同時(shí)計(jì)算單行數(shù)據(jù)的最大值和最小值
計(jì)算差值并加到buff里