Em Andamento

Translate small code snippet from Ruby to PHP

I need to translate this small portion of Ruby code to PHP. It must be tested to output equivalent data to the original code. 10$ for thw work

pairings

[

[["David", "Helen"], 0],

[["David", "Vicki"], 1],

[["Helen", "Vicki"], 2],

[["Joseph", "Vicki"], 4],

[["Helen", "Joseph"], 5],

[["David", "Joseph"], 8]

]

def optimize(pairings, names, pos, posmax, maxweight=nil)

bestpairs = nil

maxweight ||= [url removed, login to view] ** 2 + 1

while pos < posmax

pair, weight1 = pairings[pos]

break unless weight1 * ([url removed, login to view] / 2).floor < maxweight

pos += 1

if names & pair == pair

names1 = names - pair

if [url removed, login to view] < 2

bestpairs = [pair]

bestpairs << names1 unless [url removed, login to view]

return [weight1, bestpairs]

elsif (rv = optimize(pairings, names1, pos, posmax, maxweight - weight1))

maxweight, bestpairs = rv

maxweight += weight1

bestpairs << pair

end

end

end

return bestpairs && [maxweight, bestpairs]

end

----

See for details:

[url removed, login to view]

Habilidades: PHP, Ruby on Rails

Ver mais: work translate, return ruby rails, code 8, code 30, david data, 2 translate, snippet, rv, return david, php ruby, php pos, nil, need translate, joseph, php, optimize php code, output php, translate work, rails php, php output, optimize code, code translate, ruby small snippet, code pos, ruby php

Acerca do Empregador:
( 0 comentários ) NY, Canada

ID do Projeto: #601807

Premiar a:

freelancerrediff

Hi I can do it for $10 in 1 day

$30 USD em 1 dia
(1 Comentário)
0.0

4 freelancers estão ofertando em média $60 para este trabalho

adilshoukat

Dear Client, I've good experience in both ruby and PHP. Please allow me to translate the code. Thanks. Regards, Adil Shoukat

$100 USD in 3 dias
(0 Comentários)
0.0
iromli

i'll porting the Ruby code to PHP for < 1 day, but i need to test and integrate to your live site for 1 day (max 2 days)

$60 USD in 2 dias
(0 Comentários)
0.0
toronto0025

Hi please See pm Thank you

$50 USD in 2 dias
(0 Comentários)
0.0