Area of a 2D convex hull Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The PPCG Site design is on its way - help us make it awesome! Sandbox for Proposed ChallengesWhat is the area of this polygon?Find the Convex Hull of a set of 2D pointsFind the area of the largest convex polygonPoint in convex hull (2D)The happy Ender problemDoes the triangle contain the origin?What is the area of this polygon?Sort the points by linear distance in a 3D spaceElliptic systemMaximum Area of a Polygon with Vertices of a PolygonCircle intersection area
Can a zero nonce be safely used with AES-GCM if the key is random and never used again?
How to say that you spent the night with someone, you were only sleeping and nothing else?
How do I keep my slimes from escaping their pens?
Determine whether f is a function, an injection, a surjection
Losing the Initialization Vector in Cipher Block Chaining
Is there folklore associating late breastfeeding with low intelligence and/or gullibility?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
How can players take actions together that are impossible otherwise?
Keep going mode for require-package
Why use gamma over alpha radiation?
Array/tabular for long multiplication
How to say 'striped' in Latin
What do you call a plan that's an alternative plan in case your initial plan fails?
Estimated State payment too big --> money back; + 2018 Tax Reform
Statistical model of ligand substitution
Does a C shift expression have unsigned type? Why would Splint warn about a right-shift?
What was the last x86 CPU that did not have the x87 floating-point unit built in?
Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?
How can I make names more distinctive without making them longer?
Active filter with series inductor and resistor - do these exist?
What are the performance impacts of 'functional' Rust?
Why does this iterative way of solving of equation work?
What computer would be fastest for Mathematica Home Edition?
Simulating Exploding Dice
Area of a 2D convex hull
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The PPCG Site design is on its way - help us make it awesome!
Sandbox for Proposed ChallengesWhat is the area of this polygon?Find the Convex Hull of a set of 2D pointsFind the area of the largest convex polygonPoint in convex hull (2D)The happy Ender problemDoes the triangle contain the origin?What is the area of this polygon?Sort the points by linear distance in a 3D spaceElliptic systemMaximum Area of a Polygon with Vertices of a PolygonCircle intersection area
$begingroup$
You are given an array/list/vector of pairs of integers representing cartesian coordinates (x, y) of points on a 2D Euclidean plane; all coordinates are between −104 and 104, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should be rounded to the closest even integer. You may use floating-point numbers in intermediate computations, but only if you can guarantee that the final result will be always correct. This is a code-golf, the shortest correct program (ignoring non-significant whitespace, newlines and comments) wins.
Some test cases:
Input: [[50, -13]]
Result: 0
Input: [[-25, -26], [34, -27]]
Result: 0
Input: [[-6, -14], [-48, -45], [21, 25]]
Result: 400
Input: [[4, 30], [5, 37], [-18, 49], [-9, -2]]
Result: 562
Input: [[0, 16], [24, 18], [-43, 36], [39, -29], [3, -38]]
Result: 2978
Input: [[19, -19], [15, 5], [-16, -41], [6, -25], [-42, 1], [12, 19]]
Result: 2118
Input: [[-23, 13], [-13, 13], [-6, -7], [22, 41], [-26, 50], [12, -12], [-23, -7]]
Result: 2307
Input: [[31, -19], [-41, -41], [25, 34], [29, -1], [42, -42], [-34, 32], [19, 33], [40, 39]]
Result: 6037
Input: [[47, 1], [-22, 24], [36, 38], [-17, 4], [41, -3], [-13, 15], [-36, -40], [-13, 35], [-25, 22]]
Result: 3908
Input: [[29, -19], [18, 9], [30, -46], [15, 20], [24, -4], [5, 19], [-44, 4], [-20, -8], [-16, 34], [17, -36]]
Result: 2905
code-golf number geometry integer
$endgroup$
add a comment |
$begingroup$
You are given an array/list/vector of pairs of integers representing cartesian coordinates (x, y) of points on a 2D Euclidean plane; all coordinates are between −104 and 104, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should be rounded to the closest even integer. You may use floating-point numbers in intermediate computations, but only if you can guarantee that the final result will be always correct. This is a code-golf, the shortest correct program (ignoring non-significant whitespace, newlines and comments) wins.
Some test cases:
Input: [[50, -13]]
Result: 0
Input: [[-25, -26], [34, -27]]
Result: 0
Input: [[-6, -14], [-48, -45], [21, 25]]
Result: 400
Input: [[4, 30], [5, 37], [-18, 49], [-9, -2]]
Result: 562
Input: [[0, 16], [24, 18], [-43, 36], [39, -29], [3, -38]]
Result: 2978
Input: [[19, -19], [15, 5], [-16, -41], [6, -25], [-42, 1], [12, 19]]
Result: 2118
Input: [[-23, 13], [-13, 13], [-6, -7], [22, 41], [-26, 50], [12, -12], [-23, -7]]
Result: 2307
Input: [[31, -19], [-41, -41], [25, 34], [29, -1], [42, -42], [-34, 32], [19, 33], [40, 39]]
Result: 6037
Input: [[47, 1], [-22, 24], [36, 38], [-17, 4], [41, -3], [-13, 15], [-36, -40], [-13, 35], [-25, 22]]
Result: 3908
Input: [[29, -19], [18, 9], [30, -46], [15, 20], [24, -4], [5, 19], [-44, 4], [-20, -8], [-16, 34], [17, -36]]
Result: 2905
code-golf number geometry integer
$endgroup$
2
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
6
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
1
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago
add a comment |
$begingroup$
You are given an array/list/vector of pairs of integers representing cartesian coordinates (x, y) of points on a 2D Euclidean plane; all coordinates are between −104 and 104, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should be rounded to the closest even integer. You may use floating-point numbers in intermediate computations, but only if you can guarantee that the final result will be always correct. This is a code-golf, the shortest correct program (ignoring non-significant whitespace, newlines and comments) wins.
Some test cases:
Input: [[50, -13]]
Result: 0
Input: [[-25, -26], [34, -27]]
Result: 0
Input: [[-6, -14], [-48, -45], [21, 25]]
Result: 400
Input: [[4, 30], [5, 37], [-18, 49], [-9, -2]]
Result: 562
Input: [[0, 16], [24, 18], [-43, 36], [39, -29], [3, -38]]
Result: 2978
Input: [[19, -19], [15, 5], [-16, -41], [6, -25], [-42, 1], [12, 19]]
Result: 2118
Input: [[-23, 13], [-13, 13], [-6, -7], [22, 41], [-26, 50], [12, -12], [-23, -7]]
Result: 2307
Input: [[31, -19], [-41, -41], [25, 34], [29, -1], [42, -42], [-34, 32], [19, 33], [40, 39]]
Result: 6037
Input: [[47, 1], [-22, 24], [36, 38], [-17, 4], [41, -3], [-13, 15], [-36, -40], [-13, 35], [-25, 22]]
Result: 3908
Input: [[29, -19], [18, 9], [30, -46], [15, 20], [24, -4], [5, 19], [-44, 4], [-20, -8], [-16, 34], [17, -36]]
Result: 2905
code-golf number geometry integer
$endgroup$
You are given an array/list/vector of pairs of integers representing cartesian coordinates (x, y) of points on a 2D Euclidean plane; all coordinates are between −104 and 104, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should be rounded to the closest even integer. You may use floating-point numbers in intermediate computations, but only if you can guarantee that the final result will be always correct. This is a code-golf, the shortest correct program (ignoring non-significant whitespace, newlines and comments) wins.
Some test cases:
Input: [[50, -13]]
Result: 0
Input: [[-25, -26], [34, -27]]
Result: 0
Input: [[-6, -14], [-48, -45], [21, 25]]
Result: 400
Input: [[4, 30], [5, 37], [-18, 49], [-9, -2]]
Result: 562
Input: [[0, 16], [24, 18], [-43, 36], [39, -29], [3, -38]]
Result: 2978
Input: [[19, -19], [15, 5], [-16, -41], [6, -25], [-42, 1], [12, 19]]
Result: 2118
Input: [[-23, 13], [-13, 13], [-6, -7], [22, 41], [-26, 50], [12, -12], [-23, -7]]
Result: 2307
Input: [[31, -19], [-41, -41], [25, 34], [29, -1], [42, -42], [-34, 32], [19, 33], [40, 39]]
Result: 6037
Input: [[47, 1], [-22, 24], [36, 38], [-17, 4], [41, -3], [-13, 15], [-36, -40], [-13, 35], [-25, 22]]
Result: 3908
Input: [[29, -19], [18, 9], [30, -46], [15, 20], [24, -4], [5, 19], [-44, 4], [-20, -8], [-16, 34], [17, -36]]
Result: 2905
code-golf number geometry integer
code-golf number geometry integer
edited 3 hours ago
Vladimir Reshetnikov
asked 4 hours ago
Vladimir ReshetnikovVladimir Reshetnikov
1,9781613
1,9781613
2
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
6
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
1
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago
add a comment |
2
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
6
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
1
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago
2
2
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
6
6
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
1
1
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A
Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A
with columns x
and y
.
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 27 bytes
Round@*Area@*ConvexHullMesh
Try it online!
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "200"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183191%2farea-of-a-2d-convex-hull%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A
Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A
with columns x
and y
.
$endgroup$
add a comment |
$begingroup$
SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A
Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A
with columns x
and y
.
$endgroup$
add a comment |
$begingroup$
SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A
Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A
with columns x
and y
.
$endgroup$
SQL Server 2012+, 84 bytes
SELECT Round(Geometry::ConvexHullAggregate(Geometry::Point(x,y,0)).STArea(),0)FROM A
Makes use of the geometry functions and aggregates in SQL Server.
Coordindates are from table A
with columns x
and y
.
answered 3 hours ago
MickyTMickyT
10.4k21637
10.4k21637
add a comment |
add a comment |
$begingroup$
Wolfram Language (Mathematica), 27 bytes
Round@*Area@*ConvexHullMesh
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 27 bytes
Round@*Area@*ConvexHullMesh
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 27 bytes
Round@*Area@*ConvexHullMesh
Try it online!
$endgroup$
Wolfram Language (Mathematica), 27 bytes
Round@*Area@*ConvexHullMesh
Try it online!
answered 1 hour ago
attinatattinat
4897
4897
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f183191%2farea-of-a-2d-convex-hull%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
$begingroup$
Do you have any test cases?
$endgroup$
– Maltysen
3 hours ago
6
$begingroup$
Not counting whitespace in code golf is a bad idea, it leads to submissions with massive strings of whitespace plus generic code to convert the string to code and execute it.
$endgroup$
– xnor
3 hours ago
1
$begingroup$
So if someone can just make a whitespace solution...
$endgroup$
– attinat
1 hour ago
$begingroup$
Related
$endgroup$
– Giuseppe
1 hour ago