Skip to content

Instantly share code, notes, and snippets.

@hale
Created October 10, 2013 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hale/6920903 to your computer and use it in GitHub Desktop.
Save hale/6920903 to your computer and use it in GitHub Desktop.
BSS
can permutate A into B given a list of swaps (FAILED - 1)
all together now (FAILED - 2)
#apply_swap!
works for 2 elements
works for 4 elements
#swaps
works for 2 elements
works for 3 elements
works for 5 elements
works for 6 elements
works when there is a slight change
does nothing when the sequences are the same
Array
#swap_indices!
swaps elements of an array at the given indices
Failures:
1) BSS can permutate A into B given a list of swaps
Failure/Error: source.should eq(target)
expected: [1, 3, 4, 2]
got: [1, 4, 2, 3]
(compared using ==)
# ./spec/bss_spec.rb:10:in `block (2 levels) in <top (required)>'
2) BSS all together now
Failure/Error: source.should eq(target)
expected: [0, 1, 3, 7, 9]
got: [1, 9, 0, 7, 3]
(compared using ==)
# ./spec/bss_spec.rb:19:in `block (2 levels) in <top (required)>'
Finished in 0.00226 seconds
11 examples, 2 failures
Failed examples:
rspec ./spec/bss_spec.rb:4 # BSS can permutate A into B given a list of swaps
rspec ./spec/bss_spec.rb:13 # BSS all together now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment