I participated in this challenge programming in Rust, I've never worked with this language, but reading the documentation has always fascinated me. Below, you will also find some logic that I have implemented, absolutely improvable.
In the first puzzle you are asked to locate the elfπ§ with the most calories π¬ carried. The list received as input is represented by integer numbers divided into lines indicating the calories transported. These lines are further divided by empty lines. When an empty line is encountered it will mean that the next set of calories is being carried π by a different elf.
ββββββββββββββββ ββββββββββββββββββββββ
βGet Input DataβββββββββΊβDefine index = 0 β
ββββββββββββββββ β β
ββββββ€Define π§elf vect β
β ββββββββββββββββββββββ
βΌ
ββββββββββββ
βLOOP LINESβββββββββββββββββββββββ
βββββββ¬βββββ β
β β
βββββββββ΄ββββββββ β
ββββββββ€ Line is Empty?ββββββββ β
βΌ βββββββββββββββββ βΌ β
NO YES β
β β β
β βΌ β
β βββββββββββ β
β βIndex++; β β
β ββββββ¬βββββ β
β β β
β β β
β βββββββββββββββββββ β β
ββββββΊβExist elf[index]?βββββββ β
βββββ¬βββββββββ¬βββββ β
β β β
βββββYESβββ ββββΊNO βββββ β
β β β
β ββββββββββββ΄ββββββββββ β
β βPush 0 at elf[index]β β
β ββββββββββββ¬ββββββββββ β
β β β
β βββββββββββββββββββββββββββ β β
ββΊβAdd calories line at βββ β
βelf[index] β β
βββββββββββββ¬ββββββββββββββ β
β β
βββββββ΄βββββ β
β END LOOP βββββββΊNOβββββββββββββββ
βββββββ¬βββββ
β
βΌ
YES
β
β
βΌ
ββββββββββββββββββββββββ
βGet elf with max valueβ
ββββββββββββββββββββββββ
The elfπ§ with the most caloriesπ¬ may have run out of stash, the challenge. in addition to the previous one, he asks to find the three elves who have the most calories.
The flow is similar to part 1, only the result should be: take the three elvesπ§ that have the most caloriesπ¬ and add the result