diff --git a/README.md b/README.md index 31410dcb9b..103cea1ab9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Exercism Exercises in Ruby -#### Table of Contents +## Table of Contents - [Setup](#setup) - [Anatomy of an Exercise](#anatomy-of-an-exercise) - [Canonical Data](#canonical-data) diff --git a/concepts/arrays/about.md b/concepts/arrays/about.md index 3d78c7a5c5..a449d63cf3 100644 --- a/concepts/arrays/about.md +++ b/concepts/arrays/about.md @@ -1,3 +1,5 @@ +# About + Data structures that can hold zero or more elements are known as _collections_. An **array** in Ruby is a collection that maintains the ordering in which its objects are added. Arrays can hold any object. Objects can be added to an array or retrieved from it using an index. Ruby array indexing is zero-based, meaning that the first element's index is always zero: ```ruby diff --git a/concepts/arrays/introduction.md b/concepts/arrays/introduction.md index e7896f78cc..2c8b3fd120 100644 --- a/concepts/arrays/introduction.md +++ b/concepts/arrays/introduction.md @@ -1,3 +1,5 @@ +# Introduction + In Ruby, **arrays** are ordered, integer-indexed collections of any object. Array indexing starts at `0`. A negative index is assumed to be relative to the end of the array — i.e. an index of `-1` indicates the last element of the array, `-2` is the next to last element in the array, and so on. Ruby arrays mix in the [Enumerable module][enumerable-module], which adds several traversal and searching methods, and with the ability to sort. diff --git a/concepts/basics/about.md b/concepts/basics/about.md index 9b14ae5c43..e6a4ffa6da 100644 --- a/concepts/basics/about.md +++ b/concepts/basics/about.md @@ -1,3 +1,5 @@ +# About + Ruby is a dynamic and strongly typed language. In dynamic languages the type of a variable or object is resolved at runtime, which means that its value or type can be changed up to the very last moment (when it gets parsed by the interpreter). And what do we mean with strongly typed? Once we know the type of a variable or object, Ruby is strict about what you can do with it, for example: diff --git a/concepts/basics/introduction.md b/concepts/basics/introduction.md index 537bc457d9..6dd5819b0b 100644 --- a/concepts/basics/introduction.md +++ b/concepts/basics/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Ruby is a dynamic [object-oriented language][object-oriented-programming]. Everything in Ruby is an [object][object]. There are two primary ways to assign objects to names in Ruby - using variables or constants. Variables are always written in [snake case][snake-case]. A variable can reference different objects over its lifetime. For example, `my_first_variable` can be defined and redefined many times using the `=` operator: diff --git a/concepts/blocks/about.md b/concepts/blocks/about.md index ca5f59c7fd..dcba72eef5 100644 --- a/concepts/blocks/about.md +++ b/concepts/blocks/about.md @@ -1,3 +1,5 @@ +# About + Blocks are small groupings of statements that can be executed multiple times. They can be thought of as closures or anonymous functions. Blocks are defined using the `do...end` syntax (above), or the `{}` (below). diff --git a/concepts/blocks/introduction.md b/concepts/blocks/introduction.md index 03db3da149..06b2a07223 100644 --- a/concepts/blocks/introduction.md +++ b/concepts/blocks/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Blocks are small groupings of statements that can be executed multiple times. They can be thought of as closures or anonymous functions. Blocks are defined using the `do...end` syntax (above), or the `{}` (below). diff --git a/concepts/booleans/about.md b/concepts/booleans/about.md index ccaf2fcd76..51351c84a5 100644 --- a/concepts/booleans/about.md +++ b/concepts/booleans/about.md @@ -1,3 +1,5 @@ +# About + ## True, False - `true` and `false` are used to represent boolean logical states. diff --git a/concepts/booleans/introduction.md b/concepts/booleans/introduction.md index aef2c5f33d..369a5bb5e8 100644 --- a/concepts/booleans/introduction.md +++ b/concepts/booleans/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## True and False True and false logical states are represented with `true` and `false` in Ruby. These may either be used as literals on their own, or as a result of logical or comparison methods. diff --git a/concepts/classes/about.md b/concepts/classes/about.md index 608d2f539e..1b01979806 100644 --- a/concepts/classes/about.md +++ b/concepts/classes/about.md @@ -1 +1,3 @@ +# About + TODO: add information on classes concept diff --git a/concepts/classes/introduction.md b/concepts/classes/introduction.md index cacf371834..69919723e8 100644 --- a/concepts/classes/introduction.md +++ b/concepts/classes/introduction.md @@ -1 +1,3 @@ +# Introduction + TODO: add introduction for classes concept diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index 83b224f5db..7cbdd31242 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -1,3 +1,5 @@ +# About + An `if` statement can be used to conditionally execute code: ```ruby diff --git a/concepts/conditionals/introduction.md b/concepts/conditionals/introduction.md index 2d1d2e8db5..5e4379d671 100644 --- a/concepts/conditionals/introduction.md +++ b/concepts/conditionals/introduction.md @@ -1 +1,3 @@ +# Introduction + TODO: Write this diff --git a/concepts/enumeration/about.md b/concepts/enumeration/about.md index b9634f311f..df368dc22c 100644 --- a/concepts/enumeration/about.md +++ b/concepts/enumeration/about.md @@ -1,3 +1,5 @@ +# About + Enumeration is the act of stepping through a collection (`Array`, `Hash`, etc) and performing some action on each object. Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more. diff --git a/concepts/enumeration/introduction.md b/concepts/enumeration/introduction.md index 56a9b9131c..8baac70043 100644 --- a/concepts/enumeration/introduction.md +++ b/concepts/enumeration/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Enumeration is the act of stepping through a collection (`Array`, `Hash`, etc) and performing some action on each object. Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more. diff --git a/concepts/exceptions/about.md b/concepts/exceptions/about.md index 86f7138e36..bc30ace9cf 100644 --- a/concepts/exceptions/about.md +++ b/concepts/exceptions/about.md @@ -1,3 +1,5 @@ +# About + It is important to note that exceptions should be used in cases where something exceptional happens, an error that needs special handling. Exceptions should not be used for control-flow of a program, as that is considered bad design, which often leads to bad performance and maintainability. In Ruby exceptions follow a class hierarchy where `Exception` is the base class. These are the most common Ruby's built-in exceptions: diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 2d1d2e8db5..5e4379d671 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -1 +1,3 @@ +# Introduction + TODO: Write this diff --git a/concepts/floating-point-numbers/about.md b/concepts/floating-point-numbers/about.md index a31d87ed0c..1a8b9d0a61 100644 --- a/concepts/floating-point-numbers/about.md +++ b/concepts/floating-point-numbers/about.md @@ -1,3 +1,5 @@ +# About + A floating-point number is a number with zero or more digits behind the decimal separator. Examples are `4.0`, `0.1`, `3.14`, `-6.4` `16.984025` and `1024.0`. In Ruby, floating-point numbers are implemented through the [Float](https://ruby-doc.org/core-2.7.0/Float.html) class. You can find a short introduction to floating-point numbers at [0.30000000000000004.com][0.30000000000000004.com]. @@ -8,7 +10,7 @@ To repeatedly execute logic, one can use loops. In this example the `while` loop The `#years_before_desired_balance` method from the previous exercise could have been written by using any of the three mentioned loops: -### `while` +## `while` ```ruby def self.years_before_desired_balance(current_balance, desired_balance) @@ -21,7 +23,7 @@ def self.years_before_desired_balance(current_balance, desired_balance) end ``` -### `until` +## `until` ```ruby def self.years_before_desired_balance(current_balance, desired_balance) @@ -34,7 +36,7 @@ def self.years_before_desired_balance(current_balance, desired_balance) end ``` -### `loop` +## `loop` ```ruby def self.years_before_desired_balance(current_balance, desired_balance) diff --git a/concepts/floating-point-numbers/introduction.md b/concepts/floating-point-numbers/introduction.md index 72bc78872f..a43d53ef5b 100644 --- a/concepts/floating-point-numbers/introduction.md +++ b/concepts/floating-point-numbers/introduction.md @@ -1,4 +1,4 @@ -## Loops +# Loops A floating-point number is a number with zero or more digits behind the decimal separator. Examples are `4.0`, `0.1`, `3.14`, `-6.4` `16.984025` and `1024.0`. In Ruby, floating-point numbers are implemented through the [Float](https://ruby-doc.org/core-2.7.0/Float.html) class. diff --git a/concepts/instance-variables/about.md b/concepts/instance-variables/about.md index 003910afc0..cd66c749ea 100644 --- a/concepts/instance-variables/about.md +++ b/concepts/instance-variables/about.md @@ -1,3 +1,5 @@ +# About + ## Key Points: - When a class' `.new` method is called to create an object instance, the `.initialize` method is passed all arguments to initialize the instance's state. diff --git a/concepts/instance-variables/introduction.md b/concepts/instance-variables/introduction.md index ff8f8273d3..3c0b4e4f3e 100644 --- a/concepts/instance-variables/introduction.md +++ b/concepts/instance-variables/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Objects can hold their own state by setting _instance variables_, which are created by prefixing `@` to a variable name. ```ruby diff --git a/concepts/loops/about.md b/concepts/loops/about.md index b30a340509..62f6bfa823 100644 --- a/concepts/loops/about.md +++ b/concepts/loops/about.md @@ -1,3 +1,5 @@ +# About + ## `while` ```ruby diff --git a/concepts/loops/introduction.md b/concepts/loops/introduction.md index 050095f094..0b1fd19d03 100644 --- a/concepts/loops/introduction.md +++ b/concepts/loops/introduction.md @@ -1,3 +1,5 @@ +# Introduction + A floating-point number is a number with zero or more digits behind the decimal separator. Examples are `4.0`, `0.1`, `3.14`, `-6.4` `16.984025` and `1024.0`. In Ruby, floating-point numbers are implemented through the [Float](https://ruby-doc.org/core-2.7.0/Float.html) class. diff --git a/concepts/nil/about.md b/concepts/nil/about.md index 51f90cc44a..73c7be7c17 100644 --- a/concepts/nil/about.md +++ b/concepts/nil/about.md @@ -1,3 +1,5 @@ +# About + ## Key Points: - When a class' `.new` method is called to create an object instance, the `.initialize` method is passed all arguments to initialize the instance's state. diff --git a/concepts/nil/introduction.md b/concepts/nil/introduction.md index 3848d3d440..f4dfd2c0e6 100644 --- a/concepts/nil/introduction.md +++ b/concepts/nil/introduction.md @@ -1,3 +1,5 @@ +# Introduction + [Nil][nil-dictionary] is an English word meaning "nothing" or "zero". In Ruby, `nil` is used to express the _absence_ of an object. In other programming languages, `null` or `none` values may play a similar role. diff --git a/concepts/numbers/about.md b/concepts/numbers/about.md index 92750518df..291ebc0b33 100644 --- a/concepts/numbers/about.md +++ b/concepts/numbers/about.md @@ -1,3 +1,5 @@ +# About + One of the key aspects of working with numbers in Ruby is the distinction between integers (numbers with no digits after the decimal separator) and floating-point numbers (numbers with zero or more digits after the decimal separator). They are implemented through the [`Integer`][integer-ruby] and [`Float`][float-ruby] class. diff --git a/concepts/numbers/introduction.md b/concepts/numbers/introduction.md index 4c47a20c12..2d04263e8d 100644 --- a/concepts/numbers/introduction.md +++ b/concepts/numbers/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Two common types of numbers in Ruby are: - Integers: numbers with no digits behind the decimal separator (whole numbers). Examples are `-6`, `0`, `1`, `25`, `976` and `500000`. diff --git a/concepts/ostruct/after.md b/concepts/ostruct/after.md index 1385ccc76a..90ebf90bae 100644 --- a/concepts/ostruct/after.md +++ b/concepts/ostruct/after.md @@ -1,3 +1,5 @@ +# After + Ruby comes with a Standard Library (often shortened to "stdlib") - a collection of classes for working with things such as dates, json, and networking. It also provides some useful functionality for making your code easier to work with. diff --git a/concepts/ostruct/introduction.md b/concepts/ostruct/introduction.md index 1385ccc76a..2c8aa3ae5a 100644 --- a/concepts/ostruct/introduction.md +++ b/concepts/ostruct/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Ruby comes with a Standard Library (often shortened to "stdlib") - a collection of classes for working with things such as dates, json, and networking. It also provides some useful functionality for making your code easier to work with. diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 493d294a0e..42363038b1 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -1,3 +1,5 @@ +# About + The key thing to remember about Ruby strings is that they are objects that you call methods on. You can find all the methods in the [Ruby docs][ruby-doc.org-string] It's also worth knowing that strings can be created using single quotes (`'`) or double quotes (`"`). Single-quoted strings don't process ASCII escape codes(\n, \t etc.), and they don't do [string interpolation][ruby-for-beginners.rubymonstas.org-interpolation] while double-quoted does both. diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md index b2515ab7bf..94ddba0f50 100644 --- a/concepts/strings/introduction.md +++ b/concepts/strings/introduction.md @@ -1 +1,3 @@ +# Introduction + A `String` in Ruby is an object that holds and manipulates an arbitrary sequence of bytes, typically representing characters. Strings are manipulated by calling the string's methods. diff --git a/docs/24pullrequests.md b/docs/24pullrequests.md index ae80681a3a..3acb0c6fda 100644 --- a/docs/24pullrequests.md +++ b/docs/24pullrequests.md @@ -1,4 +1,4 @@ -## 24 Pull Requests for Exercism - Ruby Edition! +# 24 Pull Requests for Exercism - Ruby Edition! We are welcoming contributors to the project. diff --git a/docs/ABOUT.md b/docs/ABOUT.md index aa902250fb..4dfdb8edea 100644 --- a/docs/ABOUT.md +++ b/docs/ABOUT.md @@ -1,3 +1,5 @@ +# About + Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index e2c1aace5f..03b831c2aa 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -1,4 +1,4 @@ -## Installation +# Installation Choose your installation method at the [Ruby installation page](https://www.ruby-lang.org/en/documentation/installation/) for instructions on installing Ruby. diff --git a/docs/LEARNING.md b/docs/LEARNING.md index f74f9ec21e..d708b65571 100644 --- a/docs/LEARNING.md +++ b/docs/LEARNING.md @@ -1,4 +1,4 @@ -## Recommended Learning Resources +# Recommended Learning Resources Exercism provides exercises and feedback but can be difficult to jump into for those learning Ruby for the first time. These resources can help you get started: diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index bc26f664b4..3610e39e52 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -1,13 +1,13 @@ -## Recommended Resources +# Recommended Resources -### Environment +## Environment * [Ruby](https://www.ruby-lang.org/) * [Ruby Gems](https://rubygems.org/) * [Bundler](http://bundler.io/) * [RVM](https://rvm.io/) * [rbenv](https://github.com/rbenv/rbenv) -### Docs +## Docs * [Ruby Doc](http://ruby-doc.org/) * [API Dock](http://apidock.com/) * [Minitest](http://docs.seattlerb.org/minitest/) diff --git a/docs/TESTS.md b/docs/TESTS.md index e56cde2487..271cb356cd 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -1,3 +1,5 @@ +# Tests + ## Running Tests Execute the tests with: diff --git a/exercises/concept/amusement-park-improvements/.docs/hints.md b/exercises/concept/amusement-park-improvements/.docs/hints.md index cf56e9a576..8f71dbc06a 100644 --- a/exercises/concept/amusement-park-improvements/.docs/hints.md +++ b/exercises/concept/amusement-park-improvements/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General Review: diff --git a/exercises/concept/amusement-park-improvements/.docs/instructions.md b/exercises/concept/amusement-park-improvements/.docs/instructions.md index 29311a7155..7d645bccaa 100644 --- a/exercises/concept/amusement-park-improvements/.docs/instructions.md +++ b/exercises/concept/amusement-park-improvements/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Continuing your work with the amusement park, you are tasked with writing some utility methods to facilitate checking an attendee can use a ride. ## 1. Check if an attendee has a ride pass diff --git a/exercises/concept/amusement-park-improvements/.docs/introduction.md b/exercises/concept/amusement-park-improvements/.docs/introduction.md index 15134a787f..11c2fd687b 100644 --- a/exercises/concept/amusement-park-improvements/.docs/introduction.md +++ b/exercises/concept/amusement-park-improvements/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## True and False True and false logical states are represented with `true` and `false` in Ruby. These may either be used as literals on their own, or as a result of logical or comparison methods. diff --git a/exercises/concept/amusement-park-improvements/.meta/design.md b/exercises/concept/amusement-park-improvements/.meta/design.md index 5ff6515da7..e64e89753b 100644 --- a/exercises/concept/amusement-park-improvements/.meta/design.md +++ b/exercises/concept/amusement-park-improvements/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the basics of the Concept of "nil" in Ruby. diff --git a/exercises/concept/amusement-park/.docs/hints.md b/exercises/concept/amusement-park/.docs/hints.md index 193b842194..73457218b9 100644 --- a/exercises/concept/amusement-park/.docs/hints.md +++ b/exercises/concept/amusement-park/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General About initializing object instances: diff --git a/exercises/concept/amusement-park/.docs/instructions.md b/exercises/concept/amusement-park/.docs/instructions.md index c2fc45e37d..f9cd7768c3 100644 --- a/exercises/concept/amusement-park/.docs/instructions.md +++ b/exercises/concept/amusement-park/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + Working with an amusement park, you've been handed a specification to design a system to administer attendance and rides. You've been tasked with modeling the Attendee (person visiting the park). ## 1. Make new attendees diff --git a/exercises/concept/amusement-park/.docs/introduction.md b/exercises/concept/amusement-park/.docs/introduction.md index 60ee8c3a98..32fd257ad0 100644 --- a/exercises/concept/amusement-park/.docs/introduction.md +++ b/exercises/concept/amusement-park/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Instance Variables Objects can hold their own state by setting _instance variables_, which are created by prefixing `@` to a variable name. diff --git a/exercises/concept/amusement-park/.meta/design.md b/exercises/concept/amusement-park/.meta/design.md index b7590fdb18..5f21cd0a50 100644 --- a/exercises/concept/amusement-park/.meta/design.md +++ b/exercises/concept/amusement-park/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the basics of the concept instance variables and "nil" in Ruby. diff --git a/exercises/concept/assembly-line/.docs/hints.md b/exercises/concept/assembly-line/.docs/hints.md index f84ce5fcb7..15cf3374e3 100644 --- a/exercises/concept/assembly-line/.docs/hints.md +++ b/exercises/concept/assembly-line/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General ## 1. Calculate the production rate per second diff --git a/exercises/concept/assembly-line/.docs/instructions.md b/exercises/concept/assembly-line/.docs/instructions.md index 315dcc571f..ddf28bc3c1 100644 --- a/exercises/concept/assembly-line/.docs/instructions.md +++ b/exercises/concept/assembly-line/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be writing code to analyze the production of an assembly line in a car factory. The assembly line's speed can range from `0` (off) to `10` (maximum). At its slowest speed (`1`), `221` cars are produced each hour. The production increases linearly with the speed. So with the speed set to `4`, it should produce `4 * 221 = 884` cars per hour. However, higher speeds increase the likelihood that faulty cars are produced, which then have to be discarded. The following table shows how speed influences the success rate: diff --git a/exercises/concept/assembly-line/.docs/introduction.md b/exercises/concept/assembly-line/.docs/introduction.md index 86588046a0..7b3bf86f9f 100644 --- a/exercises/concept/assembly-line/.docs/introduction.md +++ b/exercises/concept/assembly-line/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Numbers ## Conditionals diff --git a/exercises/concept/assembly-line/.meta/design.md b/exercises/concept/assembly-line/.meta/design.md index 85b120bbc8..ae28ce4c97 100644 --- a/exercises/concept/assembly-line/.meta/design.md +++ b/exercises/concept/assembly-line/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student how the concept of numbers is implemented in Ruby. It will introduce this concept through the two most common numeric types in Ruby: [`Integer`][integer-ruby] (whole number) and [`Float`][float-ruby] (floating-point number). diff --git a/exercises/concept/bird-count/.docs/hints.md b/exercises/concept/bird-count/.docs/hints.md index 0fdabafeee..d9814f7f42 100644 --- a/exercises/concept/bird-count/.docs/hints.md +++ b/exercises/concept/bird-count/.docs/hints.md @@ -1,27 +1,29 @@ -### General +# Hints + +## General - The bird count per day is stored in a [instance variable][instace-variable] named `birds_per_day`. - The bird count per day is an array that contains exactly 7 integers. -### 1. Check what the counts were last week +## 1. Check what the counts were last week - As this method does _not_ depend on the current week's count, it is defined as a [`class` method][class-method]. - There are [several ways to define an array][array-definition]. -### 2. Check how many birds visited yesterday +## 2. Check how many birds visited yesterday - Remember that the counts are ordered by day from oldest to most recent, with the last element representing today. - Accessing the second last element can be done either by using its (fixed) index (remember to start counting from zero) or by calculating its index using the [array's size][array-length]. -### 3. Calculate the total number of visiting birds +## 3. Calculate the total number of visiting birds - It's possible to calculate the sum of a collection using the [Array#sum][array-sum] method. -### 4. Calculate the number of busy days +## 4. Calculate the number of busy days - Ruby also provides a method for [counting elements on a collection][array-count] -### 5. Check if there was a day with no visiting birds +## 5. Check if there was a day with no visiting birds - There are some methods that can be use to check the existence on an element on a colection. For example [Enumerable#any?][enumerable-any] and [Enumerable#all?][enumerable-all] diff --git a/exercises/concept/bird-count/.docs/instructions.md b/exercises/concept/bird-count/.docs/instructions.md index 859f8a1dcc..1d845f175c 100644 --- a/exercises/concept/bird-count/.docs/instructions.md +++ b/exercises/concept/bird-count/.docs/instructions.md @@ -1,8 +1,10 @@ +# Instructions + You're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days. You have five tasks, all dealing with the numbers of birds that visited your garden. -### 1. Check what the counts were last week +## 1. Check what the counts were last week For comparison purposes, you always keep a copy of last week's counts nearby, which were: 0, 2, 5, 3, 7, 8 and 4. Implement the `BirdCount.last_week` method that returns last week's counts: @@ -11,7 +13,7 @@ BirdCount.last_week # => [0, 2, 5, 3, 7, 8, 4] ``` -### 2. Check how many birds visited yesterday +## 2. Check how many birds visited yesterday Implement the `BirdCount#yesterday` method to return how many birds visited your garden yesterday. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count. @@ -22,7 +24,7 @@ bird_count.yesterday # => 4 ``` -### 3. Calculate the total number of visiting birds +## 3. Calculate the total number of visiting birds Implement the `BirdCount#total` method to return the total number of birds that have visited your garden: @@ -33,7 +35,7 @@ bird_count.total # => 19 ``` -### 4. Calculate the number of busy days +## 4. Calculate the number of busy days Some days are busier that others. A busy day is one where five or more birds have visited your garden. Implement the `BirdCount#busy_days` method to return the number of busy days: @@ -45,7 +47,7 @@ bird_count.busy_days # => 2 ``` -### 5. Check if there was a day with no visiting birds +## 5. Check if there was a day with no visiting birds Implement the `BirdCount#day_without_birds?` method that returns `true` if there was a day at which zero birds visited the garden; otherwise, return `false`: diff --git a/exercises/concept/bird-count/.docs/introduction.md b/exercises/concept/bird-count/.docs/introduction.md index ac17cb6f6b..9633f123f0 100644 --- a/exercises/concept/bird-count/.docs/introduction.md +++ b/exercises/concept/bird-count/.docs/introduction.md @@ -1,7 +1,9 @@ +# Introduction + In Ruby, **arrays** are ordered, integer-indexed collections of any object. Array indexing starts at `0`. A negative index is assumed to be relative to the end of the array — i.e. an index of `-1` indicates the last element of the array, `-2` is the next to last element in the array, and so on. Ruby arrays mix in the [Enumerable module][enumerable-module], which adds several traversal and searching methods, and with the ability to sort. -### Create array. +## Create array. - An array in Ruby can contain different types of objects. @@ -9,7 +11,7 @@ Ruby arrays mix in the [Enumerable module][enumerable-module], which adds severa array = [1, "two", 3.0] #=> [1, "two", 3.0] ``` -### Element Assignment +## Element Assignment Elements can accessed or changed using indexes. Subarrays can be accessed by specifying a start index and a size. @@ -29,7 +31,7 @@ a[-1] = "Z" a #=> ["a", "Z"] ``` -### Element Reference +## Element Reference - Elements in an array can be retrieved using the #[] method. It returns the element at index, or returns a subarray starting at the start index and continuing for length elements. @@ -50,7 +52,7 @@ a[-2] #=> "d" a[-3, 3] #=> [ "c", "d", "e" ] ``` -### Obtaining Information about an Array +## Obtaining Information about an Array Arrays keep track of their own length at all times. To query an array about the number of elements it contains, use length, count or size. @@ -61,7 +63,7 @@ browsers.count #=> 5 browsers.size #=> 5 ``` -### Adding Items to Arrays +## Adding Items to Arrays Items can be added to the end of an array by using either push or << @@ -71,7 +73,7 @@ arr.push(5) #=> [1, 2, 3, 4, 5] arr << 6 #=> [1, 2, 3, 4, 5, 6] ``` -### Removing Items from an Array +## Removing Items from an Array The method pop removes the last element in an array and returns it diff --git a/exercises/concept/boutique-inventory-improvements/.docs/instructions.md b/exercises/concept/boutique-inventory-improvements/.docs/instructions.md index 4ab3742f2a..e567b918f7 100644 --- a/exercises/concept/boutique-inventory-improvements/.docs/instructions.md +++ b/exercises/concept/boutique-inventory-improvements/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You're continuing to work on the stock management system you built previous. Since discovering `OpenStruct` and block shortcuts, you've decided to refactor the code a little. Rather than storing the items as hashes, you're going to utilize your newfound skills. ## 1. Allow retrievable of items diff --git a/exercises/concept/boutique-inventory-improvements/.docs/introduction.md b/exercises/concept/boutique-inventory-improvements/.docs/introduction.md index 2e48d9f647..ca179015f9 100644 --- a/exercises/concept/boutique-inventory-improvements/.docs/introduction.md +++ b/exercises/concept/boutique-inventory-improvements/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Ruby comes with a Standard Library (often shortened to "stdlib") - a collection of classes for working with things such as dates, json, and networking. It also provides some useful functionality for making your code easier to work with. diff --git a/exercises/concept/boutique-inventory-improvements/.meta/design.md b/exercises/concept/boutique-inventory-improvements/.meta/design.md index 7cf1cff56b..bf2ec3a63a 100644 --- a/exercises/concept/boutique-inventory-improvements/.meta/design.md +++ b/exercises/concept/boutique-inventory-improvements/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Understand how to require from Standard Library diff --git a/exercises/concept/boutique-inventory/.docs/instructions.md b/exercises/concept/boutique-inventory/.docs/instructions.md index 1788b3c60b..e5c5843fba 100644 --- a/exercises/concept/boutique-inventory/.docs/instructions.md +++ b/exercises/concept/boutique-inventory/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + You run an online fashion boutique. Your big annual sale is coming up, so you want to create some functionality to help you take stock of your inventory to make sure you're ready. A single item in the inventory is represented by a hash, and the whole inventory is an array of these hashes. diff --git a/exercises/concept/boutique-inventory/.docs/introduction.md b/exercises/concept/boutique-inventory/.docs/introduction.md index ef48f021dc..9611a8a765 100644 --- a/exercises/concept/boutique-inventory/.docs/introduction.md +++ b/exercises/concept/boutique-inventory/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Enumeration is the act of stepping through a collection (`Array`, `Hash`, etc) and performing some action on each object. Enumeration is a key concept in Ruby and is used for sorting (`sort_by`), grouping (`group_by`), mapping (`map`), reducing (`reduce`), and much more. diff --git a/exercises/concept/boutique-inventory/.meta/design.md b/exercises/concept/boutique-inventory/.meta/design.md index 894370943b..bec3e377a5 100644 --- a/exercises/concept/boutique-inventory/.meta/design.md +++ b/exercises/concept/boutique-inventory/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Learning objectives - Learn what enumeration is diff --git a/exercises/concept/lasagna/.docs/after.md b/exercises/concept/lasagna/.docs/after.md index 9b14ae5c43..a7899ac762 100644 --- a/exercises/concept/lasagna/.docs/after.md +++ b/exercises/concept/lasagna/.docs/after.md @@ -1,3 +1,5 @@ +# After + Ruby is a dynamic and strongly typed language. In dynamic languages the type of a variable or object is resolved at runtime, which means that its value or type can be changed up to the very last moment (when it gets parsed by the interpreter). And what do we mean with strongly typed? Once we know the type of a variable or object, Ruby is strict about what you can do with it, for example: diff --git a/exercises/concept/lasagna/.docs/hints.md b/exercises/concept/lasagna/.docs/hints.md index aa6d55dd2f..5e3a996e9e 100644 --- a/exercises/concept/lasagna/.docs/hints.md +++ b/exercises/concept/lasagna/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## 1. Define the expected oven time in minutes - You need to define a [constant][constant] which should contain the [integer][integers] value specified in the recipe. diff --git a/exercises/concept/lasagna/.docs/instructions.md b/exercises/concept/lasagna/.docs/instructions.md index c8ac1801e9..dc37320c40 100644 --- a/exercises/concept/lasagna/.docs/instructions.md +++ b/exercises/concept/lasagna/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you're going to write some code to help you cook a brilliant lasagna from your favorite cooking book. You have four tasks, all related to the time spent cooking the lasagna. diff --git a/exercises/concept/lasagna/.docs/introduction.md b/exercises/concept/lasagna/.docs/introduction.md index 537bc457d9..6dd5819b0b 100644 --- a/exercises/concept/lasagna/.docs/introduction.md +++ b/exercises/concept/lasagna/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Ruby is a dynamic [object-oriented language][object-oriented-programming]. Everything in Ruby is an [object][object]. There are two primary ways to assign objects to names in Ruby - using variables or constants. Variables are always written in [snake case][snake-case]. A variable can reference different objects over its lifetime. For example, `my_first_variable` can be defined and redefined many times using the `=` operator: diff --git a/exercises/concept/lasagna/.meta/design.md b/exercises/concept/lasagna/.meta/design.md index 37a20d6f26..bf0caf3dce 100644 --- a/exercises/concept/lasagna/.meta/design.md +++ b/exercises/concept/lasagna/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the basics of programming in Ruby. diff --git a/exercises/concept/log-line-parser/.docs/hints.md b/exercises/concept/log-line-parser/.docs/hints.md index 66d46458fd..b3f946fdef 100644 --- a/exercises/concept/log-line-parser/.docs/hints.md +++ b/exercises/concept/log-line-parser/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General - The [rubymostas strings guide][ruby-for-beginners.rubymonstas.org-strings] has a nice introduction to Ruby strings. diff --git a/exercises/concept/log-line-parser/.docs/instructions.md b/exercises/concept/log-line-parser/.docs/instructions.md index a12ad4eddf..6f587fe582 100644 --- a/exercises/concept/log-line-parser/.docs/instructions.md +++ b/exercises/concept/log-line-parser/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be processing log-lines. Each log line is a string formatted as follows: `"[]: "`. diff --git a/exercises/concept/log-line-parser/.docs/introduction.md b/exercises/concept/log-line-parser/.docs/introduction.md index b2515ab7bf..94ddba0f50 100644 --- a/exercises/concept/log-line-parser/.docs/introduction.md +++ b/exercises/concept/log-line-parser/.docs/introduction.md @@ -1 +1,3 @@ +# Introduction + A `String` in Ruby is an object that holds and manipulates an arbitrary sequence of bytes, typically representing characters. Strings are manipulated by calling the string's methods. diff --git a/exercises/concept/log-line-parser/.meta/design.md b/exercises/concept/log-line-parser/.meta/design.md index d66f045444..b30bb182e7 100644 --- a/exercises/concept/log-line-parser/.meta/design.md +++ b/exercises/concept/log-line-parser/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the basics of the Concept of Strings in [Ruby][ruby-doc.org-string]. diff --git a/exercises/concept/moviegoer/.docs/hints.md b/exercises/concept/moviegoer/.docs/hints.md index e69de29bb2..93c36d9988 100644 --- a/exercises/concept/moviegoer/.docs/hints.md +++ b/exercises/concept/moviegoer/.docs/hints.md @@ -0,0 +1,2 @@ +# Hints + diff --git a/exercises/concept/moviegoer/.docs/instructions.md b/exercises/concept/moviegoer/.docs/instructions.md index 28831b385c..35a4b3c4a5 100644 --- a/exercises/concept/moviegoer/.docs/instructions.md +++ b/exercises/concept/moviegoer/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you will rewrite `if/else` statements from a movie theater's website into ternary conditionals. ## 1. Check if a moviegoer is entitled to the seniors' discount diff --git a/exercises/concept/moviegoer/.docs/introduction.md b/exercises/concept/moviegoer/.docs/introduction.md index 220dce4dc1..a630b9c8ac 100644 --- a/exercises/concept/moviegoer/.docs/introduction.md +++ b/exercises/concept/moviegoer/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + A ternary conditional in Ruby is a shorter way of writing simple `if/else` statements. If an `if/else` statement contains only two branches, one for when the condition is true and one for when it is false, it can be re-written as a ternary conditional. It uses a combination of the `?` and `:` symbols, often called the ternary operator(s). diff --git a/exercises/concept/savings-account/.docs/hints.md b/exercises/concept/savings-account/.docs/hints.md index 48fe320a80..745fd223f3 100644 --- a/exercises/concept/savings-account/.docs/hints.md +++ b/exercises/concept/savings-account/.docs/hints.md @@ -1,3 +1,5 @@ +# Hints + ## General ## 1. Calculate the interest rate diff --git a/exercises/concept/savings-account/.docs/instructions.md b/exercises/concept/savings-account/.docs/instructions.md index ed013ef5d9..9c6a13b022 100644 --- a/exercises/concept/savings-account/.docs/instructions.md +++ b/exercises/concept/savings-account/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you'll be working with savings accounts. Each year, the balance of a savings account is updated based on the interest rate. The interest rate the bank gives depends on the amount of money in the accounts (its balance): - -3.213% for a negative balance. diff --git a/exercises/concept/savings-account/.docs/introduction.md b/exercises/concept/savings-account/.docs/introduction.md index d295e22232..0b1264d534 100644 --- a/exercises/concept/savings-account/.docs/introduction.md +++ b/exercises/concept/savings-account/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + ## Floating Point Numbers ## Loops diff --git a/exercises/concept/savings-account/.meta/design.md b/exercises/concept/savings-account/.meta/design.md index a0dac57c18..0d28f2a147 100644 --- a/exercises/concept/savings-account/.meta/design.md +++ b/exercises/concept/savings-account/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the concept of floating-point numbers and introduce them to loops. diff --git a/exercises/concept/simple-calculator/.docs/hints.md b/exercises/concept/simple-calculator/.docs/hints.md index e69de29bb2..93c36d9988 100644 --- a/exercises/concept/simple-calculator/.docs/hints.md +++ b/exercises/concept/simple-calculator/.docs/hints.md @@ -0,0 +1,2 @@ +# Hints + diff --git a/exercises/concept/simple-calculator/.docs/instructions.md b/exercises/concept/simple-calculator/.docs/instructions.md index 318bc0db90..f6c1d5f4a7 100644 --- a/exercises/concept/simple-calculator/.docs/instructions.md +++ b/exercises/concept/simple-calculator/.docs/instructions.md @@ -1,3 +1,5 @@ +# Instructions + In this exercise you will be building error handling for a simple calculator. The goal is to have a working calculator that returns a string with the following pattern: `16 + 51 = 67`, when provided with arguments `16`, `51` and `+`. diff --git a/exercises/concept/simple-calculator/.docs/introduction.md b/exercises/concept/simple-calculator/.docs/introduction.md index 82e93186f4..8ffd3b77f5 100644 --- a/exercises/concept/simple-calculator/.docs/introduction.md +++ b/exercises/concept/simple-calculator/.docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Exceptions in Ruby, as in many languages, provide a way of dealing with unexpected events. Proper handling of exceptions is important when trying to prevent your program from crashing. When an exception is raised, either by raising it explicitly or by the Ruby interpreter raising it, the program diverts normal operation and eventually exits with an error message: diff --git a/exercises/concept/simple-calculator/.meta/design.md b/exercises/concept/simple-calculator/.meta/design.md index b6dd82efd7..60c9751522 100644 --- a/exercises/concept/simple-calculator/.meta/design.md +++ b/exercises/concept/simple-calculator/.meta/design.md @@ -1,3 +1,5 @@ +# Design + ## Goal The goal of this exercise is to teach the student the Concept of Exceptions in Ruby. diff --git a/exercises/practice/accumulate/.docs/instructions.append.md b/exercises/practice/accumulate/.docs/instructions.append.md index 1a70f8eb53..64b3ebbc84 100644 --- a/exercises/practice/accumulate/.docs/instructions.append.md +++ b/exercises/practice/accumulate/.docs/instructions.append.md @@ -1,4 +1,4 @@ -## Advanced +# Advanced It is typical to call [#to_enum](http://ruby-doc.org/core-2.3.1/Object.html#method-i-to_enum) when defining methods for a generic Enumerable, in case no block is passed. diff --git a/exercises/practice/high-scores/.docs/instructions.append.md b/exercises/practice/high-scores/.docs/instructions.append.md index 747232e5ac..bc87fa84fd 100644 --- a/exercises/practice/high-scores/.docs/instructions.append.md +++ b/exercises/practice/high-scores/.docs/instructions.append.md @@ -1,3 +1,5 @@ +# Instructions append + In this exercise you're going to instantiate a class and add some instance methods. http://ruby-for-beginners.rubymonstas.org/writing_classes/initializers.html A HighScore accepts an array with one or more numbers, each representing one 'game score'. The Array class can offer inspiration for working with arrays. https://ruby-doc.org/core-2.5.1/Array.html \ No newline at end of file diff --git a/exercises/practice/ocr-numbers/.docs/instructions.append.md b/exercises/practice/ocr-numbers/.docs/instructions.append.md index 8464e8ec63..d15b3c812a 100644 --- a/exercises/practice/ocr-numbers/.docs/instructions.append.md +++ b/exercises/practice/ocr-numbers/.docs/instructions.append.md @@ -1,3 +1,5 @@ +# Instructions append + Some editors trim whitespace. If you rely on trailing whitespace in a multiline string, instead use a format that doesn't rely on trailing whitespace, or adjust the settings in your editor. diff --git a/exercises/practice/robot-name/.docs/instructions.append.md b/exercises/practice/robot-name/.docs/instructions.append.md index 996a5fa781..87b7c00852 100644 --- a/exercises/practice/robot-name/.docs/instructions.append.md +++ b/exercises/practice/robot-name/.docs/instructions.append.md @@ -1,3 +1,5 @@ +# Instructions append + In order to make this easier to test, your solution will need to implement a `Robot.forget` method that clears any shared state that might exist to track diff --git a/exercises/practice/series/.docs/instructions.append.md b/exercises/practice/series/.docs/instructions.append.md index b9ff47e522..3621e908b8 100644 --- a/exercises/practice/series/.docs/instructions.append.md +++ b/exercises/practice/series/.docs/instructions.append.md @@ -1,3 +1,5 @@ +# Instructions append + In this exercise you're practicing iterating over an array, meaning: executing an operation on each element of an array. Ruby has many useful built-in methods for iterations. Take a look at [this article](http://jeromedalbert.com/ruby-how-to-iterate-the-right-way/). Most of the methods listed in the article are not methods specifically for Array, but come from [Enumerable](https://ruby-doc.org/core/Enumerable.html). The article doesn't list iterating over _consecutive elements_. The first challenge is to find a method that does.