Created
March 22, 2020 17:46
-
-
Save marti1125/221e97b314af9e2faf516c5469656914 to your computer and use it in GitHub Desktop.
hacker rank conditional statements
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
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