Mathematics Olympiad Puzzle

SPART
   X4
=====
TRAPS
=====
Determine S, P, A, R and T.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 11111; i < 99999; i++)
            {
                int tempNum = i * 4;
                if(Check(i.ToString(), tempNum.ToString()))
                {
                    Console.WriteLine(i.ToString());
                }
            }
        }
        public static bool Check(string str1, string str2)
        {
            for (int i = 0; i < str1.Length; i++)
            {
                if (str1[i] != str2[(str1.Length -1) - i])
                {
                    return false;
                }
            }
            return true;
        }
    }
}
Output: 21978
Advertisements
This entry was posted in Mathematics. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s