Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kul1/permutation
ruby permutation
https://github.com/kul1/permutation
Last synced: 26 days ago
JSON representation
ruby permutation
- Host: GitHub
- URL: https://github.com/kul1/permutation
- Owner: kul1
- Created: 2019-11-20T15:55:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-20T16:23:34.000Z (almost 5 years ago)
- Last Synced: 2024-10-04T05:21:17.243Z (about 1 month ago)
- Language: Ruby
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## QUESTION:
### WRITE PROGRAM WHICH:INPUT: ABC
OUTPUT: ABC BAC CBA BAC BCA CAB CBA CAB CBA
### SOLUTION:
EACH POSITION DISPLAY FIRSTDISPLAY THE REST WITH SWITCH THE REST CHARACTER
THERE 2 WAYS
1. WRITE PROGRAM TO CHECK EACH AFTER EACH FOR ANY NUMBER OF CHARACTER
2. SINCE THERE ARE ONLY 3 CHARACTERS WE CAN JUST DO AS MY ANSWER## ANSWER:
get input and turn to array in order to proceed in programreturn array to string and display as need
## CODE:
~~~
input = 'ABC'
x = input.split("")y = x[0]+x[1]+x[2], x[0]+x[2]+x[1], x[1]+x[0]+x[2], x[1]+x[2]+x[0], x[2]+x[1]+x[0], x[2]+x[0]+x[1]
output = y.join(",")puts README
puts "Input = #{input}"
puts "Output = #{output}"
~~~## USAGE:
~~~
ruby permutation.rb
~~~### Thank you
(c) 2019 by Prateep Kul