Ad
  • Default User Avatar

    Additional tests

    describe("basic cases", function() {
    	it("1 under 2", function() {
    	  Test.assertEquals(calculate([ [ 1, 7, 3, 10 ],  [ 1, 8, 3, 9 ]]), 6, '1 under 2');
    	});
    	it("nested", function() {
    	  Test.assertEquals(calculate([ [ 6, 7, 9, 10 ],  [ 7, 8, 8, 9 ]]), 9, "nested");
    	});
    	it("nested 2", function() {
    	  Test.assertEquals(calculate([ [ 1, 7, 4, 10 ],  [ 2, 7, 4, 9 ],  [ 3, 7, 4, 9 ]]), 9, "nested 2");
    	});
    	it("intersection up", function() {
    	  Test.assertEquals(calculate([ [ 1, 1, 4, 3 ],  [ 2, 2, 3, 4 ]]), 7, "intersection up");
    	});
    	it("intersetion right", function() {
    	  Test.assertEquals(calculate([ [ 5, 0, 7, 3 ],  [ 6, 1, 8, 2 ]]), 7, "intersetion right");
    	});
    	it("intersection up right", function() {
    	  Test.assertEquals(calculate([ [ 9, 0, 11, 2 ],  [ 10, 1, 12, 3 ]]), 7, "intersection up right");
    	});
    	it("intersection down", function() {
    	  Test.assertEquals(calculate([ [ 13, 1, 16, 3 ],  [ 14, 0, 15, 2 ]]), 7, "intersection down");
    	});
    	it("intersection down right", function() {
    	  Test.assertEquals(calculate([ [ 17, 1, 19, 3 ],  [ 18, 0, 20, 2 ]]), 7, "intersection down right");
    	});
    	it("intersection of the entire right side", function() {
    	  Test.assertEquals(calculate([ [ 13, 5, 15, 6 ],  [ 14, 4, 16, 7 ]]), 7, "intersection of the entire right side");
    	});
    	it("intersection 3 rect", function() {
    	  Test.assertEquals(calculate([ [ 1, 3, 4, 6 ],  [ 2, 1, 5, 4 ],  [ 3, 2, 6, 5 ]]), 20, "intersection 3 rect");
    	});
    	it("3*3", function() {
    	  Test.assertEquals(calculate([[1,1,2,2],[2,1,3,2],[3,1,4,2],[1,2,2,3],[2,2,3,3],[3,2,4,3],[1,3,2,4],[2,3,3,4],[3,3,4,4]]), 9, "3*3");
    	});
    	it("intersection", function() {
    	  Test.assertEquals(calculate([[ 1, 1, 6, 6 ],[ 1, 3, 4, 6 ],[ 2, 3, 4, 6 ],[ 2, 4, 5, 6 ],[ 3, 5, 4, 6 ]]), 25, "intersection");
    	});
    	it("shift right", function() {
    	  Test.assertEquals(calculate([[1,1,6,6],[2,1,6,6],[3,1,6,6],[4,1,6,6],[5,2,6,5]]), 25, "shift right");
    	});
    	it("shift right down", function() {
    	  Test.assertEquals(calculate([[1,1,7,6],[2,2,8,7],[3,3,9,8],[4,4,10,9],[5,5,11,10]]), 70, "shift right down");
    	});
    	it("wings", function() {
    	  Test.assertEquals(calculate([ [ 1, 4, 5, 6 ],  [ 2, 5, 6, 7 ],[ 3, 6, 7, 8 ],[ 4, 7, 8, 9 ],[ 2, 3, 6, 5 ],[ 3, 2, 7, 4 ],[ 4, 1, 8, 3 ]]), 38, "wings");
    	});
    	it("intersection cross", function() {
    	  Test.assertEquals(calculate([ [ 9, 5, 12, 6 ],  [ 10, 4, 11, 7 ]]), 5, "intersection cross");
    	});
    	it("intersection 2", function() {
    	  Test.assertEquals(calculate([ [ 7, 1, 11, 7 ],  [ 8, 0, 12, 3 ],  [ 8, 4, 13, 5 ],  [ 9, 5, 14, 8 ],[ 10, 2, 15, 6 ]]), 53, "intersection 2");
    	});
    	it("pyramid", function() {
    	  Test.assertEquals(calculate([[1,2,6,6],[1,3,5,5],[1,1,7,7]]), 36, "pyramid");
    	});
    	it("circle", function() {
    	  Test.assertEquals(calculate([[1,2,3,7],[2,1,7,3],[6,2,8,7],[2,6,7,8],[4,4,5,5]]), 37, "circle");
    	});
    	it("one", function() {
    	  Test.assertEquals(calculate([[1,1,2,2],[1,1,2,2],[1,1,2,2],[1,1,2,2],[1,1,2,2],[1,1,2,2]]), 1, "one");
    	});
    	it("very hard!", function() {
    	  Test.assertEquals(calculate([[3,3,6,5],[4,4,6,6],[4,3,7,5],[4,2,8,5],[4,3,8,6],[9,0,11,4],[9,1,10,6],[9,0,12,2],[10,1,13,5],[12,4,15,6],[14,1,16,5],[12,1,17,2]]), 52, 'very hard!');
    	});
    	it("waterfall", function() {
    	  Test.assertEquals(calculate([[2, 2, 17, 2], [2, 2, 17, 4], [2, 2, 17, 6], [2, 2, 17, 8], [2, 2, 17, 10], [2, 2, 17, 12], [2, 2, 17, 14], [2, 2, 17, 16], [2, 2, 17, 18], [2, 2, 17, 20], [2, 2, 17, 22], [2, 2, 17, 24], [2, 2, 17, 26], [2, 2, 17, 28]]), 390, "waterfall");
    	});
    	});
    
  • Default User Avatar

    Is this some kind of joke. A lot of time on an empty array.
    (It's a pity there isn't a smiley face that bangs its head against the wall)

  • Default User Avatar

    Very big and 1300ms. Optimization.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    couldn't decide, used backdoor.)

  • Default User Avatar

    Такие лаконичные решения получаются, наверно опыт уже большой. У меня даже с годом на этом сайте близко так не выходит.

  • Default User Avatar

    Ну ты и работаешь, без остановок.)

  • Default User Avatar
  • Default User Avatar

    Why is it so difficult to understand.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Сoding 3 min, understanding that a factor is a divisor of 30 min.)

  • Default User Avatar
    30-all   30 = 2   => 2 + 2
    15-all   15 = 1   => 1 + 1
  • Default User Avatar

    Do you want to suffer. =)

  • Default User Avatar

    Даже девчонка разобралась в этом, кто тебе подсказал?)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...