week 5

 This week I continued working on 1200 difficulty problems, but these one were not data structure oriented. 

The first one was quite easy and straight forward. The problems states that we take in test case t and each case we take in a binary string and we decide if they are "good" or "bad". They're good if they contain "010" or "101" if they don't they are "bad". Pretty easy so I take in t, while t is greater than zero I take in my string and see if it contains "010" or "101" and if it does print "good" and if not print "bad".

Second problem was not so easy it wants us to find the combination that matches N burgers and has the most premium burgers that money R can buy. The way the problem was set up seemed easy but every answer I thought of never was quite right, so I looked up the solutions and tried to understand the code but I couldn't understand the equation they were using and there was no place that goes in-depth to describe why they used the equation they did. From what I understand they are using R which is the amount of money and (y*n) seems to be the total amount of premium burgers that can be used. I don't understand (x-y) why do we divide by the difference in the cost of x and y. I understand it will divide a negative by a negative so we get a positive but I don't understand why its (x-y). But the equation under uses the same equation but uses mod instead of "/" so that if it not an whole number we round up to the nearest whole so we get an accurate answer.










Comments

Post a Comment

Popular posts from this blog

Week 9

Week 10

Week 11