This problem sucked. A benchmark for my solution is seemingly required for proper horn-tooting: 00:00:03.9170605 This problem, like Problem #19 threw me to the mental wolves. Keeping with the comparisons to #19, I also had to build up a supporting clade of methods to process the different elements of the problem. The core of the [...]
using System; using System.Numerics; public class Twenty { static void Main() { BigInteger a = 100; string b; int c = 0; for (int i = 99; i >= 1; i–) a *= i; b = Convert.ToString(a); for (int i = 0; i < b.Length; i++) c += b[i] – ’0′; Console.WriteLine(“\n{0}\n”, c); } }
I am beginning to feel as if my head is full of mush every time I have to deal with a jagged array in a loop. I stole the solution from here, but the code is entirely my own. In short, you begin at the bottom-left corner of the jagged array. You move to the [...]
Non-admission: I Google around for other solutions to problem as I work on them. I have no intention of copying anyone else’s approach to a problem, although I do look for mathematical terms to search for in turn. Looking at many of the posted solutions, I saw either crazily branching decision structures or more-or-less tiresome [...]
/twitch Anything to avoid using VS, right? For my pain, I learned that Bash, while being excellent for fast big arithmetic operations (compared to C#), doesn’t enjoy working with large multiples or exponents. using System; using System.Numerics; class Program { static void Main() { BigInteger a; string b; int c = 0; a = BigInteger.Pow(2, [...]
So, the answer was staring at me all along. No, really. Look at this picture: On the left is a bog-standard Pascal Triangle. On the right is the example problem on the Project Euler website. I drew this diagram on paper, and what immediately leaped out of me was that the number I need (the [...]