npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spacecraft-app-cli

v0.0.8

Published

A simple CLI Project to solve the Spacecraft problem with typescript

Downloads

93

Readme

Spacecraft-CLI

Build status License GitHub contributors npm version

A simple CLI to solve the Spacecraft Problem, made with TypeScript

Let's build a rocket together!

Image of a rocket

The Problem

Say, the Canadian Space Agency is building an unmanned spacecraft that’ll go to the moon.

To the moon

Here’s some more info about the project.

  • The ship’s starting coordinates are (0, 0), which is on Earth.

  • The ship’s final destination is (0, 250), which is on the moon.

  • The ship will be controlled over a CLI using a standard keyboard as follows:

  • The ship starts at (0, 0) at 0 speed, i.e. at complete rest. The ship only moves when a valid key is pressed.

  • Pressing W increases the ship’s speed and then moves it forward by speed units.

    • The ship’s maximum speed is 5.
  • Pressing S decreases the ship’s speed and then moves it forward by speed units.

    • The ship’s minimum speed is 0.
    • After launch, the ship cannot go below speed 1, i.e. it always moves forward until it reaches the moon.
  • Pressing A and D move the ship left and right by one unit respectively.

  • The ship also moves forward by speed units.

Problem

Write a CLI program in your preferred language to simulate the above spacecraft. Display output as follows:

  • Begin with (0, 0) ready for launch.
  • After every movement, display the updated position.
  • If the ship goes more than 5 points to the left/right, display wrong trajectory.
  • If the ship tries to decrease the speed below 1, display minimum speed.
  • If the ship tries to increase the speed over 5, display maximum speed.
  • When the ship reaches (0, 250) display on the moon.
  • If the ship goes beyond 250 on the y-axis, display contact lost.

Demo

Demo Example

Sample output

(0, 0) # Begin with original position.
(0, 1) # W increases the speed to 1 and moves forward.
(0, 3) # W increases the speed to 2 and moves forward.
(-1, 5) # A moves the ship left and forward.
(0, 7) # D moves the ship right and forward.
(0, 8) # S decreases the speed to 1 and moves forward.
...
(0, 250) on the moon # Ship reaches the moon

Install Globally

npm i -g spacecraft-app-cli

or

You can run directly with npx

npx spacecraft-app-cli

Getting started - Local Development

Installation

To get started locally, follow these instructions:

  1. Clone to your local computer using git.
  2. Make sure you have Node installed; see instructions here.
  3. Make sure that you have yarn installed; see instructions here.
  4. Run yarn install to install dependencies.

Usage

# starts 🚀 on coordinates (0,0) - Earth
yarn start

# Use W, A, S, or D  to starting control 🚀 .

Build the CLI bundle

yarn build

Run tests

yarn test

Contributors

Docs

License

Copyright (c) 2020 pyymenta

Spacecraft is licensed under the MIT license.