Coder Social home page Coder Social logo

jaeyson / freecodecamp_elixir Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 225 KB

Solving exercises from Freecodecamp.org using Elixir programming language. Includes benchmarks and tests for every functions.

Home Page: https://hexdocs.pm/freecodecamp_elixir

License: MIT License

Elixir 97.19% Dockerfile 0.47% Shell 2.35%
freecodecamp-elixir elixir algorithm-scripting exercises freecodecamp elixir-lang elixir-programming-language

freecodecamp_elixir's Introduction

Freecodecamp exercises using Elixir

Solving exercises from Freecodecamp.org using Elixir programming language. Includes benchmarks and tests for every functions.

Last Commit Commit activity Dependabot Actions Status Coverage Hex.pm Hexdocs

Folders that are interesting to read can be found at:

Elixir installation

Either use Docker, this Docker automated install script curl -sSL https://get.docker.com/ | sh, or use asdf.

Using Docker

using docker_start shell script (use wsl on windows or git bash, otherwise this works both ?mac? and linux), or see the file if you want to use docker commands instead.

# I haven't tried this both on windows and mac, YMMV
source docker_start

Why source docker_start instead of chmod +x ./docker_start? read run bash script doesn't work alias command.

Getting dependencies

mix deps.get --only test

Launch REPL

iex -S mix

Stopping Elixir container, remove alias created by shell script

# where "elixir" is the name of the container
docker container stop elixir

# temporary alias are not persisted across different sessions
# but if you want to remove them
unalias elixir iex mix elixirc

Create Pre-commit Hook

mix precommit

Test

mix test

Coverage

mix text --cover

Selective tests

# i.e. you want to test only "Basic Algorithms"
mix selective_test basic_algo

# or more, separated by spaces
mix selective_test basic_algo intermediate_algo

# basic_algo        = Basic Algorithm Scripting
# intermediate_algo = Intermediate Algorithm Scripting

Generate HTML Docs

# running this generates docs in "doc/" directory
mix docs

Benchmarks (using Benchee)

# view benchmark commands
mix help benchmark
# list available functions
mix benchmark --list
# specific function
mix benchmark mutation
# benchmark results saved as html in "benchmarks/" directory
mix benchmark mutation --html

freecodecamp_elixir's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar imgbotapp avatar jaeyson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

freecodecamp_elixir's Issues

StreamData.FilterTooNarrowError: too many consecutive elements were filtered out

Description

Generated too many invalid values which StreamData doesn't like.

Test from BasicAlgo.repeat_string_num_times function:

** (StreamData.FilterTooNarrowError) too many consecutive elements were filtered out.
To avoid this:

   * make sure the generation space contains enough values that the chance of a generated                                         
     value being filtered out is small. For example, don't generate all integers and filter                                       
     out odd ones in order to have a generator of even integers (since you'd be taking out                                        
     half the generation space).                                                                                                  
                                                                                                                                  
   * keep an eye on how the generation size affects the generator being filtered. For                                             
     example, you might be filtering out only a handful of values from the generation space,                                      
     but small generation sizes might make the generation space much smaller hence increasing                                     
     the probability of values that you'd filter out being generated.                                                             
                                                                                                                                  
   * try to restructure your generator so that instead of generating many values and taking                                       
     out the ones you don't want, you instead generate values and turn all of them into                                           
     values that are suitable. For example, multiply integers by two to have a generator of                                       
     even values instead of filtering out all odd integers.  

Move benchmark as a mix task

Using mix run benchmarks/basic_algo.exs seems error prone and
lots of typing. We could move this as a mix task like:

# list of available functions to be benchmarked
mix bench --list

# bench a specific function
mix bench repeat_string

# get results as html
mix bench repeat_string --html

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.