December 9th

The Journey

Mary and Joseph have to travel from Nazareth, in the North of Israel, to Bethlehem. It's a 4-day walk, but if you're heavily pregnant you'd be going a lot slower. Mary and Joseph don't want to take any wrong turns, so they have to keep track of their direction throughout the journey. The countryside is hilly and it's easy to get turned around and accidentally head back north, so Joseph has a compass to track their current bearing.

Loop through the list of turns, keeping track of their current heading. Any turn that would take them north (ie a bearing greater than 270 or less than 090) should be ignored.

Example: 

turns='170 -70 20 -40 370' means 

Your data set:

turns = '180 20 -20 130 400 330 -180 -270 130 -200 -200 -290 330 70 -350 370 -120 130 370 -300 370 -330 -310 160 120 250 -110 -310 -240 -60 -190 30 160 -40 150 -330 300 -310 90 -280 200 370 220 280 -220 70 390 230 -210 240 350 240 -90 -110 390 -100 -130 -200 210 -160 80 10 -230 390 -310 -390 240 -250 270 70 -300 -250 -80 20 270 -10 390 -230 330 190 10 90 -80 20 -370 160 290 -130 -170 20 350 -160 -200 -240 260 -370 -50 240 310 70 -250 -210 -350 20 -90 -40 100 -130 80 190 -180 -320 40 -50 90 -100 130 -300 -120 80 -70 270 20 -20 -290 190 390 80 180 330 60 -120 -300 -400 360 220 390 -170 -360 -350 60 90 -340 -250 -170 -40 160 40 330 220 -190 90 -390 240 380 -270 30 -270 150 -400 -280 -50 -220 -110 80 -10 100 -200 190 -350 40 260 110 80 60 330 180 -360 -80 -380 -340 50 -270 -190 330 -140 -140 -140 90 20 340 220 -310 -20 250 70 370 -10 30 140 -210 -260 -140 180 220 90 -130 -360 -350 180 260 400 30 -90 -130 -400 -110 -230 -110 -150 270 -190 -240 360 -320 -140 -140 -80 60 150 380 30 -290 310 -90 -320 370 -370 -150 60 -380 -270 -120 400 -80 210 -330 250 230 170 210 -110 220 230 -130 20 -170 350 370 -110 120 -70 -330 380 300 320 90 50 390 -40 -300 -160 370 -320 -390 100 150 -180 60 -160 20 170 110 -40 -70 -360 330 340 -230 390 -270 190 -310 -380 160 -40 -20 -120 220 60'