File names can be wildly varying things, ranging from a simple
303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be considered "human-friendly"?
Inspired by a post by Eduard Florinescu that has since been deleted. His idea was good, but just needed a little fleshing out.
Write a program or function in the language of your choice that can take an string, and determine if it is considered "human-friendly", as defined by this challenge.
Some further details and rules are as follows:
- Input will be a string consisting of the 95 printable ascii characters.
- "human-friendly" shall be defined thusly:
- Exclude the extension in the consideration. An extension is defined as the final period followed by a series of alpha-numeric characters (as few as 1, as many as 6).
- No more than half of the string by length (excluding extension) may consist of the following defined groupings of characters (combined):
- Decimal characters longer than 8 in a row.
- Hexadecimal characters (upper xor lower case) of at least 16 in a row (must consist of letters and numbers, and of which at least a third of the characters are numbers).
- Base64 characters (using
%+=as the special characters) of at least 12 in a row (must consist of letters and numbers, be mixed case, and of which at least a third of the characters are uppercase letters).
- If any of the above groupings overlap in definition (such as one that qualifies as base64, but has 8 digits in a row), choose the longest of them to be excluded.
- Output should be a truthy or falsy value, depending on if the string is considered "human-friendly" or not.
- Assume that only valid input will be used. Don't worry about error handling.
The winner will be determined by the shortest program/function. They will be selected in at least 7 days, or if/when there have been enough submissions. In the event of a tie, the answer that came earlier wins.
Here's a few examples of input and output that your code should be able to handle:
"results_for__michael_greer.txt.zip" => true "Georg Feuerstein - Connecting the Dots.pdf" => true "M People - Search for the Hero-ntuqTuc6HxM.mp4" => true "index.html?v=QTR4WGVTUzFsV3d8NHxvcmlnaW5hbHx8MTExMTAxBHxodHRwOi8vLCwsLHRyLDcsMA%3D%3D.html" => false "ol2DCE0SIyQC(173).pdf" => false "d41d8cd98f00b204e9800998ecf8427e.md5" => false "12792331_807918856008495_7076645197310150318_o.jpg" => false