jackson

Finished
1515 * @returns {bigint}
1616 */
1717export const square = (num) => {
18 throw new Error('Remove this line and implement the function');
18 // Edge Case: Square number is less than 1
19 if (num < 1) {
20 throw new Error('square must be between 1 and 64');
21 }
22
23 // Edge Case: Square number is greater than 64
24 if (num > 64) {
25 throw new Error('square must be between 1 and 64');
26 }
27
28 // Calculate grains on square using formula: 2^(n-1)
29 return 1n << BigInt(num - 1);
1930};
2031
2132/**
2233 * @returns {bigint}
2334 */
2435export const total = () => {
25 throw new Error('Remove this line and implement the function');
36 // Calculate total grains using formula: 2^64 - 1
37 return (1n << 64n) - 1n;
2638};
39
40// Handled Edge Cases: Square number less than 1, square number greater than 64
41// Handled Edge Cases: None (this function always returns the same constant value)
Test NameStatus
grains on square 1
Pass
grains on square 2
Pass
grains on square 3
Pass
grains on square 4
Pass
grains on square 16
Pass
grains on square 32
Pass
grains on square 64
Pass
square 0 raises an exception
Pass
negative square raises an exception
Pass
square greater than 64 raises an exception
Pass
returns the total number of grains on the board
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.