Find the most important character

The challenge is to write a program that outputs the most occurrent character in the input string, excluding these bracketing characters ()[]{}. Each submission should consist only of non-trivial* characters. Each solution is scored using the formula in the scoring section. Bracketing characters are allowed in the program, but may not be selected by the program as the most occurrent character. In cases where letters occur with the same frequency, any or all of the characters may be returned.

*Non-trivial is defined in this case to be a character that contributes to the functionality of the program. If the character can be removed without influencing how the program runs, it is a trivial character.


Score is determined as follows:

$$(\frac{n_{char}}{n_{total}}) * 100(\%) $$

With nchar being the number of occurrences of the most frequent character in the input, and ntotal being the total number of non-trivial characters in the input. With this scoring criteria, all scores should be within the range \$[0,100]\$

Highest scoring solution per language wins.


Solutions should take in any valid string as input. A convenient method of determining the most occurrent character in the program itself would be to use the program's source code as input to the program itself. The program does not have to check for non-trivial characters, as they should not be included in the program source.


A single character with the highest percentage occurrence. Each solution should be capable of outputting standard ASCII, as well as the language's codepage (if applicable).


Creative solutions are encouraged. Boring solutions with long padded strings substituted in for numbers are discouraged. Standard loopholes are disallowed.









a or b or ab

Sandbox Link


5 Answers 5


05AB1E, 99.999999999999999957%

1111111111111111111 ... (9352835025086960662 1's total) ... 11111g₅B.V

g gets the length of the large integer literal. Obviously this is too long for TIO, so try a version using 9352835025086960662 instead of the equivalent 1111...1111g.

  • \$\begingroup\$ In theory you can get a higher score by just having worse 05ab1e code after base change? \$\endgroup\$ Feb 12, 2020 at 17:45
  • 2
    \$\begingroup\$ @ExpiredData yes, getting arbitrarily close to 100% is trivial. I could also use base 9999 instead of base 255 for extra bloat. This is the highest I can get while sticking to the pseudo-rule Boring solutions with long padded strings are discouraged. \$\endgroup\$
    – Grimmy
    Feb 12, 2020 at 17:47

JavaScript (Node.js), 55.85% (or much more)


Try it online!

This is a 'fair' version, in that only the payload binary data is included (7 bits per character). But the score could be made arbitrary large by padding each encoded character with as many zeros as desired. They would still be 'non-trivial' as per the challenge rule, as removing any of them would break the decoding.

The binary string is decoded as:


PHP, 75%

foreach(count_chars($argn)as$c)$o[]=$c*'1111111111111111111111111111111111111111001111111111111111111111111111111111111111111111111010111111111111111111111111111110101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'[$i++];arsort($o);echo chr(key($o));

Try it online!


// table of valid input chars - ASCII 0-255
// index is the ASCII number, and 1 or 0 if it is valid
$valid_chars = '1111111111111111111111111111111111111111001111111111111111111111111111111111111111111111111010111111111111111111111111111110101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111';

// get input string and aggregate count of each letter
$counted_chars = count_chars( $argn );

// iterate through each 
foreach( $counted_chars as $ascii => $count ) {
    // multiply count by either 1 if valid or 0 if not
    $out[] = $count * $valid_chars[ $ascii ];

// sort resulting list descending
arsort( $out );

// display the ASCII value of the "most popular" valid char
echo chr( key( $out ) );

Counts the frequency of each character and uses a lookup table to to determine if a given character is excluded (example: ()[]{}) from being counted. Sorts by frequency and returns the "most important" remaining char.

Note: PHP's count_chars() only counts ASCII chars 0-255 which corresponds to the array of valid chars, so is not arbitrarily or unnecessarily long. Using a lookup table of flags to test the validity of a result is, while not the most efficient in this case, a valid and commonly-used programming practice.


05AB1E, tends to 50%


Try it online!

You can keep appending ".V" before the final J, any part of this string can't be removed and hence none of the characters themselves are non-trivial. Hence this tends to 50% of the program being " as you add more ".V"

Note: you couldn't have a single char command to tend to 66% inside the brackets like "J" as it can likely be shortened to ""


C (gcc), 13.2% ;

float m;a[256];l;t;c;n(char*s){bzero(a,1024);l=0;for(;*s;){a[*s]++;s++;l++;};m=0;t=0;for(;t++<255;)if(a[t]>m)c=t,m=a[t];m*=100;printf("%c %f\n",c,m/l);}

This version doesn't pad the end with semicolons. It only contains a few unneeded ones to push up my score to the next percent.

Feel free to add semicolons up until you get 100%.

Try it online!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.