Refactor grains/square
Check internally for valid squares. Shift on 1, not two -- the first bit is to mark 0 and 1, and shifting it once will turn it into 2.
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
#include "grains.h"
|
#include "grains.h"
|
||||||
|
|
||||||
unsigned long long square(int n) {
|
unsigned long long square(int n) {
|
||||||
if (!validSquare(n)) return 0;
|
if (n < 1 || n > 64) return 0;
|
||||||
if (n == 1) return 1;
|
return 1ull << (n-1);
|
||||||
return 2llu << (n-2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long total() {
|
unsigned long long total() {
|
||||||
|
|||||||
Reference in New Issue
Block a user