View Poll Results: Who do you think is the best beginner?

Voters
19. You may not vote on this poll
Page 12 of 22 FirstFirst ... 21011121314 ... LastLast
Results 111 to 120 of 216

Thread: [Beginner] Programming Challenge: 2

  1. #111
    Join Date
    Feb 2007
    Location
    Edinburgh, Scotland
    Beans
    391

    Re: [Beginner] Programming Challenge: 2

    Quote Originally Posted by jimi_hendrix View Post
    is there a C# ide in the repos that i could use to test to see if my code is compatable?
    MonoDevelop is the Mono C# IDE. Sounds like it should do.

    sudo apt-get install monodevelop
    Today we have 15 minutes of fame, tomorrow 15 minutes of anonymity.
    My Blog | Veza - Opensource TinyURL clone with sensible URLs

  2. #112
    Join Date
    Apr 2007
    Beans
    14,781

    Re: [Beginner] Programming Challenge: 2

    Quote Originally Posted by jimi_hendrix View Post
    is there a C# ide in the repos that i could use to test to see if my code is compatable?
    You mean compiler. It doesn't matter what IDE one uses, but what compiler.

    gmcs is the compiler, see the sticky on how to use it.

  3. #113
    Join Date
    Jul 2008
    Beans
    1,706

    Re: [Beginner] Programming Challenge: 2

    Quote Originally Posted by LaRoza View Post
    You mean compiler. It doesn't matter what IDE one uses, but what compiler.

    gmcs is the compiler, see the sticky on how to use it.
    yes your right...compiler...

  4. #114
    Join Date
    Jul 2008
    Beans
    1,706

    Re: [Beginner] Programming Challenge: 2

    what time will you close the thread tomarrow

  5. #115
    Join Date
    Jul 2008
    Beans
    28

    Re: [Beginner] Programming Challenge: 2

    Alright, here is my solution in ruby, which is a language I just started to learn, thanks to why's (poignant) guide to ruby, which is got to be one of the most entertaining programming resources around. It's really a shame that more open source projects don't use ruby, because it's a really powerful, fun, and elegant language. In fact, the reason I chose to learn it over python is that the code looks a hell of a lot more beautiful.

    Anyway, here it is:
    Code:
    #!/usr/bin/ruby
    
    class Person
      @name, @age, @id = nil
      def setName (name)
        if name.kind_of? String and not name.empty? and name[0] != ' '[0] and name.length < 20
          @name = name.rstrip
        else
          @name = nil
        end
      end
      def setAge (age)
        if age.kind_of? Fixnum and age>0
          @age = age
        else
          @age = nil
        end
      end
      def setId (id)
        if id.kind_of? Fixnum and (1..999999) === id
          @id = id
        else
          @id = nil
        end
      end
      def name
        @name
      end
      def id
        @id
      end
      def age
        @age
      end
    end
    
    def xgets
      result = gets.chomp
      if result.upcase == 'EXIT'
        puts "Program terminated"
        exit
      else
        return result
      end
    end
    
    person = Person.new
    while person.name == nil
      print "Name: ";
      person.setName(xgets)
    end
    while person.age == nil
      print "Age: "
      person.setAge(xgets.to_i)
    end
    while person.id == nil
      print "ID: "
      person.setId(xgets.to_i)
    end
    
    print "You are #{ person.name }, "
    print "aged #{ person.age } next year you will be #{ person.age + 1 }, "
    puts "with user id #{ person.id }, the next user is #{ person.id + 1 }."
    Last edited by xnevermore; August 8th, 2008 at 09:40 AM. Reason: Adjusted code to work for users with OLDER versions of ruby

  6. #116
    Join Date
    Jul 2008
    Beans
    28

    Re: [Beginner] Programming Challenge: 2

    Sweet, after looking through this thread I've realized that I'm the only one with a Ruby version! That should earn me some points, right?

  7. #117
    Join Date
    Apr 2007
    Beans
    14,781

    Re: [Beginner] Programming Challenge: 2

    Quote Originally Posted by jimi_hendrix View Post
    what time will you close the thread tomarrow
    Not sure. I'll wait until you are done if you want. If anyone wants me to wait, let me know as soon as possible (on this thread)

    Quote Originally Posted by xnevermore View Post
    Sweet, after looking through this thread I've realized that I'm the only one with a Ruby version! That should earn me some points, right?
    After finding all that work, I separate them by language, and try to get 10 total. If there are more than 10, I narrow down the language groups (like last time we had a lot of Python and C++, and only a few other languages. I culled the Python and C++ ones to get a top 10, although I think it ended up being only 9)

    Being the only one in a language (and it works) means it won't be bumped unless it is really needed (and since I think we have less submissions this time, it will be unlikely to happen)

  8. #118
    Join Date
    Mar 2008
    Beans
    796

    Re: [Beginner] Programming Challenge: 2

    Fixed it so it won't crash when not typing in numbers. No award winner but it was still fun making it Last changes I will be making to it so if someone finds something wrong or a bug I would love to find out but I'll be too busy to re-do any parts
    PHP Code:
    #!/usr/bin/env python
    #revised version, fixed bug that caused program to crash when user did not enter 
    #a number when asked for their Age and Forum ID

    import sys

    resp1 
    raw_input("What is your forum name (Type quit to exit)? ")
    while 
    resp1 == "":
            
    resp1 raw_input("Please enter your forum name (Type quit to exit)? ")
            if 
    resp1 == "quit":
                    print 
    "Goodbye"
                    
    exit()
            else:
                    if 
    resp1 == " ":
                            print 
    "Please do not use spaces"
                            
    exit()
                    else:   
                        if 
    resp1 != "":
                            print 
    "That's better"
    if resp1 == "quit":
        print 
    "Goodbye"
        
    exit()
    else:
        if 
    resp1 == " ":
            print 
    "Please do not use a space"
            
    exit()
        else:
            if 
    resp1 != "":
                print 
    "Thank You"

                
    resp2 raw_input("What is your age (Type quit to exit)? ")
    while 
    resp2 == "":
            
    resp2 raw_input("Please enter either a number or quit in order to exit ")
            if 
    resp2 == "quit":
                    print 
    "Goodbye"
                    
    exit()       
    if 
    resp2 == "quit":
            print 
    "Goodbye"
            
    exit()
    while 
    resp2:
            try:
                
    resp2 int(resp2)
                if 
    resp2 == int(resp2):
                    break
            
    except:
                
    resp2 raw_input("Please enter a valid number for your age (Type quit to exit)? ")
                if 
    resp2 == "quit":
                    print 
    "Goodbye"
                    
    exit()
                else:
                    if 
    resp2 == "":
                       
    resp2 raw_input("Please enter a valid number for your age (Type quit to exit)? ")
                       if 
    resp2 == "quit":
                               print 
    "Goodbye"
                               
    exit() 
    if 
    resp2 1:
            print 
    "That is not a valid age, Goodbye"
            
    exit()
    else:
            if 
    resp2 999999:
                print 
    "That is not a valid age,Goodbye"
                
    exit()
            else:
                print 
    "Thank You"


    resp3 raw_input("What is your forum ID (Type quit to exit)? ")
    while 
    resp3 == "":
            
    resp3 raw_input("Please either enter your Forum ID or quit")
            if 
    resp3 == "quit":
                    print 
    "Goodbye"
                    
    exit()
    if 
    resp3 == "quit":
            print 
    "Goodbye"
            
    exit()
    while 
    resp3:
            try:
                
    resp3 int(resp3)
                if 
    resp3 == int(resp3):
                    break
            
    except:
                
    resp3 raw_input("Please enter a valid number for your forum ID (Type quit to exit)? ")
                if 
    resp3 == "quit":
                    print 
    "Goodbye"
                    
    exit()
                else:
                        if 
    resp3 == "":
                                
    resp3 raw_input("Please enter a valid number for your forum ID (Type quit to exit? ")
                                if 
    resp3 == "quit":
                                        print 
    "Goodbye"
                                        
    exit()                  
    if 
    resp3 1:
            print 
    "That is not a valid forum ID, Goodbye"
            
    exit()
    else:
            if 
    resp3 999999:
                print 
    "That is not a valid forum ID, Goodbye"
                
    exit()
            else:
                print 
    "Thank You"


    print "You are %s, aged %s next year you will be %s, with user id %s, the next user is %s." % (resp1resp2,resp2 1resp3resp3 +1

  9. #119
    Join Date
    Jul 2008
    Beans
    1,706

    Re: [Beginner] Programming Challenge: 2

    After finding all that work, I separate them by language, and try to get 10 total. If there are more than 10, I narrow down the language groups (like last time we had a lot of Python and C++, and only a few other languages. I culled the Python and C++ ones to get a top 10, although I think it ended up being only 9)

    Being the only one in a language (and it works) means it won't be bumped unless it is really needed (and since I think we have less submissions this time, it will be unlikely to happen)
    i assume that goes the same for my C#?

    and thanks for waiting i should be done tomarrow afternoon

  10. #120
    Join Date
    Apr 2007
    Beans
    14,781

    Re: [Beginner] Programming Challenge: 2

    Quote Originally Posted by jimi_hendrix View Post
    i assume that goes the same for my C#?

    and thanks for waiting i should be done tomarrow afternoon
    Yes.

Page 12 of 22 FirstFirst ... 21011121314 ... LastLast

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
  •