daniel-ac-martin/word-ladder
Composer 安装命令:
composer create-project daniel-ac-martin/word-ladder
包简介
A command-line program and library for solving word ladder puzzles.
README 文档
README
word-ladder is a command-line program and PHP library for solving word ladder puzzles.
Word ladder is a word game invented by Lewis Caroll. The player is given two words and must find a 'ladder' from one to another on which only one letter is changed between words on adjacent rungs on the ladder. e.g.
Ladder from GIT to HUB:
GIT -> GUT -> HUT -> HUB
Word ladder problems can have more than one correct answer. Because of this, word-ladder will declare the first solution it finds, then it will analyse all solutions (the same length as the first one) and declare the best one. (Where 'best' is defined as being the solution whose least common word, is more common than all other solutions' least common words. i.e. Ladders are judged to only be as strong as their weakest link / rung.)
There are some variations on the word ladder game in which the problem must be solved in a specified number of steps. In some cases it is possible to solve the problem in fewer steps. Unlike most other solvers, word-ladder accepts an option to attempt to solve the problem in a set number of steps. (When this option is not provided it simply attempts to solve the problem in as few steps as possible.)
Program - Getting started
Download the Phar. Place it wherever you want on your system. Execute it from the command line through PHP. (Or you can execute it directly if you have a valid, modern PHP binary at /usr/bin/php.)
Program - Usage
Usage: word-ladder.phar START FINISH [STEPS]
The command-line program accepts three parameters, START, FINISH, and STEPS, where only the third, STEPS is optional.
START: The first word in the ladder.
FINISH: The last word in the ladder.
STEPS: The number of steps / rungs on the ladder.
Example:
$ php word-ladder.phar git hub
Attempting: git -> hub
First solution set (3 steps) found after 2 lookups:
0: git [a person who is deemed to be despicable or contemptible; "only a ro...]
1: gib [a castrated tomcat]
2: gub []
3: hub [the central part of a car wheel (or fan or propeller etc) through w...]
[Prevalence score: 112.26878713664]
Finding and analysing all solutions... Done.
10 solution(s) found.
0: git [a person who is deemed to be despicable or contemptible; "only a ro...]
1: gut [a strong cord made from the intestines of sheep and used in surgery]
2: hut [small crude shelter used as a dwelling]
3: hub [the central part of a car wheel (or fan or propeller etc) through w...]
[Prevalence score: 16551.249116398]
Library - Getting started
- Get Composer
- Require word-ladder with
php composer.phar require daniel-ac-martin/word-ladder - Install dependencies with
php composer.phar install
Library - Usage
The library is invoked by including Composer's autoloader and then calling the method, WordLadder\WordLadder::solve. Please see the following example.
<?php require_once 'vendor/autoload.php'; // Composer's autoloader $start = 'git'; $finish = 'hub'; $steps = 4; try { $solution = WordLadder\WordLadder::solve($start, $finish, $steps); foreach($solution->solution() as $e) { echo $e->word() . ': ' . substr($e->definition(), 0, 78 - strlen($start)) . "\n"; } } catch(Exception $e) { die('Error: ' . $e->getMessage() . "\n"); } ?>
License
Copyright (C) 2015 Daniel A.C. Martin
Distributed under the GNU GPL v3.
daniel-ac-martin/word-ladder 适用场景与选型建议
daniel-ac-martin/word-ladder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「word」 「solver」 「ladder」 「word ladder」 「word ladder solver」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 daniel-ac-martin/word-ladder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 daniel-ac-martin/word-ladder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 daniel-ac-martin/word-ladder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP sudoku logic library - Generate and solve sudoku puzzles
ImagetyperzAPI PHP is a super easy to use bypass captcha API wrapper for imagetyperz.com captcha service
PHP powered interface for querying the most popular Search Engines
Endroid Sudoku solver
PHP package for easy integration with solvecaptcha API.
Unofficial port of the Carbone API SDK to Saloon v3
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GNU
- 更新时间: 2015-05-18