repo.or.cz
/
jruby.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git]
/
bench
/
shootout
/
ary.ruby
blob
15024ba5a3c1bfd22f9ce9b4ee1c4b46444bef51
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}"