Post History
JavaScript (Node.js), 99 96 69 bytes s=>([a,b,c,d]=s.match(/-?\d+/g),a*c-b*d+(a=a*d+b*c,a<0?'':'+')+a+'i') Try it online! This regex is probably the best way to get the numbers. Also, f...
Answer
#3: Post edited
# [JavaScript (Node.js)], ~~99~~ 96 bytes- ```javascript
s=>([_,a,b,c,d]=s.match(/(-?.+)([+-].+)i (-?.+)([+-].+)i/),a*c-b*d+(a=a*d+b*c,a<0?'':'+')+a+'i')- ```
- [Try it online!][TIO-kqiks73i]
Half of this is formatting pain- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kqiks73i]: https://tio.run/##Xc7RTsMgFAbg@z7FSW@AHijQ1kWd3R6kaQylrWLmMKPxxvjsFVZjFm84HD7@5H8znybYi/tYxNmP0zq3a2gPtHvmhg/c8rFvQ/luFvtKJRXHEhntUPRxOvi3S8ZNYcVQjEhNa@IYCsvNkzoS8kiQMDRIHGGr9eewwDKFJUALXQaQ19g4aMSdyzkASCkOcC9q7ZKJBh8cVKK6opQQUSusdreKtyqqHWq1cY3Kpe8q@S/XaU2qUDtIRw7wF9YJ@32Wzf4CNNUEP291GXzFWOrvT1N58i8bI5CUJPEyX18Y22ff6w8 "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~99~~ ~~96~~ 69 bytes
- ```javascript
- s=>([a,b,c,d]=s.match(/-?\d+/g),a*c-b*d+(a=a*d+b*c,a<0?'':'+')+a+'i')
- ```
- [Try it online!][TIO-kqiks73i]
- This regex is probably the best way to get the numbers.
- Also, for some reason, JavaScript math works with strings of numbers, so that's convenient.
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kqiks73i]: https://tio.run/##Tc5NbsMgEAXgvU8x8gbjgYB/GqVNSQ6SZoGxnRKloQqom6pndz1xVWXDAN886Z3tl43u5j@TvIZ@mEYzRbMrDlZ0won@aOLqwyb3Xii5f@tRnbiwpZNd2WNhjZ1HVzphX/WesReGjKNF5hmfXLjGBGmIKYKBQwaQN9h6aOWTzwUAKCV3sJFN5clki88ealnfUSmYsdJYrx8VH1XWa6z0wg1qT@ua/I8bepJqrDzQkQP8hyvC4zbLxnCDgmpCGJe6HL7nGPUPl2F1CaeFERgl2XwZ7z@cb7Of6Rc "JavaScript (Node.js) – Try It Online"
#2: Post edited
# [JavaScript (Node.js)], 99 bytes- ```javascript
s=>([_,a,b,c,d]=s.match(/(-?.+)([+-].+)i (-?.+)([+-].+)i/),a*c-b*d+''+(a=a*d+b*c,a<0?'':'+')+a+'i')- ```
- [Try it online!][TIO-kqiks73i]
- Half of this is formatting pain
- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kqiks73i]: https://tio.run/##Xc7RTsMgFAbg@z7FSW@AHijQ1kWd3R6kaQylrWLmMKPxxvjsFVZjFm/gHD7@5H8znybYi/tYxNmP0zq3a2gPtHvmhg/c8rFvQ/luFvtKJRXHEhntUPTxdvBvl4ybwoqhGJEQpKY1cRoKy82TOhLySJAwNEgcYav157DAMoUlQAtdBpDX2DhoxJ3LOQBIKQ5wL2rtkokGHxxUorqilBBRK6x2t4q3KqodarVxjcql7yr5L9dpTapQO0hHDvAX1gn7fZbN/gI01QQ/b3UZfMVY6u9PU3nyLxsjkJQkcZivL4zts@/1Bw "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], ~~99~~ 96 bytes
- ```javascript
- s=>([_,a,b,c,d]=s.match(/(-?.+)([+-].+)i (-?.+)([+-].+)i/),a*c-b*d+(a=a*d+b*c,a<0?'':'+')+a+'i')
- ```
- [Try it online!][TIO-kqiks73i]
- Half of this is formatting pain
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kqiks73i]: https://tio.run/##Xc7RTsMgFAbg@z7FSW@AHijQ1kWd3R6kaQylrWLmMKPxxvjsFVZjFm84HD7@5H8znybYi/tYxNmP0zq3a2gPtHvmhg/c8rFvQ/luFvtKJRXHEhntUPRxOvi3S8ZNYcVQjEhNa@IYCsvNkzoS8kiQMDRIHGGr9eewwDKFJUALXQaQ19g4aMSdyzkASCkOcC9q7ZKJBh8cVKK6opQQUSusdreKtyqqHWq1cY3Kpe8q@S/XaU2qUDtIRw7wF9YJ@32Wzf4CNNUEP291GXzFWOrvT1N58i8bI5CUJPEyX18Y22ff6w8 "JavaScript (Node.js) – Try It Online"
#1: Initial revision
# [JavaScript (Node.js)], 99 bytes ```javascript s=>([_,a,b,c,d]=s.match(/(-?.+)([+-].+)i (-?.+)([+-].+)i/),a*c-b*d+''+(a=a*d+b*c,a<0?'':'+')+a+'i') ``` [Try it online!][TIO-kqiks73i] Half of this is formatting pain [JavaScript (Node.js)]: https://nodejs.org [TIO-kqiks73i]: https://tio.run/##Xc7RTsMgFAbg@z7FSW@AHijQ1kWd3R6kaQylrWLmMKPxxvjsFVZjFm/gHD7@5H8znybYi/tYxNmP0zq3a2gPtHvmhg/c8rFvQ/luFvtKJRXHEhntUPTxdvBvl4ybwoqhGJEQpKY1cRoKy82TOhLySJAwNEgcYav157DAMoUlQAtdBpDX2DhoxJ3LOQBIKQ5wL2rtkokGHxxUorqilBBRK6x2t4q3KqodarVxjcql7yr5L9dpTapQO0hHDvAX1gn7fZbN/gI01QQ/b3UZfMVY6u9PU3nyLxsjkJQkcZivL4zts@/1Bw "JavaScript (Node.js) – Try It Online"