Annulleret

Translate small snippet of ruby code to PHP

Important:

DO NOT bid if you don't code in PHP

DO NOT bid if you don't code in Ruby

You have to READ this page: [url removed, login to view]

.

I need to translate this small portion of Ruby code to PHP. It must be tested to output equivalent data to the original code on [url removed, login to view] 20$ for the work.

PHP CODE WILL BE TESTED before payment is sent.

----------------------------------------------------------------------------------------------------------------------------

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]

Færdigheder: PHP, Ruby on Rails

Se mere: translate ruby php, work translate, translate t, return ruby on rails, pos in php code, i need to translate, id to code, code 8 com, code 8, ruby small snippet, david data, translate com, ruby on rails 5, 2 translate, translate, the return of david, snippet, rv, ruby, return of david, php ruby, php pos, nil, need to translate, joseph

Om arbejdsgiveren:
( 0 bedømmelser ) NY, Canada

Projekt-ID: #952493