Problem of the Day
A new programming or logic puzzle every Mon-Fri

Internet Connection

Sorry for getting this one up so late my internet connection has been a bit spotty. Can you develop a program/algorithm to detect if you're connected to the internet? It's fine if it's not right 100% of the time. Remember just because you have a wifi connection doesn't mean you can reach the internet.

Permalink: http://problemotd.com/problem/internet-connection/

Comments:

  • Anonymous - 10 years, 1 month ago

    C# with console app to check result;

    class Program
    {
        private static int count = 0;
    
        static void Main(string[] args)
        {
            int x = 100;
            Console.WriteLine("Testing debouncer, method will run {0} times.", x);
    
            Debouncer(PrintCount, x);
    
            Console.WriteLine("\nPress Any Key To Exit");
            Console.ReadKey();
        }
    
        private static void PrintCount()
        {
            Console.WriteLine("{0} {1}", count.ToString(), DateTime.Now.ToString("hh:mm:ss.ff"));
            count++;
        }
    
        private static void Debouncer(Action method, int runCount)
        {
            for(int i = 0; i < runCount; i++)
            {
                method();
    
                Thread.Sleep(250);
            }
        }
    }
    

    reply permalink

  • Anonymous - 10 years, 1 month ago

    Posted to the wrong problem some how o_O. Answer for PotD: Debouncer

    reply permalink

Content curated by @MaxBurstein