-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution2.5.2.3.scala #70
Conversation
Signed-off-by: Andreas Roehler <[email protected]>
Signed-off-by: Andreas Roehler <[email protected]>
|
||
def cubesReach1(x: Int): Boolean = { | ||
val a = Cubes.cubes(x) | ||
a.length == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this condition a.length == 1
? The question was, whether the sequence of "cubes" ever reaches the number 1, not whether that sequence consists of a single element.
} | ||
|
||
def cubesReach1(x: Int): Boolean = { | ||
val a = Cubes.cubes(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warum hier Cubes.cubes(x)
und nicht einfach cubes(x)
? Die Funktion cubes
wurde gerade definiert.
Signed-off-by: Andreas Roehler <[email protected]>
val a = Cubes.cubes(x) | ||
a.length == 1 | ||
val a = cubes(x) | ||
a.length == 1 && a(0) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the condition a.length == 1
necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some tests that I would suggest:
assert ( cubesReach1(20) == false )
assert ( cubesReach1(50) == false )
assert ( cubesReach1(100) == true )
assert ( cubesReach1(112) == true )
assert ( cubesReach1(114) == false )
assert ( cubesReach1(778) == true )
For example, the sequence for 778 is [1198, 1243, 100, 1]
.
Signed-off-by: Andreas Roehler <[email protected]>
No description provided.