function IntToDigit(mNumber: Integer; mScale: Byte; mLength: Integer = 0): string;
var
I, J: Integer;
begin
Result := '';
I := mNumber;
while (I >= mScale) and (mScale > 1) do begin
J := I mod mScale;
I := I div mScale;
Result := cScaleChar[J + 1] + Result;
end;
Result := cScaleChar[I + 1] + Result;
if mLength > 0 then
for I := 1 to mLength - Length(Result) do
Result := '0' + Result;
end; { IntToDigit }
function DigitToInt(mDigit: string; mScale: Byte): Integer;
var
I: Byte;
L: Integer;
begin
Result := 0;
L := Length(mDigit);
for I := 1 to L do
Result := Result + (Pos(mDigit[L - I + 1], cScaleChar) - 1) *
Trunc(IntPower(mScale, I - 1));
end; { DigitToInt }
function f(mPrices: array of Real; mMoney: Real): string;
var
I, J: Integer;
L: Integer;
S, C: string;
T: Real;
begin
L := Length(mPrices);
with TStringList.Create do try
for I := 0 to Trunc(IntPower(2, L)) - 1 do begin
S := IntToDigit(I, 2, L);
T := 0;
C := '';
for J := 1 to L do if S[J] = '1' then begin
T := T + mPrices[J - 1];
C := C + ',' + FloatToStr(mPrices[J - 1]);
end;
System.Delete(C, 1, 1);
if T = mMoney then
Add(S + ':' + C);
end;
Result := Text;
finally
Free;
end;
end;