HackerRank day 26

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

namespace ConsoleApplication3
{
class Program
    {
        static void Main(string[] args)
        {

            string input1 = Console.ReadLine();
            string input2 = Console.ReadLine();
            char[] a = input1.Replace(" ", "").ToCharArray();
            char[] b = input2.Replace(" ", "").ToCharArray();



            int[] D1 = new int[2] { 0, 0 };
            int[] D2 = new int[2];
            int[] M1 = new int[2] { 0, 0 };
            int[] M2 = new int[2];
            int[] Y1 = new int[4] { 0, 0, 0, 0 };
            int[] Y2 = new int[4];
            int count = 0;
            int count2 = 0;
            int counter2 = 0;
            int counter3 = 0;
            int counter4 = 0;
            int counter5 = 0;

            for (int i = 0; i < a.Length; i++)
            {
                if (counter2 == 2)
                {
                    counter2 = 0;
                }
                if (counter3 == 4)
                {
                    counter3 = 0;
                }

                if (count == 0 || count == 1)
                {
                    D1[counter2] = (int)Char.GetNumericValue(a[i]);
                    count++;
                    counter2++;


                }
                else if (count == 2 || count == 3)
                {

                    M1[counter2] = (int)Char.GetNumericValue(a[i]);
                    count++;
                    counter2++;



                }
                else if (count == 4 || count == 7 || count == 5 || count == 6)
                {

                    Y1[counter3] = (int)Char.GetNumericValue(a[i]);
                    count++;
                    counter3++;
                }

            }




            for (int i = 0; i < b.Length; i++)
            {
                if (counter4 == 2)
                {
                    counter4 = 0;
                }
                if (counter5 == 4)
                {
                    counter5 = 0;
                }

                if (count2 == 0 || count2 == 1)
                {
                    D2[counter4] = (int)Char.GetNumericValue(b[i]);
                    count2++;
                    counter4++;


                }
                else if (count2 == 2 || count2 == 3)
                {

                    M2[counter4] = (int)Char.GetNumericValue(b[i]);
                    count2++;
                    counter4++;



                }
                else if (count2 == 4 || count2 == 7 || count2 == 5 || count2 == 6)
                {

                    Y2[counter5] = (int)Char.GetNumericValue(b[i]);
                    count2++;
                    counter5++;
                }

            }


            int day1 = D1.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, D1.Length - i - 1))).Sum();
            int month1 = M1.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, M1.Length - i - 1))).Sum();
            int Year1 = Y1.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, Y1.Length - i - 1))).Sum();

            int day2 = D2.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, D2.Length - i - 1))).Sum();
            int month2 = M2.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, M2.Length - i - 1))).Sum();
            int Year2 = Y2.Select((t, i) => t * Convert.ToInt32(Math.Pow(10, Y2.Length - i - 1))).Sum();

            int fine = 0;


            if (day1 - day2 <= 0)
            {
                if (month1 - month2 <= 0)
                {
                    if (Year1 - Year2 <= 0)
                    {
                        Console.WriteLine(fine);
                    }
                }
            }

            if (Year1 - Year2 > 0)
            {
                fine = 10000;
                Console.WriteLine(fine);
            }
            if ((month1 - month2 > 0) && (Year1 - Year2 == 0))
            {

                fine = (month1 - month2) * 500;
                Console.WriteLine(fine);
            }
            if ((day1 - day2 > 0) && (month1 - month2 == 0) && (Year1 - Year2 == 0))
            {
                fine = (day1 - day2) * 15;
                Console.WriteLine(fine);
            }



            Console.ReadLine();
        }
   

        }
    }



   

Comments

Popular posts from this blog

Authentication and Authorization in Web API -Part1

My Gardening Journey 6