TopCoder Inv 2001 R1


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

URL: http://www.topcoder.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.