HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

The jass Contest PART 1 IS OVER

09-22-2003, 08:12 PM#1
weaaddar
I got very few entrees this time which kind of gets me pertrubed but here are the winners of this segment. I'll have to extend free entry into the next segment as well, the contest will have free entry but I will use a point system to show who has been around longest and one the most entries.
Each of these people have won this segment.
Kerry
Aiursrage2k
Peppar
KaTTaNa
Lord Vexorian
PitzerMike
Sage the Mage
Congratulations for all who participated!

END OF WINNERS
START OF ANSWER
Here is a correct method and the only real way you could of messed up.
Code:
function Multiply takes integer x, integer y returns integer
   local integer TheAnswer=0
   local integer i = 1
   loop
       exitwhen i > y
       set TheAnswer = Add(TheAnswer,x)
       set i = Add(i, 1)
   endloop
return(TheAnswer)
endfunction
The only possible way you really could of messed up was to have the exitwhen i = y+1 after your code which really would of made no difference if this was dealing with numbers of the domain [1,9] but since the domain includes zero if you try to multiply something zero times with a bottom test loop it'll act like a multiple of one.

Why does this work?
Multiplication is defined as adding reagent X with itself Y times. Thus looping the addition function until the incrementor surpasses the the y value. This is the sameway that many of the early calculator did multiplication, as they relied on the gear turning principle used in your odometer today to do addition. (I.e. the 1s digit would have one tooth and turn 10 times before it met up with the the ten toothed gear which would in turn have to turn 10 times before it would meet up with the 100 toothed gear) and it would be quiet a leap to have it increment by multiples.

END ANSWER/EXPLANATION
ORIGINAL PROMPT AND STUFF.

This is the simplest of all the events please make sure to check all the rules before entering.

Prompt:
A company has devoloped a new simplistic calculator which can take 1 postive integer which is less then 10, and do some basic mathamatical function with another postive integer of the same restriction.
(I.e. The calculator can do 3+3 and 7-4 but not 14-74 or 9+90).

The onboard chip which would do the majority of the math seems to have a fatal hardware crash associated with its multiplication function which vicariously is used by all functions except for +,-, and IsEven. The main devoloper had somehow gotten the chip to interface with warcraft III and is using it as a temporary io.

As he discovered the calculator uses a highend language simmilar to jass before he had a heart attack. It is now up to you to write a multiplication function for the calculator which will hopefully salvage the chip and allow the company to further devolopment of the calculator unit.

Goal:
If the prompt was too explicicitive for you,
Write a Multiplication function without actually using the multiplication operator.

Restrictions:
-You can only edit the Multiply Function inside the multiply trigger. Rest assured the main function of Multiply works perfectly fine.
-You can only use the three hardware functions defined in the header of the map, using +,-,* will automatically result in you being disqualified.
-You are allowed to use Loop and If Then Else

The test data:
To make sure you have the the "chip we sent you" (The map) is working properly and that your software code is correct try entering this strings.
Enter this
3+3
3-9
3*3
33*900
You should get
3+3=6
3-9=-6
3*3=9
Nothing you should get no output from this last one. (if you do you've been messing with my program and that is bad!)




The DeadLine
Realistically this should take you all of 15 minutes, however because I'm generous I'll give you until Friday.
Use the e-mail or PM button to send me info that you have an answer.
I will give you an e-mail address to which you can send your answers to, send me spam and I will ban you.
09-23-2003, 12:10 PM#2
AIAndy
Is using comparisons allowed (like x == 0) ?
09-23-2003, 01:13 PM#3
Vexorian
You sounded a lot like my Programming Teacher...

It is posible to use multiply without * , but Are we really going to multiply without + ? Or I have misunderstood?

"using +,-,* will automatically result in you being disqualified"

But at the start:

"which vicariously is used by all functions except for +,-, and IsEven"

EDIT: Wouldn't it be easier if people just send their solution attached to the PM ?

EDIT II: It is really easier to send just the function to the mail, After I downloaded the map I finnally understood what to do, that said this is really easy...
09-23-2003, 02:15 PM#4
Zachary_Shadow
I'm not into jass at all...

BUT

What does this have to do with Warcraft?....
09-23-2003, 02:53 PM#5
FyreDaug
Zach, it doesn't really have to do with warcraft, all it is meant to do is show off your skills. It's just a contest, nothing important. You do it for fun.

EDIT: So you CAN'T use set X = X + Y?
09-23-2003, 07:24 PM#6
weaaddar
Fyre if you look at the map I have made up dummy functions to act like the operators of +,- (add(x,y) and subtract(x,y) respectively).
Sorry I didn't make that clear. Those two functions are considered what the chip can do "naturally", its your job to write up a software function for multiplication in this set example.

The operators are disqualified because originally my plan was to rewrite the for loop and if then else as well as addition and subtraction but it seems you can't take arguments inside an argument (i.e. you can't make a for loop function as the code operator must be a function which takes nothing). Its just part of the complications I added to the contest.

As the time comes for the next contest part I'll think of sets of booleans you can test for so you can't go totally nuts with your booleans on some of the parts this should act as sort of a restriction of the hardware which I really should of thought of before releasing this part

If you also noticed there is a small bug with the calculator when it comes to taking input in that it doesn't check that the user is listening to the restrictions of the calculator. (if a guy enters 300+3 it'll cause the calc to display 300=3 which is obviously wrong. ) I'm going to make sure the user atleast enters the operator at position 2 or else it will not run the function in the next version of the calc.
09-24-2003, 12:33 AM#7
FyreDaug
I'm still not completely understanding, without using Multiply(x,y) we have to make our own way, without using Add(x,y) or we are disqualified?

I don't get it.
09-24-2003, 02:06 AM#8
weaaddar
No you must create a Multiply(x,y) You can use the Add(X,Y) function, which is defined in "hardware", the header part of your map, but not the operator +.
Its just for the sake of complication.
09-24-2003, 02:51 AM#9
FyreDaug
Well shit that's easy.
09-24-2003, 03:03 AM#10
weaaddar
Its stupidly easy, just to establish a user base. This contest will ramp up in dificulty, but I wanted something to get everyone in something that even a casual programmer whos never even used jass could fiddle with for a few minutes and get working.
09-24-2003, 06:50 PM#11
DiscoDave
Heh. I really wish I could show off some of the stuff I've done with the script editor recently, but alas...not until we enter the competition =).
09-24-2003, 08:54 PM#12
KaTTaNa
Hehe... easy enough.
Just be sure you keep it a Jass contest and not a math contest
09-24-2003, 09:43 PM#13
weaaddar
Actually the contest is for the majority going to be playing with functions to do math. Not high end calculus deritives and integrals or nothing, but some of the most basic functions that you take for granted when you use a calculator. After I map out the basic 4 functions (+,-,*,/) (Devision will most likely be the next function) and the expanded set functions (x^2,x^10,x^y,x%y) we may move into simplistic algebric and precalculus functions (sigma(addition), Sigma(product), solve(), factor(),expand() and zero()) Depending on how well the contestants fare. I don't think I'll go into the very annoying and most hated trigonemertic functions. If I'm feeling particularly malicious I may define bullshit functions just to throw in there.
Remember because of the limitation of the input this problem becomes alot easier. I'm never going to use anything greater then 10 and you won't have to worry about negatives and fractions (I'm never going to use decimals as they are way too much of a pain) until much later. the math isn't going to be insane so you have no worry.

By the end of this if you do make it the final tiers we will have made a Calculator for warcraft III which can even help you in your homework if the numbers are just optimistic enough. Its a fun little idea and will strengthen you as a programmer and hopefully encourage the use of jass and some amazing new maps which revolve around better functionality.
09-25-2003, 01:46 AM#14
FyreDaug
Hah, like I'm gonna take Calculus, I'm in 30B and I'm stopping at 30C... when I graduate next sem.
09-25-2003, 05:33 PM#15
kaishaku
People who edit threads in such a maliscious way are bad.