Giter VIP home page Giter VIP logo

gitlab2's Introduction

Highway

A small town lies along a portion of a long, scenic highway. (Think "Blue Ridge Mountain Parkway"). The town benefits significantly from the tourists who pass through along this road and who frequently stop to eat at the local restaurants, make purchases at the local stores, etc.

The town has become concerned that litter along the highway may drive some of these tourists away. The town council has encouraged local organizations and civic groups to "adopt" a stretch of the highway, pledging to clean up any litter along their stretch. Groups can select the portion of the highway that they are interested in, and the council has decided that it's OK if their chosen sections overlap, as this will simply mean that they get cleaned more often.

Write a program to track how much of the nearby highway is covered by the pledges of the various groups.

Input

All stretches of highway are identified by a pair of floating point numbers denoting the mileage markers posted on signs alongside the highway.

The first line of input will contain two numbers, denoting the range of mileage that the town wants to keep track of.

Each subsequent line after that will contain a pair of numbers indicating a range of highway that a group has pledged to keep clean.

Output

Print a simple report indicating the length of the portion of highway being tracked, the total length of that portion not covered by any pledges, and the percentage of the road that will be cleaned.

Example

The input

0.0 100.0
20.0 30.0
40.0 50.0

indicates that the town is tracking the highway between mileage markers 0 and 100, and that one group has pledged to clear the section from marker 20 to maker 30, and another group has pledged to clear everything from marker 40 to 50.

Output from this input would look like:

Total distance:   100.0
Not covered:    80.0
Percentage covered:  20.0%

gitlab2's People

Contributors

jdlavinder avatar github-classroom[bot] 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.