Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,982 members, 7,806,869 topics. Date: Wednesday, 24 April 2024 at 05:25 AM

Programming Challenge 1 (any Language). - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Programming Challenge 1 (any Language). (1410 Views)

Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) / . / Coding Challenge 1: Permutations (2) (3) (4)

(1) (Reply) (Go Down)

Programming Challenge 1 (any Language). by kodewrita(m): 8:31am On Aug 08, 2013
Write a program, in any free language, that prints to the terminal the lyrics to this song, 99 Bottles of Beer)(http://99-bottles-of-beer.net/lyrics.html).

If you copy anything from that site, it will be obvious, so don't try it, although you may find that site useful for seeing code of many different languages.

Rules:
Do not copy code, but you can obviously read it

Try not to comment on other submissions. It will be hard to judge changing entries. If you edit your code, post the new version and make it clear there is a new code.

How it will be judged
Obviously, this is a task that is trivial (one big output statement would work) so the winner will be judged on the following:

•Clean code. Readable code is a must for being a programmer who wishes to possibly interact with others. Some languages can be more readable than others, so it will be judged on the effort of writing clean code, not which language is easier to read by design.
•Logical code. Be a programmer, not a code monkey
•Commented code. If something is possibly unclear (like an obscure use of math), let the readers know. Do not over comment, and let the code speak for itself whenever you can. Have logical variable names and function names. (Excessive commenting is a minus factor)
•Working code. It has to work as it is posted. The code will be read on the forum

Hints:

•When you get to 1 bottle, it is a singular "bottle", whereas all other instances are plural.
•Using this challenge to try out a new language brings you bonus points, so please state when you are using the language for the first time if you are.


All the best.
Re: Programming Challenge 1 (any Language). by spikesC(m): 9:47am On Aug 08, 2013
Re: Programming Challenge 1 (any Language). by Javanian: 10:01am On Aug 08, 2013
So much talk about recursion on this board recently, so i used it cheesy

http://pastebin.com/UxyirRDV
Re: Programming Challenge 1 (any Language). by Ajibel(m): 12:20pm On Aug 08, 2013
Kodewrita:
i've studied this challenge when i saw it as an exercise in the book "Think python". And i read the author's solution to it, should i post my solution and claim to have solved it grin grin grin i know am naa noni embarassed
Re: Programming Challenge 1 (any Language). by spikesC(m): 12:38pm On Aug 08, 2013
Ajibel: Kodewrita:
i've studied this challenge when i saw it as an exercise in the book "Think python". And i read the author's solution to it, should i post my solution and claim to have solved it grin grin grin i know am naa noni embarassed

No, solve it in your own way sad

I will personally look up ur solution with the book's...thanks for giving the name, makes the job easier tongue
Re: Programming Challenge 1 (any Language). by kodewrita(m): 1:51pm On Aug 08, 2013
Ajibel: Kodewrita:
i've studied this challenge when i saw it as an exercise in the book "Think python". And i read the author's solution to it, should i post my solution and claim to have solved it grin grin grin i know am naa noni embarassed
Some people we shall kidnap.....
Re: Programming Challenge 1 (any Language). by Ajibel(m): 2:48pm On Aug 08, 2013
kodewrita:
Some people we shall kidnap.....


peapul Like Spikes c embarassed
Re: Programming Challenge 1 (any Language). by spikesC(m): 3:07pm On Aug 08, 2013
wink
Re: Programming Challenge 1 (any Language). by elvis10ten(m): 7:27am On Aug 10, 2013
@javanian, why use pastebin when you can use ideone.com . Its more better. *winks*
Re: Programming Challenge 1 (any Language). by elvis10ten(m): 7:28am On Aug 10, 2013
Here is my solution. http://ideone.com/iceAYA . @kodewrita, what of that stuff na ?
Re: Programming Challenge 1 (any Language). by DharkPoet(m): 6:12pm On Aug 10, 2013
Here's mine, done in java, I'm a beginner in programming, hence java is my first language. Here's my solution again http://ideone.com/ji8Ysj
Re: Programming Challenge 1 (any Language). by elvis10ten(m): 11:56am On Aug 11, 2013
My new solution: http://ideone.com/u3zwJa
Re: Programming Challenge 1 (any Language). by codeaddict(m): 8:58am On Aug 12, 2013
Javanian: So much talk about recursion on this board recently, so i used it cheesy

http://pastebin.com/UxyirRDV
Nice approach! One error though. Lines 19-23 will print out the wrong result when n is 2.
"1 bottles of beer on the wall".
Re: Programming Challenge 1 (any Language). by Nobody: 4:54pm On Aug 15, 2013
lemme try, C#

for (int i = 99; i >= 0; i--)
{
if (i != 1 && i !=0 && i != 2)
{
lblResult.Text += i + " bottles of beer on the wall, " + i + " bottles of beer.<br />" + " Take one down and pass it around, " + (i - 1).ToString() + " bottles of beer on the wall." + "<p></p>";

}
else if (i == 2)
{
lblResult.Text += i + " bottles of beer on the wall, " + i + " bottles of beer.<br />" + " Take one down and pass it around, " + (i - 1).ToString() + " bottle of beer on the wall." + "<p></p>";
}
else if (i == 1)
{
lblResult.Text += i + " bottle of beer on the wall, " + i + " bottle of beer.<br />" + " Take one down and pass it around, no more bottles of beer on the wall." + "<p></p>";
}
else if (i == 0)
{
lblResult.Text += "No more bottles of beer on the wall, no more bottles of beer.<br />" + "Go to the store and buy some more, 99 bottles of beer on the wall.";
}
}

(1) (Reply)

Brainstorm About New Idea For 2014 / 13 & 15 Years From Nigeria Built Mobile Web Browsing Alternative To Google Chrom / My PC Can No Longer Detect My Mobile Hotspot But Can Detect Others

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 21
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.