Giter Site home page Giter Site logo

primenumbersgenerator's Introduction

PrimenumbersGenerator

Part 1 - Prime Number Generator

Please provide us with a concise, efficient and robust prime number generator written in Java that gives all prime numbers in the range between two numbers provided by the user (e.g. user gives 1 and 10 and you return "2, 3, 5, 7").

You should offer the user at least 3 different prime number generation strategies with different performance optimizations. Please include some simple but slow strategy and some others that increase performance at the expense of increased complexity. Consider also the use of multiple cores: if there is a gain, you could offer also a parallel implementation. Think also about memory usage (besides execution time).

You are allowed to take ideas from Internet or somewhere else, but not code. You should do the implementation yourself and from scratch. That said, using your own algorithms would be a nice extra.

Include some unit tests to validate the correctness of the program.

Make your program is usable via the command-line, allowing the user to select the generation strategy.

Part 2 - Prime Number Generator Server

Using the code from part 1 as the generation engine, write a server application (also in Java giving the user the chance to use your prime number generator over a REST API over HTTP (API frameworks/libraries are allowed and encouraged) .

For all users, record each execution in a database, including timestamp, range, time elapsed, algorithm chosen and number of primes returned.

For simplicity of implementation, you can use an in-memory database, like (for example) HSQLDB.

SOLUTION:

First part of assignment is in demo.primenumbers.primenumbersgen.facadeimplementation package. The file called PrimeNumberCMDRunner takes input from command line to perform the operation.

Second solution: run the app as a jar file. To perform an algorithm, a user id has to be obtained. By performing this call /api/saveandgetuser Save and return user id based on the username With this values {“username” : “king”}.

This will create a new user with the username and return id, or simply return the user if the username exist.

Then /api/runalgo Run algorithm of prime numbers { algorithm": "string", "endPosition": 0, "startPosition": 0, }

This will return elapsed time, username, algorithm,range.

The API Doc can be located at http://localhost:8080/swagger-ui.html

primenumbersgenerator's People

Contributors

kingbarric avatar

Watchers

 avatar  avatar

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.