Apr-25-2017, 09:36 PM
Hey everyone, have all of my code correct thus far (so I think lol) but steps 6 & 7 have me very lost. My instructor never gave us any information on swaps and I'm thinking there is to be a loop within a loop but i'm not sure if that is even possible with python. Appreciate any help/direction
- Draw five adjacent boxes and number the boxes 0 though 4
- Put the following numbers in boxes 0 - 4, one number per box: 6 8 4 5 2
- Draw a box, label the box I, write the number 0 in box I
- Draw a box, label the box J, write the number 999 in box J
- If the number in box I is less than 5 then do the next instruction, otherwise do instruction 12
- Replace the number in box J with 0
- If the number in box J is less than 4 then do the next instruction, otherwise do instruction 10
- If the number in the numbered box whose box number is the same as the number in box J is greater than the number in the box that follows then do the next instruction, otherwise do instruction 8
- Swap the value in the box whose box number is the same as the number in box J with the value in the box that follows
- Replace the number in box J with the number that is one more than the number currently in box J
- Go back and do instruction 5 again
- Replace the number in box I with the number that is one more than the number currently in box I
- Go back and do instruction 3 again
- You are done
list_ = [6,8,4,5,2] I = 0 J = 999 while I < 5: J = 0 while J < 4: J = J + 1 I = I + 1