This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear up text in the second chapter
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
\begin{Exercise}[title={FizzBuzz},difficulty=1] | ||
\label{ex:fizzbuzz} | ||
\Question \label{ex:fizzbuzz q1} Solve this simple problem called | ||
the Fizz-Buzz \cite{fizzbuzz} problem: | ||
\begin{quote} | ||
Write a program that prints the numbers from 1 to 100. But for multiples | ||
of three print "Fizz" instead of the number and for the multiples of | ||
five print "Buzz". For numbers which are multiples of both three and | ||
five print "FizzBuzz". | ||
\end{quote} | ||
\end{Exercise} | ||
|
||
\begin{Answer} | ||
\Question The hard part was probably writing the thing in Go. A possible | ||
solution to this simple problem is the following program. | ||
\lstinputlisting[label=src:fizzbuzz,caption=Fizz-Buzz]{ex-basics/src/fizzbuzz.go} | ||
\end{Answer} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fizz := 3 | ||
buzz := 5 | ||
for i := 1; i < 100; i++ { | ||
if i%fizz == 0 { | ||
fmt.Printf("Fizz") | ||
} else if i%buzz == 0 { | ||
fmt.Printf("FizzBuzz") | ||
} else { | ||
fmt.Printf("%v", i) | ||
} | ||
fmt.Println() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters