C# Crawler
Sagiv Hadaya is crawling in C#...just for fun





Subscribe to "C# Crawler" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

Google


Sunday, August 11, 2002
 
How Al-Qaida Site Was Hijacked

Very Interesting....must read!

How Al-Qaida Site Was Hijacked. Using tracking tools, a public Web service and impeccable timing, an American hacker explains how he managed to take over al-Qaida's dot-com domain. By Patrick Di Justo. [Wired News]


6:01:02 PM    
is it fast .Net?

Check this out: im not really sure, but it seems that the C# compiler (considering pure managed code) is far more fast than the VC++ comppiler..or is it?

please email me if you think i missunderstood it.


5:43:10 PM    
Riddle answer

Well, after waiting for your responses...here is the answer for the riddle:

the riddle was: [...]You have 3 vending machines, each have a lable WHICH IS MISPLACED (3 vending machines that no machine has its correct label). one machine say 'oranges' the other say 'apples' and the third one say 'apples and oranges'. each machine when given a coin, is spilling a product. by defalt, the machine that is ACTUALLY the 'pples and oranges' spill products randomly.

given this story..how many coins do you need in order to set the 3 lables to thier correct places?

the answer is 1...yes 1.

if you write down all posibilities for each machine you will come to this:

apple machine (label is incorrect) - could be oranges or mix.

oranges machine (label is incorrect) - could be apples or mix.

mix machine (label is incorrect) - could be apples or oranges...

now, we have one coin, so we put it in the mix machine, if we get apples, then its an apples machine, if we get an orange then its an oranges machine.

after that, we look at the 2 machines there were left, we can eliminate the machine that we found from one of them, and its left to be a mix...and the third one is... what's left.

 

cool?


5:00:24 PM    
Right On..

far more simplified version, now using the .ToCharArray() method. thanks to Joe Labrock.

using System;

namespace ConsoleApplication3

{

        class Permute

        {

                 private void swap (ref char a, ref char b)

                 {

                        if(a==b)return;

                        a^=b;

                        b^=a;

                        a^=b;

                  }

                  public void setper(char[] list)

                  {

                        int x=list.Length-1;

                        go(list,0,x);

                  }

                  private void go (char[] list, int k, int m)

                  {

                        int i;

                        if (k == m)

                           {

                                 Console.Write (list);

                                 Console.WriteLine (" ");

                            }

                        else

                             for (i = k; i <= m; i++)

                            {

                                   swap (ref list[k],ref list[i]);

                                   go (list, k+1, m);

                                   swap (ref list[k],ref list[i]);

                             }

                   }

         }

         class Class1

        {

               static void Main()

               {

                      Permute p = new Permute();

                      string c="sagiv";

                       char []c2=c.ToCharArray ();

                       /*calling the permute*/

                      p.setper(c2);

                  }

           }

}


4:46:48 PM    
1st Solution!

I have managed to write an application that writes down the permutations of a string.

if somebody has a better way to 'swap' two chars in a string... let me know.

 

using System;

namespace ConsoleApplication3

{

class Permute

{

public void swap (ref string str, int pos1, int pos2)

{

if (pos1 == pos2) return;

if (pos2<pos1) // swap positions, so pos 2 will be the higher

{

pos1^=pos2;

pos2^=pos1;

pos1^=pos2;

}

string temp;

temp = str.Substring(0,pos1);

temp += str.Substring ((pos2),1);

if (pos1+1 != pos2)

{

if (pos1==0) temp += str.Substring ((pos1+1),(pos2-1));

else temp += str.Substring ((pos1+1),(pos2-2));

}

temp += str.Substring (pos1,1);

temp += str.Substring ((pos2+1));

str =temp;

}

public void go (string list, int k, int m)

{

int i;

if (k == m)

{

for (i = 0; i <= m; i++)

Console.Write (list [i]);

Console.WriteLine (" ");

}

else

for (i = k; i <= m; i++)

{

swap (ref list, k,i);

go (list, k+1, m);

swap (ref list,k,i);

}

}

}

class Class1

{

static void Main()

{

Permute p = new Permute();

string c="1234";

p.go(c, 0, 3);

}

}

}


10:57:21 AM    



Click here to visit the Radio UserLand website. © Copyright 2002 Sagiv Hadaya.
Last update: 9/3/2002; 3:12:10 PM.
August 2002
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Jul   Sep

C#_Help

C#_Organization

DEVX

Google

Microsoft

CSharp_Friends