mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-13 23:00:47 -05:00
14 lines
301 B
Zig
14 lines
301 B
Zig
|
const std = @import("std");
|
||
|
|
||
|
pub const ChessboardError = error{IndexOutOfBounds};
|
||
|
|
||
|
pub fn square(index: usize) ChessboardError!u64 {
|
||
|
if (index > 64 or index < 1) return error.IndexOutOfBounds;
|
||
|
|
||
|
return std.math.pow(u64, 2, index - 1);
|
||
|
}
|
||
|
|
||
|
pub fn total() u64 {
|
||
|
return std.math.maxInt(u64);
|
||
|
}
|