承接 sasakocic/trip-sorter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sasakocic/trip-sorter

Composer 安装命令:

composer create-project sasakocic/trip-sorter

包简介

Trip Sorter

README 文档

README

Build Status Code Style Status CodeCov CodeClimate Issue Count Issue Count

Task

You are given a stack of boarding cards for various transportations that will take you from a point A to point B via several stops on the way. All of the boarding cards are out of order, and you don't know where your journey starts, nor where it ends. Each boarding card contains information about seat assignment, and means of transportation (such as flight number, bus number etc). Write an API that lets you sort this kind of list and present back a description of how to complete your journey. For instance the API should be able to take an unordered set of boarding cards, provided in a format defined by you, and produce this list:

  1. Take the train 78A from Madrid to Barcelona. Sit in the seat 45B.
  2. Take the airport bus from Barcelona to Gerona Airport. No seat assignment.
  3. From Gerona Airport, take flight SK455 to Stockholm. Gate 45B, seat 3A. Baggage drop at ticket counter 344.
  4. From Stockholm, take flight SK22 to New York JFK. Gate 22, seat 7B. Baggage will we automatically transferred from your last leg.
  5. You have arrived at your final destination.

The list should be defined in a format that's compatible with the input format. The API is to be an internal PHP API so it will only communicate with other parts of a PHP application, not server to server, nor server to client. Use PHP-doc to document the input and output your API accepts/returns.

Assumptions

  • Since the result is only one list, I assume that input receives boarding cards for just one particular trip, and we just need to sort them.
  • To cover all variations of output without introducing artificial intelligence, I will assume that cards have Sit in seat 45B. or No seat assignment. written on them. Having a field seat would be considered otherwise.

Installation

Install with Composer

composer install

Tests

Tests can be executed by running the following command from the root directory

composer run tests

Usage

Input is an array in the following format

$cards = [
  ['from' => 'Madrid', 'to' => 'Barcelona', 'type' => 'train', 'number' => '78A', 'info' => 'Sit in the seat 45B.'],
  ['from' => 'Barcelona', 'to' => 'Gerona Airport', 'type' => 'airport bus', 'number' => '', 'info' => 'No seat assignment.'],
  ['from' => 'Gerona Airport', 'to' => 'Stockholm', 'type' => 'flight', 'number' => 'SK455', 'seat' => '3A', 'info' => 'Gate 45B, seat 3A. Baggage drop at ticket counter 344.'],
  ['from' => 'Stockholm', 'to' => 'New York JFK', 'type' => 'flight', 'number' => 'SK455', 'seat' => '7B', 'info' => 'Gate 22. Baggage will we automatically transferred from your last leg.'],
];
$result = TripSorter::sort($cards);

Result is an array of strings:

  1. Take train 78A from Madrid to Barcelona. Sit in seat 45B.
  2. Take the airport bus from Barcelona to Gerona Airport. No seat assignment.
  3. From Gerona Airport, take flight SK455 to Stockholm. Gate 45B, seat 3A. Baggage drop at ticket counter 344.
  4. From Stockholm, take flight SK22 to New York JFK. Gate 22, seat 7B. Baggage will we automatically transferred from your last leg.
  5. You have arrived at your final destination.

Contributing

Please see CONTRIBUTING for details.

License

Please see the license file for more information.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固