Giter Site home page Giter Site logo

mix_characters's Introduction

Test

Original problem statement

The static/characters.csv file contains the list of characters appeared in the Star Wars universe. “BBY” stands for Before the Battle of Yavin, it’s the “year zero” in the Galactic Standard Calendar. For the age calculation let’s assume that it’s “year zero” and every character lives for the sake of simplicity.

Create an Elixir console app where it’s possible to ask for the following information:

  1. The name of the heaviest character (if the mass is unknown, ignore that character)

    • The average height of the male characters
    • The average height of the female characters
  2. The age distribution of the characters by gender (where the gender can be “male”, “female” and “other”). The age groups are: “below 21”, “between 21 and 40", “above 40” and “unknown”. The result should be a Map(String, Map(String, Integer)).

How to use

The API is available inside the Csv.Server module.

iex(1)> Csv.Server.heaviest()
"The heaviest is Jabba Desilijic Tiure, with 1358.0!"
iex(2)> Csv.Server.average_height_by(:male)
"The average height among males is 179.23728813559322!"
iex(3)> Csv.Server.average_height_by(:female)
"The average height among females is 165.47058823529412!"
iex(4)> Csv.Server.distribution_by_age()
%{
  "female" => %{"above 40" => 7, "below 21" => 1, "unknown" => 11},
  "male" => %{
    "above 40" => 22,
    "below 21" => 2,
    "between 21 and 40" => 7,
    "unknown" => 31
  },
  "other" => %{
    "above 40" => 2,
    "below 21" => 1,
    "between 21 and 40" => 1,
    "unknown" => 2
  }
}

Optionally you can switch out the file to static/perf.csv inside mix.exs's application section for testing a significantly larger file.

mix_characters's People

Contributors

leeh-peter avatar ptrskay3 avatar

Watchers

 avatar

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.