mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-12-22 14:43:10 -05:00
18 lines
474 B
Zig
18 lines
474 B
Zig
const std = @import("std");
|
|
|
|
pub fn score(s: []const u8) u32 {
|
|
var total: u32 = 0;
|
|
for (s) |c| {
|
|
total += switch (std.ascii.toLower(c)) {
|
|
'a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't' => 1,
|
|
'd', 'g' => 2,
|
|
'b', 'c', 'm', 'p' => 3,
|
|
'f', 'h', 'v', 'w', 'y' => 4,
|
|
'k' => 5,
|
|
'j', 'x' => 8,
|
|
'q', 'z' => 10,
|
|
else => unreachable,
|
|
};
|
|
}
|
|
return total;
|
|
}
|