Monthly Archives: September 2017

Turtle Graphics: Koch – Circle Approximation

 

Screen Shot 2015-09-07 at 9.38.05 PM   Screen Shot 2015-09-07 at 9.41.17 PM

Classwork:

Set up your working environment

1. Create a folder to hold your projects for this class, Algorithms.
2. Create a folder for ADTs.
3. Create a project in ADTs with the classes presented in the pdf above. Ensure that your project contains the files needed to test your classes. Check edmodo.com for due dates.
4. Write your own main method to test your classes. Ensure you have good documentation.
5. Submit your work to edmodo.com.

Guidelines to submit your work:

  1. Find the assignment’s post
  2. Copy and paste your work on the post.
  3. If the assignment is a program, you also have to attach the file to the post.
  4. The file has to have your initials followed an underscore and the program name.

Every program has to have a header:

  • Assignment description
  • Author’s name
  • Date
  • If the program doesn’t run successfully, write a short paragraph as part of the program header explaining the problem.

Input and output:

  • If the assignment requires input and output is generated, both should be included in your program as comments.
  • If the output is an image or animation, submit a screen shot.

Using Turtle ADT
turtle_draw papert
Seymour Aubrey Papert (February 29, 1928 – July 31, 2016)
was a South African-born American mathematician, computer scientist, and educator, who spent most of his career teaching and researching at MIT.[1] He was one of the pioneers of artificial intelligence, and of the constructionist movement in education. He was co-inventor, with Wally Feurzeig, of the Logo programming language.
Logo
Papert used Piaget’s work in his development of the Logo programming language while at MIT. He created Logo as a tool to improve the way children think and solve problems. A small mobile robot called the “Logo Turtle” was developed, and children were shown how to use it to solve simple problems in an environment of play. A main purpose of the Logo Foundation research group is to strengthen the ability to learn knowledge.[7] Papert insisted a simple language or program that children can learn—like Logo—can also have advanced functionality for expert users.
From Wikipedia

Assignment:
Regular n-gons. Ngon.java takes a command-line argument n and draws a regular n-gon using turtle graphics or the Std library. By taking n to a sufficiently large value, we obtain a good approximation to a circle. Show your images as n increases. Implement an algorithm to find the smallest value for n to get the best approximation to a circle.
Document clearly your proof.
NOTE: only show few images

Homework:
Set up your working environment in your own computer.
Assignment:
Recursive graphics. Koch.java takes a command-line argument n and draws a Koch curve of order n. A Koch curve of order order 0 is a line segment. To form a Koch curve of order n:
Draw a Koch curve of order n−1
Rotate 60° counterclockwise
Draw a Koch curve of order n−1
Rotate 120° clockwise
Draw a Koch curve of order n−1
Rotate 60° counterclockwise
Draw a Koch curve of order n−1
Below are the Koch curves of order 0, 1, 2, and 3.
As the order of the curve increases, how is the area between the curve and the “x-axis” affected? Modify the Koch ADT to include a method that implements the area computation to assist you in answering the question.
Document clearly your proof.

Koch Snowflake

 

Mandelbrot Set

Faster Madelbrot

Speed up Mandelbrot by performing the computation directly instead of using Complex. Compare. Incorporate periodicity checking or boundary tracing for further improvements. Use divide-and-conquer: choose 4 corners of a rectangle and a few random points inside; if they’re all the same color, color the whole rectangle that color; otherwise divide into 4 rectangles and recur.

screen-shot-2016-09-19-at-8-43-22-pm

Euclidean Points

Screen Shot 2015-09-07 at 9.38.05 PM   Screen Shot 2015-09-07 at 9.41.17 PM

ADTs refresher Project
Euclidean points. Create a data type EuclideanPoint (prefix your file with your initials YI_EuclideanPoint.java) that represents a d-dimensional point.
1. Write a method so that p.distanceTo(q) returns the Euclidean distance between points p and q.
2. Write a method so that p.midPoint(q) returns the Euclidean mid-point between points p and q.
3. Include a test class with at least three pair of points with different dimensions.
4. Before you start the implementation, use paper and pencil to show few examples using illustrations and computations.

screen-shot-2016-09-19-at-5-25-49-pm

Cryptography – Caesar Cypher – Third Day

September 11th, 2017

The Caesar Cipher

The key for the Caesar Cipher will be a number from 1 to 26. Unless you know the key (that is, know the number used to encrypt the message), you won’t be able to decrypt the secret code.

The Caesar Cipher was one of the earliest ciphers ever invented. In this cipher, you encrypt a message by taking each letter in the message (in cryptography, these letters are called symbols because they can be letters, numbers, or any other sign) and replacing it with a “shifted” letter. If you shift the letter A by one space, you get the letter B. If you shift the letter A by two spaces, you get the letter C. Figure 14-1 is a picture of some letters shifted over by three spaces.

 

To get each shifted letter, draw out a row of boxes with each letter of the alphabet. Then draw a second row of boxes under it, but start a certain number (this number is the key) of spaces over. After the letters at the end, wrap around back to the start of the boxes. Here is an example with the letters shifted by three spaces:


Invent with Python

Making paper cryptography paper tools

 


A virtual Cipher Wheel

Assignments: visit edmodo.com to submit your work
My Cipher – Clwk 9/11/2017 – Caesar Cipher Device

1. Look at the Caesar Cipher Device on the link below. Create your own cipher and a device that can be used to encrypt and decrypt your messages.

2. Write a java program to encrypt and decrypt messages using your new cipher. Use the university SdtDraw.java to draw the device you designed for your cipher. The drawing is a representation of the cipher.

1. The program should display 2 options:
e. Encrypt a message
d. Decrypt a message
x. Exit

2. Prompt the user for the “key”. Make sure your prompt for the “key” includes all the information necessary for the user to understand what is needed when the message is decoded.

NOTE: The program should continue to display the menu until the user exits the application.

BAD Ciphers: reversing the order, flipping the letters, reversing and flipping the letters of the message, and anything that is similar to the Caesar Cipher with a silly twist to it.

DOCUMENTATION:
Header:


/** 
Full assignment description
Your Name
Date
**/

If there is any obfuscated code snippet, you must include a comment!

Footer:


/**
Multiple Input/output sessions.
**/

NOTE: your program name: MyCipher_YI.java