cs final project 2010 rohan paramesh. the programs implementing 3 programs each in c# and python ...

Post on 31-Dec-2015

213 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

C# AND PYTHON

CS Final Project 2010Rohan Paramesh

The Programs

Implementing 3 programs each in C# and Python Student Scheduler

Assigns courses and students, sorts according to different criteria

Twenty Questions A binary tree of QuestionNodes that writes

out to and reads from a text file Towers of Hanoi

Recursively provides a solution to the puzzle

C#

Microsoft’s current language Compiled Java-like

Syntax Logic

An atmosphere of whatever Java got wrong is fixed in C#

Python

Guido van Rossum Emphasis on readability Significant differences

Logic Style Syntax

Very popular nowadays with amateur developers and some large companies Google

Towers of Hanoi

Java C#public static void solveHanoi(int

disks, int from, int other, int to) {

if (disks <= 0)

return;

solveHanoi(disks-1, from, to, other);

System.out.println("Move disk " + disks + " from pole " + from + " to pole " + to + ".");

moves++;

solveHanoi(disks-1, other, from, to);

}

public static void SolveHanoi(int disks, int from, int other, int to)

{

if (disks <= 0)

return;

SolveHanoi(disks - 1, from, to, other);

Console.WriteLine("Move disk " + disks + " from pole " + from + " to pole " + to + ".");

moves++;

SolveHanoi(disks - 1, other, from, to);

}

Towers of Hanoi

Java Pythonpublic static void solveHanoi(int

disks, int from, int other, int to) {

if (disks <= 0)

return;

solveHanoi(disks-1, from, to, other);

System.out.println("Move disk " + disks + " from pole " + from + " to pole " + to + ".");

moves++;

solveHanoi(disks-1, other, from, to);

}

def solve_hanoi(disks, start, other, dest):

'''The main recursive method that solves the Tower of Hanoi puzzle. This method calls itself and also increments the number of moves.

disks -- the number of disks (integer)

start -- the starting peg (determined by class constant)

other -- the intermediate peg

dest -- the destination peg

'''

if (disks <= 0):

return

solve_hanoi(disks-1, start, dest, other)

print "Move disk ", disks, " from pole ", start, " to pole ", dest, "."

global moves

moves += 1

solve_hanoi(disks-1, other, start, dest)

Comparison

Scope Methods and Parameters Types Compiled vs. Interpreted I/O Freedom/Restrictions Accuracy Readability

top related