![]() |
Quote:
Unfortunately, my programming teacher taught me too well, and I refuse to go down that path...! :D EDIT: It was too tempting. Below is C code which, although only slightly obfuscated, computes the result using a divide-and-conquer approach. The first parameter is the sentence, and the second is the letter to count (e.g. $>./a.out 'hello there' e). It prints out -1 if not called correctly. Code:
int f(char *s, char l, int a, int b) { return a==b?s[a]==l:f(s,l,a,(a+b)/2)+f(s,l,((a+b)/2)+1,b); } |
Couldn't find this for OS X (not that I look that much :P), but if you got a PC around, or Bootcamp and such, heres an easier way ;)
http://www.softpedia.com/get/Office-...Software.shtml Maybe I'll put some long and useless javascript code later, I gtg right now..:P |
Much as I've enjoyed the coding challenge that has ensued the original post was to illustrate a quirk of the brain. Apparently most people only see 3 Fs.
Now code-on :D . I am interested to see where this might lead. |
Well, I tried it in javascript, but it got too messy, and too complicated to debug.. :p
Besides, who needs code anyway, when you could do this in Quartz Composer in under 5 mins? :) Below is the QC file, containing only 3 base patches: String Components, Structure Count, and Mathematical Expression. Then I added a Image with string and Sprite patches so the result can be seen in the viewer window. :p I've also build a "codeless" cocoa app in Xcode, using the QC file as the "logic". And my app can count any letter, symbol, word, or phrase the user wants, so it's already better than all of y'all's :D Download here :P |
Quote:
|
Quote:
Code:
-- AppleScript can discern class within a list. |
I find that the simplest way to find the fs was to hit [Command]+[F] and hit 'Next' a few times.
The answer was indeed, 6. However, when i counted manually before hitting 'Find', I failed to count the 'F's in the 'of's. |
Quote:
BTW, does the app at least work properly? Anyone tried it:p? I know it has a few bugs with main window when opening and closing the app, but does it count right?:) |
Quote:
It counted correctly, and I noticed the search is case sensitive, too. I searched "Dimple monkey twice the pudding octopi for tango man" for first "i" (4) then "I" (0). |
Okay, so I fixed some changed some stuff around. First I added a checkbox that asks you whether you want the search to be case sensitive or not. I had to triple the number of patches just for that;). Then I fixed one bug that under some circumstances, when the main text field was empty, and the search field contained something, the frequency would show -1. I added a quick conditional patch that displays "0" whenever the output displays a negative number. I also did some small interface changes, and stuff like that..
Download qc file and app here for anyone that's interested. That was actually pretty fun :D There should be more small, silly, programming contests on this forum, kinda like some forums have photoshop contests or what not :D Now I'm going to go and try to write a "F" counter program for my TI-84+ Silver Edition :p:) |
Probabilistic Method
Quote:
Quote:
Code:
#define VAL_UPDATE_BOUND 1000000$> ./a.out 'FINISHED FILES ARE THE RESULT OF YEARS OF SCIENTIFIC STUDY COMBINED WITH THE EXPERIENCE OF YEARS' F HITS: 739 MISSES: 10962 GUESS: 6 Not as compact as my previous entries though.... :p |
Good grief! I had myself wholly convinced that you all were nutters and the sentence in fact only had 3 F's in it. I was going to write an extended rant about how you all are idiots, then I decided to run a simple test on my own. I put the line into a text editor and starting deleting every letter that wasn't an F.
Didn't take me long to see that there were in fact 6 Fs, and that for some reason my mind was completely skipping over the Fs in the world "of". How ridiculous! Why on earth does that happen? Fastzp, is there an explanation for this? |
It's becuase we do nto raed letetrs, we raed wrods!
|
I just wanted to pipe up and say that I have enjoyed this thread even though I did not participate (might have something to do with being ancient and having learned practically dead languages back in the day...Cobol anyone? :p How about Fortran IV?...)
Anyway, Felix_MC, shouldn't you be working on homework, not fooling around here:D I seem to remember some last minute crises (hmm, interviews...losing your a$$ in stock games...):rolleyes::) |
Quote:
Quote:
|
Quote:
|
Quote:
Ah... Math and girls... What more could you ask for?:D Quote:
Last time I checked the fee was $15 :D Quote:
|
Quote:
|
Quote:
|
Quote:
|
| All times are GMT -5. The time now is 04:33 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.