An open API service indexing awesome lists of open source software.

https://github.com/asarkar/99-haskell

H-99: Ninety-Nine Haskell Problems
https://github.com/asarkar/99-haskell

99-haskell-problems 99-problems 99problems functional-programming haskell ninety-nine-haskell-problems ninety-nine-problems

Last synced: 18 days ago
JSON representation

H-99: Ninety-Nine Haskell Problems

Awesome Lists containing this project

README

        

[H-99: Ninety-Nine Haskell Problems](https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems)

[![](https://github.com/asarkar/99-haskell/workflows/CI/badge.svg)](https://github.com/asarkar/99-haskell/actions)

A number of problems were added to fill out 99 problems.
- These are the problems 29, 30, 42, 43, 44, 45, 51, 52, 53, 74, 75, 76, 77, 78, and 79.

## Lists

[P01](src/List/P01.hs) (*) Find the last element of a list.

[P02](src/List/P02.hs) (*) Find the last but one element of a list.

[P03](src/List/P03.hs) (*) Find the Kth element of a list.

[P04](src/List/P04.hs) (*) Find the number of elements of a list.

[P05](src/List/P05.hs) (*) Reverse a list.

[P06](src/List/P06.hs) (*) Find out whether a list is a palindrome.

[P07](src/List/P07.hs) (**) Flatten a nested list structure.

[P08](src/List/P08.hs) (**) Eliminate consecutive duplicates of list elements.

[P09](src/List/P09.hs) (**) Pack consecutive duplicates of list elements into sublists.

[P10](src/List/P10.hs) (*) Run-length encoding of a list.

[P11](src/List/P11.hs) (*) Modified run-length encoding.

[P12](src/List/P12.hs) (**) Decode a run-length encoded list.

[P13](src/List/P13.hs) (**) Run-length encoding of a list (direct solution).

[P14](src/List/P14.hs) (*) Duplicate the elements of a list.

[P15](src/List/P15.hs) (**) Duplicate the elements of a list a given number of times.

[P16](src/List/P16.hs) (**) Drop every Nth element from a list.

[P17](src/List/P17.hs) (*) Split a list into two parts.

[P18](src/List/P18.hs) (**) Extract a slice from a list.

[P19](src/List/P19.hs) (**) Rotate a list N places to the left.

[P20](src/List/P20.hs) (*) Remove the Kth element from a list.

[P21](src/List/P21.hs) (*) Insert an element at a given position into a list.

[P22](src/List/P22.hs) (*) Create a list containing all integers within a given range.

[P23](src/List/P23.hs) (**) Extract a given number of randomly selected elements from a list.

[P24](src/List/P24.hs) (*) Lotto: Draw N different random numbers from the set 1..M.

[P25](src/List/P25.hs) (*) Generate a random permutation of the elements of a list.

[P26](src/List/P26.hs) (**) Generate the combinations of K distinct objects chosen from the N elements of a list.

[P27](src/List/P27.hs) (**) Group the elements of a set into disjoint subsets.

[P28](src/List/P28.hs) (**) Sorting a list of lists according to length of sublists.

[P29](src/List/P28.hs) (*) Write a function to compute the nth Fibonacci number.

[P30](src/List/P30.hs) (**) Write a function to compute the nth Fibonacci number.

## Arithmetic

[P31](src/Arithmetic/P31.hs) (**) Determine whether a given integer number is prime.

[P32](src/Arithmetic/P32.hs) (**) Determine the greatest common divisor of two positive integer numbers.

[P33](src/Arithmetic/P33.hs) (*) Determine whether two positive integer numbers are coprime.

[P34](src/Arithmetic/P34.hs) (**) Calculate Euler’s totient function ϕ(m).

[P35](src/Arithmetic/P35.hs) (**) Determine the prime factors of a given positive integer.

[P36](src/Arithmetic/P36.hs) (**) Determine the prime factors of a given positive integer (2).

[P37](src/Arithmetic/P37.hs) (**) Calculate Euler’s totient function ϕ(m) (improved).

[P38](src/Arithmetic/P38.hs) (*) Compare the two methods of calculating Euler’s totient function.

[P39](src/Arithmetic/P39.hs) (*) A list of prime numbers.

[P40](src/Arithmetic/P40.hs) (**) Goldbach's conjecture.

[P41](src/Arithmetic/P41.hs) (**) A list of Goldbach compositions.

[P42](src/Arithmetic/P42.hs) (**) Modular multiplicative inverse.

[P43](src/Arithmetic/P43.hs) (*) Gaussian integer divisibility.

[P44](src/Arithmetic/P44.hs) (**) Gaussian primes.

[P45](src/Arithmetic/P45.hs) (*) Gaussian primes using the two-square theorem.

## Logic and Codes

[P46](src/Logic/P46.hs) (**) Truth tables for logical expressions.

[P47](src/Logic/P47.hs) (*) Truth tables for logical expressions (2).

[P48](src/Logic/P48.hs) (**) Truth tables for logical expressions (3).

[P49](src/Logic/P49.hs) (**) Gray code.

[P50](src/Logic/P50.hs) (***) Huffman code.

[P51](src/Logic/P51.hs) (*) Error correction codes.

[P52](src/Logic/P52.hs) (***) Conjunctive normal form.

[P53](src/Logic/P53.hs) (***) Resolution rule.

## Binary Trees

P54A omitted; our tree representation will only allow well-formed trees.

[P55](src/BinaryTree/P55.hs) (**) Construct completely balanced binary trees.

[P56](src/BinaryTree/P56.hs) (**) Symmetric binary trees.

[P57](src/BinaryTree/P57.hs) (**) Binary search trees (dictionaries).

[P58](src/BinaryTree/P58.hs) (**) Generate-and-test paradigm.

[P59](src/BinaryTree/P59.hs) (**) Construct height-balanced binary trees.

[P60](src/BinaryTree/P60.hs) (**) Construct height-balanced binary trees with a given number of nodes.

[P61](src/BinaryTree/P61.hs) (*) Count the leaves of a binary tree.

[P61A](src/BinaryTree/P61A.hs) (*) Collect the leaves of a binary tree in a list.

[P62](src/BinaryTree/P62.hs) (*) Collect the internal nodes of a binary tree in a list.

[P62B](src/BinaryTree/P62B.hs) (*) Collect the nodes at a given level in a list.

[P63](src/BinaryTree/P63.hs) (**) Construct a complete binary tree.

[P64](src/BinaryTree/P64.hs) (**) Layout a binary tree (1).

[P65](src/BinaryTree/P65.hs) (**) Layout a binary tree (2).

[P66](src/BinaryTree/P66.hs) (***) Layout a binary tree (3).

[P67A](src/BinaryTree/P67A.hs) (**) A string representation of binary trees.

[P68](src/BinaryTree/P68.hs) (**) Preorder and inorder sequences of binary trees.

[P69](src/BinaryTree/P69.hs) (**) Dotstring representation of binary trees.

## Multiway Trees

P70B omitted; we can only create well-formed trees.

[P70C](src/MultiwayTree/P70C.hs) (*) Count the nodes of a multiway tree.

[P70](src/MultiwayTree/P70.hs) (**) Tree construction from a node string.

[P71](src/MultiwayTree/P71.hs) (*) Determine the internal path length of a tree.

[P72](src/MultiwayTree/P72.hs) (*) Construct the postorder sequence of the tree nodes.

[P73](src/MultiwayTree/P73.hs) (**) Lisp-like tree representation.

## Monads

[P74](src/Monad/P74.hs) (**) Monads without do notation.

[P75](src/Monad/P75.hs) (*) Maybe monad.

[P76](src/Monad/P76.hs) (*) Either monad.

[P77](src/Monad/P77.hs) (*) List monad.

[P78](src/Monad/P78.hs) (*) Collatz conjecture.

[P79](src/Monad/P79.hs) (**) Postfix notation.

## Graphs

[P80](src/Graph/P80.hs) (***) Conversions.

[P81](src/Graph/P81.hs) (**) Path from one node to another one.

[P82](src/Graph/P82.hs) (*) Cycle from a given node.

[P83](src/Graph/P83.hs) (**) Construct all spanning trees.

[P84](src/Graph/P84.hs) (**) Construct the minimal spanning tree.

[P85](src/Graph/P85.hs) (**) Graph isomorphism.

[P86](src/Graph/P86.hs) (**) Node degree and graph coloration.

[P87](src/Graph/P87.hs) (**) Depth-first order graph traversal.

[P88](src/Graph/P88.hs) (**) Connected components.

[P89](src/Graph/P89.hs) (**) Bipartite graphs.

## Miscellaneous Problems

[P90](src/Misc/P90.hs) (**) Eight queens problem.

[P91](src/Misc/P91.hs) (**) Knight’s tour.

[P92](src/Misc/P92.hs) (***) Von Koch’s conjecture.

[P93](src/Misc/P93.hs) (***) An arithmetic puzzle.

[P94](src/Misc/P94.hs) (***) Generate K-regular simple graphs with N nodes.

[P95](src/Misc/P95.hs) (**) English number words.

[P96](src/Misc/P96.hs) (**) Syntax checker.

[P97](src/Misc/P97.hs) (**) Sudoku.

[P98](src/Misc/P98.hs) (***) Nonograms.

[P99](src/Misc/P99.hs) (***) Crossword puzzle.

## Running tests

```
./.github/run.sh
```

To run all matching tests:
```
./.github/run.sh -m
```

To run exactly matching tests:
```
./.github/run.sh -m "//"
```

To run a _specific test_:
```
./.github/run.sh -m "/Ch11/evaluates expression/eval/"
```

To run a file containing a `main` method:
```
stack runhaskell app/Main.hs
```

To run an executable listed in `package.yaml`:
```
stack build
stack exec
```

## License

Released under [Apache License v2.0](LICENSE).