Questions tagged [reverse]

Rearranging the order of a sequence such that the final order is a mirror image of the original.

Rearranging the order of a sequence such that the final order is a mirror image of the original.

3773 questions
18
votes
5 answers

How to make reversed for loop with array index as a start/end point in Kotlin?

now i'm trying to make reversed for a loop.The simple way of reverse for is for(i in start downTo end) but,what if I use array as a start/end point?
Galih indra
  • 333
  • 1
  • 4
  • 13
18
votes
2 answers

C memcpy in reverse

I am working with audio data. I'd like to play the sample file in reverse. The data is stored as unsigned ints and packed nice and tight. Is there a way to call memcpy that will copy in reverse order. i.e. if I had 1,2,3,4 stored in an array, could…
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
18
votes
4 answers

Reversing CRC32

I'm looking for a way to reverse a CRC32 checksum. There are solutions around, but they are either badly written, extremely technical and/or in Assembly. Assembly is (currently) beyond my ken, so I'm hoping someone can piece together an…
pat
  • 16,116
  • 5
  • 40
  • 46
17
votes
5 answers

Sort by multiple columns in bash

I have a file with 2 columns, "Name" and "Age", looking like this: Alex, 15 Mary, 12 Alex, 28 Zoe, 16 Alex, 17 I will sort by the first column in alphabetical order, using sort -t ',' -k1,1 filename.txt, but if there are same names, I want…
Alex
  • 149
  • 1
  • 1
  • 7
17
votes
4 answers

How to reverse bitwise AND (&) in C?

How to reverse bitwise AND (&) in C? For example I have an operation in C like this: ((unsigned int)ptr & 0xff000000)) The result is 0xbf000000. What I need at this moment is how to reverse the above, i.e. determine ptr by using the result from the…
VaioIsBorn
  • 7,683
  • 9
  • 31
  • 28
16
votes
4 answers

Linked list recursive reverse

I was looking at the code below from stanford library: void recursiveReverse(struct node** head_ref) { struct node* first; struct node* rest; /* empty list */ if (*head_ref == NULL) return; /* suppose first = {1, 2,…
Phoenix
  • 365
  • 3
  • 5
  • 8
16
votes
18 answers

Reverse Contents in Array

I have an array of numbers that I am trying to reverse. I believe the function in my code is correct, but I cannot get the proper output. The output reads: 10 9 8 7 6. Why can't I get the other half of the numbers? When I remove the "/2" from count,…
John
  • 279
  • 3
  • 4
  • 8
16
votes
3 answers

The reverse/inverse of the normal distribution function in R

To plot a normal distribution curve in R we can use: (x = seq(-4,4, length=100)) y = dnorm(x) plot(x, y) If dnorm calculates y as a function of x, does R have a function that calculates x as a function of y? If not what is the best way to…
geotheory
  • 22,624
  • 29
  • 119
  • 196
16
votes
3 answers

Reverse video playback in OpenCV

Is it possible to play videos backwards in OpenCV? Either by an API call or by buffering video frames and reversing the order into a new video file. Thanks
darasan
  • 235
  • 1
  • 2
  • 6
15
votes
5 answers

Does passing reverse=True when sorting a list in Python affect efficiency?

When calling sort() on a list in Python, passing cmp=f slows down the sort. Does passing reverse=True affect the efficiency of the sort in any way (or is it identical to sorting without reversing)?
jrdioko
  • 32,230
  • 28
  • 81
  • 120
15
votes
3 answers

How to traverse Linked Hash Map in reverse?

Possible Duplicate: Iterating through a LinkedHashMap in reverse order How to traverse Linked Hash Map in a reverse order? Is there any predefined method in map to do that? I'm creating it as follows: LinkedHashMap map = new…
Jagadeesh
  • 2,730
  • 6
  • 30
  • 45
15
votes
1 answer

What is the most pythonic way to have inverse enumerate of a list?

The first thing that comes to mind is: >>> l = list('abcdef') >>> for i in range(len(l)-1, -1, -1): ... item = l[i] ... print(i, item) ... 5 f 4 e 3 d 2 c 1 b 0 a I tried using the following: >>> l ['a', 'b', 'c', 'd', 'e', 'f'] >>> for i,ch in…
Iliyan Bobev
  • 3,070
  • 2
  • 20
  • 24
15
votes
21 answers

Efficiently reverse the order of the words (not characters) in an array of characters

Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Example input and output: >>> reverse_words("this is a string") 'string a is this' It should be O(N)…
jfs
  • 399,953
  • 195
  • 994
  • 1,670
15
votes
7 answers

Reverse Scoring Items

I have a survey of about 80 items, primarily the items are valanced positively (higher scores indicate better outcome), but about 20 of them are negatively valanced, I need to find a way to reverse score the ones negatively valanced in R. I am…
Nick Frost
  • 151
  • 1
  • 1
  • 6
15
votes
4 answers

How to reverse a generic list without changing the same list?

I have a generic list that is being used inside a method that's being called 4 times. This method writes a table in a PDF with the values of this generic list. My problem is that I need to reverse this generic list inside the method, but I'm calling…
Phoenix_uy
  • 3,173
  • 9
  • 53
  • 100