Skip to main content
1 of 2
SomoKRoceS
  • 1.5k
  • 5
  • 5

Source Code Character Frequency


Write a program using SBCS that get a single byte character as an input and prints the frequency of that character in the program's source code (percentage format) as an output.

Example:

Assuming my program is: ab#cd%b then the output of the program should be:

input output ----- ------ a 14.29% b 28.57% # 14.29% c 14.29% d 14.29% % 14.29% 

Notes:

  • Output must be in percentage format.
  • Printed value must be with 2 digits after decimal (Print 15.00%, not 15%. print 15.12%, not 15.12345%).
  • You man trim the rest of the digits after decimal in any way you want (ceiling, round, floor, simple trimming, ...)

Scoring:

This is - the shortest code wins.

SomoKRoceS
  • 1.5k
  • 5
  • 5