Hi

You have provided in c++ but can anyone say in c# and also why I am
getting this error based on my answer?

I have now attached the code fole I did in c#

Thanks and Regards,
Saravana kumaran N.

On Wed, 11 Sep 2019, 9:04 pm Bartholomew Furrow, <[email protected]> wrote:

> Run Time Error means your program is crashing. The first thing I'd try, if
> I were you, is running your program on some inputs that are valid for the
> second test set but not the first. In particular, I'd start with the
> largest possible input (10^16), and then try several other large inputs.
>
> Often programs that work on small numbers, like 100000, have problems on
> larger numbers -- they might use too much memory (run time error), or do
> too much recursion (run time error), or take too long (time limit
> exceeded), or overflow a data type (numbers at or above 2^31 don't fit in
> most 32-bit integer types, which could cause a variety of problems).
>
> Good luck!
> Bartholomew
>
> On Wed, Sep 11, 2019 at 8:16 AM Saravana Kumaran <[email protected]>
> wrote:
>
>> I am Practising Round A - Kick Start 2018 Even digit Problem and when I
>> submit my code I am getting Test Set Passed and Run Time Error(RE).
>>
>>
>> Can anyone Help me why i am getting RE??
>>
>>
>> Thanks and Regards,
>> Saravana kumaran N.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-code/d1d8b366-a3e1-4e9e-9e58-498651692ed1%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-code/d1d8b366-a3e1-4e9e-9e58-498651692ed1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CAHaiWHOv9Yh-GJoWyxYQKt8_NwP717Es1HOTgRf7y%2BsyBqrVeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-code/CAHaiWHOv9Yh-GJoWyxYQKt8_NwP717Es1HOTgRf7y%2BsyBqrVeA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAGSRCg6iRCijXTee5KdWPYof7fpN9UHQ0rwfic1uv3uk3ci_bw%40mail.gmail.com.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string TestCase;
            TestCase = Console.ReadLine();

            int No_of_TestCase = Convert.ToInt32(TestCase);

            for (int i = 1; i <= No_of_TestCase; i++)
            {
                string Input;
                Input = Console.ReadLine();
                int Inputint = Convert.ToInt32(Input);
                int Inputplus = Inputint;
                int Inputminus = Inputint;
                int plus = 0;
                int minus = 0;
                bool NormalAlert = false;
                List<int> listOfInts = new List<int>();
                while (Inputint > 0)
                {
                    listOfInts.Add(Inputint % 10);
                    Inputint = Inputint / 10;
                }
                listOfInts.Reverse();
                int[] arr_of_val = listOfInts.ToArray();
                int length = arr_of_val.Length;
                bool[] arr_of_Bool = new bool[length];
                for (int ii = 0; ii < length; ii++)
                {
                    if ((arr_of_val[ii] % 2) == 0)
                    {
                        arr_of_Bool[ii] = true;
                    }
                }
                NormalAlert = arr_of_Bool.All(x => x);
                if (NormalAlert)
                {
                    Console.WriteLine("Case #{0}: {1}", i, plus);
                }
                else
                {
                    bool PlusAlert = false;
                    bool MinusAlert = false;
                    while ((PlusAlert == false) || (MinusAlert == false))
                    {
                        if (PlusAlert == false)
                        {
                            Inputplus = Inputplus + 1;
                            int InputplusDemo = Inputplus;
                            plus = plus + 1;
                            List<int> listOfIntplus = new List<int>();
                            while (InputplusDemo > 0)
                            {
                                listOfIntplus.Add(InputplusDemo % 10);
                                InputplusDemo = InputplusDemo / 10;
                            }
                            listOfIntplus.Reverse();
                            int[] arr_of_val_plus = listOfIntplus.ToArray();
                            int lengthplus = arr_of_val_plus.Length;
                            bool[] arr_of_Bool_plus = new bool[lengthplus];
                            for (int ip = 0; ip < lengthplus; ip++)
                            {
                                if ((arr_of_val_plus[ip] % 2) == 0)
                                {

                                    arr_of_Bool_plus[ip] = true;
                                }
                            }
                            PlusAlert = arr_of_Bool_plus.All(x => x);
                        }

                        if (MinusAlert == false)
                        {
                            Inputminus = Inputminus - 1;
                            int InputminusDemo = Inputminus;
                            minus = minus + 1;
                            List<int> listOfIntminus = new List<int>();
                            while (InputminusDemo > 0)
                            {
                                listOfIntminus.Add(InputminusDemo % 10);
                                InputminusDemo = InputminusDemo / 10;
                            }
                            listOfIntminus.Reverse();
                            int[] arr_of_val_minus = listOfIntminus.ToArray();
                            int lengthminus = arr_of_val_minus.Length;
                            bool[] arr_of_Bool_minus = new bool[lengthminus];
                            for (int im = 0; im < lengthminus; im++)
                            {
                                if ((arr_of_val_minus[im] % 2) == 0)
                                {
                                    arr_of_Bool_minus[im] = true;
                                }
                            }
                            MinusAlert = arr_of_Bool_minus.All(x => x);
                        }

                        if (PlusAlert == true && MinusAlert == true)
                        {
                            if (plus == minus)
                            {
                                Console.WriteLine("Case #{0}: {1}", i, plus);
                            }
                            else if (plus > minus)
                            {
                                Console.WriteLine("Case #{0}: {1}", i, minus);
                            }
                            else
                            {
                                Console.WriteLine("Case #{0}: {1}", i, plus);
                            }
                        }
                    }
                }


            }
        }    
    }

Reply via email to