SRL Archive - Research & Development Lounge

Crossfoot


batnas

2008-05-09 15:59:16

hi
i have made a Crossfoot function
now i hope i can explain it good enough for all of you, so you can understand it ;D

Crossfoot is when you take each part(?) of a minimum 2 digit and then you take each part and add them to each other
for example: Crossfoot of: 7364 is 7+3+6+4=20=2+0=2:
Crossfoot of: 7364 is = 2

I hope you all like it and can use it in SRL maybe under math??

Here we go…
Function Crossfoot(s:String):Integer;
var
PlaceInString, FinalResult, Lengt : Integer;
TempString : String;
Begin
Lengt := Length(s);
repeat
PlaceInString := 0;
FinalResult := 0;
repeat
PlaceInString := PlaceInString+1;
TempString := copy(s, PlaceInString, 1);
FinalResult := StrToInt(TempString)+FinalResult;
Lengt := Lengt-1;
until (Lengt = 0);
Lengt := Length(IntToStr(FinalResult));
s := IntToStr(FinalResult);
until (Lengt = 1);
Result := FinalResult;
End;

Hope it works for you it work for me…
If you find any errors please post it here

\\Batnas

richk1693

2008-05-09 16:25:57

What would be a use for this? Other than existing, what could it be used for?

batnas

2008-05-09 16:34:52

I cant remember right now what i should use it for…
But anyway it was very funny to make it

Please some feedback if anyone of you out there try it

\\Batnas

isjusme

2008-05-10 14:44:53

You could use it as a random password generator. type in a random number, get the cross thingy, and over and over until you has a password.

batnas

2008-05-11 08:31:59

he he nice!
thats what i should have used it for :D
now i can make an ultra random password maker ;|

\\Batnas

mixster

2008-05-11 10:47:04

There already is an ultra random password maker and I don't understand how you could make a password from it as it outputs a number… So, with that use gone, is there really any other?

smithsps

2008-05-18 21:13:52

Improved?

function Crossfoot(Num: integer): integer;
var
Place, Len : integer;
NumStr: string;
begin
NumStr := IntToStr(Num);
Len := Length(NumStr);
while (Len > 1) do
begin
DecEx(Place, Place);
DecEx(Result, Result);
while (Len > 0) do
begin
Inc(Place);
IncEx(Result, StrToInt(copy(NumStr, Place, 1)));
Dec(Len);
end;
Len := Length(IntToStr(Result));
NumStr := IntToStr(Result);
end;
end;

Lol it makes it look complicated:D