PHPackages                             balsama/skyscrapers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. balsama/skyscrapers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

balsama/skyscrapers
===================

A little helper for solving NYTimes Skyscraper puzzles.

1.0.x-dev(9y ago)07MITPHP

Since Sep 28Pushed 9y ago1 watchersCompare

[ Source](https://github.com/balsama/skyscrapers)[ Packagist](https://packagist.org/packages/balsama/skyscrapers)[ RSS](/packages/balsama-skyscrapers/feed)WikiDiscussions 1.0.x Synced 4w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c2df11a0f6fce94031e3f663a801bd882e74379a5a6af396c6dea244ba300a55/68747470733a2f2f7472617669732d63692e6f72672f62616c73616d612f736b7973637261706572732e7376673f6272616e63683d312e302e78)](https://travis-ci.org/acquia/lightning)

Skyscrapers
===========

[](#skyscrapers)

A php class to help you solve the Skyscrapers puzzles from NY Times Magazine.

Usage
-----

[](#usage)

### Basic

[](#basic)

```
$view = new View();

// There are four buildings per view, for a total of 24 purmutations.
$view->setBlocks(4);

// Only show permutations in which exactly three Skyscrapers are visible.
$view->setDesiredVisible(3);

// Only show permutuations where the fourth Skyscraper is of height 4
$view->addConstraint(4, "==", 4);

// Also, only show permutations where the second is greater than 1
$view->addConstraint(2, ">", 1);

// And the first is not 2
$view->addConstraint(1, "!=", 2);

// Get the solutions
$possibleSolutions = $view->getSolutions();

```

### Description

[](#description)

A View is what one would see if standing at the end of a row or column on the puzzle-board. Instatiate a View:

```
$view = new View();

```

The number of total Skyscrapers in a view is set by the blocks() method. By default, there are three blocks in a view. The puzzles in NYTimes have been either 4 or 5 blocks long. To change the number of blocks:

```
$view->setBlocks($number_of_blocks);

```

The NYTimes puzzle provides the number of Skyscrapers visible for certain views. To set that number for the view, you can use the setDesiredVisible() method. By default it is 3. To change the desired number visible:

```
$view->setDesiredVisible($number_visible);

```

As you solve the puzzle, you'll come across situations where you know that certain blocks will hold a skyscraper of a certain height (or below or above a certain height). Constraints can be chained - that is, you can define more than one constraint without affecting previously defined constraints. To make the class aware of these, you can add a constraint. The addConstraint() method takes three arguments:

- Position: The position of the block in the view (1 is closest).
- Operator: The relationship of the building to the value (available operators:
    - greater than ("&gt;")
    - less than ("&lt;")
    - equals ("==")
- Value: The value to use for comparison.

The following constrains the results to those which have a Skyscraper in the third block with a height of three:

```
$view->setConstraint(3, "==", 3);

```

Once you have the blocks, desired visible, and any constraints set, you can get the results with:

```
$view->getSolutions();

```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

3562d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6073b94ae2519d22681a73ae734eff3d679543ea15bcae3a2d4dbcb271ca9ac?d=identicon)[balsama](/maintainers/balsama)

---

Top Contributors

[![balsama](https://avatars.githubusercontent.com/u/1536654?v=4)](https://github.com/balsama "balsama (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/balsama-skyscrapers/health.svg)

```
[![Health](https://phpackages.com/badges/balsama-skyscrapers/health.svg)](https://phpackages.com/packages/balsama-skyscrapers)
```

###  Alternatives

[nmarfurt/measurements

A PHP library for representing and converting dimensional units of measure.

17179.2k1](/packages/nmarfurt-measurements)[strawberryfield/strawberryfield

A strawberry field for Drupal 10/11

113.3k5](/packages/strawberryfield-strawberryfield)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
