Coder Social home page Coder Social logo

guessserver's People

Contributors

dependabot[bot] avatar gardusig avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

guessserver's Issues

Create scenario for this use case

grpc-service

The goal of this project is to document the setup for establishing a gRPC communication between a server and its clients.

GuessNumber Service

Statements

  • A special number is randomly generated at the server startup
    • It gets updated every time a guess is made by a client with the exact same number
  • For each guess, the server will respond with
    • < if given number is less than special number
    • > if given number is greater than special number
    • = if given number is equal to special number
      • There will also be a locked box as your prize
  • Guessed numbers must lie within the interval defined by: $[-8 * 10^{18}, +8 * 10^{18}]$
    • Every number with up to $18$ digits
    • Given that your computer probably can't process more than $10^{10}$ operations in a second, a naive approach of guessing each possible number would take at least $5$ years to execute
  • There is in fact one algorithm capable of solving this question a bit faster - binary search
    • Instead of guessing each number, you can benefit from the server response to avoid making unnecessary guesses
    • Since each wrong guess reduces the amount of possibilities by its half
      • Worst case goes from $O(N)$ to $O(log_2(N))$
        • $N$ is the amount of possible values: $\approx 16 * 10^{18}$
          • which also happens to be quite close to the amount of possible numbers to fit inside a 64-bit integer: $log_2(16 * 10^{18}) \approxeq 64$

Protocol Buffers

There are two defined procedures to be remotely called

  • GuessRandomNumber
    • Input: Guess
    • Output: GuessResponse
  • OpenBox
    • Input: LockedBox
    • Output: Box

Check it out!

Programming Languages

  1. Go

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.