Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168731
Image: ubuntu2004
input = """ #|#|#|## ---X---- ###||### """ # Prepare the input from the string north,start,south = input.strip().split('\n') start = start.find('X') # Setup the state variables X = start hits = 0 while (X >= 0) and (X < len(north)): print 'Robot at position:', X print 'To the north:', north[X] print 'To the south:', south[X] X += 1
Robot at position: 3 To the north: | To the south: | Robot at position: 4 To the north: # To the south: | Robot at position: 5 To the north: | To the south: # Robot at position: 6 To the north: # To the south: # Robot at position: 7 To the north: # To the south: #