Replying to @datascience_fun
Hi David, great solution, but for part two it doesn´t work for my input.txt and the samples. I had to tweak it this way.
1
0
0
A classmate of mine mentioned the same issue with both their solution and mine. I always cut and paste the inputs into a txt file so I didn’t get the last \n issue.
0
0
1