This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//read a protected/private attribute | |
\PHPUnit_Framework_Assert::readAttribute($object, 'protected_attr'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Silex\Provider; | |
use Silex\Application; | |
use Silex\SilexEvents; | |
use Silex\ControllerProviderInterface; | |
use Silex\ControllerCollection; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
function total_surface_area(boxes) { | |
let total_surface = 0; | |
for (let box of boxes) { | |
const sides = [box[0]*box[1], box[1]*box[2], box[2]*box[0]]; | |
const smallest_side = Math.min(...sides); | |
const box_surface = (sides[0] + sides[1] + sides[2])*2 + smallest_side; | |
total_surface = total_surface + box_surface; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
function total_surface_area(boxes) { | |
return boxes.reduce((acc, box) => { | |
const sides = [box[0]*box[1], box[1]*box[2], box[2]*box[0]]; | |
const smallest_side = Math.min(...sides); | |
const box_surface = ((sides[0] + sides[1] + sides[2]) * 2) + smallest_side; | |
return acc + box_surface; | |
}, 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
const sides = (box) => [box[0]*box[1], box[1]*box[2], box[2]*box[0]]; | |
const smallest_side = (sides) => Math.min(...sides); | |
const box_surface = (sides) => ((sides[0] + sides[1] + sides[2]) * 2) + smallest_side(sides); | |
function total_surface_area(boxes) { | |
return boxes.reduce((acc, box) => { | |
return acc + box_surface(sides(box)); | |
}, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const old_sides = (box) => [box[0]*box[1], box[1]*box[2], box[2]*box[0]]; | |
const sides = ([a, b, c], acc = []) => | |
(acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b])); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const old_box_surface = (sides) => ((sides[0] + sides[1] + sides[2]) * 2) + smallest_side(sides); | |
const box_surface = (sides) => | |
(sides.reduce((acc, side) => (acc + side)) * 2) + smallest_side(sides); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b])); | |
const box_surface = sides => sides.reduce((acc, side) => (acc + side)) * 2 + Math.min(...sides); | |
function total_surface_area(boxes) { | |
return boxes.reduce((acc, box) => { | |
return acc + box_surface(sides(box)); | |
}, 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b])); | |
const box_surface = (acc, side) => (acc + side) ; | |
function total_surface_area(boxes) { | |
return boxes.reduce((acc, box) => { | |
const box_sides = sides(box) | |
return acc + box_sides.reduce(box_surface) * 2 + Math.min(...box_sides); | |
}, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const boxes = [[2, 3, 4], [1, 1, 10]]; | |
const apply = (f, i) => (f(i)); | |
const sides = ([a, b, c], acc = []) => (acc.length == 3) ? acc : sides([b, c, a], acc.concat([a * b])); | |
const box_surface = (acc, side) => (acc + side) ; | |
function total_surface_area(boxes) { | |
return boxes.reduce((acc, box) => | |
apply((b) => acc + b.reduce(box_surface) * 2 + Math.min(...b), sides(box)), 0); |
OlderNewer