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

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

S-99: Ninety-Nine Scala Problems
https://github.com/asarkar/99-scala

99-problems 99-scala-problems 99problems functional-programming ninety-nine-problems ninety-nine-scala-problems scala

Last synced: 3 months ago
JSON representation

S-99: Ninety-Nine Scala Problems

Awesome Lists containing this project

README

        

[S-99: Ninety-Nine Scala Problems](https://aperiodic.net/phil/scala/s-99/)

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

## Working with lists

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

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

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

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

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

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

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

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

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

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

[P11](list/src/P11.scala) (*) Modified run-length encoding.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

## Arithmetic

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

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

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

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

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

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

P37 (**) Calculate Euler’s totient function ϕ(m) (improved).

P38 (*) Compare the two methods of calculating Euler’s totient function.

[P39](arithmetic/src/P39.scala) (*) A list of prime numbers.

[P40](arithmetic/src/P40.scala) (**) Goldbach's conjecture.

[P41](arithmetic/src/P41.scala) (**) A list of Goldbach compositions.

## Logic and Codes

[P46](logic/src/P46.scala) (**) Truth tables for logical expressions.

[P47](logic/src/P47.scala) (*) Truth tables for logical expressions (2).

P48 (**) Truth tables for logical expressions (3).

[P49](logic/src/P49.scala) (**) Gray code.

[P50](logic/src/P50.scala) (***) Huffman code.

## Binary Trees

P54 Omitted; our tree representation will only allow well-formed trees.

[P55](bintree/src/P55.scala) (**) Construct completely balanced binary trees.

[P56](bintree/src/P56.scala) (**) Symmetric binary trees.

[P57](bintree/src/P57.scala) (**) Binary search trees (dictionaries).

[P58](bintree/src/P58.scala) (**) Generate-and-test paradigm.

[P59](bintree/src/P59.scala) (**) Construct height-balanced binary trees.

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

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

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

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

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

[P63](bintree/src/P63.scala) (**) Construct a complete binary tree.

[P64](bintree/src/P64.scala) (**) Layout a binary tree (1).

[P65](bintree/src/P65.scala) (**) Layout a binary tree (2).

P66 (***) Layout a binary tree (3).

[P67](bintree/src/P67.scala) (**) A string representation of binary trees.

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

[P69](bintree/src/P69.scala) (**) Dotstring representation of binary trees.

## Multiway Trees

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

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

[P70](mtree/src/P70.scala) (**) Tree construction from a node string.

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

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

[P73](mtree/src/P73.scala) (**) Lisp-like tree representation.

## Graphs

P80 (***) Conversions.

[P81](graph/src/P81.scala) (**) Path from one node to another one.

[P82](graph/src/P82.scala) (*) Cycle from a given node.

[P83](graph/src/P83.scala) (**) Construct all spanning trees.

[P84](graph/src/P84.scala) (**) Construct the minimal spanning tree.

[P85](graph/src/P85.scala) (**) Graph isomorphism.

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

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

[P88](graph/src/P88.scala) (**) Connected components.

[P89](graph/src/P89.scala) (**) Bipartite graphs.

## Miscellaneous Problems

P90 (**) Eight queens problem

P91 (**) Knight’s tour.

P92 (***) Von Koch’s conjecture.

P93 (***) An arithmetic puzzle.

P94 (***) Generate K-regular simple graphs with N nodes.

P95 (**) English number words.

P96 (**) Syntax checker.

P97 (**) Sudoku.

P98 (***) Nonograms.

P99 (***) Crossword puzzle.

## Running tests

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

To run all tests from a package:
```
./.github/run.sh
```

## License

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