Seriously, why not flip a coin instead of introducing all kinds of bias?
Math? In my head? Are you insane?
“Well, Mr Snelgrove, I happen to know that in the future I will not have the slightest use for algebra, and I speak from experience.” PSK
I also wrote a little program. I thought there would be close to a 50/50 split between even and odd, and there was when I chose words at random, or short passages. But I was surprised to find when longer passages were used (and I chose passages from several different writers) the split was always around 60% odd, 40% even. There must be some common words used in writing that are odd. This is for Chipmunk Basic:
10 open “/users/gardwitz/desktop/text2.txt” for input as #1
20 text$ = input$(10000,#1)
30 print
40 for char = 1 to len(text$)
50 l$ = mid$(text$,char,1)
60 if l$ = " " or l$ = “.” or l$ = “-” or l$ = “/” or l$ = chr$(10) or l$=chr$(9) then goto 100
70 if asc(l$) >= 97 and asc(l$) <= 122 then v = v+(asc(l$)-96) : word$ = word$+l$ : goto 90
80 if asc(l$) >= 65 and asc(l$) <= 90 then v = v+(asc(l$)-64) : word$ = word$+l$ : goto 90
90 next char
100 if len(word$) = 0 then goto 90
110 print word$ ": " v;
120 word$ = “”
130 if v/2 = int(v/2) then print “even” : v = 0 : e = e+1 : gosub 150 : goto 90
140 print “odd” : v = 0 : o = o+1 : gosub 150 : goto 90
150 if char >= len(text$) then goto 170
160 return
170 print
180 print "Word count: " e+o
190 print "Even: " e " "(e/(e+o))*100 “%”
200 print "Odd: " o " "(o/(e+o))*100 “%”
Edit: But strangely - when I check the words from your link, I get this result:
Word count: 504
Even: 252 50 %
Odd: 252 50 %
So why the 60/40 split with actual writing samples?
Edit again: I think I figured it out. Here’s the top ranked words:
the: 33 odd
of: 21 odd
to: 35 odd
and: 19 odd
a: 1 odd
in: 23 odd
is: 28 even
it: 29 odd
you: 61 odd
that: 49 odd
he: 13 odd
Word count: 11
Even: 1 8.333333 %
Odd: 11 91.666667 %
And top 20 gives 70% odd
Oh and while I’m at it, here’s a little odd music composition of mine using this code modified:
DM: Roll for initiative.
ME: She loves me… She loves me not… She loves me …
That’s an interesting idea. But what encoding do you use for a non-roman alphabet, or even a non-alphabetic language?
When I enter “橙汁” for “orange juice” my algorithm breaks.
Counting the number of strokes seems an obvious solution there.
Carefully place a coin in your mouth. Using your tongue, flip the coin over several times. Remove the coin from your mouth to see which side is up. There. You have done it.
This topic was automatically closed after 5 days. New replies are no longer allowed.