Post by MarioGS on Dec 31, 2012 19:04:14 GMT -5
Inspired by a tally a member on the old Sony boards used to keep, I wanted to kow that would hold up so far this season, but looking at every puzzle and counting each letter would be tedious, so I coded a program in C++ that does a lot of the work.
With this program, you enter any puzzle (all-caps only, and no spaces), and it calculates which letter combo is more helpful, or if it's a tie. The result is then added to a tally which can be viewed at any time by entering "R" (for "Results"). You can also manually add or subtract 1 from a combo's tally if needed. To view details about a puzzle you are about to enter, putting an asterisk in front of it will show you how many letters in each combination appear and which is better.
Here is what the various inputs and outputs would look like...
...and here is the code for anybody who wishes to use it. If anyone would like me to modify this to use another letter combination, let me know.
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int cdma;
int bgho;
int ties;
cout<<"BGHO INITIAL VALUE (Default = 0): ";
cin>>bgho;
cout<<"CDMA INITIAL VALUE (Default = 0): ";
cin>>cdma;
cout<<"TIE INITIAL VALUE (Default = 0): ";
cin>>ties;
string puzzle;
int c;
int b;
cout<<endl;
cout<<"Enter your word puzzles to see whether there are more occurences of BGHO or CDMA. Your entries must be in all-caps and cannot have any spaces. You must either omit spaces or replace them with a non-alphabetic symbol. To view a comparison between BGHO and CDMA in a puzzle, enter it with an asterisk (*) in front (Example: *PUZZLE)."<<endl;
cout<<" "<<endl;
cout<<"To add or subtract one from the tally, enter any of the following commands accordingly: +BGHO +CDMA +TIE -BGHO -CDMA -TIE"<<endl;
cout<<" "<<endl;
cout<<"Enter R to view tally results. Enter X to exit the program."<<endl;
cout<<" "<<endl;
while(puzzle!="X") {
cout<<"PUZZLE (no spaces): ";
cin>>puzzle;
c=0;
b=0;
for(int i=0;i<puzzle.length();i++) {
if(puzzle=='C' || puzzle=='D' || puzzle=='M' || puzzle=='A')
c++;
if(puzzle=='B' || puzzle=='G' || puzzle=='H' || puzzle=='O')
b++;
}
if(c>b)
cdma++;
if(b>c)
bgho++;
if(b==c)
ties++;
if(puzzle[0]=='*') {
cout<<"This puzzle has "<<b<<" of BGHO and "<<c<<" of CDMA. ";
if(b>c) {
cout<<"BGHO is the better combination."<<endl;
cout<<" "<<endl;
}
if(c>b) {
cout<<"CDMA is the better combination."<<endl;
cout<<" "<<endl;
}
if(b==c) {
cout<<"Both combinations would have been equally helpful. It's a tie."<<endl;
cout<<" "<<endl;
}
}
if(puzzle=="+BGHO")
bgho += 0;
if(puzzle=="+CDMA")
cdma += 0;
if(puzzle=="+TIE" || puzzle=="+TIES")
ties +=0;
if(puzzle=="-BGHO")
bgho -= 2;
if(puzzle=="-CDMA")
cdma -= 2;
if(puzzle=="-TIE" || puzzle=="-TIES")
ties -= 2;
if(puzzle=="R") {
ties -= 1;
cout<<endl;
cout<<"BGHO: "<<bgho<<endl;
cout<<"CDMA: "<<cdma<<endl;
cout<<"TIES: "<<ties<<endl;
cout<<endl;
}
}
}
With this program, you enter any puzzle (all-caps only, and no spaces), and it calculates which letter combo is more helpful, or if it's a tie. The result is then added to a tally which can be viewed at any time by entering "R" (for "Results"). You can also manually add or subtract 1 from a combo's tally if needed. To view details about a puzzle you are about to enter, putting an asterisk in front of it will show you how many letters in each combination appear and which is better.
Here is what the various inputs and outputs would look like...
...and here is the code for anybody who wishes to use it. If anyone would like me to modify this to use another letter combination, let me know.
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int cdma;
int bgho;
int ties;
cout<<"BGHO INITIAL VALUE (Default = 0): ";
cin>>bgho;
cout<<"CDMA INITIAL VALUE (Default = 0): ";
cin>>cdma;
cout<<"TIE INITIAL VALUE (Default = 0): ";
cin>>ties;
string puzzle;
int c;
int b;
cout<<endl;
cout<<"Enter your word puzzles to see whether there are more occurences of BGHO or CDMA. Your entries must be in all-caps and cannot have any spaces. You must either omit spaces or replace them with a non-alphabetic symbol. To view a comparison between BGHO and CDMA in a puzzle, enter it with an asterisk (*) in front (Example: *PUZZLE)."<<endl;
cout<<" "<<endl;
cout<<"To add or subtract one from the tally, enter any of the following commands accordingly: +BGHO +CDMA +TIE -BGHO -CDMA -TIE"<<endl;
cout<<" "<<endl;
cout<<"Enter R to view tally results. Enter X to exit the program."<<endl;
cout<<" "<<endl;
while(puzzle!="X") {
cout<<"PUZZLE (no spaces): ";
cin>>puzzle;
c=0;
b=0;
for(int i=0;i<puzzle.length();i++) {
if(puzzle=='C' || puzzle=='D' || puzzle=='M' || puzzle=='A')
c++;
if(puzzle=='B' || puzzle=='G' || puzzle=='H' || puzzle=='O')
b++;
}
if(c>b)
cdma++;
if(b>c)
bgho++;
if(b==c)
ties++;
if(puzzle[0]=='*') {
cout<<"This puzzle has "<<b<<" of BGHO and "<<c<<" of CDMA. ";
if(b>c) {
cout<<"BGHO is the better combination."<<endl;
cout<<" "<<endl;
}
if(c>b) {
cout<<"CDMA is the better combination."<<endl;
cout<<" "<<endl;
}
if(b==c) {
cout<<"Both combinations would have been equally helpful. It's a tie."<<endl;
cout<<" "<<endl;
}
}
if(puzzle=="+BGHO")
bgho += 0;
if(puzzle=="+CDMA")
cdma += 0;
if(puzzle=="+TIE" || puzzle=="+TIES")
ties +=0;
if(puzzle=="-BGHO")
bgho -= 2;
if(puzzle=="-CDMA")
cdma -= 2;
if(puzzle=="-TIE" || puzzle=="-TIES")
ties -= 2;
if(puzzle=="R") {
ties -= 1;
cout<<endl;
cout<<"BGHO: "<<bgho<<endl;
cout<<"CDMA: "<<cdma<<endl;
cout<<"TIES: "<<ties<<endl;
cout<<endl;
}
}
}