More reviewed
Files containing only a newline at the end of the file indicate that I have reviewed that task and didn't need to change anything. The file now has a new timestamp indicating it has been reviewed
This commit is contained in:
parent
652ab83563
commit
e3dde8b1ed
|
@ -1,8 +1,8 @@
|
|||
## Operations on Collections (#4)
|
||||
|
||||
`all()`, `none()` and `any()` can be used to produce identical results.
|
||||
Implement the `List<Int>` extension functions `allNonZero()` and `hasZero()`
|
||||
using each of `all()`, `none()` and `any()`.
|
||||
Implement `List<Int>` extension functions `allNonZero()` and `hasZero()` using
|
||||
each of `all()`, `none()` and `any()`.
|
||||
|
||||
- `allNonZero()` checks that all elements in the list are non-zero.
|
||||
|
||||
|
@ -10,4 +10,8 @@ using each of `all()`, `none()` and `any()`.
|
|||
|
||||
The implementations using `all()` are given in the starter code.
|
||||
|
||||
Hint: You can negate the results of `all()`, `none()` or `any()`.
|
||||
<div class="hint">
|
||||
|
||||
You can negate the results of `all()`, `none()` or `any()`.
|
||||
|
||||
</div>
|
||||
|
|
|
@ -9,9 +9,8 @@ class Delegator {
|
|||
}
|
||||
```
|
||||
|
||||
Define `getValue()` and `setValue()` as extension functions to `List<String>`
|
||||
(Hint: IntelliJ IDEA will generate skeletons for you). The code in `main()`
|
||||
will test your solution.
|
||||
Define `getValue()` and `setValue()` as extension functions to `List<String>`.
|
||||
The code in `main()` will test your solution.
|
||||
|
||||
BONUS: Try adjusting `getValue()` and `setValue()` to work with:
|
||||
|
||||
|
@ -23,6 +22,12 @@ class Delegator {
|
|||
|
||||
And explain what happens.
|
||||
|
||||
<sub> This task doesn't contain the automatic tests,
|
||||
it's always marked as "Correct" on "Check".
|
||||
Please compare your solution with the provided one! </sub>
|
||||
<div class="hint">
|
||||
|
||||
IntelliJ IDEA will generate skeletons for you.
|
||||
|
||||
</div>
|
||||
|
||||
<sub> This task doesn't contain automatic tests, so
|
||||
it's always marked as "Correct" when you run "Check".
|
||||
Please compare your solution to the one provided! </sub>
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
Define `var x = 1`. Now define `val y = x` and `val z = y`. Next, assign
|
||||
2 to `x` and display the values of all three identifiers on different lines:
|
||||
first `x`, then `y`, then `z`.
|
||||
first `x`, then `y`, then `z`.
|
||||
|
|
|
@ -11,4 +11,4 @@ filled with sequential numbers in a form of snake. For example, `showSnake(3,
|
|||
```
|
||||
|
||||
For proper alignment, use `"%3d".format(number)` to place any necessary spaces
|
||||
before the number.
|
||||
before the number.
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
Create a function `other()` that takes a `String` parameter and returns a
|
||||
`String` containing every other letter of the parameter. For example, the
|
||||
argument "cement" produces "cmn".
|
||||
argument "cement" produces "cmn".
|
||||
|
|
|
@ -9,4 +9,4 @@ parameters. In `main()`, display the result of combining `first()` and
|
|||
| `first()` Arguments | `second()` Arguments |
|
||||
|---------------------|----------------------|
|
||||
| true, true, true | false, false, false |
|
||||
| true, false, true | false, true, false |
|
||||
| true, false, true | false, true, false |
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Summary 1 (#4)
|
||||
|
||||
This exercise modifies `Overflow.kt` to test `Long` and `Double`. Implement
|
||||
`testLong()` to display the `Long` maximum value incremented by `1`. Make
|
||||
`testLong()` to display `Long`'s maximum value incremented by `1`. Make
|
||||
`testDouble()` display the `Double` maximum value incremented by `1`. Make
|
||||
`testDouble2()` display the result of comparing `Double.MAX_VALUE` and
|
||||
`Double.MAX_VALUE + 1`.
|
||||
`Double.MAX_VALUE + 1`.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## Summary 1 (#5)
|
||||
|
||||
Implement `everyFifth()` to display every fifth number in the given range. For
|
||||
example, `everyFifth(11, 30)` displays the numbers `15`, `20`, `25`, and `30`.
|
||||
example, `everyFifth(11, 30)` displays the numbers `15`, `20`, `25`, and `30`.
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
Implement `everyFifthNonWhitespace()` to display every fifth non-whitespace
|
||||
character in the given text. For example, `everyFifthNonWhitespace("abc d e fgh
|
||||
ik")` displays the characters `e` (fifth character if not counting
|
||||
whitespaces) and `k` (tenth).
|
||||
ik")` displays the characters `e` (the fifth character if not counting
|
||||
whitespaces) and `k` (the tenth).
|
||||
|
|
|
@ -20,4 +20,4 @@ in `121341`:
|
|||
| - | 121341 | 3 |
|
||||
|
||||
The "Removed" values are in the table for clarity, but you don't need a
|
||||
"Removed" variable in your solution.
|
||||
"Removed" variable in your solution.
|
||||
|
|
|
@ -9,4 +9,4 @@ Reverse the digits in a decimal number using a `while` loop. An auxiliary
|
|||
| 123 | 4 |
|
||||
| 12 | 43 |
|
||||
| 1 | 432 |
|
||||
| 0 | 4321 |
|
||||
| 0 | 4321 |
|
||||
|
|
|
@ -10,4 +10,4 @@ following:
|
|||
#######
|
||||
#########
|
||||
###########
|
||||
```
|
||||
```
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
Create a `String` by iterating over a range of characters that you define. The
|
||||
resulting `String` should contain all English letters in alphabetical order:
|
||||
"abc...z".
|
||||
"abc...z".
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## The `in` Keyword (#2)
|
||||
|
||||
Use `step` to write a function that sums only even numbers up to a given
|
||||
number (the parameter).
|
||||
Use `step` to write a function that sums only even numbers, up to a given
|
||||
number (the parameter).
|
||||
|
|
|
@ -6,4 +6,4 @@ Write a function that checks whether a character is a lowercase letter.
|
|||
|
||||
Test to see whether its code is between the codes for `a` and `z`.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,4 +4,8 @@ Write a function that checks whether its `String` parameter is a valid
|
|||
identifier. A valid identifier is a non-empty `String` that starts with a letter
|
||||
or underscore and consists of only letters, digits and underscores.
|
||||
|
||||
Use `s.isEmpty()` to check whether `s` is an empty `String`.
|
||||
<div class="hint">
|
||||
|
||||
Use `s.isEmpty()` to check whether `s` is an empty `String`.
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## Mastering the IDE: `main` Live Template
|
||||
|
||||
`main` is another useful live template, which unfolds the `main()` function
|
||||
declaration for you automatically. Type `main`, and then press
|
||||
<span class="shortcut">&shortcut:ExpandLiveTemplateByTab;</span>. Then call
|
||||
the `foo()` function from `main()` and run `main()` (do you remember the
|
||||
shortcut for that?).
|
||||
The `main` live template automatically produces the `main()` function
|
||||
declaration. Type `main`, and then press <span
|
||||
class="shortcut">&shortcut:ExpandLiveTemplateByTab;</span>. Call the `foo()`
|
||||
function from `main()` and run `main()` (do you remember the shortcut for
|
||||
that?).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
## `var` & `val` (#1)
|
||||
|
||||
Define a `val answer` and set its value to `42`. On the next line, try to
|
||||
Define `val answer` and initialize it to `42`. On the next line, try to
|
||||
reassign `answer` to `43`. What error does Kotlin produce? Fix the error by
|
||||
replacing `val` with `var`. Display the value of `answer` on the console.
|
||||
replacing `val` with `var`. Display the value of `answer` on the console.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## `var` & `val` (#2)
|
||||
|
||||
Define `var a = 10`. Now define a `val b = a`. Now assign `42` to `a` and
|
||||
display both `a` and `b` on different lines.
|
||||
Define `var a = 10` and a `val b = a`. Now assign `42` to `a` and
|
||||
display both `a` and `b` on different lines.
|
||||
|
|
|
@ -12,11 +12,10 @@ println(y) // 1
|
|||
```
|
||||
|
||||
Your code should remain unchanged for different initializers, like `var x =
|
||||
"first"`, `var y = "second"`. Thus, using `x = 2`, `y = 1` is not the expected
|
||||
solution.
|
||||
"first"`, `var y = "second"`.
|
||||
|
||||
<div class="hint">
|
||||
|
||||
You may need to introduce a third auxiliary `val`.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
The <span class="control">`Project`</span> window showing the course structure
|
||||
on the left and <span class="control">`Task description`</span> window on the
|
||||
right are called *tool windows*. You can adjust their size by clicking on the
|
||||
boundary and moving it. You can hide the tool window from the view temporarily
|
||||
boundary and moving it. You can temporarily hide the tool window from the view
|
||||
to make better use of the screen: click the "hide" button (the one with an
|
||||
arrow) at the top right corner of the tool window. To see it again, choose
|
||||
its name by clicking on the right or left side of the screen or by choosing it
|
||||
arrow) at the top right corner of the tool window. To see it again, choose
|
||||
its name by clicking on the right or left side of the screen or by choosing it
|
||||
in the <span class="control">`View | Tool Windows`</span> application menu.
|
||||
|
||||
Hide the <span class="control">`Task description`</span> tool window and
|
||||
then open it again.
|
||||
then open it again.
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
## Mastering the IDE: Project Tool Window
|
||||
|
||||
The icons at the top of the <span class="control">`Project`</span> Tool Window
|
||||
allow to perform several convenient operations.
|
||||
For example, you can locate the currently opened file in the
|
||||
<span class="control">`Project`</span> Tool Window by clicking on the
|
||||
<span class="control">`Scroll from Source`</span> icon.
|
||||
perform several convenient operations. For example, you can locate the
|
||||
currently opened file in the <span class="control">`Project`</span> Tool Window
|
||||
by clicking on the <span class="control">`Scroll from Source`</span> icon.
|
||||
|
||||
Alternatively, press <span class="shortcut">&shortcut:SelectIn;</span> or choose
|
||||
You can also press <span class="shortcut">&shortcut:SelectIn;</span> or choose
|
||||
<span class="control">`Navigate | Select in...`</span> from the menu above.
|
||||
Then choose <span class="control">`Project View`</span> in the open menu.
|
||||
|
||||
Press the <span class="control">`Collapse All`</span> button on the
|
||||
<span class="control">`Project`</span> Tool Window to hide all the
|
||||
project content, then open the current file by trying all the options listed
|
||||
above.
|
||||
project content, then open the current file by trying the options listed
|
||||
above.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## `break` & `continue` (#1)
|
||||
|
||||
Implement a function `readNumbers()` that reads user input in an infinite loop.
|
||||
When the user enters zero, it `break`s from the loop and prints the sum of the
|
||||
entered numbers. If the user enters a non-number, it prints "Not a number:
|
||||
$input" and goes back to accepting input.
|
||||
When the user enters zero, it `break`s from the loop and displays the sum of
|
||||
the entered numbers. If the user enters a non-number, it displays "Not a
|
||||
number: $input" and goes back to accepting input.
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
Complete the implementation of the functions `analyzeStrings1()` and
|
||||
`analyzeStrings2()` provided in the starter code. Each function takes a
|
||||
`List<List<String>>` as an argument and displays its contents to the console.
|
||||
If a `String` is the word `"stop"`, don't display any more elements from the
|
||||
current (inner) `List`. The code in `analyzeStrings1()` uses `break`, while
|
||||
`analyzeStrings2()` uses `continue`. Add the missing labels for `break` and
|
||||
`continue`.
|
||||
parameter which is a `List<List<String>>` and displays its contents to the
|
||||
console. If a `String` is the word `"stop"`, don't display any more elements
|
||||
from the current (inner) `List`. The code in `analyzeStrings1()` uses `break`,
|
||||
while `analyzeStrings2()` uses `continue`. Add the missing labels for `break`
|
||||
and `continue`.
|
||||
|
||||
Now rewrite `analyzeStrings1()` without using labels.
|
||||
|
||||
<div class="hint">
|
||||
|
||||
You can remove all the labels from `analyzeStrings1()` and `break` will
|
||||
jump from the closest inner loop, so this loop doesn't need labels.
|
||||
jump from the closest inner loop, so that loop doesn't need labels.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue