Skip to content

Commit

Permalink
basic datatypes_1 completed
Browse files Browse the repository at this point in the history
  • Loading branch information
vinay committed Jan 9, 2024
0 parents commit a5801ba
Show file tree
Hide file tree
Showing 42 changed files with 2,027 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: Bug Report
about: Create a report to help us improve something that is not working correctly
title: "Bug - :"
labels: "Status: Needs Review, Type: Bug"
assignees: ""
---

<!-- Thank you for taking the time to submit a bug report to The Odin Project. In order to get issues closed in a reasonable amount of time, you must include a baseline of information about the bug in question. Please read this template in its entirety before filling it out to ensure that it is filled out correctly. -->

Complete the following REQUIRED checkboxes:
- [ ] I have thoroughly read and understand [The Odin Project Contributing Guide](https://github.com/TheOdinProject/.github/blob/main/CONTRIBUTING.md)
- [ ] The title of this issue follows the `Bug - location of bug: brief description of bug` format, e.g. `Bug - Exercises: File type incorrect for all test files`

The following checkbox is OPTIONAL:
<!-- Completing this checkbox does not guarantee you will be assigned this issue, but rather lets us know you are interested in working on it. -->
- [ ] I would like to be assigned this issue to work on it

<hr>

**1. Description of the Bug:**
<!-- A clear and concise description of what the bug is. Include any screenshots that may help show the bug in action. -->


**2. How To Reproduce:**
<!--
What steps one might need to take in order to reproduce this bug, e.g.:
1. Log in
2. Visit a lesson page
3. Click the complete button
4. The complete button does not update
-->


**3. Expected Behavior:**
<!--
A brief description of what you expected to happen, e.g.:
1. Log in
2. Visit a lesson page
3. Click the complete button
4. The complete button updates correctly
-->


**4. Desktop/Device:**
<!-- The more information you are able to provide, the better. -->
- Device: <!-- [e.g. iPhone6] -->
- OS: <!-- [e.g. iOS] -->
- Browser: <!-- [e.g. chrome, safari] -->
- Version: <!-- [e.g. 22] -->

**5. Additional Information:**
<!-- Any additional information about the bug. -->

38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Feature Request
about: Suggest a new feature or enhancement for this project
title: ""
labels: "Status: Needs Review"
assignees: ""
---

<!-- Thank you for taking the time to submit a new feature request to The Odin Project. In order to get issues closed in a reasonable amount of time, you must include a baseline of information about the feature/enhancement you are proposing. Please read this template in its entirety before filling it out to ensure that it is filled out correctly. -->

Complete the following REQUIRED checkboxes:
- [ ] I have thoroughly read and understand [The Odin Project Contributing Guide](https://github.com/TheOdinProject/.github/blob/main/CONTRIBUTING.md)
- [ ] The title of this issue follows the `location for request: brief description of request` format, e.g. `Exercises: Add exercise on XYZ`

The following checkbox is OPTIONAL:
<!-- Completing this checkbox does not guarantee you will be assigned this issue, but rather lets us know you are interested in working on it. -->
- [ ] I would like to be assigned this issue to work on it

<hr>

**1. Description of the Feature Request:**
<!--
A clear and concise description of what the feature or enhancement is, including how it would be useful/beneficial or what problem(s) it would solve.
-->


**2. Acceptance Criteria:**
<!--
A list of checkbox items that explain the requirements needed to be met to resolve this request, e.g.:
- [ ] A theme toggle is present on the dashboard
- [ ] Clicking the theme toggle changes between light and dark
- [ ] A user's theme choice persists after leaving the website
-->


**3. Additional Information:**
<!-- Any additional information about the feature request, such as a link to a Discord discussion, screenshots, etc. -->

32 changes: 32 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- Thank you for taking the time to contribute to The Odin Project. In order to get this pull request (PR) merged in a reasonable amount of time, you must complete this entire template. -->

## Because
<!-- Summarize the purpose or reasons for this PR, e.g. what problem it solves or what benefit it provides. -->


## This PR
<!-- A bullet point list of one or more items describing the specific changes. -->


## Issue
<!--
If this PR closes an open issue in this repo, replace the XXXXX below with the issue number, e.g. Closes #2013.
If this PR closes an open issue in another TOP repo, replace the #XXXXX with the URL of the issue, e.g. Closes https://github.com/TheOdinProject/curriculum/issues/XXXXX
If this PR does not close, but is related to another issue or PR, you can link it as above without the 'Closes' keyword, e.g. 'Related to #2013'.
-->
Closes #XXXXX

## Additional Information
<!-- Any other information about this PR, such as a link to a Discord discussion. -->


## Pull Request Requirements
<!-- Replace the whitespace between the square brackets with an 'x', e.g. [x]. After you create the PR, they will become checkboxes that you can click on. -->
- [ ] I have thoroughly read and understand [The Odin Project Contributing Guide](https://github.com/TheOdinProject/.github/blob/main/CONTRIBUTING.md)
- [ ] The title of this PR follows the `location of change: brief description of change` format, e.g. `Data types exercise: Update spec files`
- [ ] The `Because` section summarizes the reason for this PR
- [ ] The `This PR` section has a bullet point list describing the changes in this PR
- [ ] If this PR addresses an open issue, it is linked in the `Issue` section
- [ ] If this PR includes changes that needs to be updated on the `solutions` branch, I have created another PR (and linked it to this PR).
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 The Odin Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# The Odin Project Ruby Exercises

## About this repository

This repository is a complement to the Ruby course for The Odin Project. It contains a series of Ruby exercises alongside pre-written tests that will help guide the student towards a solution, providing a Test Driven Development experience.

Each set of exercises should only be done **after** being directed to do so in the assignment of the corresponding Ruby lesson. I.e. if you just finished the Basic Data Types lesson you should **only** do the exercises in the `1_data_types` folder for now.

## Cloning and installation

Clone this repository to your local machine. To do this, click on the green "Code" button at the top right of list of files and copy the link in the prompt. Then, run the following command in your terminal:

git clone <link>

This will create a folder called 'ruby-exercises' inside the directory you ran the command in.

CD into that folder:

cd ruby-exercises

Now before beginning work on the exercises, you'll want to install a gem called RSpec. RSpec is a popular Ruby testing framework that is used in this repository to provide you with tests that check your solutions.

To install RSpec, run the following command in your terminal:

gem install rspec

You should see a message that says something along the lines of "6 gems installed" in your terminal. Verify that the installation was successful by simply running the following command:

rspec

Which should print a few lines about not finding any examples. This is ok and means it's working!

If your shell reports that it cannot find the rspec binary, it may be necessary to run the following command:

rbenv rehash

## Usage

Each directory contains a read me with instructions for the exercises within them.
1 change: 1 addition & 0 deletions ruby_basics/10_basic_enumerables/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper --format documentation --color
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def display_current_inventory(inventory_list)
# use #each to iterate through each item of the inventory_list (a hash)
# use puts to output each list item "<key>, quantity: <value>" to console
end

def display_guess_order(guesses)
# use #each_with_index to iterate through each item of the guesses (an array)
# use puts to output each list item "Guess #<number> is <item>" to console
# hint: the number should start with 1
end

def find_absolute_values(numbers)
# use #map to iterate through each item of the numbers (an array)
# return an array of absolute values of each number
end

def find_low_inventory(inventory_list)
# use #select to iterate through each item of the inventory_list (a hash)
# return a hash of items with values less than 4
end

def find_word_lengths(word_list)
# use #reduce to iterate through each item of the word_list (an array)
# return a hash with each word as the key and its length as the value
# hint: look at the documentation and review the reduce examples in basic enumerable lesson
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
require 'spec_helper'
require_relative '../exercises/basic_enumerable_exercises'

RSpec.describe 'Basic Enumerable Exercises' do

describe 'display current inventory exercise' do

it 'outputs each inventory item' do
expect($stdout).to receive(:puts).with("apples, quantity: 1")
expect($stdout).to receive(:puts).with("bananas, quantity: 3")
expect($stdout).to receive(:puts).with("oranges, quantity: 7")
fruit = { apples: 1, bananas: 3, oranges: 7 }
display_current_inventory(fruit)
end

# remove the 'x' from the line below to unskip the test
xit 'outputs item without quantity when value is nil' do
expect($stdout).to receive(:puts).with("pineapples, quantity: ")
fruit = { pineapples: nil }
display_current_inventory(fruit)
end
end

describe 'display guess order exercise' do

xit 'outputs each guess of strings in order' do
expect($stdout).to receive(:puts).with("Guess #1 is cookies")
expect($stdout).to receive(:puts).with("Guess #2 is cake")
expect($stdout).to receive(:puts).with("Guess #3 is ice cream")
guesses = ['cookies', 'cake', 'ice cream']
display_guess_order(guesses)
end

xit 'outputs each guess of integers in order' do
expect($stdout).to receive(:puts).with("Guess #1 is 553")
expect($stdout).to receive(:puts).with("Guess #2 is 554")
expect($stdout).to receive(:puts).with("Guess #3 is 555")
guesses = [553, 554, 555]
display_guess_order(guesses)
end
end

describe 'find absolute values exercise' do

xit 'returns an array of positive integers' do
numbers = [0, -7, 14, -21]
result = [0, 7, 14, 21]
expect(find_absolute_values(numbers)).to eq(result)
end

xit 'returns an array of positive floating point numbers' do
numbers = [-3.14, 6.28, -9.42]
result = [3.14, 6.28, 9.42]
expect(find_absolute_values(numbers)).to eq(result)
end
end

describe 'find low inventory exercise' do

xit 'returns a hash with integer values' do
fruit = { apples: 1, peaches: 4, bananas: 3, oranges: 7 }
result = { apples: 1, bananas: 3 }
expect(find_low_inventory(fruit)).to eq(result)
end

xit 'returns a hash with floating point number values' do
cakes = { chocolate_cake: 2.5, vanilla_cake: 4.25, carrot_cake: 3.75 }
result = { chocolate_cake: 2.5, carrot_cake: 3.75 }
expect(find_low_inventory(cakes)).to eq(result)
end
end

describe 'find word length exercise' do

xit 'returns a hash with rocket syntax when using strings' do
animals = ['cat', 'horse', 'rabbit', 'deer']
result = { 'cat' => 3, 'horse' => 5, 'rabbit' => 6, 'deer' => 4 }
expect(find_word_lengths(animals)).to eq(result)
end

xit 'returns a hash with symbols syntax when using symbols' do
animals = [:cat, :horse, :rabbit, :deer]
result = { cat: 3, horse: 5, rabbit: 6, deer: 4 }
expect(find_word_lengths(animals)).to eq(result)
end
end
end
18 changes: 18 additions & 0 deletions ruby_basics/10_basic_enumerables/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups
end

module FormatterOverrides
def dump_pending(_)
end
end

RSpec::Core::Formatters::DocumentationFormatter.prepend FormatterOverrides
1 change: 1 addition & 0 deletions ruby_basics/11_predicate_enumerables/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper --format documentation --color
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def coffee_drink?(drink_list)
# use #include? to return true when the drink_list (array) contains the string "coffee" or "espresso"
end

def correct_guess?(guess_list, answer)
# use #any? to return true when any element of the guess_list (array) equals the answer (number)
end

def twenty_first_century_years?(year_list)
# use #all? to return true when all of the years in the year_list (array) are between 2001 and 2100
end

def correct_format?(word_list)
# use #none? to return true when none of the words in the word_list (array) are in upcase
end

def valid_scores?(score_list, perfect_score)
# use #one? to return true when only one value in the score_list (hash) is equal to the perfect_score (number)
end

0 comments on commit a5801ba

Please sign in to comment.