Practice Problems (Mixed Code)¶
Given a day
of the week encoded as 0=Sun, 1=Mon, 2=Tue, …6=Sat, and a boolean
indicating if we are on vacation
, return a string of the form "7:00"
indicating when the alarm clock should ring. Weekdays, the alarm should be "7:00"
and on the weekend it should be "10:00"
. Unless we are on vacation – then on weekdays it should be "10:00"
and weekends it should be "off"
.
Example Input |
Expected Output |
---|---|
|
|
|
|
|
|
You and your date are trying to get a table at a restaurant. The parameter you
is the stylishness of your clothes, in the range 0..10, and date
is the stylishness of your date’s clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very stylish, 8 or more, then the result is 2
(yes). With the exception that if either of you has style of 2 or less, then the result is 0
(no). Otherwise the result is 1
(maybe).
Example Input |
Expected Output |
---|---|
|
|
|
|
|
|
Create the method front_back(str, start, end)
that takes three strings and returns
a string based on the following conditions.
If
str
containsstart
at the beginning andend
at the end then return"s_e"
.If
str
containsstart
at the beginning of the string return"s"
.if
str
containsend
at the end of the string return"e"
.Otherwise return
"n"
.
Example Input |
Expected Output |
---|---|
|
|
|
|
|
|
|
|
|
|