Annulé

Solve specific PHP string expansion problem

I have a string composed of letters and square brackets ONLY. The square brackets define groups of letters. One letter from each group can be chosen in each expansion. I need to expand these letters into its actual strings.

From this:

$str = 'ABCCDF[GH]IJJ[KLM]'

To this:

$sub[0] = 'ABCCDFGIJJK';

$sub[1] = 'ABCCDFHIJJK';

$sub[2] = 'ABCCDFGIJJL';

$sub[3] = 'ABCCDFHIJJL';

$sub[4] = 'ABCCDFGIJJM';

$sub[5] = 'ABCCDFHIJJM';

The solution should be in PHP, compatible with 7.2

Should use no external libraries, only core PHP

I expect a function with a string as input and an array of strings as a return

function (string $string) : array

{

}

Should work with strings like the example but no limit in the number of groups or in the number of letters in each group. Should be a generic function.

Could be a recursive function.

The letters between brackets are groups, and you can choose only one (1) of these letter for each expansion.

You should do the corresponding permutations

Other valid examples the function should solve are:

$str = 'AB[ST]DF[GH]IJJ[KLM]A'

To this:

$sub[0] = 'ABSDFGIJJKA';

$sub[1] = 'ABSDFHIJJKA';

$sub[2] = 'ABSDFGIJJLA';

$sub[3] = 'ABSDFHIJJLA';

$sub[4] = 'ABSDFGIJJMA';

$sub[5] = 'ABSDFHIJJMA';

$sub[6] = 'ABTDFGIJJKA';

$sub[7] = 'ABTDFHIJJKA';

$sub[8] = 'ABTDFGIJJLA';

$sub[9] = 'ABTDFHIJJLA';

$sub[10] = 'ABTDFGIJJMA';

$sub[11] = 'ABTDFHIJJMA';

For example:

A[BC]D should be expanded in:

ABD

ACD

Another example AA[DCF] should be expanded in:

AAD

AAC

AAF

Another example with many groups AF[RT]SD[ER]D should be expanded in:

AFRSDED

AFTSDED

AFRSDRD

AFTSDRD

One las example [AB]

Should be expanded in:

A

B

Strings without brackets are returned as is:

AABCDFGTY is expanded in AABCDFGTY

Examples of illegal (never expected strings) YOU SHOULD NOT HANDLE THIS CASES BECAUSE I TAKE CARE OF INPUT VALIDATION, THIS INFO IS ONLY FOR CLARITY:

[A[B]]CCDD -> never nested brackets

AB[CCD]FGG -> never groups with a repeated letter

ADFG$% HJ -> characters different from letters and square brackets

NOTE:

* The returned array elements order is not important

* There should not be exception handling in the input side. I take care of that. The input string is only letters [A-Z] and symbols '[' and ']'

* Groups could be at the very beginning and/or at the very end then '[AE]DDFFGV[FGH]' is a valid string to be parsed.

* Letters inside one group will never be repeated, for example, AB[CCD]E is not valid input and you don't need to check this case because I handle it.

Compétences : PHP

en voir plus : php html dotproject problem, php string search text file, php send email problem, php string functions with examples pdf, php string concatenation, heredoc in php w3schools, php substr, php multiline string, php text formatting, php array to string, php string variable, php refresh page problem, php excel utf problem, php pro bid problem, read pdf file php string, php mail spam problem, php string break line line, php excel output problem length, php code expansion, php auction feedback problem

Concernant l'employeur :
( 0 commentaires ) BOGOTA, Colombia

Nº du projet : #18635643

21 freelance font une offre moyenne de $27 pour ce travail

mahamadali

I am experienced php developer and web designer with the depth knowledge related to MySQL,Laravel,Code Ignitor,WordPress,MSSQL,JSON,JAVASCRIPT,AJAX,XML,jQuery,CSS,HTML5,Material Designing with the integration of web te Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(293 Commentaires)
7.0
royalwebraisers

HI, can help you in the project to break and manage the string to different way. please let me know when we can start working. Looking forward for your response. Thanks.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(118 Commentaires)
6.4
justTry

Hi! Assuming you want this wrapped as a funcion which you can call passing the raw string to it and getting back the array of output strings back, I have couple questions. 1) Intermittent spaces won't matter rega Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(154 Commentaires)
6.0
jamesmartin81

I have experience of Website in PHP, Laravel, CodeIgnitor, Wordpress, Opencart, Woocommerce, Photoshop, Adobe Illustrator . We also have experience of making Android,Window and iphone application with ionic & phonegap. Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(81 Commentaires)
5.5
niceDev

Hi there. I able to start right now. Ping me. Thank you. With regards. Yegor. ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(37 Commentaires)
5.7
ocarinacngvw

Update: I finished creating the function (and tested it with all examples you gave). Choose me and I'll give you the PHP file immediately. Original Bid: Hello. I'm an expert in PHP programming. I can easily create code Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(36 Commentaires)
5.5
muhamed3uda

Hi, i can work with you into site topic and provide strong fast code thanksHi, i can work with you into site topic and provide strong fast code thanks

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(84 Commentaires)
5.6
techplusintl

Hi there, Greetings from TechPlus! I've reviewed requirements & ready to Solve specific PHP string expansion problem. 5+ Years Expertise in : CMS (Wordpress, Magento, Shopify, OpenCart, Joomla, Drupal, Presta Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(61 Commentaires)
5.6
ozzy72

Hi, I am PHP coder any can deliver function. It's a kind of alphanumeric permutation. But 1 thing is not clear to me: You are saying that the group are valid when they are at the beginning or at the end. But in your Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(25 Commentaires)
5.1
sambestsolutions

Hi I am an Engineering undergraduate experenced in web development with php for more than 4 years. I can create you the required string using allowed characters from each [login to view URL] combining other. Relevant Skills an Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(13 Commentaires)
4.2
WCTech

Please come on chat and provide me an opportunity , i have 5 year of experience in php and can convert letters into its actual strings according to your need , so please message me. Thanks

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(58 Commentaires)
4.6
elkadymos

Hi, I can help you with that starting immediately and finishing the function in less than an hour. I have more than 4 years of PHP, JavScript, JQuery, CSS, and WordPress development. If you have any question, plea Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(15 Commentaires)
4.1
MichealSMoreno

Dear client. I've read your project description carefully and very interested. Let's discuss over chat and get started. Waiting for your reply. Regards.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(7 Commentaires)
3.9
mahidevran

Hi. As a programmer with academic background, I can write such fuction within 15 minutes. Just drop me a message.

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 0 jours
(12 Commentaires)
3.4
sifisolutions

We Believe in Delivering Perfect Work and Providing Full Satisfaction to Our Client . We also Insure to Deliver the Work in the given Time Frame . we have highly Qualified Professionals in our team

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(10 Commentaires)
2.9
tilakputta

Its a simple task to finish in 2 to 3 hours... accept the bi, i will start working on it right now and deliver it ASAP.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(3 Commentaires)
2.4
Roku27

Hi, I can do this job for you. Please let me know when we need to start work on it so we can make it done asap. Looking forward to your response. Thanks.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(1 Évaluation)
0.8
vw7487274vw

This can be done very quickly. This specific problem takes me back to the earliest parts of my career when we would have coding challenges such as this.

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)
0.0
soulstealermex86

After reading your entry, im fairly confident that I can help you with the function, I should be able to deliver it by today at around 10pm PST

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)
0.0
aleal2283

Just talk to me and we will resolve this problem! In this case the solution is to see with a little more detail

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)
0.0