Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amrani/simple_text_editor
HackerRank Coding Challenge
https://github.com/amrani/simple_text_editor
Last synced: 12 days ago
JSON representation
HackerRank Coding Challenge
- Host: GitHub
- URL: https://github.com/amrani/simple_text_editor
- Owner: amrani
- License: mit
- Created: 2017-03-20T22:31:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-31T18:24:18.000Z (almost 8 years ago)
- Last Synced: 2024-11-05T13:24:38.670Z (about 2 months ago)
- Language: Ruby
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleTextEditor
This Simple Text Editor gem solves the coding challange on [HackerRank](https://www.hackerrank.com/challenges/simple-text-editor).
To experiment with that code, run `bin/console` for an interactive prompt.
To execute the rspec tests run `bundle exec rake spec`
## Installation
Add this line to your application's Gemfile:```ruby
gem "simple_text_editor", '0.1', :git => "git://github.com/amrani/simple_text_editor.git"
```And then execute:
$ bundle
## Usage
Operations:
1. append(w) - Append string w to the end of s.
2. delete(k)- Delete the last k characters of s.
3. print(k)- Print the k character of s.
4. undo()- Undo the last (not previously undone) operation of type 1 or 2, reverting S to the state it was in prior to that operation.
Please visit the [HackerRank challenge](https://www.hackerrank.com/challenges/simple-text-editor) for details.## Import HackerRank Test File
Open the console with `bin/console` or in an existing project.
Then run```ruby
SimpleTextEditor::Import::HackerRankFile.new "./path/to/input.txt"
```##### Sample HackerRank Input
```
8
1 abc
3 3
2 3
1 xy
3 2
4
4
3 1
```##### Sample HackerRank Output
```
c
y
a
```## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).