i want to shuffle the elements of an array without using random and shuffle functions.any one please help me.
ex:
input:a[1,2,3,4,5]
ouput:a[2,5,3,1,4]
1 4209
i want to shuffle the elements of an array without using random and shuffle functions.any one please help me.
ex:
input:a[1,2,3,4,5]
ouput:a[2,5,3,1,4]
-
>>> numList = range(25)
-
>>> numList
-
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
-
>>> dd = dict(zip(map(str, numList),numList))
-
>>> [int(k) for k in dd.keys()]
-
[24, 20, 21, 22, 23, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JC |
last post by:
I am very new to programming and learning on my own.
Why do I keep getting duplicate values using this code? I want to shuffle a
deck of 52 cards. The logic seems right to me.
Randomize
For...
|
by: Joerg Schuster |
last post by:
Hello,
I am looking for a method to "shuffle" the lines of a large file.
I have a corpus of sorted and "uniqed" English sentences that has been
produced with (1):
(1) sort corpus | uniq >...
|
by: CaseyB |
last post by:
If I wanted to create a game like Solitaire that would first randomly
shuffle a deck of cards, I figured out that all I had to use is the Random()
class or rnd and make sure I use the Randomize...
|
by: Pratik |
last post by:
For the time being, I'm doing a simple swap method for my deck of
cards using the random number generator in cstdlib. I've created a
dynamic array of a type class Card. When I go to shuffle it and...
|
by: Tuxedo |
last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any
elements thereafter in an array in random order:
var a = new...
|
by: tooru honda |
last post by:
Hi,
I have read the source code of the built-in random module, random.py.
After also reading Wiki article on Knuth Shuffle algorithm, I wonder if
the shuffle method implemented in random.py...
|
by: Aamir Mahmood |
last post by:
Hi everyone,
I have to write a function to shuffle a collection. If anyone has any idea
on how to implement it please share with me.
The signature of function is:
ICollection...
|
by: rubyhuang |
last post by:
the problem is A standard pack of cards can be represented as an array of 52 integers with each number representing a
standard card. Thus:
0 1 2 3 4 5 6 7 8 9 10 11 12.....39 40 41 42 43 44 45 46...
|
by: whodgson |
last post by:
I`m trying to write a shuffle function to shuffle a sorted array with an even number of elements but it won`t print past the first 2 elements as shown below.
When i print the temp array it only...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |