Here is a code golf scoring system where each key has its own cost.  Based on 
the relative speed (for me) difference of typing 'a' vs '+' or ')'.  'a' is 1 
(but scored as 10 to avoid decimal data entry for scoring table).  Spaces are 
free.  This can be easily modified to score an entire script, where all 
whitespace would be free, and perhaps comment characters given a bonus, before 
also being stripped.  Shifted characters generally have "0.4 keystrokes" added 
to them.

The scoring system generally reflects my hatred of typing parentheses, and how 
frequently I mistype some of the characters with high scores, especially in the 
dark. all keys from ascii 32 to 126 are scored.

 
ks =. (] , (23 24 23 16 ,~  4 -~ 26&{.)@:(_32&{.)) 0 23 22 24 25 26 27 18 27 27 
27 28 17 21 18 19 21 15 15 16 16 17 17 18 18 19 17 14 18 21 18 20 22 14 19 15 
16 16 16 17 19 19 18 18 18 18 19 18 19 15 14 16 18 20 16 15 17 20 16 19 20 19 
27 26 12

clearer visualization of score table:

12 16 $ , (;/ ,.~ [: <"0 a. {~ 32 + i.@#) ks 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
| |0 |!|23|"|22|#|24|$|25|%|26|&|27|'|18| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|(|27|)|27|*|27|+|28|,|17|-|21|.|18|/|19| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|0|21|1|15|2|15|3|16|4|16|5|17|6|17|7|18| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|8|18|9|19|:|17|;|14|<|18|=|21|>|18|?|20| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|@|22|A|14|B|19|C|15|D|16|E|16|F|16|G|17| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|H|19|I|19|J|18|K|18|L|18|M|18|N|19|O|18| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|P|19|Q|15|R|14|S|16|T|18|U|20|V|16|W|15| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|X|17|Y|20|Z|16|[|19|\|20|]|19|^|27|_|26| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|`|12|a|10|b|15|c|11|d|12|e|12|f|12|g|13| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|h|15|i|15|j|14|k|14|l|14|m|14|n|15|o|14| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|p|15|q|11|r|10|s|12|t|14|u|16|v|12|w|11| 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 
|x|13|y|16|z|12|{|23|||24|}|23|~|16| |0 | 
+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+ 


 
score =: 10 %~ [: +/ [ {~ 32 -~ a.&i.@]

  ks score '(10 %~ [: +/ [ {~ 32 -~  (a.&i.)@])' 
52.4
  ks score '10 %~ [: +/ [ {~ 32 -~ a.&i.@]' 
41.6 


an alternative score that adds the character count, and average per character 
count (distorted by spaces) 

  ks ([:(, %/) #@:] ,~ 10 %~ [: +/ [ {~ 32 -~ a.&i.@]) '10 %~ [: +/ [ {~ 32 -~ 
a.&i.@]' 
41.6 30 1.38667 


  ks ([:(, %/) #@:] ,~ 10 %~ [: +/ [ {~ 32 -~ a.&i.@]) '[:(, %/) #@:] ,~ 10 %~ 
[: +/ [ {~ 32 -~ a.&i.@]' 
68.3 47 1.45319 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to