Score function added

Added a function to calculate the score.