Giter Site home page Giter Site logo

cp-challenges's Introduction

CP-Challenges

These are my attempts to answer my professor's questions to leave my Computer Programming classes. Answered in the language requested, as well as JS since that's where I used most of my mental space

Original Email

Hi Maor,

Here are some problems for you to try. See what you can do and what you are comfortable with. There is no class Monday, so you have more time.

Python work:

  1. Write a function that returns the nth Fibonacci number.
  2. Write a method that returns a factorial for a given input. Do this in a loop. Create another function that does this recursively.
  3. Write a method to test if a number is prime.
  4. Go to projecteuler.net, do problems 8 and 14.
  5. Create two ordered lists of random numbers of some predetermined size. Create a function that takes in the two lists and returns a list of all the numbers correctly ordered by pulling out each subsequent number from the beginning of the two lists and placing it in a third list. Call this function "MergeIt".
  6. Create a function to determine if two words (given as parameters) are palindromes
  7. Create a function to determine if two numbers (given as parameters) are permutations of each other.
  8. Create a class called Student. Explain all the parts of your class and create an instance of student. The student should be able to "say" its name. It should have a list of grades associated with it as well. Show how to set the grades for the student.

Java work:

  1. Create a method that searches for a substring inside another string. You cannot use premade Java libraries to do this (outside of String). Explain your algorithm in the comments.
  2. Create a function that outputs all Carmicheal primes from 1 to n using Big Integer.
  3. Create a search function that takes in arrays. If there are less than k numbers in the array, than use Selection Sort, if there are more than k numbers than use QuickSort. You don't have to write your own QuickSort, but you do need to write your own Selection Sort. Find the optimal k to be used by timing it for many, many different k's.
  4. Binary Search breaks down a problem by looking at each half (look it up). Write your own code similar to binary search but break the problem into thirds instead of halves.
  5. Create a Person class that has variables name and age. Create a Teacher class that is inherited from Person but also has variables job and subject. Make sure to create getters, setters, default constructor, copy constructor, overridden toString method, equals method, copy method, and anything else relevant. Create an array of Teachers in main and use the toString method to output each teachers information.
  6. Create a Duck Interface that has a quack method. Create a Mallard Duck and a GoldenEyeSea Duck. Give them each a distinct way of quacking (using a string). Find a way to use polymorphism in main and explain how this works.
  7. Give an example (in code) where it would be preferable to create an abstract class over an interface. Give another example (in code) where it would be preferable to create an interface instead of an abstract class.
  8. Create a Student class. Give the student a Paper and a Pen as variables (note: Paper and Pen are other classes that you create). Show how the student would use the paper and pen.

best, Prof Fried

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.