[1,2,3].permutation(2).to_a

[1,2,3].permutation(2).to_a e$B$,e(B [[2, 2], [2, 3]] e$B$K$J$j$^$9!#e(B

% ./ruby -ve ‘p [1,2,3].permutation(2).to_a’
ruby 1.9.0 (2007-10-09 patchlevel 0) [i686-linux]
[[2, 2], [2, 3]]
% ./ruby test/ruby/test_array.rb
Loaded suite test/ruby/test_array
Started
…F…
Finished in 0.065778 seconds.

  1. Failure:
    test_permutation(TestArray) [test/ruby/test_array.rb:1205]:
    <[[1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2]]> expected but was
    <[[2, 2], [2, 3]]>.

79 tests, 566 assertions, 1 failures, 0 errors

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs