Revision c6d81c20-b7a5-4db2-84d7-17803671fb3b - Code Golf Stack Exchange

#Mathematica 122 (104?)

 g@s_ := ({w, p} = ToExpression@StringSplit@s; 
 Array[If[Switch[p, 1, # <= (w + 1 - #2), 2, # <= #2, 3, # >= #2, 4, # > (w - #2)],
 "X", ""] &, {w, w}]) // Grid


----------


 GraphicsGrid[{{g["12 1"], g["12 3"]}}]

![another method][3]


----------

Under a liberal interpretation of "output", the following (104 chars) will work. 
 
 f@s_ := ({w, p} = ToExpression@StringSplit@s; 
 Graphics[Polygon@Delete[{{w, 0}, {0, 0}, {w, w}, {0, w}}, p], Axes -> True])


 f["50 4"]

![triangle][1]




----------


If input in the form of a list were permitted, the following (75 chars) would suffice:

 f[{w_, p_}] := 
 Graphics[Polygon@Delete[{{w, 0}, {0, 0}, {w, w}, {0, w}}, p], Axes -> True]


----------


 [1]: https://i.sstatic.net/lcJ83.png
 [2]: https://i.sstatic.net/EYp2O.png
 [3]: https://i.sstatic.net/tRgnH.png

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