Week 1

 Week one of me trying to improve my skills and hopefully achieve some success in competitive programming. Today, I looked at some YouTube videos from experienced competitive programmers and a lot of them have used a website called codeforces, which host competitions and problems sets for competitive programmers. I tried a problem after watching some long intro videos to see how it works and get a feel for what I might be doing. I tried the easiest problem because I've been out of practice with my java for a bit and the projects before were for GUI so it wasn't the same. 

Below is the results and the problem description. I couldn't find any difficulty easier than 800 but I thought this would be doable because it was titled "math and brute force" so there was no data structures or anything.

For the first couple of tries I forgot to save and my code had a tiny typo. After, this showed me how shallow my problems solving is. I thought I new exactly what to do I just make sure the input is from 1 - 100 then I divided my input by 2 and tried to take the modulo of the halved number... This did not work for short sighted because it failed test 2, which tests 5 as the input and I had the input as an int which makes 2.5 into 2 and makes the 2%2==0 true when it should be false. But where I made a bit of a break through was when I made the "int" a "double", which got me to test case 8. Test case 8 tests 6 but it fails because I'm taking the mod of 2, which fails to include numbers like 6 and 10 which can split evenly but are odd. So I change mod of 2 to mod of k which is the input divided by 2 and stored as an int so it becomes the closest whole number. Now I take the input and mod it by the input divided by two, which I though would work but there was a small case that I didn't account for which was 3 and thats the only number that gives my program problems but I dealt with it by making it so if k==1 which means the input is 3 then it would just print "NO" else then carries on my code that I had previously. I basically just made that If statement as a gate to the code.

The last picture is the code that was accepted.





Comments

  1. Ronin,
    Great work this week. I'm glad you found a resource that can help you get back into the swing of things. Can't wait to see you progress this semester!

    ReplyDelete

Post a Comment

Popular posts from this blog

Week 9

Week 10

Week 11