Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37

Thread: Hey Feztaa...

  1. #1

    Hey Feztaa...

    I have an idea...

    let's both code a simple program, me in python, you in perl. we'll compare the two side-by-side when we're done and see who's code looks cleaner.

    what do you think?

  2. #2

    Re: Hey Feztaa...

    Ok. How about you write a rot13 encryption program in python.

    The only requirements are that it must rot13 encode whatever the commandline arguments are, and if there are none it takes input from stdin and rot13 encodes that.

    If you don't know what rot13 is, it basically means to convert letters into numbers, subtract 13, and convert it back into letters. So a=n, b=o, c=p, etc (and vice versa).

    Here's mine:

    Code:
    #!/usr/bin/env perl
    
    sub rot13
    {
     $string=join(' ',@_);
     $string=~tr/a-zA-Z/n-za-mN-ZA-M/;
     print $string;
    }
    
    if (defined(@ARGV))
    {
     rot13(@ARGV);
    }
    else
    {
     while (<STDIN>)
     {
      rot13("$_");
     }
    }
    
    print "\n";
    Have fun!

  3. #3
    Guest

    Re: Hey Feztaa...

    For fun, I made it in Ruby (and I'll leave the Python code to inkedmn though I have the solution):

    Code:
    #!/usr/bin/env ruby
    
    class String
     def rot13
      tr! "A-Za-z", "N-ZA-Mn-za-m"
     end
    end
    
    
    if ARGV.size < 1 then
     ARGF.each do |x|
      print x.rot13 + " "
     end
    
    else
     ARGV.each do |x|
      print x.rot13 + " "
     end
    end
    
    print "\n"

  4. #4

    Re: Hey Feztaa...

    I don't know any ruby, but what the hell is ARGF?

  5. #5
    Guest

    Re: Hey Feztaa...


    I don't know any ruby, but what the hell is ARGF?
    equivalent of
    Code:
    while (<STDIN>) {}

  6. #6
    Associate
    Join Date
    May 2001
    Posts
    19

    Re: Hey Feztaa...


    I don't know any ruby, but what the hell is ARGF?
    I'm guessing it's typossian for ARGV.


  7. #7

    Re: Hey Feztaa...

    I'm guessing it's typossian for ARGV.
    It can't be, though, because then the if statement would be pointless -- the same thing would be happening in the else block as the initial if block.

  8. #8
    Associate
    Join Date
    May 2001
    Posts
    19

    Re: Hey Feztaa...




    It can't be, though, because then the if statement would be pointless -- the same thing would be happening in the else block as the initial if block.
    yeah, I hadn't noticed that gnuvince already explained it.

  9. #9

    Re: Hey Feztaa...

    sorry it took so long, haven't had any free time...

    Code:
    #!/usr/bin/env python
    from string import maketrans, translate
    
    def rot13():
     * *string = raw_input("Enter something: ")
     * *trans = maketrans( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
     * * * * * * * * * * *"NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm" )
     * *newstring = translate(string, trans)
     * *print newstring
     * *return newstring
    rot13()
    clean as a whistle, amigo

  10. #10

    Re: Hey Feztaa...

    python is so cool.
    ;D 8) ;D 8) ;D 8)

Similar Threads

  1. Feztaa?
    By GnuVince in forum General Chat
    Replies: 1
    Last Post: 11-01-2002, 09:03 PM
  2. Feztaa
    By gmoreno in forum General Chat
    Replies: 25
    Last Post: 09-04-2002, 01:06 PM
  3. Feztaa
    By GnuVince in forum General Chat
    Replies: 8
    Last Post: 08-03-2002, 12:43 AM
  4. Feztaa
    By in forum General Chat
    Replies: 7
    Last Post: 12-14-2001, 02:36 AM
  5. Feztaa
    By gorn in forum General Chat
    Replies: 3
    Last Post: 11-22-2001, 05:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •