Slashdot Mirror


User: CableModemSniper

CableModemSniper's activity in the archive.

Stories
0
Comments
1,528
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 1,528

  1. Re:It is like magic. on HyperCard Comes Back From the Dead to the Web · · Score: 1

    I think you're thinking of 2.96: http://gcc.gnu.org/gcc-2.96.html

  2. Re:Hope they've mentioned JC on The Secret History of Star Wars · · Score: 1
    He's mentioned, mostly in the context of debunking the

    and he was consulted when the seeds of the original StarWars trilogy were being planted by Lucas.

    thing
  3. Re:Sudden outbreak... on EA Loosens Spore, Mass Effect DRM · · Score: 1

    loose is a verb too.

  4. Re:Looks like Prodigy art on Homer Simpson Drawn With Web 2.0-Style ASCII Art · · Score: 1

    Mad Maze was awesome.

  5. Re:Some people can handle threads... on Threads Considered Harmful · · Score: 1

    Sure you can wrap up the c handlers in c++ objects which then have automagic destructors, but that is a lot of extra layers and code just to get around using a goto.
    Let me preface this by saying I don't think gotos are always "bad", that said, I don't think they're the best solution for this example when writing in C++. Extra layers, yes (but mostly negligible), but extra code? This is why we have libraries. To wit:
    def foo
    library_thing1
    ScopeGuard u1 = MakeGuard(boost::bind(undo_library_thing1));
    ...
    stuff that can go horribly bad
    ...
    end

    I apologize for the lack of indentation, I just couldn't get it right.

    You don't even need to create a new class if you don't want to, and the setup and teardown are right next to each other, so you don't have to scan down to the bottom of the function to be sure you cleaned up after yourself (goto or no).

    1. scope guard: http://www.ddj.com/cpp/184403758
    2. boost::bind: http://www.boost.org/doc/libs/1_35_0/libs/bind/bind.html
  6. Re:Civilian use? on Stealth Paint From German Inventor Werner Nickel · · Score: 1

    It's defeat-able by invisibility paint!

  7. Re:rotting carcass on GPS Used To Find Graves In Eco-Burial Sites · · Score: 1

    Not even once? Impressive.

  8. Re:So I didn't randomly simulate it on Psychologists Don't Know Math · · Score: 1

    Final iteration. I should not consider the scenarios where monty can choose between 2 goats as two rounds, but rather one, as it's the same outcome regardless of which door Monty chooses

    class Round < Struct.new(:car_door, :initial_chosen_door, :switched_to_door)
      def won?
        car_door == switched_to_door
      end

      def switched?
        initial_chosen_door != switched_to_door
      end
    end

    rounds_switch = []
    rounds_noswitch = []
    doors = [1,2,3]
    doors.each do |car_door|
      doors.each do |initial_chosen_door|
        (doors - [car_door, initial_chosen_door])[0...1].each do |montys_door|
          round_noswitch = Round.new(car_door,
                                     initial_chosen_door,
                                     initial_chosen_door)
          round_switch = Round.new(car_door,
                                   initial_chosen_door,
                                   (doors - [initial_chosen_door, montys_door]).first)
          rounds_noswitch << round_noswitch
          rounds_switch << round_switch
          puts "The car was behind: #{car_door}, I didn't switch and chose #{initial_chosen_door}, Monty revealed the goat behind door: #{montys_door}, I #{round_noswitch.won? ? "won" : "lost"}"

          puts "The car was behind: #{car_door}, I did switch and initially chose #{initial_chosen_door}, Monty revealed the goat behind door: #{montys_door}, and I switched to #{round_switch.switched_to_door}, I #{round_switch.won? ? "won" : "lost"}"
        end
      end
    end

    puts "Out of #{rounds_noswitch.size} rounds where I didn't switch, I won #{rounds_noswitch.select { |i| i.won? }.size} times."

    puts "Out of #{rounds_switch.size} rounds where I _did_ switch, I won #{rounds_switch.select { |i| i.won? }.size} times."

  9. Re:Doesn't sum to 1... on Psychologists Don't Know Math · · Score: 1

    I figured out the bug. The scenarios where Monty has two doors to choose from, him choosing the first door or the second shouldn't count as 2 rounds, because which door he chooses is irrelevant.

  10. Re:So I didn't randomly simulate it on Psychologists Don't Know Math · · Score: 1

    So I tweaked the code as follows, output is omitted. I get the same winningness whether you switch or not (and it adds up to 1 this time ;) ).
    class Round < Struct.new(:car_door, :initial_chosen_door, :switched_to_door)
      def won?
        car_door == switched_to_door
      end

      def switched?
        initial_chosen_door != switched_to_door
      end
    end

    rounds_switch = []
    rounds_noswitch = []
    doors = [1,2,3]
    doors.each do |car_door|
      doors.each do |initial_chosen_door|
        (doors - [car_door, initial_chosen_door]).each do |montys_door|
          round_noswitch = Round.new(car_door,
                                     initial_chosen_door,
                                     initial_chosen_door)
          round_switch = Round.new(car_door,
                                   initial_chosen_door,
                                   (doors - [initial_chosen_door, montys_door]).first)
          rounds_noswitch << round_noswitch
          rounds_switch << round_switch
          puts "The car was behind: #{car_door}, I didn't switch and chose #{initial_chosen_door}, Monty revealed the goat behind door: #{montys_door}, I #{round_noswitch.won? ? "won" : "lost"}"

          puts "The car was behind: #{car_door}, I did switch and initially chose #{initial_chosen_door}, Monty revealed the goat behind door: #{montys_door}, and I switched to #{round_switch.switched_to_door}, I #{round_switch.won? ? "won" : "lost"}"
        end
      end
    end

    puts "Out of #{rounds_noswitch.size} rounds where I didn't switch, I won #{rounds_noswitch.select { |i| i.won? }.size} times."

    puts "Out of #{rounds_switch.size} rounds where I _did_ switch, I won #{rounds_switch.select { |i| i.won? }.size} times."

  11. Re:Doesn't sum to 1... on Psychologists Don't Know Math · · Score: 1

    That may very well be true. On the other hand, I'd much rather hear about the bugs in the code or in the assumptions expressed in the code, because the idea is to demonstrate that it is 2/3 and 1/3 by exhausting all the possibilities. Saying the results are wrong because they don't come out to the expected results doesn't help the code as an argument to convince someone who isn't already convinced of the results. Can you see where I miscounted? Of course you may not be interested in an exhaustive enumeration as proof and may be disinclined to help me ;).

  12. So I didn't randomly simulate it on Psychologists Don't Know Math · · Score: 1

    I just went thru all the possibilities exhaustively.
    I look forward to seeing someone complain about my code, I probably did something mathematically wrong

    % cat monty_exhaust.rb
    class Round < Struct.new(:car_door, :initial_chosen_door, :switched_to_door)
      def won?
        car_door == switched_to_door
      end

      def switched?
        initial_chosen_door != switched_to_door
      end
    end

    rounds = []
    doors = [1,2,3]
    doors.each do |car_door|
      doors.each do |initial_chosen_door|
        (doors - [car_door, initial_chosen_door]).each do |montys_door|
          round_noswitch = Round.new(car_door,
                                     initial_chosen_door,
                                     initial_chosen_door)
          round_switch = Round.new(car_door,
                                   initial_chosen_door,
                                   (doors - [initial_chosen_door, montys_door]).first)
          rounds << round_noswitch
          rounds << round_switch
        end
      end
    end

    puts "Won when switching %: "
    switching_rounds = rounds.select { |r| r.switched? }.uniq
    puts switching_rounds.select { |r| r.won? }.size / switching_rounds.size.to_f

    puts "Won when wasn't switching %: "
    nonswitching_rounds = rounds.select { |r| !r.switched? }.uniq
    puts nonswitching_rounds.select { |r| r.won? }.size / nonswitching_rounds.size.to_f

    % ruby monty_exhaust.rb
    Won when switching %:
    0.5
    Won when wasn't switching %:
    0.333333333333333

  13. Re:You're a naive idealist. on Writers Find Blogging To Be a Stressful Method of Reporting · · Score: 1

    So, um don't be a blogger. Get into a profession where you can make a ton of money and not be tearing your hair out from stress. If the goal is to get money, don't lock yourself in a box by saying, "I have to be a blogger, so to make sure I make oodles of cash safely, let's fix blogging."

  14. Re:More on Rick Astley's char sheet on Celebrity AD&D Character Sheets · · Score: 1

    *applause*

  15. Re:They've misused the Chaotic Neutral Alignment on Celebrity AD&D Character Sheets · · Score: 1

    Agreed. Not CN at all, his motives are always pretty clear.

  16. Re:Error in 'George Bush' on Celebrity AD&D Character Sheets · · Score: 1

    Hehe. George W. Bush, material component for all Dick Cheney's spells.

  17. Re:Red Alert Counterstrike? Re:Old news on Engineers Make Good Terrorists? · · Score: 3, Funny

    The reign of terror imposed by GDI can only be ended by GDI+. Or maybe OpenGL.

  18. Re:Hello Citizen on US Cyber Command Wants Greater Attack Mentality · · Score: 1

    I see the makings of a Law and Order episode.

  19. Re:Tagging? on Should IT Shops Let Users Manage Their Own PCs? · · Score: 1

    Click the grey arrow (triangle) next to the list of existing tags. You're it.

  20. Re:Verilog on What Programming Languages Should You Learn Next? · · Score: 1

    Being able to pass a pointer to a public property (or a pair of getter/setter methods) isn't about bypassing the encapsulation. It's about abstracting away _which_ property (the name of it, and/or even the class or type of the object whose property you are manipulating).

  21. Re:Verilog on What Programming Languages Should You Learn Next? · · Score: 1

    What about if you have a void* pointer? In that case, do you have to cast it to the correct pointer type before dereferencing?
    Yes.
  22. Re:I think slashdot Mac users are more vulnerable on Should Mac Users Run Antivirus Software? · · Score: 1

    ".exe" implies a very specific intel binary executable for Microsoft OS's, and it should stay that way.
    No it doesn't. DOS / Windows / other MS OSes are not the only OSes that use .exe as the extension for executables, and it's not all Intel either.
  23. Re:Bull on Mozilla Hitting 'Brick Walls' Getting Firefox on Phones · · Score: 1

    Usable UI fine, but innovative? Why does a web browser's interface need to be innovative?

  24. cute on Demiforce Releases "Trism", New Game for iPhone, iPod Touch · · Score: 0, Redundant

    cute.

  25. Re:SIgned ints for cash on World of Warcraft Gold Limit Reached, It's 2^31 · · Score: 1

    And of course by Brawl I meant Melee. Sigh