Woohoo!
This is a concerning a recent code-lenght thread in C board. The original challenge is here: KAMIL
I finally managed to squeeze it into the 256 bytes. This would be 240 bytes, if you removed the comments and whitespace (230 if you removed cin.get(); too. (Although the filename probably should come from command line?) I get 16 points!!!
Anyone care to score more?
The test file I used and the output:Code:#include<iostream> #include<fstream> #include<string> using namespace std; int main(){ string s; string t="TDLF"; ifstream f("test.txt"); while(f>>s){ int c=1; for(size_t i=0;i<s.size();i++) c*=t.find(s[i])==t.npos?1:2; /*man I'm PROUD of the t.npos thing, hopefully legal for all std::string implementations?*/ cout<<c<<endl; } cin.get(); //could remove that for extra 10 bytes }
#Edit: found ways to get rid of a few more bytes.FILIPEK
FATLEAD
NORMAL
WOW
DELFI
WOOHOO
output: 4 16 2 1 8 1