Need some hints please!

Associate
Joined
8 Oct 2006
Posts
1,236
Hey all,

Not coded for a while, and my problem solving skills leave a lot to be desired at the moment!

Basically, looking to code up a system, and stumped about a small problem of it, to return percentages of probability of guesses,

A comma seperated text file of hundreds of different values in format:

James, 23, 44
Mark, 12, 12
Rick, 77,32
Mark 14, 47
James, 27,27
Rick, 16, 18
James, 23, 23
Mark, 44, 55
James, 23, 44
....

User interaction would be:

User enters: Name and a number

Then program should then find all the rows which start with that name and return percentage of when the 2nd column was guessed, in relation to the true value (third column)

When 'james & 23' was choosen, probability has been:

45% - 23
20% - 44
...etc

Any hints please? Thinking of doing it in Python. Thanks a lot,
 
In Perl

open(my $stupidfile, "filename") or die "can't open $stupidfile\n";
my %NameSugggestion;
my %NameCorrect;
my $NumberGuesses;
while(my $line = <$stupidfile>){
my ($name, $guess, $correctans) = split /,/, $line;
$NameSuggestion{$name}{$guess}++;
$NameCorrect{$name} = $correctans;
$NumberGuesses{$name}++;
}

$name = "Bob";
$guess = "12":

print "There where $NumberGuesses{$name}{$guess} guesses for $name and value $guess\n";

my $prob = $NameSuggestion{$name}{$guess}/$NumberGuesses{$name}*100;

print "Out of all guesses for $name $prob%where for value $guess\n";
 
I'm not going to do your homework for you. I've got that script working with some minor edits within 90 seconds - so perhaps you should go and try a little harder young man.

LOL :D

@OP: Maybe you should work out the logic and work from there, i know some people think you should just jump straight in and code but if you aren't too sure where to start try just typing up the logic in Notepad or something in a made up pseudo code and go from there.

Lets face it if you can't work this out or put the effort in maybe a programming subject isn't the best thing for you. :/
 
Back
Top Bottom