Header Ads

FLAMES Using Javascript

Introduction
Angels of Love are shell shocked with this new invention. It seems that the FLAMES have the power to pronounce and prophesy the truth as accurately.

FLAMES is ISO Certified and also a registered under Acts of Love. :-)
FLAMES
What is FLAMES?
F - Friend
L - Love
A - Affectionate
M - Most Beloved
E - Enemy
S - Sister


How to find it?

1. Take Guy, and Girl Name.

Example: Guy : Ajith ; Girl : Shalini

2. Strike out all common letters between these two names.

Remaining Words: jt and Slni

3. Now, Count the remaining letters from both the words 6.

4. Now take the word FLAMES, calculate from the F and strike it on 6th letter S.

FLAME

5. Now again calculate from the next letter, keep on calculate and strike it out until to reach out only one letter remaining from the word FLAMES which decide your relationship.

M

Well. Applying this algorithm by manually would take more time na. :-)

var strGame = “FLAMES”;
var positionIndex = -1;
var removableCharIndex = -1;

// — Main Logic Starts —
function doMatch(frmObject)
{
var strName1 = trimSpace(frmObject.Name1.value).toUpperCase();
var strName2 = trimSpace(frmObject.Name2.value).toUpperCase();

if(validateInputValues(strName1, strName2, frmObject) == false)
return false;

var existName1 = strName1;

var i = 0;
while(existName1.charAt(i))
{
if(doExist(strName2, existName1.charAt(i)) >= 0)
{
strName2 = doRemoveChar(strName2, existName1.charAt(i));
strName1 = doRemoveChar(strName1, existName1.charAt(i));
}
i++;
}

var MatchlessCount = strName1.length + strName2.length;
var resultWord = FindLastAlphabet(MatchlessCount);

alert(”\n” + repeatChar(’*', 65) + “\n” +
“You : \t” + frmObject.Name1.value.toUpperCase() + “\n”
+ “Your Mate : \t” + frmObject.Name2.value.toUpperCase() + “\n”
+ “Relationship :” + repeatChar(’-', 10) + resultWord
+ repeatChar(’-', 10)
+ “\n” + repeatChar(’*', 65));

resetValues();
}

//– Find the word according to the final count.
function FindLastAlphabet(MatchlessCount)
{
var existRemainNumber, remainNumber;

remainNumber = MatchlessCount % 6;
if(remainNumber == 0) remainNumber = 6;

extractChar = strGame.charAt(remainNumber-1);
strGame = doRemoveChar(strGame, extractChar);
positionIndex = remainNumber;

remainNumber = MatchlessCount % 5;
if(remainNumber == 0) remainNumber = 5;
positionIndex = getRemainRotationNumber(remainNumber);

remainNumber = MatchlessCount % 4;
if(remainNumber == 0) remainNumber = 4;
positionIndex = getRemainRotationNumber(remainNumber);

remainNumber = MatchlessCount % 3;
if(remainNumber == 0) remainNumber = 3;
positionIndex = getRemainRotationNumber(remainNumber);

remainNumber = MatchlessCount % 2;
if(remainNumber == 0) remainNumber = 2;
positionIndex = getRemainRotationNumber(remainNumber);

return getWord(strGame);
}

//——– Rotate the FLAMES word if the count exceeds total count. —
function getRemainRotationNumber(remainNumber)
{

var removableCharIndex = positionIndex + (remainNumber - 1);
if(removableCharIndex <= strGame.length)
{
extractChar = strGame.charAt(removableCharIndex - 1);
strGame = doRemoveChar(strGame, extractChar);
}
else
{
removableCharIndex = removableCharIndex - strGame.length;
extractChar = strGame.charAt(removableCharIndex - 1);
strGame = doRemoveChar(strGame, extractChar);
}

return removableCharIndex;
}

No comments:



Powered by Blogger.