Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Query - Converting an Array into another one

Expand Messages
  • Tabassum Shaikh
    Okay. I got your point. And I couldnt agree more. But maybe I am being totally misinterpreted here. I had solutions to the puzzle. (See below) I just wanted to
    Message 1 of 7 , Mar 29, 2006
    • 0 Attachment
      Okay. I got your point. And I couldnt agree more.

      But maybe I am being totally misinterpreted here.

      I had solutions to the puzzle. (See below)
      I just wanted to make it a better one, a more flexible one.
      I posted the mail for just pointers/directions and not the answer itself!
      (If you read my entire original mail, esp the last para)
      I had subscribed to this group to learn perl. But I guess its more abt solving the issue rather than solving it the best possible way.

      Anyways, maybe my presentation of the prob was wrong or maybe I was wrong in posting it. I shall take care of it going fwd.

      Sorry ppl, for cluttering your mailboxes.
      This one is the last.

      Solutions:
      for(my $x=0;$x<3;$x++)
      {
      for(my $y=0;$y<3;$y++)
      {
      print("Enter the value to save in the array : ");
      $input = <stdin>;
      $arr1[$x][$y] = $input;
      }
      }
      my $m=0;
      for(my $i=2;$i>=0;$i--)
      {
      my $n=0;
      for(my $j=2;$j>=0;$j--)
      {

      $arr2[$m][$n] = $arr1[$i][$j];
      print ("$arr2[$m][$n]");
      $n++;
      }
      $m++;
      }

      or perhaps used a mathematical logic like:

      #Changing the columns
      $a[0][0] +=$a[0][2];
      $a[1][0] +=$a[1][2];
      $a[2][0] +=$a[2][2];
      $a[0][2] = $a[0][0]-$a[0][2];
      $a[1][2] = $a[1][0]-$a[1][2];
      $a[2][2] = $a[2][0]-$a[2][2];
      $a[0][0] = $a[0][0]-$a[0][2];
      $a[1][0] = $a[1][0]-$a[1][2];
      $a[2][0] = $a[2][0]-$a[2][2];
      #Changing the rows
      $a[0][0] +=$a[2][0];
      $a[0][1] +=$a[2][1];
      $a[0][2] +=$a[2][2];
      $a[2][0] = $a[0][0]-$a[2][0];
      $a[2][1] = $a[0][1]-$a[2][1];
      $a[2][2] = $a[0][2]-$a[2][2];
      $a[0][0] = $a[0][0]-$a[2][0];
      $a[0][1] = $a[0][1]-$a[2][1];
      $a[0][2] = $a[0][2]-$a[2][2];


      "Charles K. Clarkson" <cclarkson@...> wrote:
      Tabassum Shaikh wrote:

      : I didnt say that it was a real life problem either.

      It was implied. By not saying what you were doing,
      you implied that this was a real life problem.


      : I agreed that it was a puzzle.
      :
      : I didnt know that we couldnt post puzzles in here.

      Of course you can post puzzles here. If you do post
      a puzzle which looks just like homework and you don't
      explain your post, don't be surprised that we land on
      you like a ton of bricks. PBML posters are forbidden
      from answering homework problems.

      You didn't have the patience to post a full
      explanation. Why fault us for not having the patience
      to confirm this wasn't homework?

      Most of the people answering questions here
      realize the importance of working out homework
      problems for yourself. The very last thing we want to
      do is mistakenly answer someone's homework and rob
      them of a needed lesson.


      HTH,

      Charles K. Clarkson
      --
      Mobile Homes Specialist
      254 968-8328




      Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



      ---------------------------------
      YAHOO! GROUPS LINKS


      Visit your group "perl-beginner" on the web.

      To unsubscribe from this group, send an email to:
      perl-beginner-unsubscribe@yahoogroups.com

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      ---------------------------------





      ---------------------------------
      New Yahoo! Messenger with Voice. Call regular phones from your PC for low, low rates.

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.