126 questions
Advice
0
votes
6
replies
66
views
Python append list
I am a beginner learning GCSE level python, but stuck on this book problem
Here, the num1.txt file data is appended to the temp1list
num1.txt file data:
10,20,30,40
20,30,40,50
30,40,50,60
40,50,60,70
...
1
vote
2
answers
202
views
Solving box stacking problem in n log n, no rotations allowed
I need to solve a box stacking problem with the following rules:
Box is a tuple {x, y, height}.
You CAN NOT rotate boxes.
To stack a box b1 on top of another box b2, b1.x<=b2.x and b1.y<=b2.y.
...
0
votes
3
answers
119
views
How can I write a function called update that allows me to update something in this dictionary?
I want to create a function called update in Python for a list dictionary but I don't have any idea how to do this.
I tried to do reserch but the most common information shows how to do changes simply ...
4
votes
1
answer
472
views
How to find the longest increasing subsequence in a circular buffer?
I am trying to solve a sorting problem in which it would be useful to determine the longest increasing subsequence in a circular buffer.
As an example, let's take the following sequence:
5, 3, 4, 2, 1
...
0
votes
1
answer
230
views
How to reset a stream?
I am trying to connect a pathology analyzer and receive data. Following is my code.
private void ReceiveData(string IP, string PortNo)
{
var port = Convert.ToInt32(PortNo);
...
1
vote
1
answer
50
views
n.Logn algorithm to find longest subsequence not the length
This code finds the length of the longest subsequence in n.logn time but not the correct sequence.
How to find the sequence that is longest in n.logn not the length?
#include<bits/stdc++.h>
#...
1
vote
0
answers
139
views
Length of Longest Increasing Subsequence with at most K deletions
The input is a list of integers and an integer k. The output has to be the length of the longest possible increasing subsequence of contiguous elements(neighbor elements, for example in '1 0 2' 1 and ...
0
votes
1
answer
156
views
How to make this fenwick tree LIS solution faster?
Longest increasing subsequence, but with fenwick tree
Where numbers can be non unique, positive, negative and up to +/- 2^31
Hi tried a lot, and it should work. But its slow. I know that segment ...
0
votes
1
answer
62
views
How to get multi-dimension specific data samples on the basis of list element?
I need to evaluate my model's performance with limited training data. I am randomly selecting p of original training data. Assume p is 0.2 in this case. Here is some intil lines of code:
p = p*100
...
-3
votes
3
answers
69
views
Remove element in list in a dictionary from specific keys [closed]
I have a dictionary like below:
my_dict = {'A' : [1, 2, 3, 4, 5], 'B' : [10, 1, 2, 5, 8], 'C': [6, 5, 3, 1]}
I want to remove values less than 3 from "A" and "C" while B remains ...
0
votes
1
answer
97
views
I do have a list of dictionaries and I am interested in getting values of only select key
I have used this code on my dataframe of sql queries to obtain list of dictionaries that has select, where, join columns:
def augment(x):
try:
return Parser(x).columns_dict
except:
...
0
votes
0
answers
290
views
TCP Connection keep disconnecting with Analyzer Mindray BS240
I'm working on a TCP communication program for the chemestry analyzer "Mindray BS240". The problem is that the analyzer keep disconnecting and reconnecting (every 30s). Here is my code, what ...
-1
votes
1
answer
104
views
Read all the words starting from substring
I have csv file in which keywords are given. I have to match all the words starting with the keywords from the text.
text = "1 who were randomized 1 1 to daro 600 mg twice daily or matching pbo ...
0
votes
2
answers
117
views
given a list with integers separated by math symbols, find if a certain value can be calculated by placing braces
I'm trying to write a function which get:
An integer. (s)
A list with integers separated by math symbols.(L)
By using recursion to determinate if the value of s can be calculate from the list by ...
0
votes
2
answers
152
views
How can I get more than one list as an output of recursive function called on list of lists?
I am trying to use a recursive function that prints all lists that has the maximum length out of the lists ( could be one or more if they have the same length)
given an input such as :
[[],[3],[2],[6]...
0
votes
1
answer
257
views
How can I find the list with maximum length using recursion?
I am trying to use a recursive function that prints the list that has the maximum length out of the lists resulting from my following code:
allincreasing :: Ord a => [a] -> [[a]]
allincreasing = ...
1
vote
1
answer
175
views
How can I use isSrderd and subsequences?
The goal is to find the Longest Increasing Subsequence (LIS) of a list in Haskell. I tried to run the following code, but the error of couldn't find modules appeared. I saw answers to This question ...
-1
votes
2
answers
68
views
Sort list multiple key and upper nearest value
How I want to order my list:
isRegular = True
bold = True
italic = True
The upper nearest value of weight. In my example, I want the nearest value to 400.
My list contains these NamedTuple:
class ...
0
votes
1
answer
224
views
how do I catch values returned from selenium web driver and store as one list
I'm new to programming and I am using selenium to get data from scheduled matches from flashscore, I intend to assign each list returned from each loop to a variable so I can perform some calculations ...
1
vote
1
answer
463
views
update box stacking problem but all the height are same
The Box Stacking Statement: Given n rectangle boxes, that the i box has height h[i], width w[i] and depth d[i]. Create a stack of boxes that is the tallest one possible, but only can stack a box on ...
0
votes
1
answer
247
views
2-D Array Pyramid in Ruby?
def adjacent_sum(arr)
narr = []
l = arr.length
arr.each.with_index do |num,index|
if index < arr.size-1
narr << arr[index] + arr[index+1]
end
end
return narr
end
...
-1
votes
1
answer
395
views
I have a list that returns two values at one position of the array
I have a list that returns two values at one position of the array.
In the example is the 0 position of the array c.
I want to know how to retrieve the first value and then the second value
Thank you
0
votes
1
answer
150
views
Why is an ancestral array needed when recovering longest increasing subsequence?
I looked at the following website describing the longest increasing subsequnce algorithm: https://www.fyears.org/2016/12/LIS.html
In the section "how to reconstruct the subsequence?", it ...
1
vote
2
answers
191
views
Longest Increasing Subsequence using recursion and cache
i've been trying to implement a cache in my recursive LIS function so it doesn't calculate the same value twice. I would really aprecciate if someone can give me a hint of what im getting wrong.
This ...
0
votes
1
answer
639
views
longest increasing subsequence problem - n log n solution that returns the actual subsequence - explanation/clarification needed
I've tried to implement the n log n solution to the longest increasing subsequence problem (where you need to find a longest subsequence where each element is larger than the previous one of a given ...
0
votes
1
answer
243
views
Longest Increasing Subarray after add or subtract some element an amount less than K
Given an array and we can add or subtract some element an amount less than K to make the longest increasing subarray
Example: An array a=[6,4,3,2] and K=1; we can subtract 1 from a[2]; add 1 to a[4] ...
0
votes
3
answers
934
views
python list : keep unique values
I got the following value in my list :
A= [{'43c776cc-dcfe-498e-9e0c-465e498c4509'},
{'43c776cc-dcfe-498e-9e0c-465e498c4509'},
{'43c776cc-dcfe-498e-9e0c-465e498c4509'},
{'fbcbdda3-...
0
votes
1
answer
200
views
How to combine string elements of a list for Apriori Algorithm in python?
So I am trying to program Apriori Algorithm.
I have here
L1= ['apple', 'banana','orange','mango]
This list already passed the support threshold, now I have to combine the items for another support ...
0
votes
3
answers
691
views
How to find the longest alternating increasing subsequence by alternating between two arrays
Given two arrays of numbers, how do I find the longest increasing subsequence by alternating between the elements of the two arrays?
for example
A = [4, 1, 10, 5, 9]
B = [4, 5, 7, 14]
so the output ...
0
votes
2
answers
55
views
Python queryto get height price user with count
I have two tables like :
User:
Id | Name | Age |
1 | Pankhuri | 24
2 | Neha | 23
3 | Mona | 25
And another
Price log:
Id | type | user_id | price | created_at|
1 | credit | 1 | 100 | 2021-...
0
votes
1
answer
112
views
Dynamic Programming: Can recursion with memoization work with any recursive solution or only solutions in specific formats?
I am reading about dynamic programming and was trying to solve the Longest Increasing subsequence problem.
I tried to come up with a brute force recursion approach where I generated all possible ...
0
votes
1
answer
82
views
what is the most appropriate data structure supporting binary search to solve LIS?
I would like to solve the Longest increasing subsequence problem in Haskell, with the patience sorting algorithm.
I first did it with lists, and it worked in O(n^2) time.
Now I would like to do create ...
0
votes
1
answer
101
views
Python dictionary in string format
I have a dictionary like this
verdict = {'1': 'PASS', '2': 'FAIL}
I want to print this dictionary in a string format without using for loop.
output:
1: PASS
2: FAIL
So far I have tried this:
print(*...
0
votes
1
answer
151
views
Is there any prefeered Python package to create lis type of file(output file generated by SQR)
I have to create .lis(output generated from SQR) type of file using python.
I am not able to find any existing python package for it.
please help. Thanks
0
votes
2
answers
147
views
How to sort a list that contains inner lists by the inner lists in python
I have a list that contains lists, examples:
table[0] = ['255.255.255.255', '58267', '233', 'ESTABLISHED']
table[1] = ['255.132.0.0', '38367', '273', 'CLOSED']
I want to sort the list 'table' by the ...
0
votes
2
answers
2k
views
Spark collect_list change data_type from array to string
I am having a following aggregation
val df_date_agg = df
.groupBy($"a",$"b",$"c")
.agg(sum($"d").alias("data1"),sum($"e").alias(&...
3
votes
2
answers
4k
views
Where to set Mindray BC-5150 HL7 communication port number and ip address
I'm working on a LIS TCP communication service with the Mindray BC-5150 laboratory device, and I could not found where to put the communication settings (service address and port number),but I did ...
2
votes
6
answers
2k
views
Python create multi dimensional array of of normal array
I want to create a multi dimensional Array out of normal array. When there is a 0 in my start array i want to change the row number by 1.
My start array looks like this:
arr = [1, 2, 3, 0, 4, 5, 6, 0, ...
0
votes
1
answer
54
views
List wtih Python
I have next code:
listTest = ["ration","hello","exclamation"]
word=['masha[a-z]*']
channels=['BOOMERANG','NICK']
targets=['KIDS','BOYS']
l=[]
for j in range(22): ...
0
votes
0
answers
390
views
Longest Increasing Subsequence variations dynamic programming
I have this question:
Given the following:
A = [9,6,9,3,8,9,2,0,4,12]
C = [r,g,r,g,r,g,r,r,r,g]
Where
- r = red
- g = green
This list represent the color of the number in the same index in ...
1
vote
1
answer
444
views
Wavio Sequence - UVa - LIS-nLogn
I am trying to solve uva's question 10534. The question is straight forward i.e
Store LIS at each index i in array L1[].
Reverse the input array nums[].
Store LIS of this reverse array nums[] in L2[]
...
0
votes
0
answers
188
views
Alternating Sub-sequence SPOJ Python (ALTSEQ)
This is the 1st time I am trying coding practices on platform like SPOJ. I have used bottom-up approach of dynamic programming and I am submitting below solution for finding maximum length of ...
-2
votes
1
answer
46
views
How do I print out the specific index? [closed]
My code: text = [['Name', 'Surname', '2009']]
What I tried to do: text[1];
I want so that the 'Surname' would print out, but I keep getting - IndexError: list index out of range.
-3
votes
1
answer
4k
views
What is the complexity for std::upper_bound and std::lower_bound for Vector in C++?
What is the complexity of the std::lower_bound and std::upper_bound functions.
I know in case of std::set<int> it is log(n), but I have no idea for a std::vector<int>.
I was going through ...
3
votes
1
answer
1k
views
Longest Increasing and Decreasing subsequence (Top-Down with memoization)
Question - Given an array of integers, A of length N, find the length of longest subsequence which is first increasing then decreasing.
Input:[1, 11, 2, 10, 4, 5, 2, 1]
Output: 6
Explanation:[1 2 10 ...
0
votes
1
answer
193
views
How to match list of areas to a "address"(string) and get the area which is present in both list and string Asp.net core
Hello every one i have string containing Address and list of Areas from Db, i want to get the area from address string which is present in both list of areas and address string.how can i do this ...
0
votes
2
answers
1k
views
How to remove special characters from a list of strings?
I am reading a file and using a regex on the file content to perform some operations. While reading the file, I don't find any special characters in it but after using the regex on the file content ...
2
votes
1
answer
148
views
Is the r-value parameter really an l-value parameter inside the function scope?
I have found the following snippet in a code implementing a list class
void push_front( const T & x ) { insert( begin( ), x ); }
void push_front( T && x ) { insert( begin( ), std:...
7
votes
1
answer
3k
views
Longest K Sequential Increasing Subsequences
Why I created a duplicate thread
I created this thread after reading Longest increasing subsequence with K exceptions allowed. I realised that the person who was asking the question hadn't really ...
0
votes
0
answers
208
views
Why Mindray BC3600 asking for coldfire login and password when connecting to LIS?
We are developing LIS for Mindray BC 3600. When we are connecting to the analyser it is asking for "coldfire login:" and password. But neither the suppliers nor service center know what it is. Is ...