Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gfarrell/random-puzzles-hs
Random puzzles in Haskell
https://github.com/gfarrell/random-puzzles-hs
Last synced: 13 days ago
JSON representation
Random puzzles in Haskell
- Host: GitHub
- URL: https://github.com/gfarrell/random-puzzles-hs
- Owner: gfarrell
- License: bsd-3-clause
- Created: 2020-04-21T20:38:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T16:02:47.000Z (almost 5 years ago)
- Last Synced: 2024-11-16T14:11:37.537Z (2 months ago)
- Language: Haskell
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Random Puzzles
A collection of random puzzles written in Haskell. Some of these will be
ideas for interview challenges.There is no executable version of this, it is designed to be run as
tests only. To run the puzzles, use `stack test`.If you can think of more fun puzzles let me know and I'll add them!
## 01: Rectangles
*Aim:* find the top left and bottom right corners of a series of
rectangles in an image. The image is represented as a matrix of `Pixel`s
(`[[Pixel]]`), which can be either `On` or `Off`.To make this a bit easier, the *only* shapes will be rectangles, and
they won't overlap, so you don't have to worry about other polygons.### Example
```haskell
let image = [ [Off, Off, Off, Off, Off, Off, Off]
, [Off, Off, Off, Off, Off, Off, Off]
, [Off, Off, Off, On, On, On, Off]
, [Off, Off, Off, On, On, On, Off]
, [Off, Off, Off, Off, Off, Off, Off] ]
```We would expect the result of this to be a pair of coordinates:
- Top left: (3, 2)
- Bottom right: (5, 3)### Files:
- [source](src/Rectangles.hs)
- [proof](test/RectanglesSpec.hs)