Mark Grealish

Cats and wizardry.



Faith in humanity -1

[W From] [Littleben]: wanna do 2s? For 1600 rate this week, currently 1500 [W To] [Littleben]: I saw you spamming trade earlier. Are you just sending blind /tells to every possible healer? :) [W From] [Littleben]: u can just say no, there’s no need to bark [W To] [Littleben]: Hehe Littleben is ignoring you. :|

Project Euler

I was led onto the existence of the wonderful Project Euler through, of all things, an Ars Technica article highlighting unfortunate changes coming to Visual Studio 11. It’s fun, it is challenging, and I am doing some genuine learning through the site. I’ll post my code as I complete problems.

Project Euler Problem #1

Project Euler Problem #2

using System; public class Two { static void Main() { int a = 1; int b = 1; int c = 0; int sum = 0; int cap = 4000000; do { c = a + b; if (c % 2 == 0) sum += c; a = b; b = c; } while (c […]

Project Euler Problem #3

using System; public class Three { static void Main() { long a = 600851475143; int b = Convert.ToInt32(Math.Sqrt(a)); int c = 0; for (int i = b; i >= 2; i--) { if (a % i == 0) if (ChkPrime(i)) { c = i; break; } } Console.WriteLine('{0}', c); } static bool ChkPrime(int c) { […]

Project Euler Problem #4

using System; public class Four { static void Main() { int a = 0; int b = -1; int c = 999; for (int i = 100; i < = c; i++) { for (int j = 100; j <= c; j++) { a = i * j; if ((a == Reverse(a)) && (a > […]

Project Euler Problem #5

using System; public class Five { static void Main() { int a = 20; int b = 0; while (b <= 0) { for (int i = 11; i < 20; i++) { if (a % i != 0) { a += 20; break; } else if (i == 19) { b = a; break; […]

It’s over 9000!

I’ve started raiding through Open Raid, a free service built upon World of Warcraft’s cross-realm raiding. Ventrilo, competent PVPers and raiders who can follow directions. Really, what is there to not like?

Big exams #3 through to #6

Listos version: Games Design: Winged it on the strength of a treatise on how sprites are drawn. Database Administration: I did not go. I had reasons. See below. Web Design: Oh so easy. Systems and Networking: Very easy. Games Design: One of the two subjects I will probably have to repeat. I hit my big […]

Project Euler Problem #6

using System; public class Six { static void Main() { double a = 100; double b = 0; double c = 0; for (int i = 1; i < = a; i++) { b += (i * i); c += i; } c = c * c; if (b > c) Console.WriteLine("\n{0}\n", b - c); […]

Project Euler Problem #7

The answer is a bit of a trick, and there is actually a hint within the question: Start your prime count at 2, not at 1, or 0, like me. using System; public class Seven { static void Main() { int a = 2; int b = 0; int c = 10001; while (b < […]

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 = […]

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. — […]

Took the kids to the beach :)

Did they enjoy it? You tell me.

Another from the beach

This one’s clocked up a fair few likes on Instagram.

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 #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 […]

Here comes the sun!

Galaxy of Passion – A Star Wars Telenovela

Still a better story than the prequel.

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 #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 #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); […]

The Transit of Venus

I missed it owing to being on the incorrect portion of this rotating oblate sphere (and, yes, rain). It is the last time Venus will transit the sun from Earth in this century-and unless I live to the ripe old age of 136, also the very last time in my life. This makes me sad, […]

Project Euler Problem #15 (in progress)

Solving this problem requires an understanding of Pascal’s Triangle, “…triangular array of the binomial coefficients in a triangle.” TL;DR: The integers in each row is equal to the sum of the two above it. While I still do not have a fully working solution for problem 15, I have written a heavy-handed Pascal’s Triangle generator. […]

Project Euler Problem #15

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 […]

Project Euler Problem #16

/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, […]

I walked to Grange last night (and then back home)

The main road became a tributary road. The tributary became a boreen. The boreen became a mud track in a forest. The forest track gave way to a raised causeway in a bog. After the sun set, there were sheep.

Project Euler Problem #17

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 […]

Problem #18

I am irked by this. I have an algorithm. However, to find it I had to go look up the solutions of other users who have blogged about it. Blah.

Project Euler Problem #18

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 […]

Garrett meets SNES

Charon at 29 days

She is starting to show the same temperament as her queen: Nosy, friendly, and in constant need of yet another belly rub. Charon’s coat is a shade lighter than Lucy’s – a dark charcoal grey instead of black – and her stripes are more prominent than her queen’s in daylight. Charon’s coat is (like my […]

How many avout does it take to change the light bulb?

1 avout to change the light bulb. 1 assistant to help him up the ladder, and then hold it steady. 9 who have fallen back to avocations to grow a tree, chop it down, and carve it into a stepladder. 5 more to collect the sand, smelt the glass, blow the bulb, and spin the […]

Problem #19 non-solution

I’ve been having way too much fun with these: using System; public class Nineteen { static void Main() { } // Days in one month. Assumes "1-12" input. static int daysMonth(int year, int month) { int[] a = new int[13] {0,31,28,31,30,31,30,31,31,30,31,30,31}; int b = 0; if ((leap(year)) && (month == 2)) b = 29; else […]

Not the most l33t of newbies

Caira turns with the keyboard and Garrett can’t help but use a controller.

Om nom nom nom nom

Project Euler Problem #19

Mark now knows more than Mark ever wished to know about leap years, months, days, and weeks – generally a whole lot of the Georgian calendar and calendar days versus solar days. using System; public class Nineteen { static void Main() { int a = 0; for (int i = 1901; i < = 2000; […]

Project Euler Problem #20

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('{0}', c); } }

Project Euler Problem #21

It took me a few adjustments – namely having to eliminate numbers those numbers whose summed divisors equalled the original (6, 28, 496, etc.). I reduced my workload by eliminating primes. using System; public class TwentyOne { static void Main() { int a = 1; int b = 0; for (int i = 1; i […]

Project Euler Problem #22

My stroke of brilliance: c += ((b[i] - '0') + 10) % 26; Take b[i]. In this example make it the letter ‘A’. Subtract ‘0’. You are left with. 17. Add 10. It becomes 27. Modulo 26. It returns 1. Works for every other letter (although you have to change the value of “z” to […]

Project Euler Problem #23

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 […]

Grades: January and June

January: Systems and Networking: 83% Digital Media with Photoshop: 78% Programming with C#: 78% Games Culture: 88% Mathematics: 61% Learning to Learn: 71% 76.5% June: Systems and Networking: 89% Programming with C#: 68% Web Design: 62% Database Management: N/G Games Design: N/G Mathematics: 70% 72.3% Eh. I could have, should have done better. A bad […]

Father’s day 2012

[Minecraft] The Lyceum

Project Euler Problem #24

00:00:00.0716283 This one hurt my head, even after I was led onto Narayana Pandita’s algorithm. The algorithm depends on finding the largest integer that is smaller than another integer in the sequence/array; however, I’ve looked at several code solutions that just come in from the right and pick the first integer that is smaller than […]

Project Euler Problem #25

My submission was incorrect until I realized that my algorithm starts outputting Fibonacci numbers at the fourth Fibonacci term; it excludes the leading 0,1,1. I therefore set my counter to 3. using System; using System.Numerics; public class TwentyFive { static void Main() { BigInteger a = 1; BigInteger b = 2; BigInteger c = 0; […]

It is *never* too late to jump on a bandwagon


Killer endures

…even if she is a veritable tubcat these days.

Subtitled: For science!

If they fits, they sits