Greetings, Jedi Padawans, fellow coders, and esteemed Jedi Knights.
In the Star Wars universe, Jedi Knights are skilled in the use of the Force, a mystical energy that they can manipulate to achieve various abilities. In this coding challenge, we'll be simulating Jedi training by creating a program that generates a sequence of numbers and applies various transformations to them using...the power of code!
Instructions:
Write a program that generates a sequence of 10 random numbers between 1 and 10.
Use the Force (code) to apply the following transformations to the sequence:
- Multiply every even number by 2
- Add 5 to every odd number
- Replace any number greater than 10 with 1
- Print the final sequence to the console.
Hints:
- You can use the rand method in Ruby or the random module in Python to generate random numbers.
- You can use an if statement to check whether a number is even or odd.
- You can use a for loop to iterate over the sequence and apply the transformations.
The challenge begins. May the fourth be with you!