I am very new to zig and doing a very simple coding exercise. The question is about scoring words in scrabble and presents a table. As a sort of challenge I wanted to replicate the scoring table as an array of arrays where the index of the outer array represent the points for a letter and the inner arrays contain the letters that match that score. Then I wanted to convert this to a lookup table (really just a flat array of scores) in comptime. I also wanted to be able to change the table without having to change any of the conversion code.
I'm currently having difficulty with the very initial part, declaring the multi dimensional input array. I've tried this:
const point_letters = [_][_]u8 {
[_]u8{'A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T',},
[_]u8{'D', 'G',},
[_]u8{'B', 'C', 'M', 'P',},
[_]u8{'F', 'H', 'V', 'W', 'Y',},
[_]u8{'K',},
[_]u8{},
[_]u8{},
[_]u8{'J', 'X',},
[_]u8{},
[_]u8{'Q', 'Z',},
};
as well as
const point_letters = [_](*[_]u8){
([_]u8{'A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T',}).*,
([_]u8{'D', 'G',}).*,
([_]u8{'B', 'C', 'M', 'P',}).*,
([_]u8{'F', 'H', 'V', 'W', 'Y',}).*,
([_]u8{'K',}).*,
([_]u8{}).*,
([_]u8{}).*,
([_]u8{'J', 'X',}).*,
([_]u8{}).*,
([_]u8{'Q', 'Z',}).*,
};
But they both give the same error pointing at the size for the inner arrays:
error: unable to infer array size