Jedi Training Challenge

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 …


This content originally appeared on DEV Community and was authored by dev.to staff

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:

  1. Multiply every even number by 2
  2. Add 5 to every odd number
  3. Replace any number greater than 10 with 1
  4. Print the final sequence to the console.

Example Output:
Image description

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!


This content originally appeared on DEV Community and was authored by dev.to staff


Print Share Comment Cite Upload Translate Updates
APA

dev.to staff | Sciencx (2023-05-04T15:00:00+00:00) Jedi Training Challenge. Retrieved from https://www.scien.cx/2023/05/04/jedi-training-challenge/

MLA
" » Jedi Training Challenge." dev.to staff | Sciencx - Thursday May 4, 2023, https://www.scien.cx/2023/05/04/jedi-training-challenge/
HARVARD
dev.to staff | Sciencx Thursday May 4, 2023 » Jedi Training Challenge., viewed ,<https://www.scien.cx/2023/05/04/jedi-training-challenge/>
VANCOUVER
dev.to staff | Sciencx - » Jedi Training Challenge. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/04/jedi-training-challenge/
CHICAGO
" » Jedi Training Challenge." dev.to staff | Sciencx - Accessed . https://www.scien.cx/2023/05/04/jedi-training-challenge/
IEEE
" » Jedi Training Challenge." dev.to staff | Sciencx [Online]. Available: https://www.scien.cx/2023/05/04/jedi-training-challenge/. [Accessed: ]
rf:citation
» Jedi Training Challenge | dev.to staff | Sciencx | https://www.scien.cx/2023/05/04/jedi-training-challenge/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.