<-->
본문 바로가기

알고리즘

algorithm, part1 | Coursera 과제 하는법 (mac)

반응형

 

 

영어를 못해서

첫번째 테스트용 과제 세팅하느라 하루를 다썼다.

그래도 단어 하나씩 찾아가면서 과제 제출하고 통과했다.

(영어 잘하는분은 원문 읽으면서 하는게 더 빨라요!)

 

세팅 하는 방법

lift.cs.princeton.edu/java/mac/

 

Hello World in Java (Mac OS X)

Tip Typically, you should compile from IntelliJ (because IntelliJ highlights the lines on which any compile-time errors or warnings occur) and execute from the command line (because the command line makes it is easy to specify command-line arguments and us

lift.cs.princeton.edu

1. lift-java.pkg를 다운받아서 intelliJ IDEA (자바 통합 개발환경)를 설치한다.

2. sample project중 하나를 작업폴더로 다운 받아서 테스트겸 실행 해본다. (ex: hello.zip)

3. 컴파일과 실행 명령어는 아래를 확인한다. 실행 명령어는 확장자(.java)를 빼고 입력한다.

컴파일 명령어: javac 파일명.java
실행 명령어 : java 파일명

4. 새로운 자바 클래스를 만들고 싶으면 좌측 상단의 LIFT -> New Java Class를 클릭하면된다.

 

5. Barnsley.java와 CollidingDisks.java를 작업 폴더에 추가 한후 설명 커맨드 라인을 참고해 실행해 본다.

 

6. algs4.jar 라이브러리가 안읽어지는 경우

algs4.cs.princeton.edu/code/

 

Java Algorithms and Clients

Java Algorithms and Clients Java programming environment. Here are instructions for setting up an IntelliJ-based Java programming environment for Mac OS X, Windows, and Linux. Design goals. Our original goal for this book was to cover the 50 algorithms tha

algs4.cs.princeton.edu

여기서 algs4.jar를 찾아 다운받고 algs4.jar가 있는 경로를 classpath에 추가하면된다.

 

과제 설명

 

coursera.cs.princeton.edu/algs4/assignments/hello/specification.php

 

Programming Assignment 0: Hello, World

Add an import statement like the following at the top of your program: import edu.princeton.cs.algs4.StdIn; import edu.princeton.cs.algs4.StdOut; import edu.princeton.cs.algs4.StdRandom; If you use IntelliJ and the provided project folder, IntelliJ will au

coursera.cs.princeton.edu

과제는 총 3개의 파일을 "hello.zip"이라는 파일명으로 압축하여 제출하면된다.

1. HelloWorld.java
2. HelloGoodbye.java
3. RandomWord.java

웹사이트의 커맨드라인은 각 파일들의 실행 결과이며,

3번째 RandomWord.java은 배열을 쓰면 안된다.

입력을 하나씩 읽는다. i번째 입력은 1/i의 확률을 가지고,

당첨되면 champion값을 i번째 입력 String으로 바꾼다.

이를 StdIn.isEmpty() = true 가 될때까지 반복하면 된다.

 

사용할 수 있는 메소드는 RandomWord 결과 커맨드 아래에 적혀있다.

 

테스트를 통과하지 못했을 경우

1. 3개의 java 파일명과 zip파일명이 hello.zip 인지 확인

2. 출력한 내용이 실행 결과와 동일한지 확인

3. 로직 확인(과제 요구사항을 만족했나?)

'알고리즘' 카테고리의 다른 글

정렬의 stability  (0) 2021.04.05
quickSort 파이썬 구현 (백준 2750)  (0) 2021.03.10
15일차 - 똑똑똑똑똑  (0) 2021.03.08
Devide and Conquer(mergeSort)  (0) 2021.03.08
선택 정렬 시간복잡도  (0) 2021.03.01