Created
October 2, 2011 07:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
Wow! Didn't think of that! Very clever.
(lambda s:(lambda r:s.stdout.write(r[r.find(' ', int(0.3 * len(r)))+1:]+'\n'))(' '.join(s.argv)))(__import__('sys'))
What about this one?
def wadsworth(s):
return s[int(30*len(s)/100.+.5):]
@jabbalaci
That doesn't split the array on whitespace.
@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
from sys import argv
str = ' '.join(argv)
print str[str.find(' ', int(round(0.3 * len(str))))+1:]