Use 1 instead of 2, makes the bitshift easier.

This commit is contained in:
Nicolás A. Ortega 2017-04-02 14:24:14 +02:00
parent 22ff7b923d
commit 87f5e242dc
No known key found for this signature in database
GPG Key ID: 3D786FB3123FF1DD
5 changed files with 5 additions and 5 deletions

View File

@ -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!");

View File

@ -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";

View File

@ -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!")

View File

@ -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

View File

@ -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");