Posted By

evandrix on 11/23/10


Tagged

topcoder


Versions (?)

TopCoder Inv 2001 R1


 / Published in: Java
 

URL: http://www.topcoder.com

  1. import java.util.*;
  2.  
  3. public class HowEasy {
  4. public int pointVal(String problemStatement) {
  5. StringTokenizer st = new StringTokenizer(problemStatement, " ");
  6. int totalChars = 0, numTokens = 0;
  7. while(st.hasMoreTokens()) {
  8. String t = st.nextToken();
  9. if (t.matches("[A-Za-z]+\\.?"))
  10. {
  11. totalChars += t.endsWith(".") ? t.length() - 1 : t.length();
  12. numTokens++;
  13. }
  14. }
  15.  
  16. int average = numTokens != 0 ? totalChars / numTokens : 0;
  17. return (average <= 3) ? 250 : (average == 4 || average == 5) ? 500 : 1000;
  18. }
  19. }

Report this snippet  

You need to login to post a comment.