reversing

returning the list reversed

自古美人都是妖i 提交于 2019-12-04 06:53:53
问题 i have this question: Write a function reverse3(nums) that takes a list of ints of length 3 called nums and returns a new list with the elements in reverse order, so [1, 2, 3] becomes [3, 2, 1]. i solved it by: def reverse3(nums): return [nums[2]] + [nums[1]] + [nums[0]] however, the answer is straight foward. My main question, how do i get nums reversed, when i don't know how many ints there are in nums ?. I've got this: nums[::-1] which does return nums reversed.but i'm looking for a

Why is it not possible to reverse a cryptographic hash?

陌路散爱 提交于 2019-12-02 18:12:25
Why can't you just reverse the algorithm like you could reverse a math function? How is it possible to make an algorithm that isn't reversible? And if you use a rainbow table, what makes using a salt impossible to crack it? If you are making a rainbow table with brute force to generate it, then it invents each plaintext value possible (to a length), which would end up including the salt for each possible password and each possible salt (the salt and password/text would just come together as a single piece of text). Jeremy Salwen MD5 is designed to be cryptographically irreversible . In this

Reverse a LinkedList c++ [duplicate]

混江龙づ霸主 提交于 2019-12-02 01:13:48
Possible Duplicate: Unable to reverse a linked list I'm trying to reverse a linked list: void LinkedList::reverseList() { Node *next=_head; Node *prev=0; while(next!=0) { Node *tmp=next->_next; next->_next=prev; prev=next; next=tmp; } } Lets say the list is: 4->3->2->1 When I print the list, I only see 1 (The print function is good). Any help? Thanks Since you said you wanted to find the problem on your own, I'll just give you a hint instead of the solution. Your reverse function works in that it successfully reverses the list. That isn't the problem. You probably have 2 calls to print . One

byte reverse AB CD to CD AB with python

十年热恋 提交于 2019-11-30 05:05:45
问题 I have a .bin file, and I want to simply byte reverse the hex data. Say for instance @ 0x10 it reads AD DE DE C0, want it to read DE AD C0 DE. I know there is a simple way to do this, but I am am beginner and just learning python and am trying to make a few simple programs to help me through my daily tasks. I would like to convert the whole file this way, not just 0x10. I will be converting at start offset 0x000000 and blocksize/length is 1000000. here is my code, maybe you can tell me what