Last active
September 22, 2023 15:25
-
-
Save ahmaddidiks/4ddde88ddd4ce81c4a40a099e27395f7 to your computer and use it in GitHub Desktop.
Mini challenge kelas Go kak Fitri
This file contains hidden or 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
package main | |
import "fmt" | |
const KALIMAT = "selamat malam" | |
func main() { | |
result := make(map[string]int) | |
for _, rune := range KALIMAT { | |
word := string(rune) | |
fmt.Println(word) | |
value, exist := result[word] | |
if exist { | |
result[word] = value + 1 | |
} else { | |
result[word] = 1 | |
} | |
} | |
fmt.Printf("%v", result) | |
} |
This file contains hidden or 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
package main | |
import "fmt" | |
const max_iter = 15 | |
func main() { | |
for i := 1; i < max_iter+1; i++ { | |
if i%3 == 0 && i%5 == 0 { | |
fmt.Println("FizzBuzz") | |
} else if i%3 == 0 { | |
fmt.Println("Fizz") | |
} else if i%5 == 0 { | |
fmt.Println("Buzz") | |
} else { | |
fmt.Println(i) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment