Pyth,32 29 24字节
AtMQVH+*\.G\#;+\X*\#G+GH
在线尝试!
输入样例:
(4, 5)
样本输出:
...#
...#
...#
...#
X###
7
怎么运行的:
AtMQVH+*\.G\#;+\X*\#G+GH
assign('Q',eval_input())
AtMQ assign('[G,H]',Pmap(lambda d:tail(d),Q))
VH ; for N in range(H):
+*\.G\# implicit_print(plus(times(".",G),"#"))
+\X*\#G implicit_print(plus("X",times("#",G)))
+GH implicit_print(plus(G,H))
先前尝试:
JthQK@Q1+*++*\.J\#btK+\X*\#Jt+JK
在线尝试!
输入样例:
(4, 5)
样本输出:
...#
...#
...#
...#
X###
7
怎么运行的:
JthQK@Q1+*++*\.J\#btK+\X*\#Jt+JK
assign('Q',eval_input()) --Q is now an official pair of numbers (4, 5)
JthQ assign("J",decrement(first(Q))) --gets the first element, and then take 1 from it, and assign it to J
K@Q1 assign("K",lookup(Q,1)) --K is now the second element (count from 0) of the pair.
+ +\X*\#J concat(-----------------------------------------------------------,concat("X",times("#",J)))
* tK repeat(--------------------------------------,decrement(K))
+ b concat(-------------------------,"\n")
+ \# concat(-------------,"#")
*\.J repeat(".",J)
t+JK decrement(add(J,K)) <--- auto-print
#
in“最佳解决方案”中的数量(这是从不向左或向下移动的任何解决方案)?