At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I'll be on again later tonight and I'll try to do it.
What problems are you having with the function? What do you have so far?
I can'tget it to output the right thing
post the code and we can try to help, and should it be two lists or one list that is then broken int two ?
ok it should output this >>>interleave ([1,2,3], [4,5,6,7]) [1,4,2,5,3,6,7]
Why does it specifically have to be recursive?
what should happen in the event of a >>>interleave ([1,2,3], [4,5,6,7,8,9,10])?
That cant happen because I wrote the code for here last night that it splits them in half or if it is an odd number it makes the second list bigger by 1.
Here was my code lis=list(raw_input('Please enter a list:')) x=len(lis)/2 lis1=lis[:x] lis2=lis[x:] print lis1,lis2
if interleave([1,2,3],[4,5,6,7,8,9,10]) would output [1,4,2,5,3,6,7,8,9,10]
interleave is the opposite of the function u just wrote onyx, I tried zip with two list n I end up with a list of tuples
o ok I thought we were adding on to mine maybe as a simple shuffling method?
well the split function that u wrote onyx is just say a subscript of a bigger method shuffle which calls interleave and split
Yea so you would run split first and then interleave and you would do that repeatedly which would give you a shuffled deck. but since split is run first there would be no way to get a lisst with len 3 and one with length 7
thats good, leaves me to write less fail safes
ok this is shuffle:Define a function shuffle() which repeatedly splits a list in half, then interleaves the two resulting lists together. Your function should also take an additional integer parameter to control the number of split/interleave steps i.e.
ok so do you want me to change mine to take an addition integer?
ok so onyx are you interleaving or shuffling?, and what am i taking?
shuffle output is:>>>shuffle (1, [1 ,2 ,3 ,4 ,5 ,6 ,7]) 1 ,4 ,2 ,5 ,3 ,6 ,7] >>>shuffle (2, [1 ,2 ,3 ,4 ,5 ,6 ,7]) (intermediate step - shuffle (1, [1 ,4 ,2 ,5 ,3 ,6 ,7]) ) [1 ,5 ,4 ,3 ,2 ,6 ,7]
also reckk, are we doing your work for you? because if you give us a better layout of the work we're doing for you, that'd be nice
Reckk sorry but your thing didn't make any sense to me. Nessman I already did split but now it seems they want something new so I might have to do it over
Onyx split is alright
no, it looks like he wants split, one function, interleave, another function, and shuffle a function that takes them both in order in an attempt to shuffle
also rekk, do you need a shuffle program, my dealing program is random, so you know
Reck I'm not trying to be mean here but why try to make a go fish game if you can't code it yourself what practice is taking all our code copying and pasting it and seeing if output is right.
no Onyx I compare ur codes with mine's
and try to make mine shorter
um then y don't you post the codes of what you have and we can make any necessary changes.
ok def split(b): c=list(b) x=len(c)/2 a=c[:x] d=c[x:] return a,d
ok what about the shuffle one you need post what you have so far.
that's where I am at now I tried interleave using zip but it didnt work
that's why I ask for u guys help
hey onyx, this if fun, and it doesn't hurt us. maybe this is part of a dumb pre req course he never plans to peruse. rekk i'll help you if you want to come clean that we are doing you work, i'll help you regardless, not sure about onyx, seems to have a problem with doing others work
I will too I'm fine with helping I just want to know what were doing it for that's what I was trying to get to
ok it's basically an assignment , like the cesar cipher I sent u Nessman
I am far from being a pro in python programming so I take or look for help wherever I can
Ok that's fine is it for college,high school, or just a for fun assignment? And I'm working on it right now.
Nessman did you already do interleave()?
no i have not, looking over his cipher functions, impressive method (thus far)
it's for college the cesar cipher was the 1st assignment
this one is the 2nd,Nessman the deal() function that u wrote gave me a syntax error about the attribute of pop
oh I forgot here's a hint for interleave:[Hint: If a list is longer than the other then the additional elements should be placed at the end of the new list.]
i don't understand what your nested if loops in encode and decode do, and my style would have let me put the key as an argument so you need to know the magic number to unlock the data
and i don't like gen_decode and gen_encode, they don't tell you the key and don't let you input the key, you can't use one to reverse the other, its a little too random
well the lecturer asked for the opposite of all that u said, she let key=2 be a constant value in encode and decode so for a string encode('mad') would output 'ocf' and decode('ocf') would output 'mad'
gen_decode and gen_encode took gen_key which return a random key and the decode or encode the string but I messed up with the last part so it didn't work properly gen_decode should give u back what was gen_encode
well the problem is that you have no way of making sure they have the same key if its randomly generated, its a giant problem unless you can save the key with the output, then it becomes no more secure then encode-decode if you want to shave lines remove the key = 2/gencode lines, you only use the variable once, and it never changes, this only removes 5 lines total, but those can obviously be cut
Hey reckk does it really have to be recursive because if not I think I'd be done by now. haha I never completely understood recursive functions so it takes me a while to write them.
give me what you have onyx, i might be able to help recur it (recursive is not what i would choose in this situation)
oh for the encode decode thing, if you can import specific words instead of the whole module, its just good style
ok Onyx show Nessman
def interleave(lis1,lis2): interWove=[lis1,lis2] if len(lis1)>1 and len(lis2)>1: return interWove.append(interleave(lis1[1:],lis2[1:])) elif len(lis2)>1: return interWove.append(interleave(None,lis2[1:])) else: return interWove.append(interleave(lis1[1:],None)) print interleave([1,3,5,7],[2,4,6,8]) What I was trying to do was everytime it is called it will append just the first numbers(numbers in lis1,lis2. but like I said I'm not good at recursive haha.
This one works but only if they are the same length I have to go to bed so you can try and mod it to work with different lengths I know how, you can use if statements but I was trying to figure out a shorter way since you said you wanted short codes.
def interleave(lis1,lis2): if len(lis1)==0 and len(lis2)==0: return  interWove=[lis1,lis2] print interWove return interWove+interleave(lis1[1:],lis2[1:]) print interleave([1,3,5,7],[2,4,6,8])
ok thanx onyx have a gud night
Lol I always say I'm about to get off but i can't stop without finishing something haha here it is where it works for both. def interleave(lis1,lis2): if len(lis1)==0 and len(lis2)==0: return  if len(lis1)==0: return lis2 if len(lis2)==0: return lis1 interWove=[lis1,lis2] return interWove+interleave(lis1[1:],lis2[1:])
not sure what he means for both but mine will take uneven length lists without slowing down
okay so what is next on the docket?
thats what I meant by both uneven and even and good night for real this time. haha
lol ok Onyx
Your code work perfectly I will try to mod it so it's concise but I like it Define a function shuffle() which repeatedly splits a list in half, then interleaves the two resulting lists together. Your function should also take an additional integer parameter to control the number of split/interleave steps i.e.
Shuffle outputs: >>>shuffle (1, [1 ,2 ,3 ,4 ,5 ,6 ,7]) 1 ,4 ,2 ,5 ,3 ,6 ,7] >>>shuffle (2, [1 ,2 ,3 ,4 ,5 ,6 ,7]) (intermediate step - shuffle (1, [1 ,4 ,2 ,5 ,3 ,6 ,7]) ) [1 ,5 ,4 ,3 ,2 ,6 ,7]
the file name says interleave but it has the entire interleave, split, and shuffle (split courtesy of onyx), it uses my version of interleave but will work with onyx's code, take her for a test drive, and once again my deal function is random, might cut out the entire shuffle stage on the final product
ok so wat was ur output for the deal function?
ok my deal file wasn't the right one last night as well, or what ever i messed up earlier, this one produces a tuple with two parts, the first part is a list of hands, each hand being a list of tuples, each tuple being a card pair, and the second part of hte first tuple is the remaining cards in teh deck the hands are randomized
k interleave worked perfectly thanx agan
so if you enter "print deal(deck(),5,2)" you'll see what i mean, i just load my deck function strait into the dealing function, its a nice program, thank the man who made the random module
yeah they a very good a programming to come up wiith these module's
can I attach a pdf file here?
only one way to find out
it doesn't work it took forever
n didn't work I have a cool python book that I wanted to share it has tons of python programs
perhaps you can post it online, do you have dropbox, or regularly use a file uploading service?
no I don't only use em for uploading game file
ok try this link file:///C:/Documents%20and%20Settings/Maxin/My%20Documents/School%20work/Com%20sci/Python%20books/IYOCGwP_book1.pdf
that's a link to your local file, that's definitely not going to work for me, i need like a "http://dl.dropbox.com/u/18955243/How%20to%20use%20the%20Public%20folder.rtf" a link to a web adress, this link contains a text file introducing the public folder on the service called dropbox, dropbox is a good service, has a free option, i suggest you look into it
ok I am gonna look on it now, look at this final question for me please: Write a function askForcard() which takes a card and a hand and return a tuple where first part of the tuple is a Boolean value if the cardvalue is found in the hand. For example, if we are asking our opponent for a ‘J’ and the opponents hand is [('H', 'A'), ('D', 'J')] we are retuned tuple where first part is a boolean value indicating if the card is present and second part returns the position of the card in the opponents hand, if the card is not there just return 0 for position. E.g.
it outputs: >>> askForCard('J', [('H', 'A'), ('D', 'J')]) (True, 1) >>> askForCard('4', [('H', '2'), ('D', 'J')]) (False, 0) 7. when I finish implement everything I am gonna send it to u and u give me ur idea r ideas on how u could make the level of the computer more difficult
ok i'm tired, i'll work on it tomorrow? how far ahead of schedule are you?
its due friday but go get some rest. hopefully u here 2marrow same time. I am gonna try the drop box thing b4 u leave so gimme 10-15mins I just read it
there is the book
hope u like
thanks reckk, i'll read it when i'm not so tired
ok have a great night am gonna get some zzzzzzzzz's also
hola nessman did u check out the book
Hey what do you still need done?
a function askForcard() which takes a card and a hand and return a tuple where first part of the tuple is a Boolean value if the cardvalue is found in the hand. For example, if we are asking our opponent for a ‘J’ and the opponents hand is [('H', 'A'), ('D', 'J')] we are retuned tuple where first part is a boolean value indicating if the card is present and second part returns the position of the card in the opponents hand, if the card is not there just return 0 for position. E.g. >>> askForCard('J', [('H', 'A'), ('D', 'J')]) (True, 1) >>> askForCard('4', [('H', '2'), ('D', 'J')]) (False, 0)
I will try but Idk if I can do that one sorry
did u guys ever finish this assignment? because i need help with this same assignment and i can't access the files that was uploaded