Giter VIP home page Giter VIP logo

rust-task-lotto's Introduction

The Rust Programming Language in a Day: Task #1 - The Lottery

Task description

Write a command line tool that takes a list of numbers for international lotteries, eg. 6 out of 45, 6 out of 49, 5 out of 50, etc.

  • cargo run -- 6 45 means to take 6 out of 45
  • This will yield 6 random numbers out of a pot of 45 numbers
  • Write a struct Lotto representing your Lotto results
  • Write a function format_lotto_results that formats your lotto results for pretty printing
  • Make sure you adhere ownership and borrowing rules
  • Bonus: Allow for multiple runs. E.g. cargo run -- 6 45 6 49 5 50 does three runs: 6 out of 45, 6 out of 49, 5 out of 50
  • Use the rand crate for random number generation (this might be helpful)

Working with Codespaces

  1. Fork this repo
  2. On the upper right corner, there is a button named Code
  3. Click the Code button and click "New codespace"
  4. A new codespace for you pops up. You can reuse this codespace after creation.

You are all set up with VSCode, Rust, a Terminal, etc.

See more about [Codespaces](GitHub Codespaces)

Tests and execution

  1. Run the tests with cargo test. All tests need to pass!

  2. Run the app with cargo run -- 6 45. This should be the desired output

6 of 45: [31, 29, 38, 4, 21, 24]

With the numbers being different each time of course!

rust-task-lotto's People

Contributors

ddprrt avatar noah-kogler 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.