8000 GitHub - unicornware/pizza-delivery: How many houses will receive a pizza? πŸ πŸ•
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

unicornware/pizza-delivery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ• pizza-delivery

Conventional Commits TypeScript tested with mocha

Overview

Getting Started
Installation
Usage
Development & Testing
Built With
Contributing
Todo List

Getting Started

pizza-delivery is a simple Node.js program that models a pizza shop.

The project focuses on using object-oriented programming principles to answer questions posed by the Pizza Delivery Exercise.

Installation

  1. Authenticate with GitHub Package Registry (GPR)

    NPM

    //registry.npmjs.org/:_authToken=$PAT_GPR
    @unicornware:registry=https://npm.pkg.github.com/

    Yarn 1

    //registry.yarnpkg.com/:_authToken=$PAT_GPR
    @unicornware:registry=https:/
    9A85
    /npm.pkg.github.com/

    Yarn 2

    npmScopes:
      unicornware:
        npmAlwaysAuth: true
        npmAuthToken: $PAT_GPR
        npmRegistryServer: https://npm.pkg.github.com

    where:

  2. Add project to dependencies

    yarn add @unicornware/pizza-delivery # or npm i @unicornware/pizza-delivery

Usage

Pizza Delivery Exercise

Part 1

A delivery person is delivering pizzas to an infinite two-dimensional grid of houses. She begins by delivering a pizza to the house at her starting location; a dispatcher then calls via radio and tells her where to move next. Moves are always exactly one house to the north (^), south (v), east (>), or west (<). After each move, she delivers a pizza to the house at her new location. The dispatcher has been a little spacey lately, so she sometimes ends up delivering more than one pizza to the same house.

Here are some examples:

  • > delivers pizzas to two houses: one to the house at the starting location, and one to the house directly east of the starting location.
  • ^>v< delivers pizzas to four houses in a square; the house at the starting/ending location ends up with two pizzas.
  • ^v^v^v^v^v delivers a bunch of pizzas to some very lucky people at only two houses.

Given the string of dispatcher inputs in this file, how many houses receive at least one pizza?

To find out the answer to Part 1, run the following in your terminal:

ts-node ./challenge

Part 2

The next day, to speed up the process, the delivery person rents a pizza-delivering goat. She and the goat begin at the same starting location, and they both deliver a pizza to this starting house. She and the goat then take turns moving based on the dispatcher's instructions.

Here are some examples:

  • ^v now delivers pizzas to three houses; The delivery person goes north and the goat goes south.
  • ^>v< now delivers pizzas to three houses; The delivery person and the goat both end up back where they started.
  • ^v^v^v^v^v now delivers pizzas to 11 houses; The delivery person treks north and the goat treks south.

Given the same string of dispatcher inputs as in Part 1, how many houses receive at least one pizza?

To find out the answer to Part 2, run the following in your terminal:

ts-node ./challenge --workers 2

Using Different Dispatcher Inputs

Are you a pizza dispatcher interested in finding how many houses your workers visited? Run the snippet below to find out:

ts-node ./challenge --inputs <path-to-dispatcher-inputs-file> --workers <num-workers>

where:

  • <path-to-dispatcher-inputs-file> is the path to your dispatcher inputs file
  • <num-workers> is the total number of delivery workers on shift

Pizza Delivery API

Interested in the pizza-delivery internals? Check out the docs:

abstracts

models

Development & Testing

See the Contributing Guide for details on contributing code and running tests.

Built With

About

How many houses will receive a pizza? πŸ πŸ•

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 
0