Coder Social home page Coder Social logo

thealgorithms / nim Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 15.0 159 KB

Collection of various algorithms implemented in Nim for educational purposes.

License: MIT License

Nim 99.61% Dockerfile 0.39%
algorithms data-structures educational interview-questions math mathematics nim string

nim's Introduction

The Algorithms Official Website


This is a static Next.js site providing a searchable library of all the algorithms in The Algorithms. All the data about the algorithms gets scraped directly from the git repositories.

Translating the website

You can help us translate the TheAlgorithms website using Weblate here. There you can complete the translations for our current languages, or suggest something if you are unsure. Also feel free to add a new language. The current languages are:

Translation status by language

Getting Started

If you haven't installed it yet, install Node.js and yarn. Then, install all the dependencies:

yarn

After that, run the script that fetches all the algorithms from GitHub:

yarn fetch-algorithms

Finally, run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the website.

Alternatively, you can also use the Ready-to-Code Gitpod and easily check how your deployment looks. It will automatically run the commands mentioned above on run.

Contributing

If you want to add a new feature or fix a bug, create a new branch or fork and commit there. Before opening a PR, be sure to

  • Run yarn lint and fix potential errors
  • Run yarn build to check if everything still builds successfully

Open the pull request against main. Vercel will automatically create a preview deployment, and the pull request will be squash merged after being reviewed by a member.

License

The source code of website itself (this repository) is licensed under MIT, while all the licenses for the code and explanations on the website can be found in the respective repositories.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Powered by Vercel

nim's People

Contributors

anupkumarpanwar avatar archargelod avatar ayushsgithub avatar dlesnoff avatar panquesito7 avatar satinwukerorig avatar vil02 avatar zoomrmc 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nim's Issues

[BUG] Incorrect link to the `DIRECTORY.md` file

Description

The contributing guidelines link directly to the DIRECTORY.md file, to make it easier for other people to find the algorithm list.
However, the given link is incorrect and is not working, which should be immediately fixed.

Steps to contribute

  1. Fork the repository here.
  2. Create a new branch named fix_directory_link.
  3. Open the CONTRIBUTING.md file.
  4. Go to line 41, and replace directory.md with DIRECTORY.md.
  5. There's another instance of the same. Go to line 52 and replace directory.md with DIRECTORY.md.
  6. Commit and push your changes.
  7. Create a pull request to compare your changes.
  8. You're done now! πŸŽ‰ You just have to wait until the maintainers review your PR.

If you need any help with this, let us know about it. πŸ™‚

Additional information

This is a good first issue. Please leave it open to first-time contributors and beginners.

Change the About Section

I do not like very much the "All algorithms implemented in Nim" description. I prefer something along the lines of:
"Collection of various algorithms implemented in Nim for educational purposes." similar to the C++ repository description which is more explicit and less conceited.

We could also add a link to the documentation of the project, which will be the object of a future issue.

We might want to add more tags to the description. We can already add educational, interview-questions and more like mathematics, string, as we add more code examples.

[BUG] Wrong label link

Description

In the README.md file, there's a badge that links to the contributing guidelines.
However, that link is pointing to the master branch, which doesn't exist. It still redirects you, but I still think we should update that to use the correct branch name.

Steps to contribute

  1. Fork the repository here.
  2. Create a new branch named fix_badge_link.
  3. Open the README.md file.
  4. At the top of the file, you'll see a Markdown link with the text Contributions Welcome. Update the link to point to the main branch instead of the master branch.
  5. Commit and push your changes.
  6. Create a pull request to compare your changes.
  7. You're done now! πŸŽ‰ You have to wait until the maintainers review your PR.

If you need any help, let us know! πŸ™‚

Additional information

This is a good first issue. Please leave it open to first-time contributors and beginners.

CI failure: linear search algorithm, string array and recursive algorithm.

Currently, CI fails due to the linear search algorithm.
There is an issue with the recursive algorithm for string arrays.

proc recursiveLinearSearch*[T](arr: openArray[T], key: T, idx: Nat = arr.low.Nat): OptNat=
  # Recursion is another method for linear search.
  # Recursive calls replace the for loop.

  # `none(Natural)` is returned when the array is traversed completely
  # and no key is matched, or when `arr` is empty.
  if idx > arr.high:
    return none(Natural)
  if arr[idx] == key:
    return some(idx)
  echo idx, " ", arr[idx], " ", key
  recursiveLinearSearch(arr, key, idx + 1)

for the test:

var arr = ["0", "c", "a", "u", "5", "7"]
check recursiveLinearSearch(arr, "5") == some(Natural(4))

outputs:

0  5
1  5
2  5
3  5
4  5
5  5

Expected output:

0 0 5
1 c 5
2 a 5
3 u 5

We could maybe fix it by converting the example test array to a sequence:

var arr = @["0", "c", "a", "u", "5", "7"]

[BUG] Update `DIRECTORY.md` file (semi-)automatically

Description

There's a script to build the DIRECTORY.md file. However, there's no workflow or anything that creates it automatically.
The users won't be able to see a list of algorithms. There's also a broken link in the readme.

I propose to create a GitHub Actions workflow to build it automatically on every push (not pull_request as this could mess up the PR branch) if there are any changes.
With protected branches, there's no way to push directly, but a pull request can be created by GitHub Actions, and then reviewed by the maintainers.

What do you think about this? πŸ™‚

chore: move compiler defaults from `nim.cfg` to `config.nims`

At this moment, in some cases setting the default gc/mm setting for the compiler results in a compilation error.
The workaround for this is moving the setting to the nim.cfg file. Having an additional configuration file is not great, so as soon as the fix for the bug lands in stable the setting should be moved back to the config.nims and nim.cfg should be removed.

This is a PR that sould have fixed the issue: nim-lang/Nim#19455. Not sure why we're still hitting it.

Issue with the DIRECTORY.md script

@ZoomRmc proposed a script to automatically fetch the names of the different algorithms implementations.
This script does not detect the catalan_numbers.nim file in the dynamic programming directory.
I would accept any PR that partially fix these algorithm's detection issues.

CI: The `DIRECTORY.md` CI action does nothing

@Panquesito7 previously added a CI action to open a pull request each time a contribution is made, to update the directory.md file.
It appears to do nothing right now.

I guess that the newly created DIRECTORY.md file is not detected when added.

Looking for maintainers!

Description

The repository was recently created, so we need people that are proficient and experienced in the Nim programming language.
Anyone interested, feel free to comment here and contribute to our repository.

Thanks for your interest! πŸ™‚

linear_search failing tests: upstream bug with openArray to `array[string]`?

Currently the testcase "Search in a string array matching with a string matching value" is failing, returning None, due to openArray of arr resolving to array of empty strings, inside the recursive search it's ["", "", "", "", "", ""].

Changing the arr to const or to a variable seq (instead of array) fixes execution.

I'll try to investigate and post an upstream issue.

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.