- 파이썬을 이용해서 게임을 만들어보자!The Game- 게임 소개A game of Ants Vs. SomeBees consists of a series of turns. In each turn, new bees may enter the ant colony. Then, new ants are placed to defend their colony. Finally, all insects (ants, then bees) take individual actions. Bees either try to move toward the end of the tunnel or sting ants in their way. Ants perform a different action depending on their type, s..
mint는 동전이 만들어지는 장소이다.이 문제에서 나는 Minty class를 만들어야 한다.이 클래스는 올바른 year와 worth를 가진 Coin을 출력한다.각각의 Minty class는 year stamp가 있다. update메소드는 year stamp를 Minty class의 present_year 클래스 attribute에 설정한다.create 메소드는 minty의 year가 stamped된(업데이트되지 않은 경우 Minty.present_year와 다를 수 있음) Coin인스턴스를 리턴한다.Coin 생성자는 각각의 coin의 연도가 올바른지, 각 coin의 종류(이 경우에서는 'Dime' 또는 'Nickel')가 올바른 cents 값을 가지는지 확인해야 한다.Coin의 worth 메소드의 반환..
이 프로젝트에서는 타이핑 속도를 측정하는 프로그램을 작성할 것이다.사용자가 단어를 입력한 후 맞춤법을 수정하는 기능인 autocorrect(자동 수정 입력)기능을 구현할 수 있다.이 프로젝트는 typeracer에서 영감을 받았다. Getting Started Video 참고 가능Phase 1: Typing Problem 1: pick함수 구현3개인수 받는다paragraphs: strings의 listselect 함수: 선택될 수 있는 string들에 true반환하는 함수k: 인덱스로 쓰이는 음이 아닌 정수 k리턴값은 select에서 true만족하는 것들 모아서 만든 리스트k가 너무 커서 만족하는 paragraph가 없으면 empty string을 리턴한다. => 새로 만든 리스트에서 out of list..
학교 수업에서 터미널을 사용하기 위해 내가 사용하는 Windows에 Ubuntu를 깔아야 했다. 우분투 설치하기 우분투 공식 홈페이지의 방법대로 깔았는데 시간이 꽤 오래걸렸다. 중간에 에러가 나서 고치는데에도 좀 애먹었는데 어떻게 잘 해결했었다. 우분투 사용하기 우분투를 깔았는데 내가 원하는 폴더로 접근하는법을 모르겠었다. 사진으로 보는 문제 상황 윈도우 경로랑 달라서 뭔고 했다 근데 명령어 하나면 바로 해결됨 파일탐색기 주소창 부분(사진참고)에 wsl이라고 치면 알아서 그 경로에서 리눅스가 열린다. 아래와 같이 내가 원하는대로 접근할 수 있다.
Q3: Insect CombinatoricsConsider an insect in an M by N grid. The insect starts at the bottom left corner, (1, 1), and wants to end up at the top right corner, (M, N). The insect is only capable of moving right or up. Write a function paths that takes a grid length and width and returns the number of different paths the insect can take from the start to the goal. (There is a closed-form solution..
Problem 8: make_averaged function 구현make_averaged functionoriginal_function을 인자로 받는 high-order functionreturn값은 original_function과 동일한 수의 인수를 받는 함수이다.이 함수를 호출하면 이것은 original_function을 반복적으로 호출한 평균값을 리턴할 것이다.특히, 이 함수는 original_function을 total_samples횟수만큼 호출해야하고 이 호출들의 결과의 평균을 반환해야 한다.주의할 점기본 룰은 굴린 dice의 수의 합을 구하는 것. 여기에 규칙을 적용하는 것임 주의def make_averaged(original_function, total_samples=1000): ""..
Commentary functions게임 설명하는 함수를 사용할 것사용할 인수score0, score1, 이전의 leading player, leader리턴값현재 leading player(점수가 더 높은 플레이어), print할 메시지 또는 None그냥 메세지 출력하는 함수니까 프로그램상의 문제를 일으키지는 않을 것Problem 6: announce_lead_changes 구현lead가 바뀌는걸 쫓아가는 주석함수이다.leading player가 바뀌면 이 함수는 메시지를 출력한다.leading player가 없거나(== 즉, 두 플레이어의 점수가 똑같다면) 이전 leading player로부터 아무 변화가 없다면 이 함수는 None을 message로 리턴한다.이 함수의 마지막에 두 값을 리턴해야한다.더..
Problem 1~4: 게임 rule구현하기두 명의 플레이어가 번갈아서 최소 100점의 총점이 되면 끝남각 턴마다, 현재 플레이어는 굴릴 주사위의 개수를 최대 10개까지 선택턴 점수는 주사위 결과의 합계임.몇가지 조건이 있음Sow Sad: 아무리 많은 주사위를 던져도 한 번 1이 나오면 그 플레이어의 턴 점수는 1이다.Example 1: The current player rolls 7 dice, 5 of which are 1's. They score 1 point for the turn.Example 2: The current player rolls 4 dice, all of which are 3's. Since Sow Sad did not occur, they score 12 points for the..