reset password
Author Message
Anonymous
Posts: 166
Posted 00:03 Mar 13, 2014 |

Since everbody is asking questions (even though its past the due date) i had a question about the calculateMoney Method. How exactly do you make it so that draw is calculated in the method. I used something similar to the calculate bid but im still getting the wrong answer in the test field my normal moves are calculated but not the draw moves.

ex.

            if (first_moves[i] == second_moves[i]){
                if (draw % 2 ==1) {
                    first_money -= first_moves[i];

                    draw++;
                } 
                else {
                    second_money -= second_moves[i];
                    draw++;
                }

ytsai8
Posts: 47
Posted 00:15 Mar 13, 2014 |

Is it because you say if(draw%2 ==1) player1 wins?

draw starts at 0 (I assume this is how you write), so  0 % 2 == 0, so when the first draw happens p2 wins.

you might want to change it to if(draw%2==0) OR just initialize draw = 1;

Anonymous
Posts: 166
Posted 00:37 Mar 13, 2014 |

I tried doing both yet they both still fail the test. frown

ytsai8
Posts: 47
Posted 00:43 Mar 13, 2014 |

int draw = 1;   //player 1 has the tieBreaker

 if(draw==1){
                    p1Money -= first_moves[i];
                    draw = 2;   //now player 2 has tie breaker
                }
                else if(draw==2){
                    p2Money -= second_moves[i];
                    draw = 1;
                }

 

This is how i do mine, instead of doing draw++, i had it as a indication of who has the tie breaker currently. But im not sure why yours doesnt work. you can try mine, if it still fails, it might be something else that is not working properly.

Anonymous
Posts: 166
Posted 01:27 Mar 13, 2014 |

still didnt work:( it treats the code as it dousnt exist