Skip to main content
2 of 4
added an explanation
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

JavaScript (Node.js), 61 bytes

A lookup table based on the ASCII code of each letter.

s=>Buffer(s).map(c=>t+='50363133463254'[(c^98)%22]-3|0,t=0)|t

Try it online!

###How?

By XOR'ing the ASCII code with 98 and applying a modulo 22, we gather the characters with a non-zero sharpness into the range [0..13]. This results in a lookup table of 14 entries.

If the result of the formula is out of range, we get undefined - 3 | 0, which is 0.

 char. | code | XOR 98 | MOD 22 | sharpness
-------+------+--------+--------+-----------
  'A'  |  65  |   35   |   13   |    +1
  'B'  |  66  |   32   |   10   | 
  'C'  |  67  |   33   |   11   |    -1
  'D'  |  68  |   38   |   16   | 
  'E'  |  69  |   39   |   17   | 
  'F'  |  70  |   36   |   14   | 
  'G'  |  71  |   37   |   15   | 
  'H'  |  72  |   42   |   20   | 
  'I'  |  73  |   43   |   21   | 
  'J'  |  74  |   40   |   18   | 
  'K'  |  75  |   41   |   19   | 
  'L'  |  76  |   46   |    2   | 
  'M'  |  77  |   47   |    3   |    +3
  'N'  |  78  |   44   |    0   |    +2
  'O'  |  79  |   45   |    1   |    -3
  'P'  |  80  |   50   |    6   | 
  'Q'  |  81  |   51   |    7   | 
  'R'  |  82  |   48   |    4   | 
  'S'  |  83  |   49   |    5   |    -2
  'T'  |  84  |   54   |   10   | 
  'U'  |  85  |   55   |   11   |    -1
  'V'  |  86  |   52   |    8   |    +1
  'W'  |  87  |   53   |    9   |    +3
  'X'  |  88  |   58   |   14   | 
  'Y'  |  89  |   59   |   15   | 
  'Z'  |  90  |   56   |   12   |    +2
Arnauld
  • 197.6k
  • 20
  • 179
  • 650