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
30
votes
4 answers

Reversed cumulative sum of a column in pandas.DataFrame

I've got a pandas DataFrame with a boolean column sorted by another column and need to calculate reverse cumulative sum of the boolean column, that is, amount of true values from current row to bottom. Example In [13]: df = pd.DataFrame({'A': [True]…
wl2776
  • 4,099
  • 4
  • 35
  • 77
27
votes
2 answers

How can I make reverse scanning of a binary file faster?

I have a binary file specification that describes a packetized data structure. Each data packet has a two-byte sync pattern, so scanning for the beginning of a packet is possible, using a BinaryReader and FileStream…
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
27
votes
7 answers

Reversible pseudo-random sequence generator

I would like some sort of method to create a fairly long sequence of random numbers that I can flip through backwards and forwards. Like a machine with "next" and "previous" buttons, that will give you random numbers. Something like 10-bit…
PapaFreud
  • 3,636
  • 4
  • 34
  • 45
27
votes
4 answers

Python Reverse Generator

I'm looking for a way to reverse a generator object. I know how to reverse sequences: foo = imap(seq.__getitem__, xrange(len(seq)-1, -1, -1)) But is something similar possible with a generator as the input and a reversed generator as the output…
ak.
  • 2,422
  • 4
  • 21
  • 18
25
votes
8 answers

What's "better" the reverse method or the reversed built-in function?

What is typically regarded as more Pythonic/better/faster to use, the reverse method or the reversed built-in function? Both in action: _list = list(xrange(4)) print _list rlist = list(reversed(_list)) print rlist _list.reverse() print _list
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
25
votes
2 answers

Django Reverse Query in Template

I have models like this class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def __unicode__(self): return self.name class Entry(models.Model): blog = models.ForeignKey(Blog) …
brsbilgic
  • 11,613
  • 16
  • 64
  • 94
25
votes
23 answers

Reverse an array without using Array.Reverse()

How to reverse an array (in C#) without using Array.Reverse() method? For example, int[] arr = {1,3,4,9,8}; // some code here Console.WriteLine(string.Join(",", arr)); should result in 8,9,4,3,1 I got this as an interview task.
xorpower
  • 17,975
  • 51
  • 129
  • 180
25
votes
10 answers

Python enumerate reverse index only

I am trying to reverse the index given by enumerate whilst retaining the original order of the list being enumerated. Assume I have the following: >> range(5) [0, 1, 2, 3, 4] If I enumerate this I would get the following: >>…
rozzy
  • 2,828
  • 6
  • 25
  • 35
25
votes
3 answers

Java negative indexOf (counting from the end [length()] )

Is there any way in Java to found indexOf of a char starting from the end and having length() as a reference as other languages do? new String("abcd").reverseIndexOf("d"(,[4 or -0])) or new String("abcd").indexOf("d",-0) // Should return a…
Whimusical
  • 6,401
  • 11
  • 62
  • 105
24
votes
9 answers

Django reverse() for JavaScript

In my project I have a lot of Ajax methods, with external client-side scripts (I don't want to include JavaScript into templates!) and changing URLs is kind of pain for me because I need to change URLs in my Ajax calls manually. Is there is some…
dir01
  • 2,120
  • 4
  • 18
  • 17
23
votes
1 answer

Concat a video with itself, but in reverse, using ffmpeg

I was able to reverse with: ffmpeg -i input.mp4 -vf reverse output_reversed.mp4 And I can concat with: ffmpeg -i input.mp4 -i input.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4 But can I…
Vitam
  • 333
  • 1
  • 2
  • 6
23
votes
6 answers

Python list error: [::-1] step on [:-1] slice

I thought I understood the basics of list slicing in python, but have been receiving an unexpected error while using a negative step on a slice, as follows: >>> a = list(range(10)) >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> a[:-1] [0, 1, 2, 3, 4, 5,…
Matt Kelty
  • 241
  • 1
  • 2
  • 6
23
votes
1 answer

Can somebody explain this Javascript method?

Original source: http://twitter.com/tobeytailor/status/8998006366 (x=[].reverse)() === window // true I've noticed that this behavior affects all the native types. What exactly is happening here?
user120242
  • 14,918
  • 3
  • 38
  • 52
22
votes
3 answers

How to find the main function's entry point of elf executable file without any symbolic information?

I developed a small cpp program on platform of Ubuntu-Linux 11.10. Now I want to reverse engineer it. I am beginner. I use such tools: GDB 7.0, hte editor, hexeditor. For the first time I made it pretty easy. With help of symbolic information I…
Lucky Man
  • 1,488
  • 3
  • 19
  • 41
22
votes
1 answer

How to get Google-Service.Json file in decompile apk?

I want to know that is it possible to get google-service.json file when reverse engineering on android apk. Because in firebase Google-Service json file contain all keys of project.
user3527444
  • 269
  • 1
  • 4
  • 7