Self-hatred

Posts Tagged ‘mathematics’

Project Euler Problem #14

using System; public class Fourteen { static void Main() { long a = 1000000; long b = 0; long c = 0; long d = 0; for (int i = 1; i < = a; i++) { b = Chain(i); if (b >= c) { c = b; d = i; } } Console.WriteLine(“\n{0}\n”, d); [...]

Project Euler Problem #13

After I submitted my solution, I Googled around and found a fair deal of “lol, this one is easy!”. And, yeah, it is. Add 100 numbers together and output the first ten digits of the sum. So. Easy. C# is persnickety about numbers and handling. Out of the box, C# does not like working with [...]

Project Euler Problem #12

This was a question of two parts: Calculate the next triangle number in sequence. Take said triangle number and calculate how many divisors it has. Loop until you find one with 500, and break. The first part was simple: Start with n = 1. For every iteration of the loop, add n to n, and [...]

Project Euler Problem #11

I took a pure brute force approach to this problem: Working with [x,y] coordinates is a headache. I also chose to go the route of testing every valid combination; way, way too many submissions on the Project Euler forums (and on the Internet in general) are along the lines of “I just did Ctrl+F for [...]

Project Euler Problem #10

As of the time of publishing, I have not yet submitted this solution to the website because it is offline. I have, however, searched around and verified the correctness. I kept returning an incorrect answer until I switched variables a and b to long. It works. This was a boring problem: I just copied my [...]

Project Euler Problem #9

Okay, this one was tough. Not in the computation – it took me about an hour to refine and submit my solution once I Googled the algorithm; my real problem was in completely understand the requirements of the question, and what it implied. I looked up the Pythagorean triplet, and the history of it. — [...]

Project Euler Problem #8

I started here for clarification on the problem’s requirement. I had more problem correctly parsing the input than I did in crunching the highest product (three hours versus two minutes?). :/ — using System; using System.IO; public class Eight { static void Main() { int[] a = numIn(); int b = 0; int c = [...]