-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringfun.rb
More file actions
65 lines (59 loc) · 1.72 KB
/
Copy pathstringfun.rb
File metadata and controls
65 lines (59 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#this program does funny stuff with strings
#TODO: add file io to output funky strings to some txt file, add inputmanager to reduce duplication
#note: kevin t. ackerman is the guy with the top 10 ytps of the month thing
#note: i am kevin t. hackerman
$output = File.new
def lastletter
puts "This bit of the code takes the last character of a given input string and repeats it for the length of the string, dawg."
input = gets.chomp
output = input[input.length - 1] * input.length
puts output
main
end
def twoofeach
#this bit of the program is the one written about in appideas.txt on lenovo
#TODO: strings composed only of more than two repeating characters shorten to two characters, figure this out
puts "This bit of the code takes a given input string and doubles every character in it, save the ones already doubled, pal."
input = gets.chomp
i = 0
output = ""
until i == input.length
if input[i] != input[i + 1]
output.concat input[i]*2
end
i+=1
end
puts output
main
end
def newlines
#this bit of the code takes each character and prints it on a new line
puts "This bit of the code takes each character of the input string and writes it on a new line"
input = gets.chomp
output = ""
i = 0
until i == input.length
output.concat input[i]
output.concat "\n"
i+=1
end
puts output
main
end
def main
puts "Welcome to the program! Please enter your input. \n 1. LastLetter \n 2. TwoOfEach \n 3. NewLines"
input = gets.chomp
if input == '1'
lastletter
elsif input == '2'
twoofeach
elsif input == '3'
newlines
elsif input == 'end'
puts "Goodbye grungo"
abort
else
puts "Invalid input. Now you'll pay the ultimate price >:("
end
end
main