This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Exercise 1


Numbers, letters, variables, assignment and mixing it up

 

Task Discussion


  • Roelof said:

    Here are my solutions to exercise 1.

     

    https://github.com/roelof1967/homework/tree/master/chapter1

    https://github.com/roelof1967/homework/tree/master/chapter4

    I hope someone has the time to look at these and give me feedback.

    on Aug. 28, 2013, 9:38 a.m.

    Andre Dublin said:

    Looks good, yes

    on Aug. 28, 2013, 11:11 p.m. in reply to Roelof
  • Jure said:

    on Oct. 29, 2012, 9:51 a.m.
  • David O'Dowd said:

    I've added some of my examples from the first four chapters https://github.com/davidodowd/coursework

    on Sept. 30, 2012, 7:03 p.m.

    Andre Dublin said:

    Looking good.

    on Sept. 30, 2012, 8:23 p.m. in reply to David O'Dowd
  • Ajiwo said:

    on Aug. 30, 2012, 7:47 a.m.
  • narendhar said:

    I have finished the excercise 1.

    https://github.com/narendahr15/coursework

    on Aug. 20, 2012, 11:19 a.m.

    Andre Dublin said:

    Looks good, how did you come to the number on line 2 in https://github.com/narendahr15/coursework/blob/master/ex1b.rb

    Nice to see some C code in there :)

    If you didn't know Ruby is an interpreted language like PHP in C

    Also you should put some space between your '=' operator and your vars for readability.

    on Aug. 20, 2012, 11:30 a.m. in reply to narendhar
  • swarna_nkl said:

    I couln't insert to my files to git hub , it throws error permission denied public key,

     

    swarnal@swarnal:~/LTP$ git init
    Initialized empty Git repository in /home/swarnal/LTP/.git/
    swarnal@swarnal:~/LTP$ git add 1pgm
    swarnal@swarnal:~/LTP$ git commit -m "first commit"
    [master (root-commit) 7f0077b] first commit
     1 files changed, 1 insertions(+), 0 deletions(-)
     create mode 100644 1pgm
    swarnal@swarnal:~/LTP$ git remote add origin git@github.com:swarnankl/swarna-p2pUassignment.git
    swarnal@swarnal:~/LTP$ git pull origin master
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
    swarnal@swarnal:~/LTP$ git push -u origin master
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
     

    Thanks

    swarna

    on Aug. 20, 2012, 2:51 a.m.

    Andre Dublin said:

    Have you set up git? https://help.github.com/articles/set-up-git

    What OS are you using?

    on Aug. 20, 2012, 7:15 a.m. in reply to swarna_nkl

    Andre Dublin said:

    Anymore luck with this problem?

    on Aug. 27, 2012, 9:42 p.m. in reply to swarna_nkl

    Rhodee said:

    please try adding github to your list of safe ssh domains.

     

    This can be done with 

        ssh -T git@github.com

     

    SSH will bark-no worries: simple accept the prompt with a 'y' or 'yes' if you like typing.

     

    After that check your ssh permissions to ensure your key is actually being picked up by your system:

     

    ssh-add -l

     

    Please post the results of both commands

    on Aug. 28, 2012, 10:22 a.m. in reply to Andre Dublin
  • Krister Löfgren said:

     

    Hi,

    I've done the first three excercises in chapter 1 (the chocolate one was too silly and I didn't understand the last one :/ ). 

    https://github.com/tardigrader/coursework/blob/master/a_few_things_to_try_1.rb

    A
    ll the best,
    Krister

    on Aug. 18, 2012, 3:46 p.m.

    Krister Löfgren said:

    on Aug. 18, 2012, 3:50 p.m. in reply to Krister Löfgren

    Andre Dublin said:

    Looks great.  For formatting of your code you may want to put some space between your '=' operator and your variable so other programmers will be able to pick up what you have written.

    on Aug. 19, 2012, 8:44 p.m. in reply to Krister Löfgren

    Krister Löfgren said:

    Yes, that would make it more readable. Thank you, Andre.

    on Aug. 20, 2012, 6:31 a.m. in reply to Andre Dublin
  • narendhar said:

    Where to find the ltp chapters in reading assignment?

    on Aug. 18, 2012, 1:06 a.m.

    Andre Dublin said:

    You can find it here http://pine.fm/LearnToProgram/

    on Aug. 19, 2012, 8:42 p.m. in reply to narendhar
  • Frank Murphy said:

    Exersice 1, should be:

    https://github.com/Frankly3D/LearnRuby

    the one with the extension.

    Havn't figured out how to delete the other as yet.

    on April 3, 2012, 7:40 a.m.

    Frank Murphy said:

    Got the delete sorted, always just after I post :(

    on April 3, 2012, 7:44 a.m. in reply to Frank Murphy

    Andre Dublin said:

    To delete files from you repo you can do this

    $ git rm <filename>

    or if you want to remove files from your repo but not delete it from disk you can do

    $ git rm --cached <filename>

    So far everything looks good, as for your age in seconds problem.  Use ruby to calculate your age to seconds instead of thinking about the answer.  Let the computer to the work for you.

    Hint

    Age / Days in Year / Hours in Day / Seconds in Hour

    on April 3, 2012, 7:47 a.m. in reply to Frank Murphy
  • Peter Hwang said:

    Hey All - here is my week 1 homework.  That was fun!  Thanks again for all the help!

    https://github.com/hwangpet/coursework

    on March 21, 2012, 11:39 p.m.

    Andre Dublin said:

    Excellent, everything looks great. I'm glad you got your ruby build working.

    on March 22, 2012, 7:28 a.m. in reply to Peter Hwang
  • Tony Shaper said:

    Hi I have just uploaded the first weeks exercises to Github. Location is

    https://github.com/cylons/coursework    Sorry it's a bit late.

    In the first exercise I have used constants for hours in day etc. According to my Ruby book constants should start with capital letter and "unlike most other programming languages" are mutable i.e. can be changed. I find it slightly amusing to have constants that can be changed.

    It reminds me of the old programmers lament "Constants aren't and Variables won't!"

    Any comments welcome.

    on March 20, 2012, 4:50 p.m.

    Andre Dublin said:

    Looks good Tony.  Your right about the constants in ruby, its best practice to let those values remain unchanged.

    The best practice method of writing constants in ruby is this

    MY_CONSTANT_VARIABLE

    aka screaming snake case

    not

    MyConstantVariable

    aka Camelcase

    Camelcase must be used for classes and modules

    check out the ruby-style-guide

    on March 20, 2012, 4:56 p.m. in reply to Tony Shaper
  • Peter Hwang said:

    I'm having some trouble adding my program to the coursework using git.  I'm really new to all of this so I'm probably just doing something dumb.

    Basically, I'm trying to add my week.rb from my documents folder to the coursework.  Check out the error I'm getting below.  Any thoughts?

     

    Command I am running:

    Peters-MacBook-Air:coursework hwangpet$ git add /Users/hwangpet/Documents/Week1.rb

    Error I get:

    fatal: '/Users/hwangpet/Documents/Week1.rb' is outside repository

     

    on March 18, 2012, 11:18 p.m.

    Andre Dublin said:

    It looks as if Documents isn't a working git repo.  My suggestion would be to do this:

    1) Navigate to your Documents folder, then run this command.

    $ git clone git@github.com/hawngpet:coursework.git

    This way you have a working copy of your github repo on your harddrive.

    Now you can perform the usual workflow

    $ git add . or $ git add filename
    
    $ git commit -m 'your message'
    
    $ git push origin master
    
    

    on March 19, 2012, 7:26 a.m. in reply to Peter Hwang

    Peter Hwang said:

    Tried without luck.  See below.  I might spend some time with some of my engineers tommorrow to see if they can help:

     

    Last login: Mon Mar 19 21:59:02 on ttys002
    Peters-MacBook-Air:~ hwangpet$ ls
    Desktop        Downloads    Movies        Pictures    coursework
    Documents    Library        Music        Public        tutorial.txt
    Peters-MacBook-Air:~ hwangpet$ cd Documents
    Peters-MacBook-Air:Documents hwangpet$ ls
    About Stacks.lpdf    firstprog.py        webpage.html
    Battle of the Exes.ods    margy_picks.xls        week1_numbers.rb
    calc.rb            peter_hwang_picks.xls
    Peters-MacBook-Air:Documents hwangpet$ git clone git@github.com/hawngpet:coursework.git
    Cloning into 'coursework'...
    ssh: Could not resolve hostname github.com/hawngpet: nodename nor servname provided, or not known
    fatal: The remote end hung up unexpectedly

    on March 19, 2012, 11:03 p.m. in reply to Andre Dublin
  • sedmonds said:

    Submitted exercises for Week 1 via Github: http://github.com/sedmonds/p2pu_ltp

    I appreciate all coding-related feedback. Thanks and have an excellent week.

    on March 18, 2012, 7:59 a.m.
  • Mark Finlay said:

    Alright lads, happy Paddy's Day from Dublin, Ireland!

    Here's my attempt at the questions for LTP: https://github.com/rudedoc/coursework-week1

    on March 17, 2012, 2:58 p.m.

    Andre Dublin said:

    Nice use of the Time class

    on March 17, 2012, 11 p.m. in reply to Mark Finlay
  • Haitham Gasim said:

    Hi All.

    Please find my week1 assignment at the following address:

     https://github.com/haithamgasim/coursework/tree/master/p2pu/intro_to_ruby

    Comments will be much appreciated.

    Thanks.

    Haitham

    on March 17, 2012, 1:29 p.m.

    Andre Dublin said:

    Looking good

    on March 18, 2012, 2:35 p.m. in reply to Haitham Gasim
  • Anonym said:

    Hi Guys,

    Please find my week1 assignment. Wow, I have just written my first Ruby programs! :-)

    I would appreciate any comments and suggestions. Here is a link to the assignment: 

    https://github.com/JakubJarosz/RubyP2PU/tree/master/ltp-week1

    Thanks,

    Jakub

    on March 16, 2012, 1:52 a.m.

    Andre Dublin said:

    Looks great Jakub! Keep up the good work.

    on March 16, 2012, 7:22 a.m. in reply to Anonym
  • Rhodee said:

    Hi everyone!

     

    Please find my week one assignment here. Please ask me questions. I am not exactly a complete Ruby nuby, but I certainly am not that far from the beginning. Besides, being new means you can ask all kinds of questions =)

    link: https://github.com/Rhodee/ltp-p2pu

    Cheers,

     

    rhodee

    on March 10, 2012, 4:25 p.m.
  • Andre Dublin said:

    When you have finished your assignment and posted to Git, please leave a link here to your repo of the current assignment to let us know your down and for review.

    on March 7, 2012, 11:08 p.m.