Skip to content

Instantly share code, notes, and snippets.

@qguv
Created October 2, 2011 07:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qguv/1257195 to your computer and use it in GitHub Desktop.
Save qguv/1257195 to your computer and use it in GitHub Desktop.
This is a simple program to calculate the last intelligible 70% of any string of text, also known as Wadsworth's Constant
#! /bin/python
print "Wadsworth's Constant"
theString = raw_input('] ')
theStringLength = len(theString)
WadsworthsAmount = int(round((0.3) * theStringLength))
firstSpace = theString.find(' ', WadsworthsAmount)
if firstSpace == -1:
FinalString = theString[WadsworthsAmount:]
else:
FinalString = theString[firstSpace+1:]
print FinalString
@aelse
Copy link

aelse commented Oct 2, 2011

from sys import argv
str = ' '.join(argv)
print str[str.find(' ', int(round(0.3 * len(str))))+1:]

@qguv
Copy link
Author

qguv commented Oct 2, 2011 via email

@e000
Copy link

e000 commented Oct 3, 2011

(lambda s:(lambda r:s.stdout.write(r[r.find(' ', int(0.3 * len(r)))+1:]+'\n'))(' '.join(s.argv)))(__import__('sys'))

@jabbalaci
Copy link

What about this one?

def wadsworth(s):
    return s[int(30*len(s)/100.+.5):]

@aelse
Copy link

aelse commented Oct 3, 2011

@jabbalaci
That doesn't split the array on whitespace.

@jabbalaci
Copy link

@aelse
No, but it chops off the first 30% of any text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment