Help, coding substrings

 
Hello, grab a string of length 13:

1111 0000 11110
Then make substring of length 4-13

1111 1110 1100 1000 0000 0001 0011 0111
11110 11100 and so on...

How to code the above and write every combination of substrings of 4-13 length in a txt or csv file? 
 
Hsjsj Whhsvzhys:
Hello, grab a string of length 13:

1111 0000 11110
Then make substring of length 4-13

1111 1110 1100 1000 0000 0001 0011 0111
11110 11100 and so on...

How to code the above and write every combination of substrings in a txt or csv file? 


Look here for "every combination": https://www.mql5.com/en/code/25724
For wirting to a file use this:  https://www.mql5.com/en/articles/2720#add2

Permutations and Combinations
Permutations and Combinations
  • www.mql5.com
It doesn't happen very often, but every once in awhile one needs to iterate over all of the combinations or permutations of a set of objects. Or more specifically, given a set of N objects, you want to consider k of them at a time (for each combination or permutation). Practically, combinations and permutations algorithms can be used as a...
 
Hsjsj Whhsvzhys:
Hello, grab a string of length 13:

1111 0000 11110
Then make substring of length 4-13

1111 1110 1100 1000 0000 0001 0011 0111
11110 11100 and so on...

How to code the above and write every combination of substrings in a txt or csv file? 

Hello,

try this..

StringSubstr(IntegerToString(1111000011110),4,(13-4))

or

StringSubstr(IntegerToString(1111000011110),4,9)
 
Nikolaos Pantzos:

Hello,

try this..

or

I tried it, it doesn't does all the combinations of 4-13 length 

 
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
 
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
There's no need to see my code, if you go to the original question to answer... How to code all permutations of substrings of length 4-13 from a binary sequence of 13? 
 
This is how far i have go, it does all permutations of 4 but some are repeated and it doesnt stops on only 4 of length it goes to 1 2 3 sequence lengths,
im still trying to figure out for permutations from 5-13 also without repetitions of substrings 
	{
//---
   // test 1
   string test1= "test1.csv";
   int handle= FileOpen(test1,FILE_CSV|FILE_READ|FILE_WRITE,';');
   string test;
   int a= 0,sub= 0;
   while(100>a) 
   {
      test= StringSubstr(IntegerToString(1111000011110),0+sub,4);
      FileWrite(handle,test+"\t");
      sub++;
      a++;
   }
   Print(handle);
   FileClose(handle);
   
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
Hgu Gh:
There's no need to see my code, if you go to the original question to answer... How to code all permutations of substrings of length 4-13 from a binary sequence of 13? 

Wrong.  You should show your code.  The problem would likely to be found quickly.  Your asking people to create a solution for you without even giving us your attempt.  I can spend a few minutes finding the fault in your code, but I don't have an hour to write something from the beginning.  And there would be 500 people here just like that.

In the words of Jerry Maguire "help me help you"

 
Cornelis Duiker:

Wrong.  You should show your code.  The problem would likely to be found quickly.  Your asking people to create a solution for you without even giving us your attempt.  I can spend a few minutes finding the fault in your code, but I don't have an hour to write something from the beginning.  And there would be 500 people here just like that.

In the words of Jerry Maguire "help me help you"

I posted my code fyi
 
Hgu Gh:
I posted my code fyi

Nothing will ensure that your substrings are unique when you simply do a StringSubString() and FileWrite() immediately after.

Look into some data structures (e.g. arrays) to store your substrings - organize them so that it's easy to compare each new substring with already extracted ones to make sure they are unique, before writing to file. 

Array Functions - MQL4 Reference
Array Functions - MQL4 Reference
  • docs.mql4.com
. In a particular case of a one-dimensional array of 50 elements, calling of the first element will appear as array[0], of the last one - as array[49]. What's new in MQL5 Added functions for quick insertion, deletion, copying and expanding array elements. The new ArraySwap() function swaps the contents of two dynamic arrays of the...