Algorithm Optimisation Championship. - page 69

 
Andrey Dik:

Do you see that in bold? A bigger value is better. Whoever finds the highest number is the winner.

What do you mean, "The problem must be open-ended?"

All right.

1. There will be a total of 500 characters in the text. Only letters. No spaces between words and no punctuation marks.

(2) The text will be compiled by the referee and put into the FF as numbers.

3. Let's not get distracted by secondary issues.

 
Реter Konow:

Good.

1. There will be a total of 500 characters in the text. Only letters. No spaces between words and no punctuation.

(2) The text will be compiled by the referee and put into the FF in the form of numbers.

3. Let's not get distracted by secondary issues.

If there is a referee (and where are we going to get one?) I will also be able to take part. If not, I will not be able to participate and will compile the tasks, you will compete without me.

If anyone from MQ is watching this thread, get in touch! Need a human judge for the competition.

If anyone responds, I will give that person the task code to insert text into it.

After solving this problem will be even more interesting, I promise.

 

Andrey Dik:

If anyone responds, I will give that person the task code for inserting text into it.


Knowing the code of the task (and even more so the possibility to compose it at one's own discretion) is an advantage.

All or none of the participants should know the task code.

Let's assume that everyone knows the code of the task. So what? The main thing is to solve the problem.

 
Реter Konow:

Knowing the code of the problem (especially the possibility to compose it at your own discretion) is an advantage.

All or none of the participants should know the problem code.

Let's assume that everybody knows the code of the problem. So what? The main thing is to solve the problem.

Why are you so mistrustful?!!! I'll show you the code of course! Only the judge will compile it.

Everyone will see the code, you will see how and what is counted in the FF, but the judge will insert his text and the correct solution will have to be found. Knowing the code won't help you in any way.

 
Anyway, I'm starting to make some serious preparations.
 
Andrey Dik:

There will be even more interesting ones after this one is solved, I promise.

Frankenstein lives
 
Реter Konow:
Anyway, I'm starting to make some serious preparations.

It's about time.

ZS. For some reason MQ representatives don't come here. who are we going to hand over the FF for compilation?

 
#property library
#property strict

int  countRuns    = 0; 

//+------------------------------------------------------------------+
int GetParamCount () export
{ 
  textLen = StringLen(Code);
  return (textLen);
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void GetParamProperties (double &min, double &max, double &step) export
{ 
  min = 0.0;
  max = 40.0;
  step = 1.0;
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double FF (double &param []) export
{ 
  countRuns++; 
  
  int sizeArray = ArraySize (param); 
  if(sizeArray != textLen) 
    return (0.0);
  
  int ffVolue = 0; 
  
  for (int i=0; i< textLen; i++)
  {
    if(GetCode(param [i]) == StringSubstr(Code, i, 1))
      ffVolue++;
  }
    
  return (double(ffVolue));
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int GetCountRunsFF () export
{ 
  return (countRuns);
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void PrintCodeToFile (double &param []) export
{
  int sizeArray = ArraySize (param); 
  if(sizeArray != textLen) 
  {
    Print ("Неверное количество параметров, печать в файл производится не будет!");
    return;
  }
  
  string code = "";
  
  for(int i=0; i<textLen; i++)
  {
    code+=GetCode (param[i]);
  }
  
  int handle = FileOpen ("decodeFF.csv", FILE_READ|FILE_WRITE|FILE_ANSI|FILE_CSV);
  
  if(handle==INVALID_HANDLE)
  {
    Print ("Ошибка записи в файл востановленного текста ФФ. Ошибка: "+ (string)GetLastError()); 
    return;
  }
  FileWriteString(handle, code);
  FileClose (handle);
}
//+------------------------------------------------------------------+

string GetCode (double param)
{
  int p = (int) MathRound (param);
  if(p <0)
    p = 0;
  if(p > 40)
    p = 40;

  return (Key [p]);
}

string Key [41] = {"а", "б", "в", "г", "д", "е", "ё", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", ";", ":", ".", ",", "-", "?", "!", " "};
int textLen = 0;
string Code = "редко научная статья сочетает в себе эти два типа";

The Code variable contains the string you are looking for.

Try to read the string using your optimization algorithm.

Administrators: please replace content of the Code variable with arbitrary text (regular Russian text with punctuation and without special characters) with the number of characters 300 ... 800 so that the string would contain characters from the string Key, compile and put in this branch. We will try to read the string.

There are 49 characters in the Code variable right now. Accordingly, the maximum possible value FF can output 49.0 (a match of all characters in the string). My algorithm now shows a result of 47.0 for 100'000 FF runs and about 25.0 for 1000 runs.

 
That's good. All clear and straightforward. Doing the algorithm.
 
What was the problem, putting this out for the championship?!?!!