Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created March 22, 2020 17:46
Show Gist options
  • Save marti1125/221e97b314af9e2faf516c5469656914 to your computer and use it in GitHub Desktop.
Save marti1125/221e97b314af9e2faf516c5469656914 to your computer and use it in GitHub Desktop.
hacker rank conditional statements
package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
)
func main() {
reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
NTemp, err := strconv.ParseInt(readLine(reader), 10, 64)
checkError(err)
N := int32(NTemp)
if N%2 != 0 {
fmt.Println("Weird")
}
if N%2 == 0 && N > 2 && N <= 5 {
fmt.Println("Not Weird")
}
if N%2 == 0 && N > 6 && N <= 20 {
fmt.Println("Weird")
}
if N%2 == 0 && N > 20 {
fmt.Println("Not Weird")
}
}
func readLine(reader *bufio.Reader) string {
str, _, err := reader.ReadLine()
if err == io.EOF {
return ""
}
return strings.TrimRight(string(str), "\r\n")
}
func checkError(err error) {
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment