backup de julho
[h2N7SspZmY.git] / data / cache / 9 / 91f3dbdea756b9119d769e9b7af6ed82.code
blobb0776b7f11794aa0e7c13ad06c66f0844f5249d4
1 <span class="co1">#!/usr/bin/ruby</span>
2 lines = <span class="kw4">IO</span>.<span class="me1">read</span><span class="br0">&#40;</span>ARGV<span class="br0">&#91;</span>0<span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="kw3">split</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\&quot;</span>,<span class="es0">\&quot;</span>&quot;</span><span class="br0">&#41;</span>;
3 lines<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">delete</span>!<span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\&quot;</span>&quot;</span><span class="br0">&#41;</span>
4 lines<span class="br0">&#91;</span><span class="sy0">-</span><span class="nu0">1</span><span class="br0">&#93;</span>.<span class="me1">delete</span>!<span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\&quot;</span>&quot;</span><span class="br0">&#41;</span>
5 lines.<span class="me1">sort</span>!
6 res = 0
7 lines.<span class="me1">each_index</span><span class="br0">&#123;</span><span class="sy0">|</span>i<span class="sy0">|</span>
8         l = lines<span class="br0">&#91;</span>i<span class="br0">&#93;</span>
9         <span class="kw3">p</span> = 0
10         l.<span class="me1">bytes</span>.<span class="me1">each</span><span class="br0">&#123;</span><span class="sy0">|</span>b<span class="sy0">|</span>
11                 <span class="co1">#print &quot;#{b}: #{b.to_i - 'A'[0].to_i + 1}\n&quot;</span>
12                 <span class="kw3">p</span> <span class="sy0">+</span>= b.<span class="me1">to_i</span> <span class="sy0">-</span> <span class="st0">'A'</span><span class="br0">&#91;</span>0<span class="br0">&#93;</span>.<span class="me1">to_i</span> <span class="sy0">+</span> 1 <span class="kw1">if</span> b.<span class="me1">to_i</span> <span class="sy0">&gt;</span> 0
13         <span class="br0">&#125;</span>
14         res <span class="sy0">+</span>= <span class="kw3">p</span> <span class="sy0">*</span> <span class="br0">&#40;</span>i <span class="sy0">+</span> 1<span class="br0">&#41;</span>
15 &nbsp;
16         <span class="kw3">print</span> <span class="st0">&quot;#{res}, #{p}:#{l}<span class="es0">\n</span>&quot;</span>
17 <span class="br0">&#125;</span>