php.ini에서 short_open_tag = Off 로 설정.
'Computer/Programming'에 해당되는 글 7건
- 2012.07.06 PHP 파일에 삽입된 <?xml 해결방법
- 2012.05.11 Freckles - Skiena and Revilla Programming Challenges book
- 2012.03.01 Python으로 작성한 Min-Heapify
- 2012.03.01 Python으로 작성한 Max-Heapify
- 2012.02.26 Python으로 작성한 Recursive Insertion Sort
- 2012.02.08 파이썬에서 문자열을 클립보드로 보내기
- 2011.10.20 Java UDP Pinger Lab
This is my result of the individual project from Algorithm class CSCI 3101 Hawaii Pacific University.
알고리듬 수업에서 수행한 개인 프로젝트의 결과물입니다.
Freckles – Skiena and Revilla Programming Challenges book.
알고리즘 트레이닝 북에 실린 주근깨 문제입니다.
I implemented Prim and Kruskal algorithms for this project with Python. See attached files on the bottom of this post if you need.
You are allowed to edit attached source codes, but please do not remove my name as an author on the top.
참고로, 한국에서 판매하는 책에 해답(C로 작성된 소스코드)이 실려있지만, 실제로 작성해서 컴파일/실행해본 결과 제대로 작동이 되질 않았습니다. 따라서, 이것을 필자가 파이썬으로 재작성했고, 프로젝트의 조건은 Prim과 Kruskal 두 개의 알고리즘으로 구현해야하는 것이었습니다. 소스코드는 첨부된 하단에 파일을 참고해주세요. 내용은 수정해도 되지만, 제 이름은 삭제하지 말아주세요.
The below is the problem from the book.
아래는 알고리즘 트레이닝 북에 실린 문제의 원문입니다.
In an episode of the Dick Van Dyke television show, Dick’s son Richie connects the freckles on his father’s back to form a picture of the Liberty Bell. Consider Dick's back to be a plane with freckles at various (x, y) locations. Your job is to connect the dots so as to minimize the amount of ink used. Richie connects the dots by drawing straight lines between pairs, possibly lifting the pen between lines. When Richie is done there must be a sequence of connected lines from any freckle to any other freckle.
Input
The input begins with a single positive integer on a line by itself indicating the number of test cases, followed by a blank line.
The first line of each test case contains 0 < n <= 100, giving the number of freckles on Dick's back. For each freckle, a line follows; each following line contains two real numbers indicating the (x, y) coordinates of the freckle.
Put a blank line between each two consecutive test cases.
Output
For each test case, your program must print a single real number to two decimal places: the minimum total length of ink lines that can connect all the freckles. The output of each two consecutive cases must be separated by a blank line.
Sample Input
1
3
1.0 1.0
2.0 2.0
2.0 4.0
Sample Output
3.41
---------------------------------------------------------------------------------------------------------
My source codes
Prim:
Kruskal:
파이썬으로 작성한 Max-Heapify의 코드다. 의사코드는 Introduction to Algorithms라는 MIT Press에서 나온 교재에서 참조했다.
Source code: MinHeapify.py
파이썬으로 작성한 Max-Heapify의 코드다. 의사코드는 Introduction to Algorithms라는 MIT Press에서 나온 교재에서 참조했다.
Source: MaxHeapify.py
참고로, 맥에서만 가능하다.
from AppKit import NSPasteboard, NSArray
pb = NSPasteboard.generalPasteboard()
pb.clearContents()
strClipboard = NSArray.arrayWithObject_('Message Here')
pb.writeObjects_(strClipboard)
서버를 실행할 때 포트번호를 임의로 적어주면 된다.
예) javac PingServer.java && java PingServer localhost 1024
클라이언트의 실행법은 서버의 IP와 포트번호를 적으면 된다.
예) javac PingClient.java && java PingClient localhost 1024
서버의 코드는 Computer Networking, Kurose and Ross, 5th edition에서 작성된 그대로다.
Programming Assignment 3: UDP Pinger Lab
In this lab, you will study a simple Internet ping server written in the Java language, and implement a corresponding client. The functionality provided by these programs are similar to the standard ping programs available in modern operating systems, except that they use UDP rather than Internet Control Message Protocol (ICMP) to communicate with each other. (Java does not provide a straightforward means to interact with ICMP.)The ping protocol allows a client machine to send a packet of data to a remote machine, and have the remote machine return the data back to the client unchanged (an action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-trip times to other machines.
You are given the complete code for the Ping server below. Your job is to write the Ping client.
Client:
// File name: PingClient.java