Adventure Forums

Adventure Forums (https://adventuregamers.com/archive/forums/)
-   Chit Chat (https://adventuregamers.com/archive/forums/chit-chat/)
-   -   Super Huge Homework Help! (https://adventuregamers.com/archive/forums/chit-chat/14188-super-huge-homework-help.html)

tabacco 04-23-2006 09:34 PM

Quote:

Originally Posted by SakSquash
What's min()?

Like I said, it's a function that returns the lowest of two numbers. If that confuses you, try googling for "min" and "javascript"

SakSquash 04-24-2006 05:09 AM

Nevermind.

SoccerDude28 04-24-2006 09:01 AM

Okay take this example. You have 3 numbers: X, Y and Z. (X, Y and Z can be any 3 numbers at random)

How would you go about finding which one is the smallest. Forget about programming for now, just use your common sense logic.

SakSquash 04-24-2006 12:11 PM

Well...I would look at it...see which one is the smallest..and say yup, that's the smallest.

I think i'm missing your point?

AFGNCAAP 04-24-2006 01:02 PM

What SoccerDude meant is: how to find the smallest number if you can compare only two at the time? (because the "min" function gives you the smaller of two, not three)

So, suppose you have three rocks and a scale such as this one (doesn't show you the weight, only allows to compare two things). How would you proceed to find the lightest one?

SoccerDude28 04-24-2006 01:28 PM

Quote:

Originally Posted by SakSquash
Well...I would look at it...see which one is the smallest..and say yup, that's the smallest.

I think i'm missing your point?

In computers you can only compare two elements to each other at one point. To find out if something is smaller than another you use a comparison operator (namely the "<" or ">" signs).

so to compare if X is smaller than Y, you would say if(X<Y).

So let's go back to our small example. You have 3 numbers hidden from you X, Y and Z. They can contain any number. You can compare two of them at a time, using the if operator like the example above. How do you go about finding the minimum of the 3 numbers. You can only compare two of them together at one point, and their contents is unknown to you before you run the program.

SakSquash 04-24-2006 01:32 PM

I dunno? Something like X<Y, X<Z, Y<Z?

SoccerDude28 04-24-2006 01:42 PM

Quote:

Originally Posted by SakSquash
I dunno? Something like X<Y, X<Z, Y<Z?

Okay suppose you have 4 elements W, X, Y and Z, how would you find the minimum? EDIT: And you can also only compare 2 at a time.

Huz 04-24-2006 04:03 PM

God.

Aj_ 04-24-2006 04:06 PM

Quote:

Originally Posted by SakSquash
I dunno? Something like X<Y, X<Z, Y<Z?

With three variables you only need to test twice. Once you know that X is smaller than Y and Z, you know it's the smallest.
For example:
x = 4
y = 5
z = 6

compare x, y // result x, compare it to the next
compare x, z // result x, x is the smallest

x = 5
y = 4
z = 6

compare x, y // result y
compare y, z // result y

x = 5
y = 6
z = 4

compare x, y // result x
compare x, z // result z

For just three you're looking at something like this, in pseudo code:
if (x<y)
result=x
else
result=y

if (result>z)
result=z

any more variables and you should be thinking about loops, on the same principle, just keep passing the smallest number to the next in the list, comparing, then passing that along, the number at the end is the smallest.

SoccerDude28 04-24-2006 04:21 PM

That's what I was trying to get to. I wanted Saksquash to think about a little though :shifty:

Aj_ 04-24-2006 04:40 PM

Quote:

Originally Posted by SoccerDude28
That's what I was trying to get to. I wanted Saksquash to think about a little though :shifty:

If he uses that logic with three variables, then the chances are he'll use them with four. He had a stab at it, didn't get it, I gave him an example to help him. I don't see the point in asking the same question twice.

SakSquash 04-24-2006 05:48 PM

God, I hate math.

Jeysie 04-24-2006 06:32 PM

Quote:

Originally Posted by SakSquash
God, I hate math.

Then, if I might be blunt, what the heck are you doing taking programming classes? I mean, coding is full of math, or at least related ways of thinking.

Peace & Luv, Liz

SakSquash 04-24-2006 06:49 PM

The course is web design...as in html...I didn't know i'd be doing java.

Jeysie 04-24-2006 07:03 PM

So... somehow you never expected a web design course to consist of learning web technologies?

Peace & Luv, Liz

SakSquash 04-24-2006 08:09 PM

Shut the **** up.

tabacco 04-24-2006 09:32 PM

Quote:

Originally Posted by Jeysie
So... somehow you never expected a web design course to consist of learning web technologies?

Peace & Luv, Liz

No, he's right. I wouldn't neccesarily expect an HTML course to incorporate Javascript. I think it's good that it does, because it's a useful technology, but it's not something I think is a given in an intro to HTML course.

Jeysie 04-24-2006 10:22 PM

Quote:

Originally Posted by tabacco
No, he's right. I wouldn't neccesarily expect an HTML course to incorporate Javascript. I think it's good that it does, because it's a useful technology, but it's not something I think is a given in an intro to HTML course.

Heh. Well, I have to admit I'm now curious about why he's taking the course. Because even if an Intro to HTML course didn't have javascript stuff, if you were going to be "serious" about web designing, you'd have to take classes on other web technologies eventually anyway, I would think.

Which is one reason why I never bothered getting serious about webmastering even though I enjoy it... trying to figure out most programming concepts (i.e. anything beyond HTML and CSS) gives me a headache.

Peace & Luv, Liz


All times are GMT -8. The time now is 09:34 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Design & Logo Copyright ©1998 - 2017, Adventure Gamers®.
All posts by users and Adventure Gamers staff members are property of their original author and don't necessarily represent the opinion or editorial stance of Adventure Gamers.