day 21, pt 1

This commit is contained in:
sejo 2021-12-21 00:30:42 -06:00
parent 82def2ae0b
commit 7e403be225
1 changed files with 28 additions and 0 deletions

28
21/21.awk Normal file
View File

@ -0,0 +1,28 @@
{
pos[$2] = $5
}
END{
turn = 1
roll= 1
rollcount = 0
do{
r=0
for(i=1;i<=3;i++){
r += roll
roll = roll%100 + 1
rollcount++
}
pos[turn] = 1+(pos[turn]-1+r)%10
score[turn] += pos[turn]
# print roll,turn, pos[turn],score[turn]
turn = (turn==1) ? 2 : 1
}while(score[1]<1000 && score[2]<1000)
if(score[1]>=1000){
print rollcount*score[2]
}
else{
print rollcount*score[1]
}
}