Just some algorithms implemented in JS. Mastering a language requires time and effort. If you don't practice it - you become falsely confident in your skills.
In this repository I am revisiting classic CS problems and algorithms just for fun :)
100% optimization is not the goal of the code in this repo - it is a playground for me when I get bored. Don't take the code here too seriously.
Conway's game of life implmented in JS.
In short the rules are:
- alive and 2 siblings or less => death of loneliness
- alive and 3 siblings or more => death of over population
- alive and exactly 3 siblings => new born
- everything else => retain current state
Few implementations could be found here:
Bruteforce implementation of Shore's algorithm. I obvously don't understand quantum computers ... nor I have one.
It was amusing to implement this in bruteforce approach. The math behind it is very elegant.
Classical sorting methods
- Bubble sort
- imperative, classic implementation
- slightly optimized version
- recursive version
- Quick sort
Implemented with the new private field syntax available from Nodejs 12.x.
Using arrays internally. Quite simple and easy to do with JS.
Implemented with the new private field syntax available from Nodejs 12.x.
Using arrays internally. Quite simple and easy to do with JS.
Has the ability to keep the elements sorted based on default or provided predicate.
Moved away from the new private field syntax of JS because of issues with the editors: formatting and code completion (at time of writing).
...in progress...
Nothing special here, just some code reuse:
- Array.prototype.swap
- Factorial
- Greatest Common Divisor
I am taking suggestions, feel free to open an issue.
Feel free to fork, play around, send PRs with improvements.