Sunday, 21 September 2014

Interviews are hard

The topic of software development is vast, trying to get everything together to at least make sure I know what I know. 

I did get asked about SOLID, annoying as I should have known all this and been able to rattle it out even though the understanding was there, full on mind blank. A refresher from Agile principles, patterns, and practices in c# ( working through at the moment ). Wiki SOLID.

Also asked about, database service providers and Entity framework.

A good site for practice is project Euler, lots of small puzzles some are quite complicated and require a bit of maths to get going.

Solutions to the first two

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace basics
{
    class Program
    {
        static void Main(string[] args)
        {       
            //If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
            //Find the sum of all the multiples of 3 or 5 below 1000.

            var aList = new List<int>();
            for (int i = 1; i < 1000; i++)
            {
                if (i % 3 == 0 || i % 5 == 0)
                {
                    aList.Add(i);
                }
            }
            Console.WriteLine(aList.Sum());
            Console.Read();
        }
    }
}

---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace basics
{
    class Program
    {
        static void Main(string[] args)
        {
            //Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

            //1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

            //By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
            int first = 1, second = 1, third = 0;
            int sum = 0;

            while (third < 4000000)
            {
                // gen fibs
                third = first + second;
                first = second;
                second = third;

                // less than 4 mill and even add to sum
                if (third < 4000000 && third % 2 == 0)
                {
                    sum += third;
                }
            }

            Console.WriteLine(sum);
            Console.Read();
        }
    }
}
--------------------------------------------------------------- 


Good articles read this week

No comments:

Post a Comment