aoc2024

advent of code 2024 version unix - retour accueil

git clone git://bebou.netlib.re/aoc2024
Log | Files | Refs |

3.solve (373B)


      1 #! /bin/sh
      2 
      3 addmuls() {
      4 	grep -Eo '[0-9]+,[0-9]+' |
      5 	tr ',' '*' | paste -s -d'+' |
      6 	bc
      7 }
      8 
      9 echo "part 1"
     10 
     11 < 3.input grep -Eo 'mul\([0-9]{1,3},[0-9]{1,3}\)' |
     12 	grep -Eo "[0-9]*" |
     13 	addmuls
     14 
     15 echo "part 2"
     16 
     17 < 3.input grep -Eo "mul\([0-9]{1,3},[0-9]{1,3}\)|do\(\)|don't\(\)" |
     18 	sed "/don't()/,/do()/ d;/do()/ d" |
     19 	#awk 'BEGIN{p=1};/do()/{p=1};/don\047t()/{p=0}p' |
     20 	addmuls
     21 
     22 
     23