View output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
Enter a String | |
bengaluru | |
Enter a Sub String | |
uru | |
=> Present | |
2 | |
Enter a String | |
bengaluru |
View output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### OUTPUT | |
1 | |
Enter comma seperated integers | |
1,2,3,4,6,7,8 | |
Enter pair sum | |
10 | |
((2, 8), (3, 7), (4, 6), (6, 4), (7, 3), (8, 2)) | |
2 | |
Enter comma seperated integers |
View Output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### OUTPUT | |
1 | |
Enter comma seperated integers | |
1,2,3,4,6,7,8 | |
Enter pair sum | |
10 | |
[[2, 8], [3, 7], [4, 6]] | |
2 |
View reverse_if_4.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def string_rev_if_4(input) | |
return input.reverse if input.length < 4 | |
input | |
end | |
string_rev_if_4("he") # "eh" | |
string_rev_if_4("hel") # "leh" | |
string_rev_if_4("hell") # "hell" |
NewerOlder