Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

ednrg

@ednrg
About
Posts
80
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • He got away with it!
    E ednrg

    Was it Sasha Barron Cohen in a new character? :laugh:

    The Lounge php html database question announcement

  • Youtube
    E ednrg

    Ever realize that the video you want to watch sometimes buffers, but the ad that plays before NEVER buffers?

    The Lounge question

  • Just when I thought stupidity knew no bounds.
    E ednrg

    “Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.” ― Albert Einstein

    The Lounge com question

  • Noisy Work Environments?
    E ednrg

    2 words: Ear buds. I listen to what I want to listen to all day, not the ambient noise.

    The Lounge question tools workspace

  • All But One Shall Die!
    E ednrg

    Is this the shortest solution?

    var switcher = true;

    var range = Enumerable.Range(1,1000).ToList();

    while( range.Count > 1)
    range = range.Where(x => (switcher = !switcher) == false).ToList();

    range.Dump(); // (LinqPad)

    The Lounge question

  • All But One Shall Die!
    E ednrg

    Found the error in my ways :) It now works.

       static int FindLastManStanding(int startingPosition = 2)
        {
            int retVal = -1;
            bool lastWasKilled = false;
            List dead = new List();
    
            if (startingPosition == 1)
                captures.RemoveAt(0);
    
            int max = captures.Max();
    
            for (int i = 1; i <= captures.Count; i++)
            {
                if (i % 2 == 0)
                {
                    if ( max == captures\[i - 1\])
                        lastWasKilled = true;
    
                    dead.Add(captures\[i - 1\]);
                }
            }
    
            dead.ForEach(x => captures.Remove(x));
    
            startingPosition = lastWasKilled ? 2 : 1;
    
            if (captures.Count == 1)
                retVal = captures\[0\];
            else
                retVal = FindLastManStanding(startingPosition);
    
            return retVal;
        }
    
    The Lounge question

  • All But One Shall Die!
    E ednrg

    This is nasty and sloppy, but it figures it out to be 505. Where did I got wrong (other than write some horrific code :laugh: )?

    class Program
    {
        static List captures = new List();
    
        static void Main(string\[\] args)
        {
            PopulateCaptures();
            int survivor = FindLastOne();
    
            Console.WriteLine("The last one is: {0}", survivor);
    
            Console.Write("\\n\\nHit any key to continue...");
            Console.ReadKey();
        }
    
        static void PopulateCaptures()
        {
            for (int i = 1; i <= 1000; i++)
                captures.Add(i);
        }
    
        static int FindLastOne(int startingPosition = 0)
        {
            int retVal = -1;
    
            List dead = new List();
    
            if (captures.Count == 1)
            {
                retVal = captures\[0\];
                return retVal;
            }
    
            if (startingPosition == 0)
                startingPosition = 2;
    
            if (startingPosition == 1)
                captures.RemoveAt(0);
    
            for (int i = 1; i <= captures.Count; i++)
            {
                if (i % 2 == 0)
                {
                    dead.Add(captures\[i - 1\]);
                }
            }
    
            foreach (int i in dead)
            {
                captures.Remove(i);
            }
    
            if (captures.Count % 2 != 0)
                startingPosition = 1;
    
            if (captures.Count == 1)
                retVal = captures\[0\];
            else
                retVal = FindLastOne(startingPosition);
    
            return retVal;
        }
    }
    
    The Lounge question

  • What I don't understand is...
    E ednrg

    What I don't understand is why someone that has a job, where there are 2 things to do, use the accelerator and the brake is incapable of doing his job. The guy doesn't even need to steer it.

    The Lounge database com testing beta-testing question

  • I hate phone interviews
    E ednrg

    I do phone interviews to get a general feel for a candidate. The reason being that I have wasted a ton of time in face to face interviews with people that I wondered if they knew how to turn on a PC, let alone do any programming. If the short phone screen goes well, we bring the candidate in for a face to face interview. It has saved me about 15 scheduled face to face interviews, by eliminating the people that bloat their resumes and have no substance to back it up.

    The Lounge career com question

  • Caption Competition
    E ednrg

    If someone's going to be in a photo shirtless, it should be me -- Putin

    The Lounge

  • Things that make ya go hmmmmmm
    E ednrg

    I disagree with your disagreement.

    The Lounge csharp

  • War on science?
    E ednrg

    this just in: Family of the Wicked Witch of the West suing OZ meteorologist www.google.com

    The Lounge question announcement

  • War on science?
    E ednrg

    My point was that people were warned DAYS in advance. FEMA should never have been an issue if people just listened to the warnings and got out of there. Its a troubling trend that people are becoming more and more reliant on government. Self reliant people got out of there, were safe, and dealt with their flood insurance to rebuild their houses.

    The Lounge question announcement

  • War on science?
    E ednrg

    Unfortunately, we now live in a world where people believe they have to blame someone for everything, including natural disasters. For some reason people need to be TOLD what to do. I just don't understand this way of thinking.

    The Lounge question announcement

  • War on science?
    E ednrg

    People in the area of Katrina were warned to get out. Don't blame FEMA for people not believing what they were told.

    The Lounge question announcement

  • I think this could go further...
    E ednrg

    Normally, I wouldn't worry and just say "it's going to be overturned." But after the whole Healthcare bill debacle, you can't foresee which way it will go.

    The Lounge question

  • Minimum wage. Pah says she.
    E ednrg

    In this country, you have the option of going to another job, once you (l)earn your skills. You also have the option of eventually starting your own business. People get what they put into a job. If you sit on your ass all day, and wonder why you're making minimum wage, maybe show some initiative. Initiative is something that people seem to lack. If something in your life isn't satisfactory, change it. I was in a dead end job. Bought a few programming books. Read and studied for a year, and eventually became a programmer. It didn't happen overnight, but I did it. Since those days, I have never stopped learning new things in programming. It was because I have this inner drive now, that I didn't have before. Complacency is people's worst enemy, and EVERYONE can overcome it.

    The Lounge php com business

  • Minimum wage. Pah says she.
    E ednrg

    (SORRY, THIS WAS MEANT FOR THE PREVIOUS RESPONSE, NOT YOURS) You're blinded by your feelings. Minimum wage is NOT meant for people to live on. Who, in this world aspires to make minimum wage? You make minimum wage while LEARNING or TRAINING. This is a free country, you have the option of moving to a new job, or even a new city. In this country, you are blessed with options that people in other countries do not get.

    The Lounge php com business

  • Minimum wage. Pah says she.
    E ednrg

    I love when people don't understand that capitalism may not be perfect, but it is the best thing out there right now. Maybe it's the younger people that don't understand that communism never works. I also love people that cry about minimum wage. We deal with it in the U.S. all the time. People act like raising it will help the economy. Nothing can be further from the truth. The wage should be determined by a person's ability. People get hired at minimum wage, learn their job, and get raises. If they don't get the raises, they can use their new skills to go elsewhere as an experienced worker. If you think of it in terms of being a business owner. Would you hire someone without any skills, and train them at say $5/hr? Most likely the answer is yes. Would you hire him at $10/hr or $15/hr? Probably not. Definitely not as likely as you were at $5/hr. In fact, you might be more inclined to hire 2 or 3 people on a trial basis at $5/hr and over the course of a few months, you pick the best candidate, and at least double his salary. Maybe 2 people have great potential, and you hire 2, or maybe even all 3. So, raising the minimum wage clearly doesn't help. It actually hinders unqualified people's ability to get a break. More times than not, if a person is a good worker, they get promoted from minimum wage jobs to regular wages. If you're in a job for months and months, you either haven't proved yourself, or you should move on to another job.

    The Lounge php com business

  • Several people shot at New York's Empire State Building
    E ednrg

    It's the coddled kids becoming adults in age only. They don't know how to act when any adversity comes around, so they overreact and grab a gun because someone disrespected them. A real man brushes himself off, learns from his experience, and moves on with his life. Vince Lombardi said it best: "It's not whether you get knocked down, it's whether you get up."

    The Lounge com question announcement learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups