chrislo-sourceclassifier 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +0 -312
- data/Rakefile +2 -2
- data/sourceclassifier.gemspec +6 -6
- metadata +4 -316
- data/sources/gcc/ackermann.gcc-2.gcc +0 -93
- data/sources/gcc/ackermann.gcc-3.gcc +0 -20
- data/sources/gcc/ary.gcc +0 -40
- data/sources/gcc/binarytrees.gcc +0 -136
- data/sources/gcc/binarytrees.gcc-2.gcc +0 -140
- data/sources/gcc/binarytrees.gcc-3.gcc +0 -134
- data/sources/gcc/chameneos.gcc +0 -117
- data/sources/gcc/chameneos.gcc-2.gcc +0 -134
- data/sources/gcc/chameneos.gcc-3.gcc +0 -120
- data/sources/gcc/chameneosredux.gcc +0 -306
- data/sources/gcc/echo.gcc +0 -144
- data/sources/gcc/except.gcc +0 -52
- data/sources/gcc/fannkuch.gcc +0 -105
- data/sources/gcc/fannkuch.gcc-2.gcc +0 -94
- data/sources/gcc/fasta.gcc +0 -158
- data/sources/gcc/fasta.gcc-2.gcc +0 -132
- data/sources/gcc/fasta.gcc-3.gcc +0 -145
- data/sources/gcc/fasta.gcc-4.gcc +0 -141
- data/sources/gcc/fibo.gcc +0 -20
- data/sources/gcc/harmonic.gcc +0 -22
- data/sources/gcc/hash.gcc +0 -31
- data/sources/gcc/hash2.gcc +0 -38
- data/sources/gcc/heapsort.gcc +0 -72
- data/sources/gcc/hello.gcc-2.gcc +0 -12
- data/sources/gcc/hello.gcc-3.gcc +0 -20
- data/sources/gcc/knucleotide.gcc +0 -173
- data/sources/gcc/knucleotide.gcc-2.gcc +0 -168
- data/sources/gcc/lists.gcc +0 -226
- data/sources/gcc/magicsquares.gcc +0 -378
- data/sources/gcc/mandelbrot.gcc +0 -84
- data/sources/gcc/mandelbrot.gcc-2.gcc +0 -63
- data/sources/gcc/mandelbrot.gcc-3.gcc +0 -91
- data/sources/gcc/mandelbrot.gcc-4.gcc +0 -78
- data/sources/gcc/matrix.gcc +0 -66
- data/sources/gcc/message.gcc-2.gcc +0 -72
- data/sources/gcc/message.gcc-3.gcc +0 -64
- data/sources/gcc/methcall.gcc +0 -89
- data/sources/gcc/moments.gcc +0 -120
- data/sources/gcc/nbody.gcc +0 -142
- data/sources/gcc/nbody.gcc-2.gcc +0 -143
- data/sources/gcc/nbody.gcc-3.gcc +0 -142
- data/sources/gcc/nestedloop.gcc +0 -25
- data/sources/gcc/nsieve.gcc +0 -35
- data/sources/gcc/nsievebits.gcc-2.gcc +0 -37
- data/sources/gcc/nsievebits.gcc-3.gcc +0 -53
- data/sources/gcc/objinst.gcc +0 -95
- data/sources/gcc/partialsums.gcc +0 -86
- data/sources/gcc/partialsums.gcc-3.gcc +0 -81
- data/sources/gcc/partialsums.gcc-4.gcc +0 -68
- data/sources/gcc/pidigits.gcc +0 -105
- data/sources/gcc/primes.gcc +0 -75
- data/sources/gcc/prodcons.gcc +0 -86
- data/sources/gcc/random.gcc +0 -29
- data/sources/gcc/raytracer.gcc +0 -125
- data/sources/gcc/raytracer.gcc-2.gcc +0 -181
- data/sources/gcc/recursive.gcc +0 -68
- data/sources/gcc/recursive.gcc-2.gcc +0 -55
- data/sources/gcc/regexdna.gcc-2.gcc +0 -126
- data/sources/gcc/regexmatch.gcc +0 -136
- data/sources/gcc/revcomp.gcc +0 -85
- data/sources/gcc/revcomp.gcc-2.gcc +0 -88
- data/sources/gcc/revcomp.gcc-4.gcc +0 -71
- data/sources/gcc/reversefile.gcc +0 -103
- data/sources/gcc/reversefile.gcc-2.gcc +0 -56
- data/sources/gcc/sieve.gcc +0 -34
- data/sources/gcc/spectralnorm.gcc +0 -54
- data/sources/gcc/spellcheck.gcc +0 -72
- data/sources/gcc/spellcheck.gcc-2.gcc +0 -61
- data/sources/gcc/strcat.gcc +0 -38
- data/sources/gcc/sumcol.gcc-2.gcc +0 -98
- data/sources/gcc/sumcol.gcc-3.gcc +0 -22
- data/sources/gcc/sumcol.gcc-4.gcc +0 -18
- data/sources/gcc/sumcol.gcc-5.gcc +0 -32
- data/sources/gcc/takfp.gcc +0 -23
- data/sources/gcc/tcp-stream.gcc +0 -122
- data/sources/gcc/tcpecho.gcc +0 -122
- data/sources/gcc/tcpecho.gcc-2.gcc +0 -136
- data/sources/gcc/tcprequest.gcc +0 -122
- data/sources/gcc/threadring.gcc +0 -73
- data/sources/gcc/wc.gcc +0 -52
- data/sources/gcc/wc.gcc-2.gcc +0 -40
- data/sources/gcc/wc.gcc-3.gcc +0 -46
- data/sources/gcc/wordfreq.gcc-2.gcc +0 -85
- data/sources/perl/ackermann.perl +0 -28
- data/sources/perl/ackermann.perl-2.perl +0 -25
- data/sources/perl/ackermann.perl-3.perl +0 -20
- data/sources/perl/ackermann.perl-4.perl +0 -18
- data/sources/perl/ary.perl +0 -25
- data/sources/perl/ary.perl-2.perl +0 -23
- data/sources/perl/binarytrees.perl +0 -66
- data/sources/perl/binarytrees.perl-2.perl +0 -71
- data/sources/perl/chameneos.perl +0 -67
- data/sources/perl/echo.perl +0 -81
- data/sources/perl/except.perl +0 -73
- data/sources/perl/fannkuch.perl +0 -44
- data/sources/perl/fannkuch.perl-2.perl +0 -38
- data/sources/perl/fasta.perl +0 -112
- data/sources/perl/fasta.perl-2.perl +0 -135
- data/sources/perl/fasta.perl-4.perl +0 -122
- data/sources/perl/fibo.perl +0 -15
- data/sources/perl/fibo.perl-2.perl +0 -0
- data/sources/perl/fibo.perl-3.perl +0 -0
- data/sources/perl/harmonic.perl +0 -7
- data/sources/perl/hash.perl +0 -23
- data/sources/perl/hash.perl-2.perl +0 -17
- data/sources/perl/hash.perl-3.perl +0 -24
- data/sources/perl/hash2.perl +0 -16
- data/sources/perl/heapsort.perl +0 -65
- data/sources/perl/heapsort.perl-2.perl +0 -0
- data/sources/perl/hello.perl +0 -5
- data/sources/perl/knucleotide.perl-2.perl +0 -30
- data/sources/perl/lists.perl +0 -48
- data/sources/perl/mandelbrot.perl-2.perl +0 -32
- data/sources/perl/matrix.perl +0 -59
- data/sources/perl/matrix.perl-2.perl +0 -0
- data/sources/perl/matrix.perl-3.perl +0 -0
- data/sources/perl/message.perl +0 -27
- data/sources/perl/methcall.perl +0 -66
- data/sources/perl/moments.perl +0 -44
- data/sources/perl/nbody.perl +0 -108
- data/sources/perl/nestedloop.perl +0 -28
- data/sources/perl/nsieve.perl-2.perl +0 -41
- data/sources/perl/nsieve.perl-4.perl +0 -43
- data/sources/perl/nsievebits.perl +0 -37
- data/sources/perl/objinst.perl +0 -73
- data/sources/perl/partialsums.perl-3.perl +0 -31
- data/sources/perl/pidigits.perl +0 -52
- data/sources/perl/pidigits.perl-2.perl +0 -47
- data/sources/perl/process.perl +0 -50
- data/sources/perl/prodcons.perl +0 -47
- data/sources/perl/random.perl-4.perl +0 -17
- data/sources/perl/recursive.perl-2.perl +0 -57
- data/sources/perl/regexdna.perl +0 -48
- data/sources/perl/regexdna.perl-2.perl +0 -43
- data/sources/perl/regexdna.perl-3.perl +0 -50
- data/sources/perl/regexdna.perl-4.perl +0 -49
- data/sources/perl/regexdna.perl-5.perl +0 -42
- data/sources/perl/regexdna.perl-6.perl +0 -43
- data/sources/perl/regexmatch.perl +0 -35
- data/sources/perl/revcomp.perl-2.perl +0 -34
- data/sources/perl/reversefile.perl +0 -8
- data/sources/perl/reversefile.perl-2.perl +0 -0
- data/sources/perl/reversefile.perl-3.perl +0 -0
- data/sources/perl/sieve.perl +0 -23
- data/sources/perl/spectralnorm.perl-2.perl +0 -54
- data/sources/perl/spellcheck.perl +0 -24
- data/sources/perl/strcat.perl +0 -13
- data/sources/perl/strcat.perl-2.perl +0 -0
- data/sources/perl/sumcol.perl +0 -8
- data/sources/perl/takfp.perl +0 -23
- data/sources/perl/takfp.perl-3.perl +0 -20
- data/sources/perl/tcpecho.perl +0 -61
- data/sources/perl/tcprequest.perl +0 -61
- data/sources/perl/tcpstream.perl +0 -61
- data/sources/perl/threadring.perl +0 -55
- data/sources/perl/threadring.perl-2.perl +0 -43
- data/sources/perl/wc.perl +0 -20
- data/sources/perl/wc.perl-2.perl +0 -14
- data/sources/perl/wordfreq.perl +0 -22
- data/sources/perl/wordfreq.perl-3.perl +0 -0
- data/sources/perl/wordfreq.perl3.perl +0 -0
- data/sources/python/ackermann.python +0 -21
- data/sources/python/ary.python +0 -19
- data/sources/python/binarytrees.python +0 -39
- data/sources/python/binarytrees.python-3.python +0 -44
- data/sources/python/chameneos.python-6.python +0 -73
- data/sources/python/chameneosredux.python +0 -126
- data/sources/python/chameneosredux.python-2.python +0 -122
- data/sources/python/dispatch.python +0 -176
- data/sources/python/dispatch.python-2.python +0 -136
- data/sources/python/echo.python +0 -64
- data/sources/python/except.python +0 -62
- data/sources/python/fannkuch.python +0 -50
- data/sources/python/fannkuch.python-2.python +0 -54
- data/sources/python/fasta.python-2.python +0 -79
- data/sources/python/fibo.python +0 -17
- data/sources/python/fibo.python-2.python +0 -0
- data/sources/python/fibo.python-3.python +0 -0
- data/sources/python/harmonic.python-2.python +0 -9
- data/sources/python/hash.python +0 -21
- data/sources/python/hash.python-2.python +0 -0
- data/sources/python/hash2.python +0 -30
- data/sources/python/heapsort.python-3.python +0 -66
- data/sources/python/hello.python +0 -5
- data/sources/python/implicitode.python +0 -231
- data/sources/python/knucleotide.python +0 -55
- data/sources/python/lists.python +0 -44
- data/sources/python/magicsquares.python +0 -145
- data/sources/python/mandelbrot.python +0 -44
- data/sources/python/mandelbrot.python-2.python +0 -35
- data/sources/python/mandelbrot.python-3.python +0 -46
- data/sources/python/matrix.python +0 -34
- data/sources/python/matrix.python-2.python +0 -23
- data/sources/python/message.python +0 -24
- data/sources/python/message.python-2.python +0 -20
- data/sources/python/message.python-3.python +0 -19
- data/sources/python/meteor.python +0 -210
- data/sources/python/meteor.python-2.python +0 -192
- data/sources/python/methcall.python +0 -51
- data/sources/python/moments.python +0 -65
- data/sources/python/nbody.python +0 -123
- data/sources/python/nbody.python-2.python +0 -120
- data/sources/python/nestedloop.python +0 -24
- data/sources/python/nsieve.python +0 -27
- data/sources/python/nsieve.python-2.python +0 -23
- data/sources/python/nsieve.python-4.python +0 -25
- data/sources/python/nsievebits.python +0 -27
- data/sources/python/nsievebits.python-2.python +0 -43
- data/sources/python/objinst.python +0 -53
- data/sources/python/partialsums.python +0 -37
- data/sources/python/partialsums.python-2.python +0 -35
- data/sources/python/partialsums.python-3.python +0 -48
- data/sources/python/pidigits.python +0 -38
- data/sources/python/pidigits.python-3.python +0 -63
- data/sources/python/pidigits.python-4.python +0 -24
- data/sources/python/process.python +0 -51
- data/sources/python/process.python-2.python +0 -133
- data/sources/python/prodcons.python +0 -51
- data/sources/python/prodcons.python-2.python +0 -0
- data/sources/python/random.python +0 -27
- data/sources/python/raytracer.python +0 -203
- data/sources/python/recursive.python +0 -35
- data/sources/python/regexdna.python +0 -39
- data/sources/python/regexdna.python-2.python +0 -34
- data/sources/python/regexmatch.python +0 -36
- data/sources/python/revcomp.python-3.python +0 -31
- data/sources/python/reversefile.python +0 -13
- data/sources/python/reversefile.python-2.python +0 -0
- data/sources/python/reversefile.python-3.python +0 -0
- data/sources/python/sieve.python +0 -50
- data/sources/python/spectralnorm.python-2.python +0 -36
- data/sources/python/spellcheck.python +0 -17
- data/sources/python/strcat.python +0 -35
- data/sources/python/strcat.python-2.python +0 -0
- data/sources/python/sumcol.python-2.python +0 -0
- data/sources/python/sumcol.python-3.python +0 -0
- data/sources/python/takfp.python +0 -19
- data/sources/python/tcpecho.python +0 -67
- data/sources/python/tcprequest.python +0 -67
- data/sources/python/tcpstream.python +0 -67
- data/sources/python/threadring.python +0 -47
- data/sources/python/threadring.python-2.python +0 -40
- data/sources/python/threadring.python-3.python +0 -34
- data/sources/python/wc.python-2.python +0 -19
- data/sources/python/wordfreq.python +0 -43
- data/sources/python/wordfreq.python-2.python +0 -0
- data/sources/python/wordfreq.python-3.python +0 -28
- data/sources/python/wordfreq.python-4.python +0 -38
- data/sources/python/wordfreq.python-5.python +0 -39
- data/sources/ruby/ackermann.ruby +0 -17
- data/sources/ruby/ackermann.ruby-5.ruby +0 -153
- data/sources/ruby/ary.ruby +0 -22
- data/sources/ruby/binarytrees.ruby-2.ruby +0 -55
- data/sources/ruby/chameneos.ruby-2.ruby +0 -71
- data/sources/ruby/dispatch.ruby +0 -114
- data/sources/ruby/echo.ruby +0 -41
- data/sources/ruby/except.ruby +0 -61
- data/sources/ruby/except.ruby-2.ruby +0 -61
- data/sources/ruby/fannkuch.ruby +0 -42
- data/sources/ruby/fasta.ruby +0 -81
- data/sources/ruby/fibo.ruby +0 -15
- data/sources/ruby/harmonic.ruby-2.ruby +0 -15
- data/sources/ruby/hash.ruby +0 -19
- data/sources/ruby/hash2.ruby +0 -23
- data/sources/ruby/heapsort.ruby +0 -55
- data/sources/ruby/hello.ruby +0 -6
- data/sources/ruby/knucleotide.ruby-2.ruby +0 -44
- data/sources/ruby/lists.ruby +0 -46
- data/sources/ruby/mandelbrot.ruby-3.ruby +0 -63
- data/sources/ruby/matrix.ruby +0 -40
- data/sources/ruby/matrix.ruby-2.ruby +0 -30
- data/sources/ruby/message.ruby +0 -29
- data/sources/ruby/message.ruby-2.ruby +0 -24
- data/sources/ruby/meteor.ruby +0 -386
- data/sources/ruby/meteor.ruby-2.ruby +0 -561
- data/sources/ruby/methcall.ruby +0 -58
- data/sources/ruby/methcall.ruby-2.ruby +0 -54
- data/sources/ruby/moments.ruby +0 -64
- data/sources/ruby/nbody.ruby-2.ruby +0 -145
- data/sources/ruby/nestedloop.ruby +0 -22
- data/sources/ruby/nsieve.ruby +0 -36
- data/sources/ruby/nsieve.ruby-2.ruby +0 -25
- data/sources/ruby/nsievebits.ruby-2.ruby +0 -42
- data/sources/ruby/objinst.ruby +0 -58
- data/sources/ruby/partialsums.ruby +0 -39
- data/sources/ruby/pidigits.ruby +0 -92
- data/sources/ruby/pidigits.ruby-2.ruby +0 -109
- data/sources/ruby/prodcons.ruby +0 -41
- data/sources/ruby/random.ruby +0 -17
- data/sources/ruby/recursive.ruby-2.ruby +0 -53
- data/sources/ruby/regexdna.ruby +0 -32
- data/sources/ruby/regexdna.ruby-2.ruby +0 -38
- data/sources/ruby/regexmatch.ruby +0 -33
- data/sources/ruby/revcomp.ruby +0 -28
- data/sources/ruby/reversefile.ruby +0 -7
- data/sources/ruby/sieve.ruby +0 -30
- data/sources/ruby/spectralnorm.ruby +0 -48
- data/sources/ruby/spellcheck.ruby +0 -18
- data/sources/ruby/spellcheck.ruby-2.ruby +0 -0
- data/sources/ruby/strcat.ruby +0 -12
- data/sources/ruby/strcat.ruby-2.ruby +0 -12
- data/sources/ruby/sumcol.ruby +0 -12
- data/sources/ruby/sumcol.ruby-2.ruby +0 -5
- data/sources/ruby/takfp.ruby +0 -15
- data/sources/ruby/tcpecho.ruby +0 -45
- data/sources/ruby/tcprequest.ruby +0 -45
- data/sources/ruby/tcpstream.ruby +0 -45
- data/sources/ruby/threadring.ruby +0 -61
- data/sources/ruby/threadring.ruby-2.ruby +0 -33
- data/sources/ruby/wc.ruby +0 -15
- data/sources/ruby/wordfreq.ruby +0 -17
- data/sources/ruby/wordfreq.ruby2.ruby +0 -0
@@ -1,40 +0,0 @@
|
|
1
|
-
# The Computer Language Benchmarks Game
|
2
|
-
# http://shootout.alioth.debian.org/
|
3
|
-
# Contributed by Antti Kervinen
|
4
|
-
# Modified by Tupteq
|
5
|
-
|
6
|
-
import sys
|
7
|
-
import thread
|
8
|
-
|
9
|
-
# Set minimum stack size for threads, otherwise the program may fail
|
10
|
-
# to create such a many threads
|
11
|
-
thread.stack_size(32*1024)
|
12
|
-
|
13
|
-
def threadfun(number, lock_acquire, next_release):
|
14
|
-
global n
|
15
|
-
while 1:
|
16
|
-
lock_acquire()
|
17
|
-
if n > 0:
|
18
|
-
n -= 1
|
19
|
-
next_release()
|
20
|
-
else:
|
21
|
-
print number
|
22
|
-
main_lock.release()
|
23
|
-
|
24
|
-
# main
|
25
|
-
n = int(sys.argv[1])
|
26
|
-
main_lock = thread.allocate_lock()
|
27
|
-
main_lock.acquire()
|
28
|
-
|
29
|
-
first_lock = thread.allocate_lock()
|
30
|
-
next_lock = first_lock
|
31
|
-
|
32
|
-
for number in xrange(503):
|
33
|
-
lock = next_lock
|
34
|
-
lock.acquire()
|
35
|
-
next_lock = thread.allocate_lock() if number < 502 else first_lock
|
36
|
-
thread.start_new_thread(threadfun,
|
37
|
-
(number+1, lock.acquire, next_lock.release))
|
38
|
-
|
39
|
-
first_lock.release()
|
40
|
-
main_lock.acquire()
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# The Computer Language Benchmarks Game
|
2
|
-
# http://shootout.alioth.debian.org/
|
3
|
-
#
|
4
|
-
# contributed by Daniel Nanz 2008-03-11
|
5
|
-
# --------------------------------------------
|
6
|
-
# Coroutines via enhanced generators
|
7
|
-
# (http://www.python.org/dev/peps/pep-0342/)
|
8
|
-
|
9
|
-
import sys
|
10
|
-
import itertools
|
11
|
-
|
12
|
-
def main(n = int(sys.argv[1]), n_threads=503, cycle=itertools.cycle):
|
13
|
-
|
14
|
-
def worker(worker_id):
|
15
|
-
|
16
|
-
n = 1
|
17
|
-
while True:
|
18
|
-
if n > 0:
|
19
|
-
n = (yield (n - 1))
|
20
|
-
else:
|
21
|
-
print worker_id
|
22
|
-
raise StopIteration
|
23
|
-
|
24
|
-
|
25
|
-
threadRing = [worker(w) for w in xrange(1, n_threads + 1)]
|
26
|
-
for t in threadRing: foo = t.next() # start exec. gen. funcs
|
27
|
-
sendFuncRing = [t.send for t in threadRing] # speed...
|
28
|
-
for send in cycle(sendFuncRing):
|
29
|
-
try:
|
30
|
-
n = send(n)
|
31
|
-
except StopIteration:
|
32
|
-
break
|
33
|
-
|
34
|
-
main()
|
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/python
|
2
|
-
# The Great Computer Language Shootout
|
3
|
-
# http://shootout.alioth.debian.org/
|
4
|
-
#
|
5
|
-
# contributed by kosh
|
6
|
-
|
7
|
-
import sys
|
8
|
-
|
9
|
-
def main():
|
10
|
-
nl = nw = nc = 0
|
11
|
-
|
12
|
-
for line in sys.stdin:
|
13
|
-
nl += 1
|
14
|
-
nc += len(line)
|
15
|
-
nw += len(line.split())
|
16
|
-
|
17
|
-
print "%d %d %d" % (nl, nw, nc)
|
18
|
-
|
19
|
-
main()
|
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/python
|
2
|
-
# $Id: wordfreq.python,v 1.2 2004-07-03 05:36:11 bfulgham Exp $
|
3
|
-
# http://shootout.alioth.debian.org/
|
4
|
-
#
|
5
|
-
# adapted from Bill Lear's original python word frequency counter
|
6
|
-
#
|
7
|
-
# Joel Rosdahl suggested using translate table to speed up
|
8
|
-
# word splitting. That change alone sped this program up by
|
9
|
-
# at least a factor of 3.
|
10
|
-
#
|
11
|
-
# with further speedups from Mark Baker
|
12
|
-
|
13
|
-
import sys
|
14
|
-
|
15
|
-
def main():
|
16
|
-
count = {}
|
17
|
-
i_r = map(chr, range(256))
|
18
|
-
|
19
|
-
trans = [' '] * 256
|
20
|
-
o_a, o_z = ord('a'), (ord('z')+1)
|
21
|
-
trans[ord('A'):(ord('Z')+1)] = i_r[o_a:o_z]
|
22
|
-
trans[o_a:o_z] = i_r[o_a:o_z]
|
23
|
-
trans = ''.join(trans)
|
24
|
-
|
25
|
-
rl = sys.stdin.readlines
|
26
|
-
|
27
|
-
lines = rl(4095)
|
28
|
-
while lines:
|
29
|
-
for line in lines:
|
30
|
-
for word in line.translate(trans).split():
|
31
|
-
try:
|
32
|
-
count[word] += 1
|
33
|
-
except KeyError:
|
34
|
-
count[word] = 1
|
35
|
-
lines = rl(4095)
|
36
|
-
|
37
|
-
l = zip(count.values(), count.keys())
|
38
|
-
l.sort()
|
39
|
-
l.reverse()
|
40
|
-
|
41
|
-
print '\n'.join(["%7s %s" % (count, word) for (count, word) in l])
|
42
|
-
|
43
|
-
main()
|
File without changes
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import sys, re, string
|
2
|
-
|
3
|
-
def main():
|
4
|
-
count = {}
|
5
|
-
p = re.compile(r'[^a-z]')
|
6
|
-
for word in p.split(string.lower(sys.stdin.read())):
|
7
|
-
if not word: continue
|
8
|
-
count[word] = count.get(word, 0) + 1
|
9
|
-
|
10
|
-
bucket = {}
|
11
|
-
for key, val in count.items():
|
12
|
-
if not bucket.has_key(val):
|
13
|
-
bucket[val] = []
|
14
|
-
bucket[val].append(key)
|
15
|
-
|
16
|
-
freqs = bucket.keys()
|
17
|
-
freqs.sort()
|
18
|
-
freqs.reverse()
|
19
|
-
|
20
|
-
for freq in freqs:
|
21
|
-
words = bucket[freq]
|
22
|
-
words.sort()
|
23
|
-
words.reverse()
|
24
|
-
for word in words:
|
25
|
-
print "%7d\t%s" % (freq, word)
|
26
|
-
|
27
|
-
main()
|
28
|
-
sys.stdout.flush()
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import sys, re, string
|
2
|
-
|
3
|
-
def main():
|
4
|
-
# count is a dictionary of word counts
|
5
|
-
count = {}
|
6
|
-
# speed up function call by making a local alias
|
7
|
-
lower = string.lower
|
8
|
-
nextline = sys.stdin.readline
|
9
|
-
p = re.compile(r'[^a-z]')
|
10
|
-
while 1:
|
11
|
-
line = nextline()
|
12
|
-
if not line: break
|
13
|
-
for word in p.split(lower(line)):
|
14
|
-
if not count.has_key(word):
|
15
|
-
count[word] = 1
|
16
|
-
else:
|
17
|
-
count[word] = count[word] + 1
|
18
|
-
|
19
|
-
bucket = {}
|
20
|
-
for key, val in count.items():
|
21
|
-
if not bucket.has_key(val):
|
22
|
-
bucket[val] = []
|
23
|
-
bucket[val].append(key)
|
24
|
-
|
25
|
-
freqs = bucket.keys()
|
26
|
-
freqs.sort()
|
27
|
-
freqs.reverse()
|
28
|
-
|
29
|
-
for freq in freqs:
|
30
|
-
words = bucket[freq]
|
31
|
-
words.sort()
|
32
|
-
words.reverse()
|
33
|
-
for word in words:
|
34
|
-
if len(word) > 0:
|
35
|
-
print "%7d\t%s" % (freq, word)
|
36
|
-
|
37
|
-
main()
|
38
|
-
sys.stdout.flush()
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import sys, re, string, fileinput
|
2
|
-
|
3
|
-
def main():
|
4
|
-
# count is a dictionary of word counts
|
5
|
-
count = {}
|
6
|
-
# speed up function call by making a local alias
|
7
|
-
lower = string.lower
|
8
|
-
#nextline = sys.stdin.readline
|
9
|
-
p = re.compile(r'[^a-z]')
|
10
|
-
#while 1:
|
11
|
-
# line = nextline()
|
12
|
-
# if not line: break
|
13
|
-
for line in fileinput.input('-'):
|
14
|
-
for word in p.split(lower(line)):
|
15
|
-
if not count.has_key(word):
|
16
|
-
count[word] = 1
|
17
|
-
else:
|
18
|
-
count[word] = count[word] + 1
|
19
|
-
|
20
|
-
bucket = {}
|
21
|
-
for key, val in count.items():
|
22
|
-
if not bucket.has_key(val):
|
23
|
-
bucket[val] = []
|
24
|
-
bucket[val].append(key)
|
25
|
-
|
26
|
-
freqs = bucket.keys()
|
27
|
-
freqs.sort()
|
28
|
-
freqs.reverse()
|
29
|
-
|
30
|
-
for freq in freqs:
|
31
|
-
words = bucket[freq]
|
32
|
-
words.sort()
|
33
|
-
words.reverse()
|
34
|
-
for word in words:
|
35
|
-
if len(word) > 0:
|
36
|
-
print "%7d\t%s" % (freq, word)
|
37
|
-
|
38
|
-
main()
|
39
|
-
sys.stdout.flush()
|
data/sources/ruby/ackermann.ruby
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# -*- mode: ruby -*-
|
3
|
-
# $Id: ackermann.ruby,v 1.2 2005-06-10 00:57:22 igouy-guest Exp $
|
4
|
-
# http://www.bagley.org/~doug/shootout/
|
5
|
-
|
6
|
-
def ack(m, n)
|
7
|
-
if m == 0 then
|
8
|
-
n + 1
|
9
|
-
elsif n == 0 then
|
10
|
-
ack(m - 1, 1)
|
11
|
-
else
|
12
|
-
ack(m - 1, ack(m, n - 1))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
NUM = Integer(ARGV.shift || 1)
|
17
|
-
print "Ack(3,", NUM, "): ", ack(3, NUM), "\n"
|
@@ -1,153 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# The Computer Language Benchmark Shootout
|
3
|
-
# http://shootout.alioth.debian.org
|
4
|
-
#
|
5
|
-
# original code by Martin DeMello
|
6
|
-
# modified by Jabari Zakiya 3/20/05
|
7
|
-
# modified by Glenn Parker 3/28/05 (format results)
|
8
|
-
|
9
|
-
include Math
|
10
|
-
|
11
|
-
SOLAR_MASS = 4*PI*PI
|
12
|
-
DAYS_PER_YEAR = 365.24
|
13
|
-
|
14
|
-
Vector3D = Struct.new("Vector3D", :x, :y, :z)
|
15
|
-
|
16
|
-
class Vector3D
|
17
|
-
|
18
|
-
def *(val)
|
19
|
-
Vector3D.new(*self.map {|i| i * val})
|
20
|
-
end
|
21
|
-
|
22
|
-
def /(val)
|
23
|
-
Vector3D.new(*self.map {|i| i / val})
|
24
|
-
end
|
25
|
-
|
26
|
-
#in-place add with scale
|
27
|
-
# a.adds(b, s) -> a += b*s
|
28
|
-
|
29
|
-
def adds(other, scale)
|
30
|
-
self[0] += other[0]*scale; self[1] += other[1]*scale
|
31
|
-
self[2] += other[2]*scale
|
32
|
-
end
|
33
|
-
|
34
|
-
def subs(other, scale)
|
35
|
-
self[0] -= other[0]*scale; self[1] -= other[1]*scale
|
36
|
-
self[2] -= other[2]*scale
|
37
|
-
end
|
38
|
-
|
39
|
-
def magnitude
|
40
|
-
x=self[0]; y=self[1]; z=self[2]
|
41
|
-
sqrt(x*x + y*y + z*z)
|
42
|
-
end
|
43
|
-
|
44
|
-
# |self - other|
|
45
|
-
def dmag(other)
|
46
|
-
x=self[0]-other[0]; y=self[1]-other[1]; z=self[2]-other[2]
|
47
|
-
sqrt(x*x + y*y + z*z)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class Planet
|
52
|
-
attr_accessor :pos, :v, :mass
|
53
|
-
|
54
|
-
def initialize(x, y, z, vx, vy, vz, mass)
|
55
|
-
@pos = Vector3D.new(x, y, z)
|
56
|
-
@v = Vector3D.new(vx, vy, vz) * DAYS_PER_YEAR
|
57
|
-
@mass = mass * SOLAR_MASS
|
58
|
-
end
|
59
|
-
|
60
|
-
def distance(other)
|
61
|
-
self.pos.dmag(other.pos)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
jupiter = Planet.new(
|
66
|
-
4.84143144246472090e+00,
|
67
|
-
-1.16032004402742839e+00,
|
68
|
-
-1.03622044471123109e-01,
|
69
|
-
1.66007664274403694e-03,
|
70
|
-
7.69901118419740425e-03,
|
71
|
-
-6.90460016972063023e-05,
|
72
|
-
9.54791938424326609e-04)
|
73
|
-
|
74
|
-
saturn = Planet.new(
|
75
|
-
8.34336671824457987e+00,
|
76
|
-
4.12479856412430479e+00,
|
77
|
-
-4.03523417114321381e-01,
|
78
|
-
-2.76742510726862411e-03,
|
79
|
-
4.99852801234917238e-03,
|
80
|
-
2.30417297573763929e-05,
|
81
|
-
2.85885980666130812e-04)
|
82
|
-
|
83
|
-
uranus = Planet.new(
|
84
|
-
1.28943695621391310e+01,
|
85
|
-
-1.51111514016986312e+01,
|
86
|
-
-2.23307578892655734e-01,
|
87
|
-
2.96460137564761618e-03,
|
88
|
-
2.37847173959480950e-03,
|
89
|
-
-2.96589568540237556e-05,
|
90
|
-
4.36624404335156298e-05)
|
91
|
-
|
92
|
-
neptune = Planet.new(
|
93
|
-
1.53796971148509165e+01,
|
94
|
-
-2.59193146099879641e+01,
|
95
|
-
1.79258772950371181e-01,
|
96
|
-
2.68067772490389322e-03,
|
97
|
-
1.62824170038242295e-03,
|
98
|
-
-9.51592254519715870e-05,
|
99
|
-
5.15138902046611451e-05)
|
100
|
-
|
101
|
-
sun = Planet.new(0, 0, 0, 0, 0, 0, 1)
|
102
|
-
|
103
|
-
class Array
|
104
|
-
def each_pair
|
105
|
-
a = []
|
106
|
-
each_index {|i|
|
107
|
-
((i+1)...length).each {|j|
|
108
|
-
yield at(i), at(j)
|
109
|
-
}
|
110
|
-
}
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
bodies = [sun, jupiter, saturn, uranus, neptune]
|
115
|
-
|
116
|
-
class << bodies
|
117
|
-
def advance(dt)
|
118
|
-
mag = m1 = m2 = nil
|
119
|
-
each_pair {|b1, b2|
|
120
|
-
d = b1.distance(b2)
|
121
|
-
mag = dt/(d*d*d)
|
122
|
-
|
123
|
-
m1 = b1.mass * mag
|
124
|
-
m2 = b2.mass * mag
|
125
|
-
|
126
|
-
b1.v.adds(b2.pos, m2)
|
127
|
-
b1.v.subs(b1.pos, m2)
|
128
|
-
b2.v.adds(b1.pos, m1)
|
129
|
-
b2.v.subs(b2.pos, m1)
|
130
|
-
}
|
131
|
-
|
132
|
-
each {|b| b.pos.adds(b.v, dt)}
|
133
|
-
end
|
134
|
-
|
135
|
-
def energy
|
136
|
-
e = 0
|
137
|
-
each {|b| e += 0.5 * b.mass * (b.v.magnitude ** 2) }
|
138
|
-
each_pair {|b1, b2| e -= (b1.mass * b2.mass) / b1.distance(b2) }
|
139
|
-
e
|
140
|
-
end
|
141
|
-
|
142
|
-
def offset_momentum
|
143
|
-
p = Vector3D.new(0,0,0)
|
144
|
-
sun = self[0]
|
145
|
-
each {|b| p.adds(b.v, b.mass) }
|
146
|
-
sun.v.subs(p, 1.0/sun.mass)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
bodies.offset_momentum
|
151
|
-
puts "%.9f" % bodies.energy
|
152
|
-
Integer(ARGV[0]).times { bodies.advance(0.01) }
|
153
|
-
puts "%.9f" % bodies.energy
|
data/sources/ruby/ary.ruby
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# -*- mode: ruby -*-
|
3
|
-
# $Id: ary.ruby,v 1.3 2004-06-20 08:39:45 bfulgham Exp $
|
4
|
-
# http://www.bagley.org/~doug/shootout/
|
5
|
-
# with help from Paul Brannan and Mark Hubbart
|
6
|
-
|
7
|
-
n = Integer(ARGV.shift || 1)
|
8
|
-
|
9
|
-
x = Array.new(n)
|
10
|
-
y = Array.new(n, 0)
|
11
|
-
|
12
|
-
for i in 0 ... n
|
13
|
-
x[i] = i + 1
|
14
|
-
end
|
15
|
-
|
16
|
-
(0 .. 999).each do
|
17
|
-
(n-1).step(0,-1) do |i|
|
18
|
-
y[i] += x.at(i)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
puts "#{y.first} #{y.last}"
|