-
Notifications
You must be signed in to change notification settings - Fork 164
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
Lab 1: Fibonacci #514
Lab 1: Fibonacci #514
Conversation
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.
Looking good so far.
- Please write a proper PR description.
- Review someone elses PR
- Fix CI failure (run
gofmt
andgoimports
, you can usually configure your IDE to run these automatically)
01_fib/nicholsk/main.go
Outdated
fmt.Fprintln(out, sum) | ||
|
||
// update variables for next iteration | ||
previous = current |
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.
You can use multiple assignment here without worrying about overwriting
previous, current = current, sum
You can actually use this before the print to remove the sum variable.
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.
Neat! Thanks Dan 👍
|
||
fib(-1) | ||
|
||
expected := strconv.Quote("fib(n) doesn't accept negative integers\n") |
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.
👍 for testing your implementation.
Codecov Report
@@ Coverage Diff @@
## master #514 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 107 108 +1
Lines 1861 1876 +15
=====================================
+ Hits 1861 1876 +15
Continue to review full report at Codecov.
|
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.
Please read through the Collected Code Review Comments and fix commit messages with git rebase -i HASH
.
} | ||
|
||
func fib(n int) { | ||
|
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.
Unnecessary blank line.
No need for blank lines at beginning or end of block.
Use blank lines between type, method and function definitions and within a block for logical separation.
Please fix throughout codebase.
|
||
current, previous := 1, 0 | ||
|
||
// print first value which is always 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.
No really needed if you rearrange printing within your loop:
n1, n2 := 1, 1
for i := 0; i < n; i++ {
fmt.Println(n1)
n1, n2 = n2, n1+n2
}
Sorry it took so long to get back to this PR - feel free to reach out to me personally and I will get right to it if/when your update is ready. |
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.
Looks good to me. Through testing, neat code.
Fixes #539
Review of colleague's PR #379
Changes proposed in this PR: