Advent of code

 1er décembre 2022 

  Calorie Counting : Max de différentes additions séparées par une ligne vide
4035
   
10596
   
17891
   
5278
   
  
   
11293
   
  
  1. code.py
  2. code.sh
  3. code_autresFaconsPartie2.sh
#!/bin/bash

### Partie 1 ###
total=0
cat input.txt | while read n; do
        if [ -z "$n" ] ; then
                echo $total
                total=0
        else
                total=$(($total + $n))
        fi
        done | sort -n | tail -n 1


### Partie 2 ###
total=0
cat input.txt | while read n; do
        if [ -z "$n" ] ; then
                echo $total
                total=0
        else
                total=$(($total + $n))
        fi
        done | sort -n | tail -n 3 | sed 's/^/+ /' | xargs expr 0