19

# 挑战

`````` /\
\/
``````

``````1 /\ 2
3 \/ 4
``````

``````                      \
Steep-> /          /
/        / <-Flat
/      \
Flat-> \    \
/  \ <-Steep
/\
\/
``````

• 如果斜线/反斜线与其顶峰侧平行->视为“陡峭”部分。
• 如果斜线/反斜线垂直于其顶峰侧->视为“平坦”部分。

*有关更多参考，请参见上图。

# 输入项

``````C:\....\file.txt
``````

``````                  \
/          /
/        /
/      \
\    \
/  \
/\
\/
\  /
\    \
\      \
\        \
/          /
``````

# 输出量

``````       /
___/
/
AS:0.5
``````

# 测试用例

``````                  \
/          /
/        /
/      \
\    \
/  \
/\
\/
\  /
\    \
\      \
\        \
/          /
``````

``````       /
___/
/
AS=0.5
``````

``````                  /
\          /
/        /
\      /
\    /
/  /
/\
\/
\  /
\    \
\      \
\        \
/          /
/
/
``````

``````______/
AS=0.143 (1/7)
``````

``````           /        \
\      \
/    /
/  \
/\
\/
\  /
\    /
\      /
/        \
``````

``````        /
/
/
_/
AS=0.8
``````

6
Ioannes 2015年

2015年

1
*在叙述中没有程序员受伤。* 我在乎。+1
edc65

3

Beta Decay

4

# JavaScript（ES6），303

``````// Golfed, no indentenation, all newlines are significant

f=s=>(s=`
\${s}
`.split`
`,s.map((r,i)=>~(q=r.search(/\/\\/))&&(y=i,x=q),x=y=0),z=[],[0,2,0,2].map((d,i)=>{t=x+i%2,u=y+i/2|0,b=s[u][t];for(p=[''],n=l=0;(c=s[u][t])>' ';++l,t+=d-1,u+=(i&2)-1)c==b?p.push(p[n++].replace(/./g,' ',w='/')):w='_',p=p.map((r,i)=>(i<n?' ':w)+r);z=z[0]<(p[0]=n/l)?z:p}),z.join`
`)

// Less golfed

U=s=>(
s=(`\n\${s}\n`).split`\n`,
x = y = 0,
s.map((r,i)=>~(q=r.search(/\/\\/))&&(y=i,x=q)),
z=[],
[0,2,0,2].map((d,i) => {
t = x+i%2,
u = y+i/2|0,
b = s[u][t];
for(p=[''], n=l=0; (c=s[u][t])>' '; ++l, t += d-1, u +=(i&2)-1)
c == b
? p.push(p[n++].replace(/./g,' ',w='/'))
: w='_',
p = p.map((r,i) => (i<n?' ':w)+r);
z = z[0]<(p[0]=n/l)?z:p
}),
z.join`\n`
)

// TEST
// redirect console into the snippet body
console.log=x=>O.innerHTML+=x+'\n'

maps=[ // as javascript string literals, each baskslasch has to be repeated
`                  \\
/          /
/        /
/      \\
\\    \\
/  \\
/\\
\\/
\\  /
\\    \\
\\      \\
\\        \\
/          /`,
`                  /
\\          /
/        /
\\      /
\\    /
/  /
/\\
\\/
\\  /
\\    \\
\\      \\
\\        \\
/          /
/
/ `,
`           /        \\
\\      \\
/    /
/  \\
/\\
\\/
\\  /
\\    /
\\      /
/        \\`]

maps.forEach(m=>console.log(m + '\n'+ f(m) +'\n'))``````
``<pre id=O></pre>``