#!/usr/bin/ruby

var base = ('A'.ord - 1)

var n = DATA.slurp.chomp.split(/\s*,\s*/)                     \
            .map { |s| s - /"/g }.sort.uniq                   \
            .map { |s| s.chars.sum { |sym| sym.ord - base } } \
            .sum_kv { |idx, val| val * (idx+1) }

assert_eq(n, 5738);
say "** Test passed!";

__DATA__
"LISA","MARY","PATRICIA","LINDA","BARBARA",
"MARIA","ELIZABETH","JENNIFER","MARIA","SUSAN",
"MARGARET","DOROTHY","LISA","NANCY","KAREN","MARY"
