Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

Math (non-competiting)

#Math (non-competiting)

#Math (non-competiting)

Math (non-competiting)

deleted 290 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-("
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += "))^2+(y-(";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += "))^2-(";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += "^2")^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=0 to x=";
 document.getElementById("res").value += document.getElementById("w").value;
 document.getElementById("res").value += " and y=0 to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>

Uh oh, It looks like I broke WolframAlpha. Now make it work with Mathematica...

<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-"
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += ")^2+(y-";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += ")^2-";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += "^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=0 to x=";
 document.getElementById("res").value += document.getElementById("w").value;
 document.getElementById("res").value += " and y=0 to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>

Uh oh, It looks like I broke WolframAlpha.

<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-("
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += "))^2+(y-(";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += "))^2-(";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += ")^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=0 to x=";
 document.getElementById("res").value += document.getElementById("w").value;
 document.getElementById("res").value += " and y=0 to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>

Now make it work with Mathematica...

deleted 290 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-"
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += ")^2+(y-";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += ")^2-";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += "^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=-";
 document.getElementById("res").value += document.getElementById("w").value/2;
 document.getElementById("res").value += "x=0 to x=";
 document.getElementById("res").value += document.getElementById("w").value/2;value;
 document.getElementById("res").value += " and y=-";
  document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "y=0 to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>
<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-"
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += ")^2+(y-";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += ")^2-";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += "^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=-";
 document.getElementById("res").value += document.getElementById("w").value/2;
 document.getElementById("res").value += " to x=";
 document.getElementById("res").value += document.getElementById("w").value/2;
 document.getElementById("res").value += " and y=-";
  document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += " to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>
<input id="in" placeholder="input, with () changed to []">
<br>
<input type="color" id="c1" value="#ff0000">
<input type="color" id="c2" value="#00ff00">
<br>
<input id="w" placeholder="width">
<input id="h" placeholder="height">
<br>
<button onclick="change()">
Convert!
</button>
<br>
<input id="res" placeholder="result">
<script>
 function change() {
 var a = document.getElementById("in").value;
 document.getElementById("res").value = "";
 var arr = JSON.parse("[" + a + "]");
 document.getElementById("res").value += "plot ";
 for (var i = 0; i < arr.length; i++) {
 document.getElementById("res").value += "((x-"
 document.getElementById("res").value += arr[i][1];
 document.getElementById("res").value += ")^2+(y-";
 document.getElementById("res").value += arr[i][2];
 document.getElementById("res").value += ")^2-";
 document.getElementById("res").value += arr[i][0];
 document.getElementById("res").value += "^2)";
 }
 document.getElementById("res").value += ">=0";
 document.getElementById("res").value += " from x=0 to x=";
 document.getElementById("res").value += document.getElementById("w").value;
 document.getElementById("res").value += " and y=0 to y=";
 document.getElementById("res").value += document.getElementById("h").value/2;
 document.getElementById("res").value += "> color ";
 document.getElementById("res").value += document.getElementById("c1").value;
 document.getElementById("res").value += " background color ";
 document.getElementById("res").value += document.getElementById("c2").value;
 }
</script>
added 1028 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
added 5 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
added 64 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
added 82 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
Added a way to run here!
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
Added a way to run here!
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
deleted 1 character in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
added 1016 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
added 70 characters in body
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
Added examples
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading
Source Link
Matthew Roh
  • 5.4k
  • 4
  • 31
  • 61
Loading

AltStyle によって変換されたページ (->オリジナル) /