Skip to content

Commit 74a3fe9

Browse files
Readme for passed_failed function
1 parent 244f424 commit 74a3fe9

File tree

1 file changed

+25
-0
lines changed
  • workshop_registration_infakt_cracow/ex1

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Group students into passed and failed.
2+
3+
---
4+
5+
Write a function that returns hash of failed and passed students.
6+
7+
**Requirements:**
8+
* function takes 2 arguments:
9+
* first argument is a hash of students and their grades
10+
* second argument is a threshold that divides students between
11+
those who passed and those who failed
12+
* function returns hash with two keys - `:failed` and `:passed`, each containing
13+
hash with failed and passed students
14+
* function should work flawlessly even when second argument is a string
15+
16+
**Example usage:**
17+
```ruby
18+
hash = {"Mark" => 10, "Ellen" => 65, "Roger" => 20, "Mike" => 70}
19+
passed_or_failed(hash, "65")
20+
```
21+
22+
__Output__:
23+
```ruby
24+
=> { passed: { "Ellen" => 65, "Mike" => 70 }, failed: { "Mark" => 10, "Roger" => 20 } }
25+
```

0 commit comments

Comments
 (0)