728x90
728x90

누르면 이동

 

 

근데 int랑 일부 문법 안써져서 우가우가 함
11 단원 무지개 부분 예시는 봐지지도 않음 ㅠ
가제는 그냥 내가 기분내려고 붙인거

사용도구 : 인터넷, 나, 노트북, (가끔)구글번역기

레퍼런스 누름 나오는 거. 함수이름 0.5초면 까먹어서 캡쳐함..ㅋㅋ 

 

 

 

이 전엔 막히는거 없어서 그냥 쭉쭉 풀고 차마 기록하고 찍을 생각은 안함

 

 

Unit 8 / Lesson 5

(가제) 세계여행

아이큐문제인가 머리굴렸는데 핵심은 그게 아니라고 판단하고.. 빠르게 goal 달성함.
핵심은 중복을 피해서 길찾아가는 게 아니라 '마무리 자세'(어딜보는지)임.. 조건활용이랑..ㅋㅋ 

* 주의점 - 도중에 바라보는 방향을 판단하면 virtual direction은 알 수 없다고 뜸
그냥 의식의 흐름대로 짜고 일부 문법들 안써져서 졸라리 지저분함

 

function main() {  
      putBeeperLine(); 
      turnLeft();
      move();
      turnLeft();
      
      putBeeperLine(); 
      turnRight();
      
      if(frontIsBlocked()){ 
          meetEndLine();
      } else{  
         move();
         turnRight();
      }
      
      putBeeperLine(); 
      turnLeft();
      move();
      turnLeft();
      
      putBeeperLine(); 
      turnRight();
      if(frontIsBlocked()){ 
          meetEndLine();
      } else{  
         move();
         turnRight();
      }
      
      putBeeperLine(); 
      turnLeft();
      
      if(frontIsBlocked()){
         turnRight();
      }
      
      if(frontIsClear()){ 
      move();
      turnLeft();
      
      putBeeperLine(); 
      turnRight();
      if(frontIsBlocked()){ 
          meetEndLine();
      } else{  
         move();
         turnRight();
      }
      
      putBeeperLine(); 
      turnLeft();
      move();
      turnLeft(); 
      
      putBeeperLine();  
      turnRight();
      if(frontIsBlocked()){ 
          meetEndLine();
      } else{  
         move();
         turnRight();
      } 
      }
      
}

function meetEndLine(){
   turnRight(); 
   move();
   move();
   move();
   move();
   move();
   move();
   move(); 
}

function turnRight()
{
   turnLeft();
   turnLeft();
   turnLeft();
}

function putBeeperLine()
{
   putBeeper();
   
   while(frontIsClear()) {
      move();
      putBeeper();  
   }  
}

 

 

Unit 9 / Lesson 2

(가제) 세로줄 쌓기

 

//Karel must help rebuild 
//broken columns. Make a 
//column of beepers above
//each beeper you find on
//the first row
function main() {
   while(frontIsClear()){
      move();
      
      // make beeper column
      if(beepersPresent()){
         turnLeft();
         putBeeperLine(); 
         turnRight();
         turnRight(); 
          
         while(frontIsClear()){
            move();
         }
         turnLeft();
      }
      
   }
}

function turnRight(){
   turnLeft();
   turnLeft();
   turnLeft();
}

function putBeeperLine()
{ 
   while(frontIsClear()) {
      move();
      putBeeper();  
   }  
}

 

 

Unit 12 / Lesson 1 (마지막 문제)

(가제) 중간 지점 찾기

 

//Your final task is to teach
//Karel to find the midpoint
//of any world. You can assume
//that all worlds are square.
function main(){ 
   // count
   int i = 0;
   while(frontIsClear()) {
      move();  
      //i++; //not working
      i = i + 1;
   }  
   i = i/2 + 1; //beeper position
   // direction chg
   turnLeft();
   turnLeft();
   for(int j=0; j<i-1; j++){
       move();
   }   
   // put beeper
   putBeeper();
   // direction chg
   turnright();
   turnright();
   // run to the goal
   while(frontIsClear()) {
      move(); 
   }
}

https://stanford.edu/~cpiech/karel/lessons.html#/english/unit12/lesson1

&amp;amp;nbsp;

 

변수 선언이 함수 내에서밖에 안되서 다르게 푸는 중
지금은 5*5짜리 안됨..이게 코든가 노가단가 단순화시켜야지 이건아닌듯

function main() {
   touchAngle(); //beepers with restart
    
   chgAngle(); //4
   chgAngle();
   chgAngle();
   chgAngle();
     
   move();
   putBeeper();
   move();
   turnAround(); 
   
   move();
   putBeeper();  
   move(); 
   turnAround();
   
   while(frontIsClear()) {
      move();
   } 
   
   delBeeper();  
   
   while(frontIsClear()) {
      move();
   }
} 

function chgAngle(){
   move(); 
   while(noBeepersPresent()) {
      move();
   }
   turnAround(); 
   move();
   putBeeper();
}

function delBeeper(){
   turnAround();
   while(frontIsClear()) {
      pickBeeper();
      move();
   }
   pickBeeper();
   turnAround();
}

function touchAngle(){ 
   while(frontIsClear()) {
      move();
	}
   putBeeper();
   turnAround();
   while(frontIsClear()) {
      move();
	}
   turnAround(); 
   putBeeper();
}

 

그냥 기록용..

728x90
728x90
블로그 이미지

coding-restaurant

코딩 맛집에 방문해주셔서 감사합니다.

,

v