wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 10-16-2006, 09:27 PM   #1
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default JASS quicksilver contest Round #1 (winners announced)

Hello, let's see what's the deal here, remember the JASS survival challenge? Why did it fail? I think that it is because It required me to deal with up to 3 contests at the same time and I wasn't even able to deal with 2 of them, then I also had 2 think a lot of problem statements and make sure they had a very fair difficulty classifcation which was, seriously too difficult.

Yet I notice we need contests. So I am introducing you all these ones which are shorter and less fixed to some rules that made it impossible for me to do stuff.

Rules
- I release a problem.
- People try to solve
- Up to 1 week to get results
- Post solutions in pastebin, with a [quicksilver] preffix.
- 3 Fastest (take less time) solutions that solve the problem win.
- If somebody is too good I can classify him as too good for a round that would seem too easy for him, so more people have a chance.

Round one: The polish

There is an strange arithmetic language out there with these symbols:
  • + : addition
  • * : product
  • ! : factorial
  • (lowercase letter) (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) : variable

A valid formula is :
- A variable (lowercase letter)
- ! preceding a valid formula
- + preceding 2 valid formulas
- * preceding 2 valid formulas

You have to make a function LargestValidFormula takes string symbols returns string
It takes a string with 1 to 100 characters containing some characters and returns the largest valid formula you can get with the symbols in the input (without repeating any of them)

If there are more like one result, either is a correct answer.

Examples

LargestValidFormula("a") returns "a"

LargestValidFormula("a+b") returns "+ab" or "+ba"

LargestValidFormula("+*!aa") returns "!+aa" or "+!aa" or "+a!a" or "!*aa" or "*!aa" or "*a!a"

LargestValidFormula("abcdefg!") returns "!b" or "!a" or "!c" , etc


LargestValidFormula("+++aaaa") returns "+a+a+aa" or "++aa+aa" or "+++aaaa"

LargestValidFormula("A") returns ""


Edit: The results of the survival challenge will come up eventually and we will have awards there.


Update : October 24th: Results announced

First place: Blu_da_noob (0.037267028 seconds)
Second place: Acehart (0.085897792 seconds)

Disqualified:
- Griffen (wrong answer)
- Mathias (Limit op exceeded)

The answer
It was rather easy, the first thing you could notice is that the only case in which "" is returned is when there are no variables in the input.

Then you can figure out that all the unary operators can be added simply before a variable to get the result.

And that if you unify a binary operator and a variable they can become an unary operator so they follow above's rule.

This is my solution:
Collapse JASS:
globals
 string factorialchars = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 
 string prodchars      = "****************************************************************************************************"
 string pluschars      = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
endglobals
function LargestValidFormula takes string s returns string
 local string c
 local string r=""
 local integer i=0
 local integer L =StringLength(s)

 local integer plus=0
 local integer prod=0
 local integer fact=0
 local string  vars=""
 local integer varn
 

    loop
        
        exitwhen i==L
        set c=SubString(s,i,i+1)
        set i=i+1

        if (c=="!") then
            set fact=fact+1
        elseif (c=="+") then
            set plus=plus+1
        elseif (c=="*") then
            set prod=prod+1
        elseif (StringCase(c,true)!=c) then
            set vars=vars+c
        endif
    endloop
    set varn=StringLength(vars)

    if (varn==0) then
        return ""
    endif

    if ( varn > plus+prod) then
        set varn=plus+prod+1
    else
        set i=varn-1
        if (plus>=i) then
            set plus=i
            set prod=0
        elseif (prod>=i) then
            set prod=i
            set plus=0
        else
            set plus=i-prod
        endif
    endif


 return SubString(factorialchars,0,fact)+SubString(pluschars,0,plus)+SubString(prodchars,0,prod)+SubString(vars,0,varn)
endfunction
  • In order to save the game some time, I avoid creating strings during the process so I only use counters, the variables part must use strings though.
  • In this case the binary + variable becomes unary is still latent, but I just have it work as (binary)(exp)(variable) instead of (binary)(variable)(exp) it works the same.
  • Then the result is always: (All the unary operators)( (x - 1) binary operatos )( x variables ) , where x depends on the input. Unless, there are no variables in the input then the result is ""
  • Calculating x is the last problem, if there are more variables than binary operators, then x is (number of binary operators)+1 , else it is the number of variables present in the input and the number of binary operators in the output should change to x-1.

- Mathias, used a brute force approach, although it is not the fastest solution it is a good idea to check it in order to see how brute force works.

- Griffen's submission would have been the fastest if it wasn't for the error.

I am including a map with the test environment and all the submissions.
Attached Files
File Type: w3x quicksilver.w3x (56.6 KB, 27 views)
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 10-16-2006, 10:32 PM   #2
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

*confused*
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 10-16-2006, 11:07 PM   #3
UnMi
User
 
UnMi's Avatar
 
Join Date: Aug 2006
Posts: 213

Submissions (1)

UnMi is on a distinguished road (18)

Default

... ... ...
Unlike the last two Problems you used to post, I do not understand a single bit of this one.
UnMi is offline   Reply With Quote
Old 10-17-2006, 12:28 AM   #4
SeasonsOfLove
A Nitpicky Map Reviewer
 
SeasonsOfLove's Avatar


Official Map Reviewer
 
Join Date: Aug 2003
Posts: 257

SeasonsOfLove will become famous soon enough (44)SeasonsOfLove will become famous soon enough (44)

[Quicksilver #2] - 2nd Place

Send a message via AIM to SeasonsOfLove
Default

I understand the problem.
You're given a string with a bunch of symbols, all of which are either a variable (lowercase letter), an !, a *, or a +. You have to find the longest valid formula, which involves:
A variable (a)
A ! preceding one valid formula (!a, !+ab, !*ab)
A * or + preceding two valid formulas (*ab, +ab, *!a!b, +*!a!b*!a!b)

The hardest part for this is figuring out what he means by the question. Once you get that, it should become easier to figure out.
__________________
Clan TDG - Quality mapmaking, dedicated playtesting.
SeasonsOfLove is offline   Reply With Quote
Old 10-17-2006, 12:45 AM   #5
Naakaloh
User
 
Naakaloh's Avatar
 
Join Date: Jun 2003
Posts: 619

Submissions (2)

Naakaloh is a jewel in the rough (155)Naakaloh is a jewel in the rough (155)

Spell Making Session 09 WinnerSpell Making Session 05 Winner

Send a message via AIM to Naakaloh
Default

It's not to hard to understand; there's just one issue I'd like to confirm. Could the example "abcdefg!" return "!a", "!b", "!c", etc.?
__________________
"The geeks will play their game."
- Kowalski
Naakaloh is offline   Reply With Quote
Old 10-17-2006, 02:14 AM   #6
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

Yeah its pretty easy to understand, but implementation may be a bit more difficult.

Edit: Something I don't get though are what would be considered valid formulas, I am gonna have to write this all out based on your little priority table.

@Vex: You state "without repeating any of them", does this mean that if you have 3 ! in a symbol line for example you can use ! 3 times as Seasons seems to believe? Or can you use only one ! in the final product?
__________________
"...you play a mean banjo"

Last edited by Chuckle_Brother : 10-17-2006 at 02:28 AM.
Chuckle_Brother is offline   Reply With Quote
Old 10-17-2006, 03:14 AM   #7
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
It's not to hard to understand; there's just one issue I'd like to confirm. Could the example "abcdefg!" return "!a", "!b", "!c", etc.?
Yes.

Quote:
@Vex: You state "without repeating any of them", does this mean that if you have 3 ! in a symbol line for example you can use ! 3 times as Seasons seems to believe? Or can you use only one ! in the final product?

You can use up to 3 "!" in that case
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 10-17-2006, 03:41 AM   #8
Chuckle_Brother
Oh for the sake of fudge
 
Chuckle_Brother's Avatar


Respected User
 
Join Date: Dec 2005
Posts: 782

Submissions (2)

Chuckle_Brother will become famous soon enough (53)Chuckle_Brother will become famous soon enough (53)

Send a message via ICQ to Chuckle_Brother Send a message via AIM to Chuckle_Brother Send a message via MSN to Chuckle_Brother Send a message via Yahoo to Chuckle_Brother
Default

Ahh excellent. Many thanks for the clearup.
__________________
"...you play a mean banjo"
Chuckle_Brother is offline   Reply With Quote
Old 10-17-2006, 12:50 PM   #9
DotA_DR
User
 
Join Date: Aug 2006
Posts: 29

DotA_DR has little to show at this moment (6)

Default

Quote:
- Post solutions in pastebin, with a [quicksilver] preffix.
pastebin - what it is?
DotA_DR is offline   Reply With Quote
Old 10-17-2006, 01:09 PM   #10
Thunder_Eye
Lol I got a custom title!
 
Thunder_Eye's Avatar
 
Join Date: Aug 2004
Posts: 1,236

Thunder_Eye has a spectacular aura about (92)Thunder_Eye has a spectacular aura about (92)Thunder_Eye has a spectacular aura about (92)Thunder_Eye has a spectacular aura about (92)

Default

http://www.wc3campaigns.net/pastebin.php
__________________
Thunder_Eye is offline   Reply With Quote
Old 10-17-2006, 04:41 PM   #11
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Vexorian
Yet I notice we need contests.
So why did noone start the next spell contest?
Sheesh. :/
__________________
Rising_Dusk is offline   Reply With Quote
Old 10-17-2006, 04:57 PM   #12
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

YEAHHH, Spell contest!!! I need to make spells now!!
moyack is offline   Reply With Quote
Old 10-17-2006, 05:06 PM   #13
Fulla
Evil Overlord
 
Fulla's Avatar
 
Join Date: Jan 2006
Posts: 1,416

Submissions (3)

Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)Fulla has a spectacular aura about (79)

Default

Quote:
Originally Posted by Rising_Dusk
So why did noone start the next spell contest?
Sheesh. :/

Agreed

Was hoping to enter a jass spell :D
__________________

Last edited by Fulla : 10-17-2006 at 05:07 PM.
Fulla is offline   Reply With Quote
Old 10-17-2006, 05:16 PM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

I mean seriously, if people are too busy to start the spell sessions up again...
I'll sacrifice my ability to partake in it and run it myself.

Seriously though, we need spell sessions.
They're always very popular and fun to participate in.
__________________
Rising_Dusk is offline   Reply With Quote
Old 10-17-2006, 05:30 PM   #15
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Quote:
Originally Posted by Rising_Dusk
I mean seriously, if people are too busy to start the spell sessions up again...
I'll sacrifice my ability to partake in it and run it myself.

Seriously though, we need spell sessions.
They're always very popular and fun to participate in.

I'm with Rising, besides I think that one of JASS objectives is to make custom spell, and the best way to make some honour to this language is with a spell contest.
moyack is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 08:37 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services