These are back-end Ruby projects from Odin Project
- VSCode
- RUBY
Each of these projects functionality will be explained on this page:
Note
All of these will be programmed using Object Oriented Programming
This mechanism of this project is to shift the current letter to another letter at the (x) position after it this is an example:
letter = b ;
shifter = 1 ;
ceasor_cypher(letter, shifter) # => letter = c ;
The ceasor_cypher
method shifts the letter available to another letter in the alphabet
I had trouble trying to get the same current user letter in the array of all alphabets
- I used the
split('')
method to seperate all characters from the user text - So i then introduced myself to the
.index()
method which returns index of specified element
The aim from this is to count the amount of recognisable strings from your own dictionary in a full string object set whether they are full strings or sub-strings
Note
The dictionary will be hard coded by myself
there will be a method that will take the sentnce you create and your dictionary and will return the amount of words recognisable from your dictionary in your sentnce
sentence = "Hello there world" ; # can be user input => gets.chomp
dictionary = ['hell', 'hello', 'world'] ;
def sub_strings(string, dictionary)
...
end ;
dub_strings(sentence, dictionary) # => {:hell=> 2, :world=> 1, :hello=> 1}
I am having challenge on counting the amount of occurances of the dictionary strings in user sentence
- I truied using the
count()
method but it did not return the sub strings dupliactes - I usd the
split(" ")
method with thecount()
method which worked
list[string_downcase] = user_input_downcase.split(" ").count(string_downcase)
I learnt a new way to store string objects => %w[string1 string2 string3]
To build an algorithm that sorts out a list of numbers in an array without using built in methods:
.sort()
Trying to figure out how i can compare two integers at the same time in an array whil iterating through it
- I learnt how to use index by actually adding an integer to it
array = Array[1, 3, 2, 4]
int = array.length - 1
for i in 0..int
if array[i] > array[i + 1]
...
end
end
I learnt how to compare two elements at the same time by using mathematical expressions in the index of array