[M💙 Challenge] Where's the Number? 🔮 (Naïve Cup Shuffle ver.)
Monday Blue 💙 Challenge Series #9 Let's play some tricks this week! This time we will simulate cup shuffling process and determine the position of the target number after shuffling with predefined steps. 💼 TASK Write a program to accept 3 parameters:- ✔ Cup numbers: [ 1, 3, 4, 5, 2 ] * natural numbers start with 1 up to the number of cups and shuffled initially ✔ Target number: 1 * one of the previous stated cup number ✔ Shuffle sequence: [ 1, 4 ] * The cup position (1-based) to be swapped and swapping occurs between the cup at the opposite end. That means cup at position 1 and 4 will be swapped with 5 and 2 respectively. No shuffle will be performed when the position was located at the center for odd number of cups. Based on the example above, the following process will be carried out:- [ 1, 3, 4, 5, 2 ] ⬇ (shuffle at position 1) [ 2, 3, 4, 5, 1 ] ⬇ (shuffle at position 4) [ 1, 5, 4, 3, 2 ] and finally output "Cup no. 1 at position 1". 🔧 TEST CASE [ 1, 2 ] | 1 | [ 1, 2, 2, 2, 1 ] "Cup no. 1 at position 2." [ 1, 2, 3 ] | 2 | [ 1, 3 ] "Cup no. 2 at position 2." [ 1, 2, 3, 4, 5 ] | 4 | [ 3, 1, 4, 5, 2 ] "Cup no. 4 at position 4." ❤ BONUS Clear-cut and optimized approach is encouraged. Please refrain from giving hints to others in this post before the challenge ends one week after. Happy Coding!!! 😁💻