Giter VIP home page Giter VIP logo

typescript's Introduction

The Algorithms - TypeScript

TypeScript Repository of TheAlgorithms, which implements various algorithms and data structures in TypeScript.


These implementations are for demonstrative/educational purposes only. Dedicated implementations of these algorithms and data structures are much better for performance and security reasons. We also do not provide any guarantee for API stability.


Before contributing to this repository, make sure to read our Contribution Guidelines. You can look at other TheAlgorithms Repositories or the issues with a "help wanted" label for inspiration regarding what to implement. Our maintainers will guide you through how to make your contribution properly if you make any mistakes. The names of the maintainers of this repository are listed in the CODEOWNERS file.


typescript's People

Contributors

anshvert avatar appgurueu avatar ayoubc avatar britneywwc avatar bszmolke avatar caojoshua avatar co-bby avatar codeazq avatar dev-madhurendra avatar gefgu avatar icarusthefly avatar jonatan5524 avatar mendlero avatar mohdfaisalbidda avatar nikhilkala avatar orangegrove1955 avatar panquesito7 avatar psytew avatar rajat379 avatar raklaptudirm avatar skyfrk avatar spidermath avatar suryac72 avatar t1lt avatar testourii avatar truongnhannguyen avatar vcnovaes avatar vil02 avatar zfl4wless avatar zflxw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript's Issues

[FEATURE]: Port build_directory_md from Python to TypeScript

Motivation

The Python code run in our GitHub Action directory_formatter.yml should be replaced by TypeScript code so that contributors to this repo are better able to maintain it.

This process should be done in three separate pull requests.

  • Run both the Python and TypeScript versions in the same GitHub Action and fail if the two files are not identical.
  • Remove the running of the Python code in the GitHub Action and remove the Python file.
  • [Optional] Modify the TypeScript version to add any new information and/or look and feel.

Examples

No response

Possible workarounds

No response

[FEATURE]: Selection Sort

Motivation

I am writing to suggest the addition of a new feature to the algorithms repository - the selection sort algorithm.

Selection sort is a popular sorting algorithm that is simple to understand and implement. It works by repeatedly finding the minimum element from the unsorted portion of the list and swapping it with the first unsorted element. The algorithm continues this process until the entire list is sorted.

Adding this feature to the algorithms repository will provide a valuable resource for those looking to learn or implement selection sort. Furthermore, including selection sort in the repository will increase the diversity of sorting algorithms available, making it an even more comprehensive resource for developers and students.

I would be happy to contribute to the implementation of this new feature and help in any way possible. Thank you for your time and consideration.

Examples

No response

Possible workarounds

No response

[FEATURE]: Add Gitpod Setup

Motivation

Having gitpod ready repo makes contribution easy and also it does not requires to setup environment locally

I have worked on similar issue in PHP repo of TheAlgorithms TheAlgorithms/PHP#130

I would like to work on this feature

Examples

Other repos like Python and GoLang in TheAlgorithms use gitpod.

Screenshots:

image
image

Possible workarounds

No response

Add some maths' functions

List of some important functions

  • Absolute number
  • Aliquot Sum of a number
  • Area of various shapes
  • Arithmetic-Geometric Mean
  • Armstrong number
  • Average Mean
  • Average Median
  • Binary to Decimal conversion
  • Binary Exponentiation Iterative
  • Decimal to Binary conversion
  • Binomial Coefficient
  • Bisection Method
  • Function to check Co-prime
  • Decimal Expansion
  • Decimal Isolation
  • Degree to Radian Conversion
  • Euler Method
  • Eulers Totient
  • Factorial
  • Factors
  • Fibonacci
  • Find HCM
  • Find LCM
  • Finding a minimum in a array of numbers
  • Function to check a number is Divisible by another number or not
  • Function to check a number is Even
  • Function to check a number is Odd
  • Function to check a number is Pronic
  • Function to check a number is Square free
  • Juggler Sequence
  • Leap year
  • Matrix Multiplication
  • Number of digits in a number
  • Pascal Triangle
  • Perfect Cube
  • Perfect Square
  • Perfect Numbers
  • Prime check
  • Radian to Degree Conversion
  • Finding Square root
  • Sum of Digits of a given number

Clarify project

Could someone please state where to add the algorithms to? Like which directory and what should be the overall directory structure and stuff. It is not really clarified in the contribution guidelines, and the only pull request I can see is #21 which adds Fibonacci.ts to the project right along with the package.json and stuff, which does not seem quite right.

[BUG]: some test cases are failing.....

Description

`Summary of all failing tests
FAIL backtracking/test/generateparentheses.test.ts
● Test suite failed to run

backtracking/test/generateparentheses.test.ts:1:37 - error TS2307: Cannot find module '../generateParentheses' or its corresponding type declarations.

1 import { generateParentheses } from "../generateParentheses";
                                      ~~~~~~~~~~~~~~~~~~~~~~~~

FAIL backtracking/test/all_combinations_of_size_k.test.ts
● Test suite failed to run

backtracking/test/all_combinations_of_size_k.test.ts:1:38 - error TS2307: Cannot find module '../all-combinations-of-size-k' or its corresponding type declarations.

1 import { generateCombinations } from "../all-combinations-of-size-k";
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FAIL maths/test/ugly_numbers.test.ts
● Ugly Numbers

expect(received).toEqual(expected) // deep equality

- Expected  - 11
+ Received  + 44

  Array [
-   1,
-   2,
-   3,
-   4,
-   5,
-   6,
-   8,
-   9,
-   10,
-   12,
-   15,
+   Object {
+     "done": false,
+     "value": 1,
+   },
+   Object {
+     "done": false,
+     "value": 2,
+   },
+   Object {
+     "done": false,
+     "value": 3,
+   },
+   Object {
+     "done": false,
+     "value": 4,
+   },
+   Object {
+     "done": false,
+     "value": 5,
+   },
+   Object {
+     "done": false,
+     "value": 6,
+   },
+   Object {
+     "done": false,
+     "value": 8,
+   },
+   Object {
+     "done": false,
+     "value": 9,
+   },
+   Object {
+     "done": false,
+     "value": 10,
+   },
+   Object {
+     "done": false,
+     "value": 12,
+   },
+   Object {
+     "done": false,
+     "value": 15,
+   },
  ]

  3 | test('Ugly Numbers', () => {
  4 |   const uglyNumbers = UglyNumbers();
> 5 |   expect(Array(11).fill(undefined).map(() => uglyNumbers.next())).toEqual([1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15]);
    |                                                                   ^
  6 | })
  7 |

  at Object.<anonymous> (maths/test/ugly_numbers.test.ts:5:67)

Test Suites: 3 failed, 77 passed, 80 total
Tests: 1 failed, 691 passed, 692 total
Snapshots: 0 total
Time: 23.258 s
Ran all test suites.
Error: Process completed with exit code 1.`

Expected Behavior

All test cases should pass and all the build for each and every PRs should run successfully !

Actual Behavior

But in this case test cases are faling and build is failing due this.
need to fix it.

Steps to reproduce (if applicable)

No response

Specifications

No response

Add Quick Select Algorithm

About Quick Select Algorithm

In computer science, quickselect is a selection algorithm to find the kth smallest element in an unordered list. It is related to the quicksort sorting algorithm. Like quicksort, it was developed by Tony Hoare, and thus is also known as Hoare's selection algorithm.[1] Like quicksort, it is efficient in practice and has good average-case performance, but has poor worst-case performance. Quickselect and its variants are the selection algorithms most often used in efficient real-world implementations.
Source : Wikipedia

[FEATURE]: More explicit handling in QuickSort partition algorithm

Motivation

I've been reviewing the Quicksort partition implementation in this repository. Specifically, I'm focusing on the following segment of the code:

while (i < j) {
 while (array[++i] < pivot);
 while (array[--j] > pivot);

 if (i < j) {
    [array[i], array[j]] = [array[j], array[i]];
 }
}

In the scenario where the rightmost element is chosen as the pivot, and all other elements are greater than the pivot (e.g., [6, 5, 4, 3, 2, 1]), the code handles the out-of-bounds behavior as follows: array[-1] is undefined. When undefined is compared against a number, it is coerced into NaN, resulting in false for the comparison.

While this approach works and is quite clever, I believe it could be beneficial to make the handling of these cases more explicit. This would enhance the readability and maintainability of the code, making it easier for newcomers to understand and for the code to be adapted or modified in the future.

I suggest taking a more conventional approach, such as:

while (array[--j] > pivot) {
 if (j === left) break;
}

This change would make the algorithm's logic more straightforward and easier to follow, without relying on special JavaScript behavior.

Thank you for considering this request. I'm open to feedback and suggestions on how to further improve the code.

Examples

No response

Possible workarounds

No response

[BUG]: QuickSelect test case is failing

Motivation

Quick Select test case is failing due to this overall PR builds is failing.
Need to fix that !

Screenshot from 2023-10-02 21-21-28

Examples

No response

Possible workarounds

No response

[FEATURE] Setup the Gitpod ready-to-code system

Description

Adding the Gitpod ready-to-code system will make the process of compiling much easier in just a single click.

This is very useful when you want Gitpod to run npm commands quickly for you and run the whole project quickly. It's much better than cloning the repository, reading the readme, installing the necessary tools, etc..

Additional information

Working on this.

[FEATURE]: Adding a new category for Sequences

Motivation

TypeScript (and JavaScript) has the capability of using Generator functions, which can help us in generating sequences.
There already exists a category for Sequences, which was made for C# to make use of the existence of generator methods in C# (from what was told to me by one of the maintainers of the C# repository).
Since TypeScript also has generators, we could also add implementations for those sequences on the Website under this category. We could also add many more entries under this category, for there are many sequences whose implementations are non-trivial but not added there yet.

Examples

We could add this to increase coverage of the entries under the cateogry of Sequences, which would also look less confusing, for when someone may look at the website, it can be confusing so as to why there's only C# implementations under those sequences.

Possible workarounds

No response

[OTHER] Update all Discord links

Description

We're using a new link for The Algorithms' Discord invitation.
All Discord invitation links should point to https://the-algorithms.com/discord/.

Feel free to work on it. 🙂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.