Here is mine, in Python.
Very archaic, long and possibly slow, but it works!
Code:
file_data = open("input.txt", 'r') #import file
number_count = 0 #declare the count for the numbers
a_count = 0 #declare the count for each letter
b_count = 0
c_count = 0
d_count = 0
e_count = 0
f_count = 0
g_count = 0
h_count = 0
i_count = 0
j_count = 0
k_count = 0
l_count = 0
m_count = 0
n_count = 0
o_count = 0
p_count = 0
q_count = 0
r_count = 0
s_count = 0
t_count = 0
u_count = 0
v_count = 0
w_count = 0
x_count = 0
y_count = 0
z_count = 0
for line in file_data: #test each line individually
if line.startswith('a'): #test all possibilities for each line
a_count += 1 #add one to the count every time a certain letter is found
elif line.startswith('b'):
b_count += 1
elif line.startswith('c'):
c_count += 1
elif line.startswith('d'):
d_count += 1
elif line.startswith('e'):
e_count += 1
elif line.startswith('f'):
f_count += 1
elif line.startswith('g'):
g_count += 1
elif line.startswith('h'):
h_count += 1
elif line.startswith('i'):
i_count += 1
elif line.startswith('j'):
j_count += 1
elif line.startswith('k'):
k_count += 1
elif line.startswith('l'):
l_count += 1
elif line.startswith('m'):
m_count += 1
elif line.startswith('n'):
n_count += 1
elif line.startswith('o'):
o_count += 1
elif line.startswith('p'):
p_count += 1
elif line.startswith('q'):
q_count += 1
elif line.startswith('r'):
r_count += 1
elif line.startswith('s'):
s_count += 1
elif line.startswith('t'):
t_count += 1
elif line.startswith('u'):
u_count += 1
elif line.startswith('v'):
v_count += 1
elif line.startswith('w'):
w_count += 1
elif line.startswith('x'):
x_count += 1
elif line.startswith('y'):
y_count += 1
elif line.startswith('z'):
z_count += 1
elif line.startswith('1'): #now for the numbers
number_count += 1
elif line.startswith('2'):
number_count += 2
elif line.startswith('3'):
number_count += 3
elif line.startswith('4'):
number_count += 4
elif line.startswith('5'):
number_count += 5
elif line.startswith('6'):
number_count += 6
elif line.startswith('7'):
number_count += 7
elif line.startswith('8'):
number_count += 8
elif line.startswith('9'):
number_count += 9
print "Sum =", number_count #print the sum
if a_count != 0: #check if the file had this letter
print "a =", a_count #print the letter and its count
if b_count != 0:
print "b =", b_count
if c_count != 0:
print "c =", c_count
if d_count != 0:
print "d =", d_count
if e_count != 0:
print "e =", e_count
if f_count != 0:
print "f =", f_count
if g_count != 0:
print "g =", g_count
if h_count != 0:
print "h =", h_count
if i_count != 0:
print "i =", i_count
if j_count != 0:
print "j =", j_count
if k_count != 0:
print "k =", k_count
if l_count != 0:
print "l =", l_count
if m_count != 0:
print "m =", m_count
if n_count != 0:
print "n =", n_count
if o_count != 0:
print "o =", o_count
if p_count != 0:
print "p =", p_count
if q_count != 0:
print "q =", q_count
if r_count != 0:
print "r =", r_count
if s_count != 0:
print "s =", s_count
if t_count != 0:
print "t =", t_count
if u_count != 0:
print "u =", u_count
if v_count != 0:
print "v =", v_count
if w_count != 0:
print "w =", w_count
if x_count != 0:
print "x =", x_count
if y_count != 0:
print "y =", y_count
if z_count != 0:
print "z =", z_count
The input file should be in the same folder and be called input.txt .
EDIT: Rewritten mine, it's on post #33.
Bookmarks