Giter Club home page Giter Club logo

societegenerale_tech_interview's Introduction

Soge - Technical Question

Particle Chamber Solution

Instruction:

Try to implement the below problment Statement in Java and if time permits do it in Python as well. Can you think of how to extend the scope of the problem? Do you think Java solution to the above problem can be implementd with Spring boot in a better way? If answer is yes do it. if anser is no, explain. Submit your code for our review either by checkin to your own public github repo (and share your repo URL) or send us by email.

Problem Statement

A collection of particles is contained in a linear chamber. They all have the same speed, but some are headed toward the right and others are headed toward the left. These particles can pass through each other without disturbing the motion of the particles, so all the particles will leave the chamber relatively quickly. You will be given the initial conditions by a String init containing at each position an 'L' for a leftward moving particle, an 'R' for a rightward moving particle, or a '.' for an empty location. init shows all the positions in the chamber. Initially, no location in the chamber contains two particles passing through each other. We would like an animation of the process. At each unit of time, we want a string showing occupied locations with an 'X' and unoccupied locations with a '.'. Create a class Animation that contains a method animate that is given an int speed and a String init giving the initial conditions. The speed is the number of positions each particle moves in one time unit. The method will return an array of strings in which each successive element shows the occupied locations at the next time unit. The first element of the return should show the occupied locations at the initial instant (at time = 0) in the 'X', '.' format. The last element in the return should show the empty chamber at the first time that it becomes empty.

Answers

You can find in this repository 3 folders for each version of the solution.

  • JAVA Version : A classic java solution with the Animation Class (No Tests)
  • Python Version : A basic python version (No Tests)
  • Spring Version : A RESTfull webservice (Maven project / with JUnit Tests)

Can you think of how to extend the scope of the problem?

  • To extend the scope of the problem, we could have thought of a problem with more dimensions, or particles shocking each other. In those implementations I tried to focus on the algorithm complexity of the problem.

Do you think Java solution to the above problem can be implementd with Spring boot in a better way? If answer is yes do it. if anser is no, explain.

  • Yes it can be implemented in Spring Boot. We can re-use the static method from the project and make it more scalable. A described belows, the webservice seems to be an RESTful service, taking and reponsding in JSON. But for big computation we could have think of another protocole to send data, like gRPC and a fastest language like C++ or GOlang.

societegenerale_tech_interview's People

Contributors

makunda 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.