Posts

Find Remainder

Image
Find Remainder  Problem Code:  FLOW002 https://www.codechef.com/problems/FLOW002 This solution is about % operator in c. It gives the remainder when a is divided by b. Also, known as modulo operator. I used to use for loops a lot. However, here, I can see the effective use of a while loop.

Sum of Digits

Image
Sum of Digits   Problem Code:   FLOW006 Checked the value of 0 by printing it. Use the string library in c++ size() is used to get the length of string. I also already checked whether this string contains \n included in it. It does not.

Number Mirror

Image
Number Mirror   Problem Code:   START01 https://www.codechef.com/problems/START01

Add Two Numbers

Image
Add Two Numbers  Problem Code:  FLOW001 https://www.codechef.com/problems/FLOW001

Enormous Input Test

Image
Enormous Input Test  Problem Code:  INTEST https://www.codechef.com/problems/INTEST I did not have to solve this one as answer was already given in the ide for me somehow. However, I found a link that explains what is happening within the code. https://stackoverflow.com/questions/31162367/significance-of-ios-basesync-with-stdiofalse-cin-tienull        ios_base::sync_with_studio(false);        cin.tie(NULL); I tried with commenting both the lines too. With these lines included, the run time was 0.14 seconds However, without these lines, it increased up to 0.64 seconds for me.

ATM Problem Code: HS08TEST

Image
ATM  Problem Code:  HS08TEST https://www.codechef.com/problems/HS08TEST Pooja would like to withdraw  X  $US from an ATM. The cash machine will only accept the transaction if  X  is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal, the bank charges 0.50 $US. Calculate Pooja's account balance after an attempted transaction. Solution - I could have pasted it here instead of an image. But I really do want everyone to solve and type it out themselves.

Goal

The goal is to be excellent at problem-solving and competitive coding. Obviously, it can be achieved only through practice. Since I anyways enjoy a good problem, I will document all the solutions for the problems I solve. Codechef ->  https://www.codechef.com/problems/school