Code Monkey home page Code Monkey logo

scala-algorithms's Introduction

Scala Algorithms and Data Structures

License: GPL v3 GitHub Workflow Status Scala Steward badge Contributions Welcome

  • This repository is essentially a collection of programming exercises written in Scala that will involve Algorithms and Data Structures.
  • Take a look at our DIRECTORY for easier navigation and better overview of the project.

Getting Started

Read through our Contribution Guidelines before you contribute. Anyone can contribute to this repo to make their contribution to open-source on Github.

Get involved in the Open Source Community by completing some simple (or not so simple) tasks in this project.

This is a Public Repository open to all members of the GitHub Community. Any member of the community may contribute to this project without being a collaborator.

How to start programming in Scala

LICENSE

GNU GPLv3 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

See LICENSE

scala-algorithms's People

Contributors

adobryn avatar ivanopagano avatar jacktreble avatar johngodoi avatar justinmcnamara74 avatar lacaranian avatar megri avatar p3trur0 avatar saj1th avatar scala-steward avatar sentenza avatar snowycoder avatar tg44 avatar xoeseko 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

Watchers

 avatar  avatar  avatar  avatar  avatar

scala-algorithms's Issues

Implement the Bucket Sort algorithm

https://github.com/sentenza/hacktoberfest-scala-algorithms/blob/1e541a09eb9d7eb0dbec7feebb3d1d13d7f4c06a/src/main/scala/io/github/sentenza/hacktoberfest18/sort/CommonSortings.scala#L35

Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, a generalization of pigeonhole sort, and is a cousin of radix sort in the most-to-least significant digit flavor.

Contributing Guidelines

  • Add the missing implementation of the Bucket Sort
  • Add a test case in the spec that targets the CommonSorting object
  • Don't be afraid to submit a new PR
  • Have fun!

Add GitHub issue templates

It would be nice to have a set of templates for bugs, feature requests and Pull Requests.

  • create templates on the repository's master branch, inside .github directory

Implement the Radix Sort algorithm

https://github.com/sentenza/hacktoberfest-scala-algorithms/blob/1e541a09eb9d7eb0dbec7feebb3d1d13d7f4c06a/src/main/scala/io/github/sentenza/hacktoberfest18/sort/CommonSortings.scala#L34

Radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the individual digits which share the same significant position and value. A positional notation is required, but because integers can represent strings of characters (e.g., names or dates) and specially formatted floating point numbers, radix sort is not limited to integers.

Contributing Guidelines

  • Add the missing implementation of the Radix Sort
  • Add a test case in the spec that targets the CommonSorting object
  • Don't be afraid to submit a new PR
  • Have fun!

[Strings] Vowel counting

Add vowel counting algorithm.

Description

Count the number of occurrences of vowels in a given string.

Abstract the CommonSorting trait in order to support mutable and immutable collections

We should aim at refactoring the current CommonSortings object in order to create two different implementations: the first one will use scala.collection.immutable, while the second one will keep the current implementation provided by the CommonSorting object.

The trait that has to be refactored is:

https://github.com/sentenza/hacktoberfest-scala-algorithms/blob/1e541a09eb9d7eb0dbec7feebb3d1d13d7f4c06a/src/main/scala/io/github/sentenza/hacktoberfest18/sort/CommonSortings.scala#L25

We could have something like a GeneralSorting trait, and two implementations:

  • MutableSorting
  • ImmutableSorting

Add or improve any sorting algorhitms

Contributing Guidelines

  • Each new contribution should be added to the /sort folder

https://github.com/sentenza/hacktoberfest-scala-algorithms/blob/456108fbc8e36072099debb2704f8b37002e8795/src/main/scala/io/github/sentenza/hacktoberfest18/sort/CommonSortings.scala#L28

  • It is your choice to include only a function or an entire trait/object/class to describe the algorithm you worked on .
  • If the folder/file does not exist, create a new one.
  • Don't be afraid to make a Pull Request!

[Strings] Check Anagrams

Add check anagrams algorithm.

Two strings are anagrams if they are made of the same letters arranged differently (ignoring the case).

Writing the main loop in FP style

What we should aim for is to change the way we fetch the input from the console and then manage the loop that keeps showing the prompt.

We need:

  • out of the loop - print the LOGO and disclaimer
  • on request and at the very beginning: show the list of types (searching, sorting)
  • a showPrompt(): Unit method to print out a prompt to select the type of algorithm to execute
  • after selecting the type, we should give the user the ability to pick up one of the implemented algorithms
  • print out the results, and the loop begins again
  • the loop must be annotated with @tailrec
/**
  * A fairly standard "print this out" / "read this in" Scala recursive function
  */
@tailrec
def mainLoop(appState: AppState) {
    // a) prompt the user for input
    // b) get the user's input
    // c) execute the chosen algorithm / show a menu
    // d) write the output
    // e) if the user didn't type 'q' or 'quit' loop again
    mainLoop(newAppState)
}

Fix the interactive menu

Describe the bug
After selecting "Sorting Algorithms" we should prompt the user for choosing a particular category of algos and then list the elements in that category.

To Reproduce
Run the program:

  1. Choose 1. Sorting
  2. The main loop runs again

Expected behavior
We should see, at the very least the sorting algos and then ask for a list of comma separated integers.

Implement the Counting Sort algorithm

https://github.com/sentenza/hacktoberfest-scala-algorithms/blob/1e541a09eb9d7eb0dbec7feebb3d1d13d7f4c06a/src/main/scala/io/github/sentenza/hacktoberfest18/sort/CommonSortings.scala#L33

Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that is, it is an integer sorting algorithm. It operates by counting the number of objects that have each distinct key value, and using arithmetic on those counts to determine the positions of each key value in the output sequence.

Contributing Guidelines

  • Add the missing implementation of the Counting Sort
  • Add a test case in the spec that targets the CommonSorting object
  • Don't be afraid to submit a new PR
  • Have fun!

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.