Statistics

Problem Statement for "WritingWords"

Problem Statement

Fox Ciel wants to type a word on her old cell phone. The cell phone has only one button. The letter A is typed by tapping the button once, B by tapping it twice in a row, and so on, in alphabetical order. Thus, the last letter Z is typed by tapping the button 26 times without a pause.

You are given a String word. Compute and return the answer to the following question: How many times will Ciel tap the button while typing this word?

Definition

Class:
WritingWords
Method:
write
Parameters:
String
Returns:
int
Method signature:
int write(String word)
(be sure your method is public)

Notes

  • While typing a word, Ciel has to make a short pause after typing each letter, so that the phone can tell when one letter ends and another letter begins. These pauses do not matter in this problem.

Constraints

  • word will contain between 1 and 50 characters, inclusive.
  • Each character in word will be an uppercase English letter ('A'-'Z').

Examples

  1. "A"

    Returns: 1

    One tap types the letter A.

  2. "ABC"

    Returns: 6

    To type ABC, Ciel will do the following: Tap the button once to type A. Tap the button twice to type B. Tap the button three times to type C. The total number of taps is 1+2+3 = 6.

  3. "VAMOSGIMNASIA"

    Returns: 143

  4. "TOPCODER"

    Returns: 96

  5. "SINGLEROUNDMATCH"

    Returns: 183

  6. "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"

    Returns: 1300

  7. "WLRBBMQBHCDARZOWKKYHIDDQSCDXRJMOWF"

    Returns: 411

  8. "XSJYBLDBEFSARCBYNE"

    Returns: 196

  9. "DYGGXXP"

    Returns: 107

  10. "LORELLNMPAPQFWKHOPKMCOQHNWNKUEWHSQM"

    Returns: 465

  11. "BBUQCLJJIVSWMDKQTBXIXMVTRRBLJPTNSNFWZQFJMAFAD"

    Returns: 585

  12. "RWSO"

    Returns: 75

  13. "SBCNUVQHFFBSAQXW"

    Returns: 204

  14. "QCACEHCHZVFRKMLNOZJKPQPXRJXKITZYXACBHHKICQCO"

    Returns: 552

  15. "NDTOMFGDWDWFCGPXIQVKUYTDLCGDEWHTACIOHOR"

    Returns: 469

  16. "TQ"

    Returns: 37

  17. "VWCSGSPQOQMSBOAGUWNNYQXNZLGDG"

    Returns: 423

  18. "PBTRWBLNSAD"

    Returns: 131

  19. "UGUUMOQCDRUBETOKYXHOACHWDVM"

    Returns: 360

  20. "XRDRYXLMNDQTUKWAGMLEJU"

    Returns: 317

  21. "KWCIBXUBUMENMEYATDRMYDIAJXLOGHIQFMZ"

    Returns: 433

  22. "LVIHJO"

    Returns: 76

  23. "VSUYOYPAYULYEIMUOTEHZRIICFS"

    Returns: 413

  24. "PGGKBBIPZZRZUCXAMLU"

    Returns: 261

  25. "FYKGRUOW"

    Returns: 126

  26. "GIOOOBPPLEQLWPHAPJNADQHDCNVW"

    Returns: 325

  27. "TXJBMYPPPHAUXNSPUSGDHIIXQMBFJXJCVUDJ"

    Returns: 488

  28. "UYIBYEBMWSIQYOYGYXYMZEVYPZVJEGEBEOC"

    Returns: 523

  29. "UFTSXDIXTIGSIEEHKCHZDFLILRJQFN"

    Returns: 365

  30. "ZTQRSVBSPKYHSENBPPKQTPDDBUOTBBQCWIVRFXJU"

    Returns: 562

  31. "JDDNTGEIQVDGAIJVWCYAUBWEWPJVYGEHLJXEPBPIWU"

    Returns: 522

  32. "ZDZUBDUBZVAFSPQPQWU"

    Returns: 290

  33. "IFWOVYDDWYVVBURCZM"

    Returns: 283

  34. "YJGFDXVTNUNNESLSPLWUIUPFXLZBKNHKW"

    Returns: 491

  35. "PANL"

    Returns: 43

  36. "CFIRJCDDSOZOYVEGURFWCSFMOXEQMRJOWRGHWLKOBMEAHKGCCN"

    Returns: 601

  37. "ZZZZZAAAAA"

    Returns: 135

  38. "KKKK"

    Returns: 44

  39. "WWW"

    Returns: 69


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: