• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java 6 - Grains

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have completed this in 10 lines - the assignment notes say it took the lecturer 35 lines. I can't work out why it would take so many. I know I can't talk about specific solutions here, maybe someone could email me with any comments?
Cheers,
Martin
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If one excludes the blank and comment lines , the instructors solution is 17 lines of code.
It's a pretty "nifty" solution and if you manage to shrink it down to 10 you must really have some code.
Remember though good programming habits dictates that your code must be readable and understandable by the average programmer. Are you really sure one does not have to be a math's and/or computer whizz to understand you code.
[This message has been edited by Johannes de Jong (edited October 08, 2001).]
 
Martin Rennix
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I'm curious - but I haven't paid the $200! Doh!
Martin
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul often says he could have done it in one line of code, but it wouldn't be very readable.
 
Johannes de Jong
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd love to see him post that line of code here
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've just passed Grains, and after seeing the authors solution, I bet they could do in one line.
Maybe the one-liner could be posted in the Solutions Discussion forum so we all can be wow'd by it
reply
    Bookmark Topic Watch Topic
  • New Topic