269 questions
6
votes
4
answers
217
views
Repeated characters in a string, C program
I have a trouble with my C-code.
My input is a string. The calculator has to count how many times the first character in the string repeats until it finds another different character and write down ...
3
votes
4
answers
151
views
Increment value based on condition
I want to increment a column value based on a certain condition within a polars dataframe, while considering how many times that condition was met.
Example data.
import polars as pl
df = pl.DataFrame(...
0
votes
4
answers
195
views
Replace a series of the same character by its number of occurrences in the series [duplicate]
I get a string like this:
AABBBB$CCCDEEE$AABADEE
And I want a result like this:
2A4B$3CD3E$2ABAD2E
To do that, I made a for loop on the string array.
It works well:
import re
string = "AABBBB$...
0
votes
1
answer
79
views
Exact Algorithm behind CSRCESRV
I would like to implement the expand procedure of the macro CSRCESRV in another programming language (in my case Java).
Unfortunately, the exact compression algorithm that CSRCESRV uses is nowhere ...
2
votes
4
answers
86
views
Using Run-Length Encoding and Generating Sums
I have the following run-length encoding data.
df1 <- structure(list(lengths = c(2L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 3L, 1L), values = c(10, 9, NA, 5, 4, 3, NA, 2, NA, 1, 0, NA, 0)), row....
0
votes
1
answer
458
views
Run-length compression on an RGB image
Suppose I have an RGB image with 3 bit color depth as displayed below. My uncompressed image size would therefore be width * height * color depth in my case 200 * 200 * 3 = 120000 bits.
What would be ...
0
votes
1
answer
155
views
How to use the Polars library in Python to incrementally tag consecutive 1s?
How do I go about tagging the consecutive occurrence of 1s in a dataset using Polars? I found a very similar question here answered. I am trying to tag the data with a unique integer identifier to ...
0
votes
1
answer
422
views
Implementing a streak counter in Polars
I am trying to come up with the most idiomatic/elegant way to do a streak counter in Polars - either streaks of consecutive values or of consecutive rows in which a given condition is met. For example:...
2
votes
2
answers
476
views
How to find groups of consective 1s in Polars?
I have the following DataFrame:
import polars as pl
pl.Config(tbl_rows=16)
data = [0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0]
df = pl.DataFrame({"test": data})
I want to achieve the ...
1
vote
1
answer
537
views
Is there a way to utilize polars map_batches to make this code more efficient?
I have some polars code that functionally can do what I want, but I feel it is an inefficient implementation at best. I feel that there must be some way to achieve the same result with .map_batches(), ...
1
vote
3
answers
743
views
Polars non-contiguous uniqueness filter
TL;DR
I'd like to be able to concisely (with performance) filter on contiguous row uniqueness, not continuous row uniqueness.
Context
I have a LazyFrame with data already ordered correctly. While each ...
4
votes
1
answer
1k
views
Count consecutive True (or 1) values in a Boolean (or numeric) column with Polars?
I am hoping to count consecutive values in a column, preferably using Polars expressions.
import polars
df = pl.DataFrame(
{"value": [True,True,True,False,False,True,False,False,True,True]...
2
votes
1
answer
96
views
Indicating the end of a raw data chunk in an RLE algorithm that can contain all byte values
I'm writing an RLE algorithm in C# that can work on any file as input. The approach to encoding I'm taking is as follows:
An RLE packet contains 1 byte for the length and 1 byte for the value. For ...
0
votes
1
answer
174
views
Decoding a string; e.g c1d2 = cdd
I am trying to decode a string that can contain numbers but am not sure in how these characters can be detected apart from pattern matching like this.
This is not meant to be done with any imported ...
0
votes
0
answers
91
views
Definition of a RLE in vb.net
I'm looking to write a run length encoder in vb which when called, encodes the text of a input and sets it as the text of a label. I have the call coded, but the encoding definition is beyond any. Any ...
1
vote
1
answer
2k
views
Run Length Decoding
I have a function for run length decoding in Python. It is working with single digit numbers, but if my number is above 9, it doesn't work. As you can see in my code, I want to print c 11 times, but ...
0
votes
1
answer
36
views
Identify a vector within a list with at least n ocurrences of given value in R
I would like to write a function which would allow to filter the input data.
My input data is a list object containing named numeric vectors (minimal reproducible example below - dummy list).
vec1 <...
0
votes
2
answers
2k
views
RLE ALgorithm in python
like the title suggest I want to do an RLE algorithm and I have few problems with that
for example in RLE algorithm if we take aaaabbbccd it should return a4b3c2d1 as a result
the rle function should ...
2
votes
2
answers
2k
views
Conditional aggregation of rows in Polars based on consecutive values
I have some data with 2 columns in the following format:
import polars as pl
df = pl.from_repr("""
┌──────┬─────────┐
│ nums ┆ letters │
│ --- ┆ --- │
│ i64 ┆ str │
╞══════╪══...
0
votes
0
answers
102
views
Image compression with specific block size and max run length
I need to write two functions called compress(S) and decompress(S) that take a binary string S of length less than or equal to 64 as input and return another binary string as output. The output ...
0
votes
2
answers
446
views
What kind of texture compression/encoding is this? Run-Length encoding? Is there a way for Uploading to Open Gl?
I've got some Textures from an old computer game. They are stored in one huge file with a simple run-length encoding. I know the image width, and height, the images have also some fully transperant ...
2
votes
2
answers
109
views
Combinatorics: St. Peter's Game algorithm
There's a combinatorics puzzle (as mentioned in Mathematics From the Birth of Numbers by Jan Gullberg) where if you line up fifteen members from two categories each (e.g. fifteen of category 0 and ...
3
votes
5
answers
755
views
How do i make the program print specific letters in this specific format i give to it?
so i need to code a program which, for example if given the input 3[a]2[b], prints "aaabb" or when given 3[ab]2[c],prints "abababcc"(basicly prints that amount of that letter in ...
0
votes
1
answer
1k
views
VHDL error "indexed name returns a value whose type does not match "std_logic_vector", the type of the target expression"
I can't find out what's going wrong in this snippet of my code.
The error occurs on the data_in_bit <=data_in(posit + 1)
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ...
0
votes
2
answers
930
views
run length encoding for a string in JavaScript
I'm a new developer and got some questions from a test this week and coundn't find a way to solve this one. Any ideas?
The problem I believe is to sort a Javascript string which you have to convert ...