Today is Friday the thirtieth (30th)!
Not that hard, but I somehow misread 1900 as 1990 once...
Simply find the day of week of the 13th day of the next month.
Then count the days that pass with each month mod 7 for the day of the week for the "zero"th day of the next month.
C++ solutions, both training and real, are posted when possible; they are provided for reference purposes only.
Friday, March 30, 2012
Monday, March 26, 2012
Problem 77: Greedy Gift Givers
I failed 18 times due to division by zero, modulus of zero, etc.
This one is similar to "accounting". Create accounts for everyone, and change their amount of balance from each transaction. Then print everyone's final balances.
I used heap memory allocation, but that doesn't matter much. I just had to prevent null pointers from causing a crash.
This one is similar to "accounting". Create accounts for everyone, and change their amount of balance from each transaction. Then print everyone's final balances.
I used heap memory allocation, but that doesn't matter much. I just had to prevent null pointers from causing a crash.
Friday, March 23, 2012
Problem 108: Your Ride Is Here
This one is also easy! It's too bad I failed a few times due to const-correctness.
You pretty much "hash" each string, as a product of letters, and compare both hashes mod 47. If they match, "GO", otherwise "STAY" and then print a newline.
On second thought, I could have placed the modulus in the s_product function. Then I also realized that it could be put in after each multiplication operation.
You pretty much "hash" each string, as a product of letters, and compare both hashes mod 47. If they match, "GO", otherwise "STAY" and then print a newline.
On second thought, I could have placed the modulus in the s_product function. Then I also realized that it could be put in after each multiplication operation.
Thursday, March 22, 2012
Subscribe to:
Posts (Atom)