aboutsummaryrefslogtreecommitdiff
path: root/2022/03/common.rs
diff options
context:
space:
mode:
Diffstat (limited to '2022/03/common.rs')
-rw-r--r--2022/03/common.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/2022/03/common.rs b/2022/03/common.rs
new file mode 100644
index 0000000..cf323f5
--- /dev/null
+++ b/2022/03/common.rs
@@ -0,0 +1,7 @@
1pub fn value(c: char) -> i64 {
2 match c {
3 'a'..='z' => (c as i64) - ('a' as i64) + 1,
4 'A'..='Z' => (c as i64) - ('A' as i64) + 27,
5 _ => panic!("Error: unexpected character '{}'", c)
6 }
7}

Generated with cgit - Back to sebastiano.tronto.net