Giter VIP home page Giter VIP logo

ruby's Introduction

The Algorithms - Ruby

Gitter chat  contributions welcome    Discord chat 

All algorithms implemented in Ruby (for education)

These implementations are for learning purposes only. Therefore they may be less efficient than the implementations in the Ruby standard library.

Contribution Guidelines

Read our Contribution Guidelines before you contribute.

Community Channel

We're on Gitter! Please join us.

List of Algorithms

See our directory.

ruby's People

Contributors

andredurao avatar anew-bhav avatar anupkumarpanwar avatar aparibocci avatar apsaraguhan avatar atarax665 avatar christianbender avatar domix80 avatar doppon avatar dynamitechetan avatar femchengdu avatar jsca-kwok avatar maltejur avatar maxbarsukov avatar msaf9 avatar nimrodrak avatar onurer avatar pablohildo avatar panquesito7 avatar raivaibhav avatar rastrian avatar red0xff avatar ryanneilparker avatar sidaksohi avatar simonszu avatar stepfenshawn avatar vbrazo avatar vijay-siva avatar vil02 avatar vzvu3k6k 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  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

ruby's Issues

Add Gitpod Setup

Description

Setup Gitpod environment for running the repository in Gitpod.

Add Gitpod ready to code Badge to the README.md file.

Other repos like Python and Java in TheAlgorithms use gitpod.

Screenshots

image
image

I have worked on silimar issue TheAlgorithms/PHP#130

I would like to work on this issue

Add more ways to calculate Fibonacci

I would like to add a few ways to calculate the Fibonacci numbers, for example:

  • using the matrix;
  • classic recursive;
  • with memoization;
    and so on

I have a couple of ways to do this, and so I would like some advice.

1. So, the first way is to use the strategy pattern, for example

fibonacci = FibonacciContext.new(FibonacciRecursive.new)
puts fibonacci.compute 10

fibonacci.strategy = FibonacciMatrix.new
puts fibonacci.compute 10

with file structure like:

(math)
├── fibonacci
│      ├── strategies
│      │      ├── fibonacci_recursive.rb
│      │      ├── fibonacci_matrix.rb
│      │      └── fibonacci_golden_ratio.rb
│      ├── strategy.rb
│      └── fibonacci_context.rb
└── fibonacci.rb <--- client file

2. The second way is to make a Fibonacci module with different ways as functions and divide it into several files with this structure:

(math)
├── fibonacci
│   ├── recursive.rb
│   ├── matrix.rb
│   └── golden_ratio.rb
└── fibonacci.rb

where

# fibonacci.rb
require_relative 'fibonacci/recursive.rb'
require_relative 'fibonacci/matrix.rb'
require_relative 'fibonacci/golden_ratio.rb'

module Fibonacci
end


# fibonacci/recursive.rb
module Fibonacci
  def recursive(n)
    # ...
  end
end

...
  1. The third and simplest is to make just a lot of files in the math folder:
(math)
├── fibonacci_recursive.rb
├── fibonacci_matrix.rb
└── fibonacci_golden_ratio.rb

Well, I have given several ways, but I myself tend to the third, since most of the algorithms are designed in this way. But, on the other hand, it could be a starting point for refactoring the project structure.

Add Minitest/RSpec

Could we consider adding Minitest/RSpec to the GitHub workflow so that all these algorithms can have automated tests and we can make sure that they're still working properly?

Pending Ruby Algorithms

This repository is still missing some algorithms. The Python repository has lots of examples that we could follow and below you can find a list of suggested algorithms that were done in the Python directory and could be done for Ruby as well. Feel free to choose one of them and open a PR.

This is a follow-up to this issue #1 created by @AnupKumarPanwar.

Arithmetic Analysis

  • Bisection
  • Gaussian Elimination
  • In Static Equilibrium
  • Intersection
  • Lu Decomposition
  • Newton Forward Interpolation
  • Newton Method
  • Newton Raphson
  • Secant Method

Backtracking

  • All Combinations
  • All Permutations
  • All Subsequences
  • Coloring
  • Hamiltonian Cycle
  • Knight Tour
  • Minimax
  • N Queens
  • N Queens Math
  • Rat In Maze
  • Sudoku
  • Sum Of Subsets

Bit Manipulation

  • Binary And Operator
  • Binary Count Setbits
  • Binary Count Trailing Zeros
  • Binary Or Operator
  • Binary Xor Operator
  • Single Bit Manipulation Operations

Blockchain

  • Chinese Remainder Theorem
  • Diophantine Equation
  • Modular Division

Boolean Algebra

  • Quine Mc Cluskey

Cellular Automata

  • Conways Game Of Life
  • One Dimensional

Ciphers

  • A1Z26
  • Affine Cipher
  • Atbash
  • Base16
  • Base32
  • Base64 Encoding
  • Base85
  • Beaufort Cipher
  • Brute Force Caesar Cipher
  • Caesar Cipher
  • Cryptomath Module
  • Decrypt Caesar With Chi Squared
  • Deterministic Miller Rabin
  • Diffie
  • Elgamal Key Generator
  • Enigma Machine2
  • Hill Cipher
  • Mixed Keyword Cypher
  • Mono Alphabetic Ciphers
  • Morse Code Implementation
  • Onepad Cipher
  • Playfair Cipher
  • Porta Cipher
  • Rabin Miller
  • Rail Fence Cipher
  • Rot13
  • Rsa Cipher
  • Rsa Factorization
  • Rsa Key Generator
  • Shuffled Shift Cipher
  • Simple Keyword Cypher
  • Simple Substitution Cipher
  • Trafid Cipher
  • Transposition Cipher
  • Transposition Cipher Encrypt Decrypt File
  • Vigenere Cipher
  • Xor Cipher

Compression

  • Burrows Wheeler
  • Huffman
  • Lempel Ziv
  • Lempel Ziv Decompress
  • Peak Signal To Noise Ratio

Computer Vision

  • Harriscorner
  • Meanthreshold

Conversions

  • Binary To Decimal
  • Binary To Octal
  • Decimal To Any
  • Decimal To Binary
  • Decimal To Binary Recursion
  • Decimal To Hexadecimal
  • Decimal To Octal
  • Hexadecimal To Decimal
  • Molecular Chemistry
  • Octal To Decimal
  • Prefix Conversions
  • Roman Numerals
  • Temperature Conversions
  • Weight Conversion

Data Structures

Binary Tree

  • Avl Tree
  • Basic Binary Tree
  • Binary Search Tree
  • Binary Search Tree Recursive
  • Binary Tree Mirror
  • Binary Tree Traversals
  • Fenwick Tree
  • Lazy Segment Tree
  • Lowest Common Ancestor
  • Non Recursive Segment Tree
  • Number Of Possible Binary Trees
  • Red Black Tree
  • Segment Tree
  • Segment Tree Other
  • Treap

Disjoint Set

  • Alternate Disjoint Set
  • Disjoint Set

Hashing

  • Double Hash
  • Hash Table
  • Hash Table With Linked List
  • Quadratic Probing

Number Theory

  • Prime Numbers

Heap

  • Binomial Heap
  • Heap
  • Heap Generic
  • Max Heap
  • Min Heap
  • Randomized Heap
  • Skew Heap

Linked List

  • Circular Linked List
  • Deque Doubly
  • Doubly Linked List
  • Doubly Linked List Two
  • From Sequence
  • Has Loop
  • Is Palindrome
  • Merge Two Lists
  • Middle Element Of Linked List
  • Print Reverse
  • Singly Linked List
  • Skip List
  • Swap Nodes

Queue

  • Circular Queue
  • Double Ended Queue
  • Linked Queue
  • Priority Queue Using List
  • Queue On List
  • Queue On Pseudo Stack

Stacks

  • Balanced Parentheses
  • Dijkstras Two Stack Algorithm
  • Evaluate Postfix Notations
  • Infix To Postfix Conversion
  • Infix To Prefix Conversion
  • Linked Stack
  • Next Greater Element
  • Postfix Evaluation
  • Prefix Evaluation
  • Stack
  • Stack Using Dll
  • Stock Span Problem

Trie

  • Trie

Digital Image Processing

  • Change Brightness
  • Change Contrast
  • Convert To Negative
  • Index Calculation
  • Sepia
  • Test Digital Image Processing

Dithering

  • Burkes

Edge Detection

  • Canny

Filters

  • Bilateral Filter
  • Convolve
  • Gaussian Filter
  • Median Filter
  • Sobel Filter

Histogram Equalization

  • Histogram Stretch

Resize

  • Resize

Rotation

  • Rotation

Divide And Conquer

  • Closest Pair Of Points
  • Convex Hull
  • Heaps Algorithm
  • Heaps Algorithm Iterative
  • Inversions
  • Kth Order Statistic
  • Max Difference Pair
  • Max Subarray Sum
  • Mergesort
  • Peak
  • Power
  • Strassen Matrix Multiplication

Dynamic Programming

  • Abbreviation
  • Bitmask
  • Climbing Stairs
  • Coin Change
  • Edit Distance
  • Factorial
  • Fast Fibonacci
  • Fibonacci
  • Floyd Warshall
  • Fractional Knapsack
  • Integer Partition
  • Iterating Through Submasks
  • Knapsack
  • Longest Common Subsequence
  • Longest Increasing Subsequence
  • Longest Increasing Subsequence O(Nlogn)
  • Longest Sub Array
  • Matrix Chain Order
  • Max Non Adjacent Sum
  • Max Sub Array
  • Max Sum Contiguous Subsequence
  • Minimum Cost Path
  • Minimum Partition
  • Minimum Steps To One
  • Optimal Binary Search Tree
  • Rod Cutting
  • Subset Generation
  • Sum Of Subset

Electronics

  • Electric Power
  • Ohms Law

File Transfer

  • Receive File
  • Send File

Fuzzy Logic

  • Fuzzy Operations

Genetic Algorithm

  • Basic String

Geodesy

  • Haversine Distance
  • Lamberts Ellipsoidal Distance

Graphics

  • Bezier Curve
  • Vector3 For 2D Rendering

Graphs

  • A Star
  • Articulation Points
  • Basic Graphs
  • Bellman Ford
  • Bfs Shortest Path
  • Bfs Zero One Shortest Path
  • Bidirectional A Star
  • Bidirectional Breadth First Search
  • Breadth First Search
  • Breadth First Search Shortest Path
  • Check Bipartite Graph Bfs
  • Check Bipartite Graph Dfs
  • Connected Components
  • Depth First Search
  • Dijkstra
  • Dijkstra Algorithm
  • Dinic
  • Directed And Undirected (Weighted) Graph
  • Edmonds Karp Multiple Source And Sink
  • Eulerian Path And Circuit For Undirected Graph
  • Even Tree
  • Finding Bridges
  • Frequent Pattern Graph Miner
  • G Topological Sort
  • Gale Shapley Bigraph
  • Graph List
  • Graph Matrix
  • Graphs Floyd Warshall
  • Greedy Best First
  • Kahns Algorithm Long
  • Kahns Algorithm Topo
  • Karger
  • Minimum Spanning Tree Boruvka
  • Minimum Spanning Tree Kruskal
  • Minimum Spanning Tree Prims
  • Multi Heuristic Astar
  • Page Rank
  • Prim
  • Scc Kosaraju
  • Strongly Connected Components
  • Tarjans Scc

Hashes

  • Adler32
  • Chaos Machine
  • Djb2
  • Enigma Machine
  • Hamming Code
  • Md5
  • Sdbm
  • Sha1

Knapsack

  • Greedy Knapsack
  • Knapsack

Linear Algebra

Src

  • Conjugate Gradient
  • Lib
  • Polynom For Points
  • Power Iteration
  • Rayleigh Quotient
  • Test Linear Algebra
  • Transformations 2D

Machine Learning

  • Astar
  • Data Transformations
  • Decision Tree
  • Forecasting
  • Run
  • Gaussian Naive Bayes
  • Gradient Boosting Regressor
  • Gradient Descent
  • K Means Clust
  • K Nearest Neighbours
  • Knn Sklearn
  • Linear Discriminant Analysis
  • Linear Regression
  • Logistic Regression
  • Multilayer Perceptron Classifier
  • Polymonial Regression
  • Random Forest Classifier
  • Random Forest Regressor
  • Scoring Functions
  • Sequential Minimum Optimization
  • Similarity Search
  • Support Vector Machines
  • Word Frequency Functions

Maths

  • 3N Plus 1
  • Abs
  • Abs Max
  • Abs Min
  • Add
  • Aliquot Sum
  • Allocation Number
  • Area
  • Area Under Curve
  • Armstrong Numbers
  • Average Mean
  • Average Median
  • Average Mode
  • Bailey Borwein Plouffe
  • Basic Maths
  • Binary Exp Mod
  • Binary Exponentiation
  • Binomial Coefficient
  • Binomial Distribution
  • Bisection
  • Ceil
  • Chudnovsky Algorithm
  • Collatz Sequence
  • Combinations
  • Decimal Isolate
  • Entropy
  • Euclidean Distance
  • Eulers Totient
  • Explicit Euler
  • Extended Euclidean Algorithm
  • Factorial Iterative
  • Factorial Python
  • Factorial Recursive
  • Factors
  • Fermat Little Theorem
  • Fibonacci
  • Fibonacci Sequence Recursion
  • Find Max
  • Find Max Recursion
  • Find Min
  • Find Min Recursion
  • Floor
  • Gamma
  • Gaussian
  • Greatest Common Divisor
  • Hardy Ramanujanalgo
  • Is Square Free
  • Jaccard Similarity
  • Kadanes
  • Karatsuba
  • Krishnamurthy Number
  • Kth Lexicographic Permutation
  • Largest Of Very Large Numbers
  • Least Common Multiple
  • Line Length
  • Lucas Lehmer Primality Test
  • Lucas Series
  • Matrix Exponentiation
  • Miller Rabin
  • Mobius Function
  • Modular Exponential
  • Monte Carlo
  • Monte Carlo Dice
  • Newton Raphson
  • Number Of Digits
  • Numerical Integration
  • Perfect Cube
  • Perfect Number
  • Perfect Square
  • Pi Monte Carlo Estimation
  • Polynomial Evaluation
  • Power Using Recursion
  • Prime Check
  • Prime Factors
  • Prime Numbers
  • Prime Sieve Eratosthenes
  • Pythagoras
  • Qr Decomposition
  • Quadratic Equations Complex Numbers
  • Radians
  • Radix2 Fft
  • Relu
  • Runge Kutta
  • Segmented Sieve
  • Series
  • Geometric Series
  • Harmonic Series
  • P Series
  • Sieve Of Eratosthenes
  • Sigmoid
  • Simpson Rule
  • Softmax
  • Square Root
  • Sum Of Arithmetic Series
  • Sum Of Digits
  • Sum Of Geometric Progression
  • Test Prime Check
  • Trapezoidal Rule
  • Ugly Numbers
  • Volume
  • Zellers Congruence

Matrix

  • Count Islands In Matrix
  • Inverse Of Matrix
  • Matrix Class
  • Matrix Operation
  • Nth Fibonacci Using Matrix Exponentiation
  • Rotate Matrix
  • Searching In Sorted Matrix
  • Sherman Morrison
  • Spiral Print

Networking Flow

  • Ford Fulkerson
  • Minimum Cut

Neural Network

  • 2 Hidden Layers Neural Network
  • Back Propagation Neural Network
  • Convolution Neural Network
  • Perceptron

Other

  • Activity Selection
  • Anagrams
  • Autocomplete Using Trie
  • Binary Exponentiation
  • Davis–Putnam–Logemann–Loveland
  • Detecting English Programmatically
  • Dijkstra Bankers Algorithm
  • Doomsday
  • Euclidean Gcd
  • Fischer Yates Shuffle
  • Frequency Finder
  • Game Of Life
  • Gauss Easter
  • Greedy
  • Integeration By Simpson Approx
  • Largest Subarray Sum
  • Least Recently Used
  • Lfu Cache
  • Linear Congruential Generator
  • Lru Cache
  • Magicdiamondpattern
  • Markov Chain
  • Max Sum Sliding Window
  • Median Of Two Arrays
  • Nested Brackets
  • Palindrome
  • Password Generator
  • Primelib
  • Scoring Algorithm
  • Sdes
  • Sierpinski Triangle
  • Tower Of Hanoi
  • Triplet Sum
  • Two Pointer
  • Two Sum
  • Word Patterns

Quantum

  • Deutsch Jozsa
  • Half Adder
  • Not Gate
  • Quantum Entanglement
  • Ripple Adder Classic
  • Single Qubit Measure

Scheduling

  • First Come First Served
  • Round Robin
  • Shortest Job First

Searches

  • Binary Search
  • Double Linear Search
  • Double Linear Search Recursion
  • Fibonacci Search
  • Hill Climbing
  • Interpolation Search
  • Jump Search
  • Linear Search
  • Quick Select
  • Sentinel Linear Search
  • Simple Binary Search
  • Simulated Annealing
  • Tabu Search
  • Ternary Search

Sorts

  • Bead Sort
  • Bitonic Sort
  • Bogo Sort
  • Bubble Sort
  • Bucket Sort
  • Cocktail Shaker Sort
  • Comb Sort
  • Counting Sort
  • Cycle Sort
  • Double Sort
  • External Sort
  • Gnome Sort
  • Heap Sort
  • Insertion Sort
  • Intro Sort
  • Iterative Merge Sort
  • Merge Insertion Sort
  • Merge Sort
  • Natural Sort
  • Odd Even Transposition Parallel
  • Odd Even Transposition Single Threaded
  • Pancake Sort
  • Patience Sort
  • Pigeon Sort
  • Pigeonhole Sort
  • Quick Sort
  • Quick Sort 3 Partition
  • Radix Sort
  • Random Normal Distribution Quicksort
  • Random Pivot Quick Sort
  • Recursive Bubble Sort
  • Recursive Insertion Sort
  • Recursive Quick Sort
  • Selection Sort
  • Shell Sort
  • Stooge Sort
  • Strand Sort
  • Tim Sort
  • Topological Sort
  • Tree Sort
  • Unknown Sort
  • Wiggle Sort

Strings

  • Aho Corasick
  • Boyer Moore Search
  • Can String Be Rearranged As Palindrome
  • Capitalize
  • Check Anagrams
  • Check Pangram
  • Is Palindrome
  • Jaro Winkler
  • Knuth Morris Pratt
  • Levenshtein Distance
  • Lower
  • Manacher
  • Min Cost String Conversion
  • Naive String Search
  • Prefix Function
  • Rabin Karp
  • Remove Duplicate
  • Reverse Letters
  • Reverse Words
  • Split
  • Swap Case
  • Upper
  • Word Occurrence
  • Z Function

Traversals

  • Binary Tree Traversals

Web Programming

  • Co2 Emission
  • Covid Stats Via Xpath
  • Crawl Google Results
  • Crawl Google Scholar Citation
  • Currency Converter
  • Current Stock Price
  • Current Weather
  • Daily Horoscope
  • Emails From Url
  • Fetch Bbc News
  • Fetch Github Info
  • Fetch Jobs
  • Get Imdb Top 250 Movies Csv
  • Get Imdbtop
  • Instagram Crawler
  • Instagram Pic
  • Instagram Video
  • Recaptcha Verification
  • Slack Message
  • Test Fetch Github Info
  • World Covid19 Stats

Add RuboCop?

Problems to solve

This project doesn't have a coding style guideline or linters. This causes two problems:

  • It is too cumbersome to manually find simple coding style issues (for both contributors and reviewers).
  • Different tastes in coding styles between contributors can lead to inconsistencies and confuse new contributors.

Possible solutions

  • Add RuboCop to this project (and check code in CI?)

Possible risks

Links

Free Fall Distance

Free Fall Distance

Find:

  • Seconds

Why?

  • I think adding the Free Fall Distance equation would allow for your users to access more in terms of ruby support/code as well hopefully get this equation out there more for use.

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.