Count the total number of letter "F" in the following text:
FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS...
This teaser is called "Alzheimer's' eye test".
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
@Justin Wong It's more of a one-liner. Basically, string.count is the number of times the thing in parentheses appears in the string. It's the following condensed into one operation.
1 2 3 4 5 6 7 8 |
|
Log in to reply
Thanks for the tip! I was thinking copy paste into microsoft word lol
I just read it over letter by letter without reading using words. Couldn't fool me! :P
its 4 simple
Copy the text into a word processing program and then use the search function with Ctrl-F for the letter "f". A good program will tell you the number of occurrences.
Ctrl + F then find F. Count the highlighted letters. Problem solved
PHP:
<?PHP
$string = "FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS...";
echo substr_count($string, "F");
?>
int main() { int b,c=0; char a[]="FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS"; for(b=0;b<strlen(a);b++) { if(a[b]=='F') c=c+1; printf("%d\n",c); }
return 0;
}
since everyone writes a code in his preferred language, here is my C++ code :D :
string s = "FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS...";
int numb = 0;
for ( int i=0; i<s.size(); i++)
if (s[i] == 'F')
numb++;
cout << "Number of F: " << numb;
cout << endl;
return 0;
oh god.. C++ can you teach me ? :v
python code for the problem
given = "FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS..."
count = 0
for i in given:
if i == 'F':
count = count + 1
print count
In a Python interactive window, such as PythonWin:
>>> "FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS...".count('F')
6
(I wouldn't trust myself to count anything myself.)
Dwarfing trust of dilemma syndrome of over study.
Log in to reply
OK, I give up. What does that mean?
Log in to reply
I thought the message was not sent as the internet at the moment could not run while I was trying to click.
Joke to you. Please don't be too serious.
Log in to reply
@Lu Chee Ket – Don't worry. I'm rarely very serious. :)
Log in to reply
@Bill Bell – All right. I think this is how this question can bring people with happiness.
In PYTHON:
Problem Loading...
Note Loading...
Set Loading...
The key thing here is to find the three "F"s in the long words but not to miss the three "F"s in the word "of," which also appears three times. You might miss it if you read the sentence too quickly.
Alternatively,