All guides
Intermediate-AdvancedSelf-pacedFree GuideSection 10/33

Livecodes et challenges

Learn to build and check a web application with development tools and AI assistants. Practise design, coding and validation.

The full lessons for this course are currently available in French. Use the section menu to navigate the French course.

💡

Free content, available without an account. Tools and models change: use the current model guide to check their versions. Models and sources

Section 13.2.5 : Livecodes et challenges

🎯 Objectif pédagogique

S'entraîner à résoudre des problèmes algorithmiques en Ruby dans un format livecode. Ces exercices développent la pensée logique et préparent aux entretiens techniques.


La méthodologie UPER

  1. →Understand : reformulez le problème, identifiez inputs/outputs/cas limites
  2. →Plan : pseudo-code en français
  3. →Execute : traduire en Ruby
  4. →Review : tester et optimiser

Challenge : Palindrome

def palindrome?(mot)
  cleaned = mot.downcase.gsub(/[^a-z0-9]/, '')
  cleaned == cleaned.reverse
end

puts palindrome?('kayak')       # true
puts palindrome?('hello')       # false

Challenge : Anagrammes

def anagrammes?(mot1, mot2)
  normaliser = ->(m) { m.downcase.delete(' ').chars.sort }
  normaliser.call(mot1) == normaliser.call(mot2)
end

puts anagrammes?('listen', 'silent')  # true

Challenge : Chiffre de César

def caesar_cipher(text, shift)
  text.chars.map do |char|
    if char.match?(/[a-z]/)
      ((char.ord - 97 + shift) % 26 + 97).chr
    elsif char.match?(/[A-Z]/)
      ((char.ord - 65 + shift) % 26 + 65).chr
    else
      char
    end
  end.join
end

puts caesar_cipher('Hello World', 3)  # Khoor Zruog

Challenge : Mot le plus fréquent

def mot_frequent(texte)
  mots = texte.downcase.scan(/\w+/)
  frequences = mots.tally
  frequences.max_by { |_mot, count| count }
end

mot, count = mot_frequent("le chat mange le poisson et le chat dort")
puts "#{mot} apparaît #{count} fois"
Quick Check

Quelle est la première étape de la méthode UPER ?

Learn AI, from prompts to agents

15 free guidesQuizzes, diagrams and workshopsNo account needed

Your progress

Progress is self-reported and stored in your browser. The final completion record is not a qualification or an independent assessment.

View progress and completion record

Learn AI, from prompts to agents

15 free guidesQuizzes, diagrams and workshopsNo account needed

One practical AI workflow in your inbox

Methods, resources and new exercises. Free, unsubscribe at any time.