Skip to content

Instantly share code, notes, and snippets.

View krokrob's full-sized avatar
🥞
Data Warehousing

Kevin ROBERT krokrob

🥞
Data Warehousing
View GitHub Profile
# Define a method that take a sentence and return the acronyme
# ex:
# puts acronymize("Gnu not unix")
# >"GNU"
def acronymize(sentence)
acronyme = ""
#Change string to array
sentence.split.each do |word|
acronyme += word[0].upcase
#
def highlow(array)
min = array[0]
max = array[0]
for number in array
if number < min
min = number
end
if number > max
# Choose a hand for the computer
# Ask the user his hand
# Compare both hands
# Define result
# store result
# print result
# let's do it again
CHOICE = ["Pierre","Feuille","Ciseaux"]
my_variable = "hello" #snakecase
puts my_variable
my_variable += " world"
puts my_variable
def water_color(color = "blue")
return color
end
puts water_color("green")
#condition
puts "Quelle température fait-il?"
print ">"
temp = gets.chomp.to_i
# def is_cool?(temp, ceil)
# return temp <= ceil
# end
# puts is_cool?(temp, 24)
# boucles: while, loop, until, for
for i in (1...100)
puts "Voici le nombre #{i}"
end
# La poste est ouverte de 10h à 12h et de 14h à 16h
# si time > 10 et < 12
# si time >14 et <16
def la_poste_is_open?(time)
time >= 10 && time <= 12 || time >= 14 && time <= 16
end
puts la_poste_is_open?(9)
puts la_poste_is_open?(11)
profs = %w(cécile gab boris seb edward kevin)
profs.sort!
profs.each_with_index do |prof, index|
puts "#{index + 1}. #{prof.capitalize!}"
end
p profs
array = ['Michel Polnareff', 'Michel Jonasz', 'Michel Delpech', 'Maxime Leforestier']
# "Mr"
new_array = []
array.each do |singer|
new_array << "Mr #{singer}"
end
# p new_array
# MAP
# input : array
# COUNT
# input : array
# output: fixnum = number of element which match with condition
array = ['Michel Polnareff', 'Michel Jonasz', 'Michel Delpech', 'Maxime Leforestier']
counter = 0
array.each do |singer|
if singer.split[1].downcase.include?("o")
counter += 1
end