Git Product home page Git Product logo

appman_nodejs_test's Introduction

AppMan Node.js Test

Problem 01

Find all possible array of 3 unique indices of a given n array that sum of all pointed numbers must be equal to a specific target.

> const { threeSum } = require('./three-sum')
> const inputArr = [5, 4, 3, 2, 1, 0]
> const target = 5
> threeSum(inputArr, target)
[ [ 1, 4, 5 ], [ 2, 3, 5 ] ]
>

Problem 02

We need to build an inverted 2-dimensional pyramid from bricks. To complete the n-th floor, we have to use exactly n brick(s). Please find max floor can be built from given input bricks

> const { maxFloor } = require('./max-floor')
> maxFloor(5)
2
>

Problem 03

We need to transform any positive number to 1 step by step with 2 rules as below:

  1. if number is even, must be transformed to (number / 2)
  2. if number is odd, must be transformed to either (number + 1) or (number - 1)

Please find min of step(s) to transform given number to 1.

> const { minStep } = require('./min-step')
> minStep(5) // 3 steps (n-1) to 4, (n/2) to 2, and (n/2) to 1.
3
>

Problem 05

Please write asynchronous function (and its test) that fetchs temperature data from OpenWeatherMap and returns Bangkok's maxTemp and minTemp (in celsius scale) for next 7 days. (You can find API key in openweather.key.txt)

> const { bangkokForecast } = require('./bangkok-forecast')
> bangkokForecast().then(console.log).catch(console.error)
[ { date: '2018-01-29', minTemp: 25.21, maxTemp: 27 },
  { date: '2018-01-30', minTemp: 23.28, maxTemp: 31.26 },
  { date: '2018-01-31', minTemp: 20.88, maxTemp: 30.81 },
  { date: '2018-02-01', minTemp: 19.33, maxTemp: 28.77 },
  { date: '2018-02-02', minTemp: 17.3, maxTemp: 31.47 },
  { date: '2018-02-03', minTemp: 18.13, maxTemp: 26.23 },
  { date: '2018-02-04', minTemp: 14.49, maxTemp: 25.41 } ]

Problem 06

Please write asynchronous function (and its test) that read a provided data-usage.log and generate summary report including username, total usage, average daily for each user.

> const { dataUsage } = require('./data-usage')
> dataUsage().then(console.log).catch(console.error)
[ { username: 'user03', total: 19387, average: 1938.7 },
  { username: 'user01', total: 15232, average: 1384.7272727272727 },
  { username: 'user02', total: 15897, average: 1445.1818181818182 } ]

appman_nodejs_test's People

Contributors

mryoyo avatar

Watchers

 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.