From 87f5e242dcae732c929dde89d2bc31a0968a0154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Sun, 2 Apr 2017 14:24:14 +0200 Subject: [PATCH] Use 1 instead of 2, makes the bitshift easier. --- src/DoublesGame.java | 2 +- src/Main.cpp | 2 +- src/doublesgame.py | 2 +- src/doublesgame.sh | 2 +- src/main.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DoublesGame.java b/src/DoublesGame.java index a58c7b7..8f31cb2 100644 --- a/src/DoublesGame.java +++ b/src/DoublesGame.java @@ -36,7 +36,7 @@ public class DoublesGame { if(a == 0) { System.out.println("Goodbye!"); break; - } else if(a != 2 << (n - 1)) { + } else if(a != 1 << n) { System.out.println("Wrong answer, try again."); } else { System.out.println("Correct!"); diff --git a/src/Main.cpp b/src/Main.cpp index 2c9f432..c83d786 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -34,7 +34,7 @@ int main(void) { if(a == 0) { std::cout << "Goodbye!\n"; return 0; - } else if(a not_eq 2 << (n - 1)) { + } else if(a not_eq 1 << n) { std::cout << "Wrong answer, try again.\n"; } else { std::cout << "Correct!\n"; diff --git a/src/doublesgame.py b/src/doublesgame.py index fab62a6..cd1cc81 100755 --- a/src/doublesgame.py +++ b/src/doublesgame.py @@ -31,7 +31,7 @@ while True: if a is 0: print("Goodbye!") break - elif a is not 2 << (n - 1): + elif a is not 1 << n: print("Wrong answer, try again.") else: print("Correct!") diff --git a/src/doublesgame.sh b/src/doublesgame.sh index fed6865..e84c903 100755 --- a/src/doublesgame.sh +++ b/src/doublesgame.sh @@ -32,7 +32,7 @@ do then echo "Goodbye!" break - elif [ $a -ne $((2 << ($n - 1))) ] + elif [ $a -ne $((1 << $n)) ] then echo "Wrong answer, try again." else diff --git a/src/main.c b/src/main.c index de41a5c..8fbf6ec 100644 --- a/src/main.c +++ b/src/main.c @@ -33,7 +33,7 @@ int main(void) { if(a == 0) { printf("Goodbye!\n"); return 0; - } else if(a != 2 << (n - 1)) { + } else if(a != 1 << n) { printf("Wrong answer, try again.\n"); } else { printf("Correct!\n");