#`'/¡R`Š©*+®'/ý
-2个字节,感谢@MagicOctopusUrn。
在线尝试或验证所有测试用例。
说明:
#` # Split input by spaces and push all items to the stack
# i.e. "4 1/2" → "4" and "1/2"
'/¡ # Push the second item by "/"
# i.e. "1/2" → [1,2]
R` # Revert the list, and also push all items to the stack
# i.e. [1,2] → [2,1] → 2 and 1
Š # Triple-swap the stack
# [4,2,1] → [1,4,2]
© # Store the 2 in the register
* # Multiple the top two items
# 4 and 2 → 8
+ # Add the top two items
# 1 and 8 → 9
® # Push the 2 from the register to the stack again
'/ý # Join the two items by "/"
# 9 and 2 → "9/2"
使用灵活的输入和输出格式,按顺序取整数x,z,y
并在分隔的行上输出分母和分母将是4个字节(这就是为什么我向该挑战添加了解析 -tag的原因。):
*+²»
在线尝试或验证所有测试用例。
说明:
* # Multiply the first two inputs (x and z)
# i.e. 4 and 2 → 8
+ # Add the third input (y)
# i.e. 8 and 1 → 9
² # Take the second input again (z)
» # Join the stack by newlines and implicitly print it