Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <karel.h>
  2.  
  3. void turnRight();
  4.  
  5.  
  6. void jumpOver();
  7.  
  8.  
  9.  
  10. int main() {
  11. turnOn("olympics4.kw");
  12.  
  13. setStepDelay(150);
  14.  
  15. putBeeper();
  16. jumpOver();
  17.  
  18.  
  19.  
  20.  
  21. turnOff();
  22.  
  23. return 0;
  24. }
  25.  
  26. void turnRight(){
  27. turnLeft();
  28. turnLeft();
  29. turnLeft();
  30. }
  31.  
  32.  
  33. void jumpOver(){ if(frontIsBlocked(){
  34. while(frontIsBlocked()){
  35. turnLeft();
  36. while(rightIsBlocked()){
  37. movek();
  38. }
  39.  
  40. turnRight();
  41. movek();
  42.  
  43. while(rightIsBlocked()){
  44. movek();
  45. }
  46.  
  47. turnRight();
  48. movek();
  49.  
  50. while(frontIsClear()){
  51. movek();
  52. }
  53. while(frontIsBlocked()){
  54. turnLeft();
  55. } else { while(frontIsClear()){
  56. movek();
  57. while(frontIsBlocked() && leftIsClear()){
  58. turnLeft();
  59. while(rightIsBlocked()){
  60. movek();
  61. }
  62. turnRight();
  63. movek();
  64.  
  65. while(rightIsBlocked()){
  66. movek();
  67. }
  68.  
  69. turnRight();
  70. movek();
  71.  
  72. while(frontIsClear()){
  73. movek();
  74. }
  75. while(frontIsBlocked()){
  76. turnLeft();
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement