Thursday, March 22, 2007

COMP 102 Temporary Wiki

I am too lazy to have a wiki and newsgroup is something that is obsolete anyway. So for all the helps you need, please post it here, and I will answer them to the best of my ability.


Help for assignment 4:

I have received some questions about question 2 in the assignment, so I will post some clarifications from the instructor here:

From the instructor:

The "model the peers" part for 4pt is about describing how they modelled the
network, and why. This can be done on the graph, or in a few sentences. The
second part for 2pt is for only drawing the graph itself.

In this question we are talking about a P2P network where peers talk DIRECTLY
to one another.

Hope it helps..

Update: I will not be here at 1 pm but I will be back at 2 so the office hour is delayed for 1 hr.


Help for assignment 3:

1. Truncating an floating point:

Try: var truncated_value = Math.round(my_initial_floating_point_val)
reference: http://www.javascriptkit.com/javatutors/round.shtml for help.

2. loop to infinitity?

Take a look at how to use break in loop.
Cheap shot: try, while(confirm("you wanna keep playing?"))

Update: skeleton code of question 2 is available! Check the TA page!

3. Hard Way to code Tic-tat-toe.

I tried to put up a sample code in the blog but it interprets the code as valid HTML and tries to parses it. So i could not display the code probably on the blog. Let me put it this way: if you use HTML table it will requires a lot more knowledge than what you have learned in class. Better to keep things simple by not touching the HTML layout at all.

Of course, if anyone is really interested in doing that, then reply here and I will try to create the sample code.

4. Multidimensional Array

Unlike Ruby or Python, there is no built-in support for array / list type in JS. Everything is treated like an object.

Therefore, to declare a 3x3 2-dimensional array you need to do this:

a = new Array[3];
a[0] = new Array[3];
a[1] = new Array[3];
a[2] = new Array[3];

Well you get the idea. Not the most elegant way to construct it and I will avoid it as much as possible.

Again, please post your questions HERE instead. I don't check my email too often so please use this wiki. It also benefits others who may have the same questions in mind.

Update: I have made the following list to Greg as the submission format requirement. But I have not received any news so I will post the following as the preferred guildline for this submission.

1. Each assignment should be submitted electronically through a ZIP file.

(Very important!!!) The name of the zip file should be: c102-a3-lastname-firstname.zip . Files not adhered to this format is not accepted.

2. The zip file MUST contain 3 html files with the following names:

bi-converter.html
tic-tat-toe.html
mandelbrot.html

I will run a script that tests for these three files. File names other than the ones I specified will not get tested.

3. Each file MUST COMPILE: a blank screen means automatically a zero for the specified question.

4. Each script MUST contain a comment that specifies the name of the author, and if they used the skeleton code provided. Submissions that use the skeleton code but did not specify the source is considered plagiarism.

5. All files MUST BE SUBMITTED to this email address: iyuen@cs.mcgill.ca or isaac.yuen@mail.mcgill.ca . Submissions to any other places will not be accepted.

6. Submission deadline March 27th 11:59 pm.

107 comments:

Anonymous said...

Testing

Anonymous said...

To Alex, but JS does not offer a truncated version of / (unlike Java).

So Round is still your best bet, or maybe it will round up so beware to that.

Anonymous said...

Yes your equation works.

Anonymous said...

Thanks Isaac!

I have another question for you. How many && or || operators can we put in a single conditional statement?

For example, can I write:
if ( x>>3 && y>>3 && z>>3) {...}?
or if ( x>>3 || y>>3 || z>>3) {...}?

If so, is it possible to include both operators:

if ( x>>3 && y>>3 || z>>3) {...}?

How does JS interpret that?
is it (x && y) || (z)
or is is (x) && (y || z)?

-Alex

Anonymous said...

Yes Alex. Theoretically you can post infinite amount of boolean statements in the guard expression.

But, why are you doing X >> 3? '>>' is a bit-wise shift. I think you mean '>' instead?

For operator precedence, check out:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Operators

So yea, it is equivalent to ((x && y) || z) in your example

Anonymous said...

Hi Isaac,

I can't find where in the tic-tac-toe code I need to change things so that there is a player one and a player 2. I also don't know how I can switch from player 1 to 2. I am really out of idea for that, can you help me?

Thanks,
Caroline Saucier

Anonymous said...

To Caroline,

You can have a while loop and skip switching between player 1 and 2:

while( game_has_not_finished )
if (player == 1) {
// player_1_code

player = 2;
}
else
{
// player_2_code
player = 1;
}
}

Anonymous said...

well if prompt you promtp twice:

var player_1_name = prompt("Enter name player 1");

var player_2_name = prompt("Enter name player 2");

and in the while loop, you have two branch, one branch for player 1 and the other for player 2

Anonymous said...

All right, it works.

Thank you!
Caroline

Anonymous said...

Hey Isaac,

For the tic-tac-toe again... I am trying to implement the

if (board[3]==board[4]==board[5]==1) {
alert(name_1 + " wins!!"); break;
}

but no matter what combination I choose, the alert (you win) goes on as soon as there are three values on the board, no matter which player is playing. What is the problem?

thanks,
Caroline

Anonymous said...

Iwill have to see a large piece of code.

Anonymous said...

Thanks for article!

Anonymous said...

Thanks for interesting article.

Anonymous said...

Glad to read articles like this. Thanks to author!

Anonymous said...

Very interesting article, I have long sought. It is in front of me. I agree with you!

Anonymous said...

Excellent website. Good work. Very useful. I will bookmark!

Anonymous said...

Hello! Interesting article, thanks to author!

Anonymous said...

hJhD1y You have a talant! Write more!

Anonymous said...

IW4GdL Please write anything else!

Anonymous said...

lXLhTA The best blog you have!

Anonymous said...

xDnTmB actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

Thanks to author.

Anonymous said...

Magnific!

Anonymous said...

Wonderful blog.

Anonymous said...

Good job!

Anonymous said...

Wonderful blog.

Anonymous said...

Wonderful blog.

Anonymous said...

Good job!

Anonymous said...

Thanks to author.

Anonymous said...

Thanks to author.

Anonymous said...

8wR6se write more, thanks.

Anonymous said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

Hello all!

Anonymous said...

Please write anything else!

Anonymous said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

Good job!

Anonymous said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

Good job!

Anonymous said...

Please write anything else!

Anonymous said...

Nice Article.

Anonymous said...

Nice Article.

Anonymous said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

Please write anything else!

Anonymous said...

Give me ambiguity or give me something else.

Anonymous said...

Ever notice how fast Windows runs? Neither did I.

Anonymous said...

Calvin, we will not have an anatomically correct snowman!

Anonymous said...

Energizer Bunny Arrested! Charged with battery.

Anonymous said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

Anonymous said...

If ignorance is bliss, you must be orgasmic.

Anonymous said...

What is a free gift ? Aren't all gifts free?

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

The gene pool could use a little chlorine.

Anonymous said...

What is a free gift ? Aren't all gifts free?

Anonymous said...

Hello all!

Anonymous said...

When there's a will, I want to be in it.

Anonymous said...

Ever notice how fast Windows runs? Neither did I.

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

Give me ambiguity or give me something else.

Anonymous said...

Lottery: A tax on people who are bad at math.

Anonymous said...

Friends help you move. Real friends help you move bodies

Anonymous said...

C++ should have been called B

Anonymous said...

Calvin, we will not have an anatomically correct snowman!

Anonymous said...

Save the whales, collect the whole set

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

Lottery: A tax on people who are bad at math.

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

When there's a will, I want to be in it.

Anonymous said...

Thanks to author.

Anonymous said...

If ignorance is bliss, you must be orgasmic.

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

Save the whales, collect the whole set

Anonymous said...

Give me ambiguity or give me something else.

Anonymous said...

All generalizations are false, including this one.

Anonymous said...

640K ought to be enough for anybody. - Bill Gates 81

Anonymous said...

When there's a will, I want to be in it.

Anonymous said...

Lottery: A tax on people who are bad at math.

Anonymous said...

The gene pool could use a little chlorine.

Anonymous said...

Nice Article.

Anonymous said...

Thanks to author.

Anonymous said...

Save the whales, collect the whole set

Anonymous said...

All generalizations are false, including this one.

Anonymous said...

Clap on! , Clap off! clap@#&$NO CARRIER

Anonymous said...

Save the whales, collect the whole set

Anonymous said...

Energizer Bunny Arrested! Charged with battery.

Anonymous said...

What is a free gift ? Aren't all gifts free?

Anonymous said...

A lot of people mistake a short memory for a clear conscience.

Anonymous said...

Build a watch in 179 easy steps - by C. Forsberg.

Anonymous said...

The gene pool could use a little chlorine.

Anonymous said...

Calvin, we will not have an anatomically correct snowman!

Anonymous said...

Energizer Bunny Arrested! Charged with battery.

Anonymous said...

A lot of people mistake a short memory for a clear conscience.

Anonymous said...

I'm not a complete idiot, some parts are missing!

Anonymous said...

best catholic dating sites http://loveepicentre.com/map.php dating by sign

Anonymous said...

cleveland ohio married and dating http://loveepicentre.com/faq.php asian and black dating

Anonymous said...

proposal ebook http://audiobookscollection.co.uk/Governing-Sustainable-Cities/p105023/ how to write a ebook [url=http://audiobookscollection.co.uk/Hardware-and-Software-Verification-and-Testing-4th-International-Haifa-Verification-Conference-HVC-2008-Haifa-Israel-October-27-30-2008-Programming-and-Software-Engineering/p222414/]doid ebook reader[/url] xaml in nutshell ebook torrent

Anonymous said...

bonsai gardening secrets ebook http://audiobookscollection.co.uk/C-The-Complete-Reference/p185620/ free ebook asset pricing gorge pinochet [url=http://audiobookscollection.co.uk/es/Padres-y-familia/c1050/?page=14]learning corel painter ix ebook[/url] ebook of computer

Anonymous said...

poker ebook http://audiobooksplanet.co.uk/Profumo-Gaja-Scienza-Italian-Edition/p206872/ make an ebook from your library [url=http://audiobooksplanet.co.uk/Gene-avatars-the-neo-Darwinian-theory-of-evolution/p100048/]free journal implementation of ebook[/url] the best ebook writer

Anonymous said...

c# unleashed joe mayo ebook http://audiobooksworld.co.uk/Bible-and-Other-Sacred-Texts/c1112/?page=3 free ebook rice [url=http://audiobooksworld.co.uk/Techniques-of-fantasy-art/p157115/]html ebook maker[/url] ebook on chaos fractal

Anonymous said...

nikon d200 ebook http://audiobooksworld.co.uk/Gouxiong-Xue/m44929/ ebook diary of anne frank [url=http://audiobooksworld.co.uk/Xinjie-Yu/m133982/]david carnoy ebook[/url] free bruce springsteen ebook downloading
[url=http://audiobooksworld.co.uk/it/J-D/m53761/][img]http://audiobooksworld.co.uk/image/6.gif[/img][/url]

Anonymous said...

setpoint software for logitech http://buysoftwareonline.co.uk/it/category-13/Software-di-Musica?page=23 seven network software [url=http://buysoftwareonline.co.uk/category-100-110/Internet]best rendering software for archicad[/url] blackberry 4.3 software beta
[url=http://buysoftwareonline.co.uk/de/category-5/PC-Diagnose]PC Diagnose - Download OEM, Software Sale, OEM Software[/url] boeing video conferencing software
[url=http://buysoftwareonline.co.uk/es/category-100-113/Programas-de-m-sica?page=4][img]http://buyoem.co.uk/image/5.gif[/img][/url]

Anonymous said...

opera accounting software http://buysoftwareonline.co.uk/product-37166/UltraTagger-2-3 system recovery software for windows vista [url=http://buysoftwareonline.co.uk/product-14111/PhotoZoom-Pro-2-1-Mac]syria software sanctions[/url] breakthrough replication software
[url=http://buysoftwareonline.co.uk/account/account]Account Login - Software Store[/url] wm5 gps software
[url=http://buysoftwareonline.co.uk/es/category-100-104/Extensiones-de-programas?page=2][img]http://buyoem.co.uk/image/3.gif[/img][/url]

Anonymous said...

[url=http://onlinemedistore.com/products/astelin.htm][img]http://onlinemedistore.com/4.jpg[/img][/url]
pharmacy test http://onlinemedistore.com/catalogue/h.htm pharmacy online message boards new levitra [url=http://onlinemedistore.com/products/levitra.htm]pharmacy school unc[/url]
ellis hospital pharmacy schenectady ny http://onlinemedistore.com/catalogue/o.htm cardizem cd canada online pharmacy cardizem cd actos norvasc [url=http://onlinemedistore.com/products/activ8--energy-booster-.htm]activ8 energy booster [/url]
aarp pharmacy http://onlinemedistore.com/products/generic-keflex.htm wsu pharmacy [url=http://onlinemedistore.com/products/lysexl.htm]holland park pharmacy[/url]
online pharmacys http://onlinemedistore.com/products/glucophage.htm ct long term care pharmacy [url=http://onlinemedistore.com/products/himplasia.htm]himplasia[/url]

Anonymous said...

[url=http://certifiedpharmacy.co.uk/products/allopurinol.htm][img]http://onlinemedistore.com/4.jpg[/img][/url]
pharmacy by san francisco airport http://certifiedpharmacy.co.uk/products/serevent.htm the lines of communitcation within a pharmacy [url=http://certifiedpharmacy.co.uk/products/female-viagra.htm]parleigh pharmacy[/url]
malouf pharmacy competition http://certifiedpharmacy.co.uk/categories/skin-care.htm tesco pharmacy open hours [url=http://certifiedpharmacy.co.uk/products/tetracycline.htm]tetracycline[/url]
bakersfield home care pharmacy http://certifiedpharmacy.co.uk/products/mxman.htm requirements for va pharmacy program [url=http://certifiedpharmacy.co.uk/products/eriacta.htm]cvs pharmacy blood pressure[/url]
new mexico school of pharmacy http://certifiedpharmacy.co.uk/products/levitra-professional.htm top pharmacy schools in uk dpharm [url=http://certifiedpharmacy.co.uk/products/elavil.htm]elavil[/url]

Anonymous said...

[url=http://fdaapproved.co.uk/products/benicar.htm][img]http://onlinemedistore.com/5.jpg[/img][/url]
top pharmacy school http://fdaapproved.co.uk/products/indinavir.htm offshore caribean pharmacy [url=http://fdaapproved.co.uk/products/finpecia.htm]midwestern university college of pharmacy[/url]
cvs pharmacy glen ellyn http://fdaapproved.co.uk/products/levitra-professional.htm low price pharmacy hickory nc [url=http://fdaapproved.co.uk/products/xtz--energy-booster-.htm]xtz energy booster [/url]
medco health home delivery pharmacy service http://fdaapproved.co.uk/products/micardis.htm pharmacy technician board [url=http://fdaapproved.co.uk/products/requip.htm]wholefood pharmacy[/url]
shraf pharmacy http://fdaapproved.co.uk/products/lexapro.htm cvs pharmacy blood pressure [url=http://fdaapproved.co.uk/products/luvox.htm]luvox[/url]

Anonymous said...

rumors of jay z beyonce dating [url=http://freeinternetdating.info/meet/meet-and-fuck-leika-game-review]meet and fuck leika game review[/url] brian lee of perfect ten dating
dating black single women discreet http://freeinternetdating.info/matchmaker/gainesville-florida-matchmaker naruto dating sims for girls
virtual free online dating [url=http://freeinternetdating.info/personals/swingers-personals-walker-south-dakota]asperger syndrome dating websites[/url] young and old dating

Anonymous said...

trends in dating for adolecents http://loveepicentre.com/advice/ jessica yellin dating
song hye gyo dating [url=http://loveepicentre.com/map/]euroasia dating[/url] dating changes
nude dating site [url=http://loveepicentre.com]wales dating uk[/url] filipino girls dating [url=http://loveepicentre.com/user/tushu/]tushu[/url] personals sex login dating site