Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ouerghi01/elixir-99-functional-mastery

A personal journey to master functional programming by solving the classic L-99 problems. No tutorials, no videos—just pure problem-solving and learning.
https://github.com/ouerghi01/elixir-99-functional-mastery

datastructures elixir elixir-lang functional-programming lsp problem-solving

Last synced: 8 days ago
JSON representation

A personal journey to master functional programming by solving the classic L-99 problems. No tutorials, no videos—just pure problem-solving and learning.

Awesome Lists containing this project

README

        

# L-99: Ninety-Nine Lisp Problems (Solved in Elixir)

Welcome to the **L-99 Elixir Solutions** repository! This project is a collection of solutions to the famous [Ninety-Nine Lisp Problems](https://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/), rewritten in **Elixir**. These problems are a great way to learn and practice functional programming concepts.

## About the L-99 Problems

The L-99 problems are a set of programming challenges designed to teach and test functional programming skills. Originally written for Lisp, these problems have been adapted to many other languages, including Elixir. They cover a variety of topics, such as:

- List processing
- Arithmetic
- Logic and codes
- Trees
- Graphs
- Miscellaneous problems

## Why Elixir?

Elixir is a functional, concurrent programming language built on the Erlang VM. Its expressive syntax and powerful abstractions make it an excellent choice for solving functional programming problems. By working through these problems in Elixir, you'll gain:

- A deeper understanding of functional programming principles.
- Hands-on experience with Elixir's powerful pattern matching and recursion.
- Insight into idiomatic Elixir practices.

## Repository Structure

- **`lib/PS.ex`**: Contains the Elixir solutions for the problems, organized by their problem numbers.
- **`test/`**: Includes tests for each solution to ensure correctness.
- **`README.md`**: This file, providing an overview of the project.

## Problems Solved
So far, the following problems have been solved:
1. [Find the last element of a list](lib/List_processing.ex)
2. [Find the last but one element of a list](lib/List_processing.ex)
3. [Find the Kth element of a list](lib/List_processing.ex)
4. [Find the number of elements in a list](lib/List_processing.ex)
5. [Reverse a list](lib/List_processing.ex)
6. [Find out whether a list is a palindrome](lib/List_processing.ex)
7. [Flatten a nested list structure](lib/List_processing.ex)
8. [Eliminate consecutive duplicates of list elements](lib/List_processing.ex)
9. [Pack consecutive duplicates into sublists](lib/List_processing.ex)
10. [Run-length encoding of a list](lib/List_processing.ex)
11. [Modified run-length encoding](lib/List_processing.ex)
12. [Decode a run-length encoded list](lib/List_processing.ex)
13. [Direct run-length encoding](lib/List_processing.ex)
14. [Duplicate the elements of a list](lib/List_processing.ex)
15. [Replicate the elements of a list a given number of times](lib/List_processing.ex)
16. [Drop every Nth element from a list](lib/List_processing.ex)
17. [Split a list into two parts](lib/List_processing.ex)
18. [Extract a slice from a list](lib/List_processing.ex)
19. [Rotate a list N places to the left](lib/List_processing.ex)
20. [Remove the Kth element from a list](lib/List_processing.ex)
21. [Insert an element at a given position into a list](lib/List_processing.ex)
22. [Create a list containing all integers within a given range](lib/List_processing.ex)
23. [Extract a given number of randomly selected elements from a list](lib/List_processing.ex)
24. [Draw N different random numbers from the set 1..M](lib/List_processing.ex)
25. [Generate a random permutation of the elements of a list](lib/List_processing.ex)
26. [Generate the combinations of K distinct objects chosen from the N elements of a list](lib/List_processing.ex)
27. [Group the elements of a set into disjoint subsets](lib/List_processing.ex)
28. [Sort a list of lists according to length of sublists](lib/List_processing.ex)
29. [Determine whether a given integer number is prime](lib/Arithmetic_processing.ex)
30. [Determine the greatest common divisor of two positive integer numbers](lib/Arithmetic_processing.ex)
31. [Determine whether two positive integer numbers are coprime](lib/Arithmetic_processing.ex)
32. [Calculate Euler's totient function phi(m)](lib/Arithmetic_processing.ex)
33. [Determine the prime factors of a given positive integer](lib/Arithmetic_processing.ex)
34. [Determine the prime factors of a given positive integer (2)](lib/Arithmetic_processing.ex)
35. [Calculate Euler's totient function phi(m) (improved)](lib/Arithmetic_processing.ex)
36. [Compare the two methods of calculating Euler's totient function](lib/Arithmetic_processing.ex)
37. [A list of prime numbers](lib/Arithmetic_processing.ex)
38. [Goldbach's conjecture](lib/Arithmetic_processing.ex)
39. [A list of Goldbach compositions](lib/Arithmetic_processing.ex)
40. [Truth tables for logical expressions](lib/logic_codes.ex)
41. [Truth tables for logical expressions (2)](lib/logic_codes.ex)
42. [Truth tables for logical expressions (3)](lib/logic_codes.ex)
43. [Gray code](lib/logic_codes.ex)
44. [Huffman code](lib/logic_codes.ex)
45. [Check whether a given term represents a binary tree](lib/binarytrees.ex)
46. [Construct completely balanced binary trees](lib/binarytrees.ex)
47. [Symmetric binary trees](lib/binarytrees.ex)
48. [Binary search trees (dictionaries)](lib/binarytrees.ex)
49. [Generate-and-test paradigm](lib/binarytrees.ex)
50. [Construct height-balanced binary trees](lib/binarytrees.ex)

## Getting Started

### Prerequisites

To run the solutions, you'll need:

- [Elixir](https://elixir-lang.org/install.html) installed on your machine.

### Running the Solutions

1. Clone this repository:
```bash
git clone https://github.com/ouerghi01/Elixir-99-Functional-Mastery.git
cd Elixir-99-Functional-Mastery
```
2. Navigate to the `lib/` directory and run any problem file:
```bash
elixir PS.ex
```
3. To run tests:
```bash
mix test
```

## Contributing

Contributions are welcome! If you'd like to add solutions, improve existing ones, or enhance the repository, feel free to:

1. Fork the repository.
2. Create a new branch.
3. Submit a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Inspired by the original [Ninety-Nine Lisp Problems](https://www.ic.unicamp.br/~meidanis/courses/mc336/2009s2/prolog/problemas/).
- Special thanks to the Elixir community for their amazing resources and support.

---

Happy coding! 🚀