id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaHashSumLetters
prev  |  next  |  chance

Given an input String, consider only the letters and return the sum of the Caesar-adjusted number values ('A'==1, 'B'==2, 'a'==1, 'b'==2) of the letter characters inside. The input String will have a variety of characters (not all letters). Treat lowercase and uppercase letters as having the same numeric value for purposes of this problem.


This is the first in a series of problems about cryptographic hash functions, which take in data of varying length and produce a smaller amount of data, often of a fixed length.  A cryptographic hash can be used to determine data integrity of a message, or even to determine whether a user knows a secret such as a password without actually knowing the secret yourself.  All the hash functions in these exercises are quite bad because they do not react strongly to small changes in input data, which should make them have wildly different results.  For more about cryptographic hashing try the following simplified explainer, or the more complex version.
https://simple.wikipedia.org/wiki/Cryptographic_hash_function
https://en.wikipedia.org/wiki/Cryptographic_hash_function
HINT
String upper = str.toUpperCase();
char a = upper.charAt(0);
boolean isLetter = Character.isLetter(a);

apcsaHashSumLetters("A") → 1
apcsaHashSumLetters("ABC") → 6
apcsaHashSumLetters("Hi") → 17

...Save, Compile, Run (ctrl-enter)

public int apcsaHashSumLetters(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 310

Copyright Nick Parlante 2017 - privacy