Python Forum
Frog Puzzle Random To Custom
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frog Puzzle Random To Custom
#1
Question 
I just want to make the input to custom number instead of randomized number ie i want my code to sort this [0,5,1,3,4,2] instead of randomized number, can anyone revise my whole code? Thank you so much

I already try putting and changing the random part but it wont work

https://pastebin.com/xhnEUwf9

note : My code is sorting algorithm that sorts a list of numbers (representing frogs) in descending order. The sorting is done through a series of swaps, and the algorithm counts the number of moves required to achieve the sorted order.
Here's a breakdown of the sorting rule applied in my code:

**Initialization**: A list of frogs is created with random numbers between the lower_bound and upper_bound, and a 0 is appended at the beginning. The same list is copied to frogs_sorted.

**Sorting**: The frogs_sorted list is sorted in reverse order (descending).

**Swapping Mechanism**:
- The algorithm performs a loop until the sublist of frogs from index 1 to n matches the sorted list frogs_sorted.
- It uses two pointers, p and q, to traverse the list from left to right (q == 0) and right to left (q == 1).
- Swaps are made between adjacent elements or by skipping one element if it results in a larger number moving towards its correct position.
- The pointer p is incremented or decremented accordingly, and q is toggled when the end or the beginning of the list is reached.

**Counting Moves**: Each swap counts as a move, and the total number of moves is recorded in total_moves.
This algorithm is not a standard sorting algorithm like Bubble Sort, Selection Sort, or Quick Sort. It's a custom algorithm that seems to be designed for a specific problem, possibly a variation of the "frog puzzle" where the goal is to sort the frogs in a particular order with the least number of moves.
Frog sorting program. The task is Prepare a list/place to input frog numbers during the presentation later instead of random number. The frogs at the start are arranged randomly, with the empty/0 spot on the far left.
Reply


Messages In This Thread
Frog Puzzle Random To Custom - by MoreMoney - Mar-23-2024, 10:39 AM
RE: Frog Puzzle Random To Custom - by Pedroski55 - Mar-24-2024, 07:57 AM
RE: Frog Puzzle Random To Custom - by Pedroski55 - Mar-24-2024, 06:14 PM
RE: Frog Puzzle Random To Custom - by deanhystad - Mar-25-2024, 09:53 PM
RE: Frog Puzzle Random To Custom - by MoreMoney - Mar-26-2024, 08:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Codility Frog River One Westerner 2 2,459 Jan-09-2021, 06:35 PM
Last Post: deanhystad
  Slider puzzle captcha resolver, how do this? dw0rd1337 0 3,538 Jan-04-2021, 11:55 PM
Last Post: dw0rd1337
  I code a program to solve puzzle but i can't make it more dynamic. Shahmadhur13 5 2,832 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  how to program robot to pass wise man puzzle steven12341234 0 1,981 Dec-02-2018, 08:31 AM
Last Post: steven12341234
  Need help with this coding puzzle torchtopher 1 2,135 Jun-22-2018, 01:14 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020