-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmethods.rb
More file actions
105 lines (89 loc) · 2.35 KB
/
methods.rb
File metadata and controls
105 lines (89 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# *****************************************************
#
# Methods
#
# Write the three methods below. Use the tests in
# `test.rb` to verify that they work
# correctly. DO NOT print any info to the console.
#
# *****************************************************
# sleep_in?
#
# Students sleep in if it is not a weekday or we're on vacation.
#
# > Parameters
# ------------
# * weekday - true only if it is a weekday
# * vacation - true only if the student is on vacation
#
# TODO - write sleep_in?
# monkey_trouble?
#
# We have two monkeys, a and b, and the parameters a_smile and b_smile
# indicate if each is smiling.
# We are in trouble if they are both smiling or if neither of them is smiling.
# Return true if we are in trouble.
#
# > Parameters
# ------------
# * a_smiling - true only if monkey a is smiling
# * b_smiling - true only if monkey b is smiling
#
# TODO - write monkey_trouble?
# sum_double
#
# Given two int values, return their sum. Unless the two values are the same,
# then return double their sum.
#
# > Parameters
# ------------
# * a - an integer
# * b - an integer
#
# TODO - write sum_double
# *****************************************************
#
# Testing
#
# Write the three methods below, but this time the
# tests are not given to you, so write those first.
#
# *****************************************************
# blackjack
#
# Given 2 int values greater than 0, return whichever value is nearest to 21
# without going over. Return 0 if they both go over.
#
# > Parameters
# ------------
# * a - an integer
# * b - an integer
#
# TODO - write blackjack (tests first)
# n_twice
#
# Given a string and an int n, return a string made of the first and last n
# chars from the string.
#
# Hint | Use string.slice
# | http://ruby-doc.org/core-2.2.0/String.html#method-i-slice
#
# > Parameters
# ------------
# * str - a string with length at least n
# * n - an integer
#
# TODO - write n_twice (tests first)
# close_far
#
# Given three ints, a b c, return true if one of b or c is "close" (differing
# from a by at most 1), while the other is "far", differing from both other
# values by 2 or more. Note: n.abs computes the absolute value of number n.
#
# > Parameters
# ------------
# * a - an integer
# * b - an integer
# * c - an integer
#
# TODO - write close_far (tests first)