Use 1 instead of 2, makes the bitshift easier.
This commit is contained in:
parent
22ff7b923d
commit
87f5e242dc
@ -36,7 +36,7 @@ public class DoublesGame {
|
|||||||
if(a == 0) {
|
if(a == 0) {
|
||||||
System.out.println("Goodbye!");
|
System.out.println("Goodbye!");
|
||||||
break;
|
break;
|
||||||
} else if(a != 2 << (n - 1)) {
|
} else if(a != 1 << n) {
|
||||||
System.out.println("Wrong answer, try again.");
|
System.out.println("Wrong answer, try again.");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Correct!");
|
System.out.println("Correct!");
|
||||||
|
@ -34,7 +34,7 @@ int main(void) {
|
|||||||
if(a == 0) {
|
if(a == 0) {
|
||||||
std::cout << "Goodbye!\n";
|
std::cout << "Goodbye!\n";
|
||||||
return 0;
|
return 0;
|
||||||
} else if(a not_eq 2 << (n - 1)) {
|
} else if(a not_eq 1 << n) {
|
||||||
std::cout << "Wrong answer, try again.\n";
|
std::cout << "Wrong answer, try again.\n";
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Correct!\n";
|
std::cout << "Correct!\n";
|
||||||
|
@ -31,7 +31,7 @@ while True:
|
|||||||
if a is 0:
|
if a is 0:
|
||||||
print("Goodbye!")
|
print("Goodbye!")
|
||||||
break
|
break
|
||||||
elif a is not 2 << (n - 1):
|
elif a is not 1 << n:
|
||||||
print("Wrong answer, try again.")
|
print("Wrong answer, try again.")
|
||||||
else:
|
else:
|
||||||
print("Correct!")
|
print("Correct!")
|
||||||
|
@ -32,7 +32,7 @@ do
|
|||||||
then
|
then
|
||||||
echo "Goodbye!"
|
echo "Goodbye!"
|
||||||
break
|
break
|
||||||
elif [ $a -ne $((2 << ($n - 1))) ]
|
elif [ $a -ne $((1 << $n)) ]
|
||||||
then
|
then
|
||||||
echo "Wrong answer, try again."
|
echo "Wrong answer, try again."
|
||||||
else
|
else
|
||||||
|
@ -33,7 +33,7 @@ int main(void) {
|
|||||||
if(a == 0) {
|
if(a == 0) {
|
||||||
printf("Goodbye!\n");
|
printf("Goodbye!\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else if(a != 2 << (n - 1)) {
|
} else if(a != 1 << n) {
|
||||||
printf("Wrong answer, try again.\n");
|
printf("Wrong answer, try again.\n");
|
||||||
} else {
|
} else {
|
||||||
printf("Correct!\n");
|
printf("Correct!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user