Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36

Thread: Programmer's drinking song

  1. #11
    Join Date
    Sep 2007
    Location
    In here watching you!
    Beans
    Hidden!

    Re: Programmer's drinking song

    Quote Originally Posted by Shining Arcanine View Post
    Does anyone want to write a version of this in C?
    Are you talking about the C programing language? Or are you referring to C# or C, from the music viewpoint?

    Last edited by Old_Grey_Wolf; December 7th, 2010 at 05:18 AM.
    Use whatever OS or desktop works for you. Dual boot or use VMs if you want. Backup your computer regularly, and definitely before upgrading, partitioning, or installing an OS.

    No support requests by PM please.

  2. #12
    Join Date
    May 2010
    Beans
    90
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Programmer's drinking song

    Code:
    #!/usr/bin/env python
    
    def main():
        bugs = 1
        while True:
            if bugs <= 1:
                print "One tiny little bug in the code\nOne tiny little bug."
                print "Fix one bug, run it again"
                bugs += 1
            else:
                bugs += 1
                print "%i little bugs in the code\n%i little bugs." % (bugs, bugs)
                print "Fix one bug, run it again"
        return 0
    
    if __name__ == '__main__':
        main()
    This is my Python contribution. Hope you like it

  3. #13
    Join Date
    Mar 2008
    Location
    Sussex, UK
    Beans
    1,326
    Distro
    Ubuntu

    Re: Programmer's drinking song

    Thanks all, glad it touched a chord - to coin a phrase!

  4. #14
    Join Date
    Sep 2009
    Beans
    Hidden!

    Re: Programmer's drinking song

    Quote Originally Posted by TheWeakSleep View Post
    Code:
    #!/usr/bin/env python
    
    def main():
        bugs = 1
        while True:
            if bugs <= 1:
                print "One tiny little bug in the code\nOne tiny little bug."
                print "Fix one bug, run it again"
                bugs += 1
            else:
                bugs += 1
                print "%i little bugs in the code\n%i little bugs." % (bugs, bugs)
                print "Fix one bug, run it again"
        return 0
    
    if __name__ == '__main__':
        main()
    This is my Python contribution. Hope you like it
    I love you.

  5. #15
    Join Date
    Oct 2007
    Location
    Zagreb, Croatia, Europe
    Beans
    513
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Programmer's drinking song

    Quote Originally Posted by Shining Arcanine View Post
    Does anyone want to write a version of this in C?
    void fixBug(int i, int* bugNo){
    printf("%i little new bug in the code, \n%i little new bug, \n,Fix the bug, make it again," i, i);
    editCode(bugNo);
    make(bugNo);
    if (bugNo == NULL){
    return;
    }
    fixBug(i +1, bugNo);
    }

    recursive version...
    Dear god, I would like to file a bug report.

    increase Firefox startup speed and speed of Smart Location Bar:
    http://ubuntuforums.org/showthread.php?t=1088094

  6. #16
    Join Date
    Nov 2004
    Location
    Maine, USA
    Beans
    Hidden!
    Distro
    Ubuntu 14.10 Utopic Unicorn

    Re: Programmer's drinking song

    Ruby
    Code:
    #!/usr/bin/env ruby
    
    def sing(cycles)
      iterations = cycles.nil? ? 100 : cycles.to_i
      count = bugs = 1
    
      while count <= iterations
        puts "#{bugs} little bug#{"s" if bugs > 1} in the code,\n#{bugs} little bug#{"s" if bugs > 1}."
        puts "Fix one bug, and run it again...\n\n"
        count += 1
        bugs += Random.new.rand(1..3)
      end
      puts "...and the cycle goes on and on...happy coding!"
    end
    
    sing(ARGV[0])
    Last edited by trivialpackets; December 7th, 2010 at 04:12 PM.

  7. #17
    Join Date
    Sep 2007
    Location
    In here watching you!
    Beans
    Hidden!

    Re: Programmer's drinking song

    TheWeakSleep, TheLions, and eric.proctor, I should try running each of those.

    Use whatever OS or desktop works for you. Dual boot or use VMs if you want. Backup your computer regularly, and definitely before upgrading, partitioning, or installing an OS.

    No support requests by PM please.

  8. #18
    Join Date
    Mar 2006
    Beans
    2,423

    Re: Programmer's drinking song

    Quote Originally Posted by TheWeakSleep View Post
    This is my Python contribution. Hope you like it
    when i run that in a terminal it goes on forever...was that your design plan? or can you code it so it stops at 100 or something like that?

  9. #19
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Programmer's drinking song

    Quote Originally Posted by ubuntuman001 View Post
    when i run that in a terminal it goes on forever...was that your design plan? or can you code it so it stops at 100 or something like that?
    Code:
    while True:
    It will keep on going until it falls over. (That'll be the bugs )
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  10. #20
    Join Date
    Nov 2004
    Location
    Maine, USA
    Beans
    Hidden!
    Distro
    Ubuntu 14.10 Utopic Unicorn

    Re: Programmer's drinking song

    I'm working on learning python currently, so I fixed the "bug" and added a feature (random bug counts) to the code posted earlier.

    Code:
    #!/usr/bin/env python
    #Filename: programmers_song.py
    
    import random
    
    def main():
        bugs = 1
        iterations = 0
    
        print("One tiny little bug in the code\nOne tiny little bug.")
        print("Fix one bug, run it again")
        
        while True:
            bugs += random.randint(1,4)
            iterations += 1
            print "%i little bugs in the code\n%i little bugs." % (bugs, bugs)
            print "Fix one bug, run it again"
            if iterations >= 100:
                return False
    
    if __name__ == '__main__':
        main()

Page 2 of 4 FirstFirst 1234 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
  •