Code Statistics by 0B / 9B / 0B

def get_statistics(s)
  a=[0,0,0,0]
  an=/[a-zA-Z0-9]/
  ws=/[ \t\n]/
  s.each_byte{|x|
    s=x.chr
    a[an=~s ?2:ws=~s ?1: x<127&&x>32?3:0]+=1
  }
  a
end

STDIN.each do |line|
 st = get_statistics(line)
 st = [st[0], st[2], st[3]]
 puts st.map{|x|"#{x}B"}*' / '
end

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page