12,118
questions
-2
votes
0
answers
42
views
Java: Set is empty even though it is not? [closed]
Context: I have to create a program with a basic GUI that acts as an ordering system (for burgers and salads). The idea is that the first window asks them if they want a burger or salad in the form of ...
1
vote
2
answers
30
views
shell exit function for set -e
I have a script.command file with a shell script inside, so that I can double click it to execute in a new terminal window. When it finishes the script it automatically closes regardless of the exit ...
0
votes
0
answers
34
views
Aproximation Algorithim for Max Subset Problem
I'm looking for an approximation approach to what I am assuming is an NP hard problem. Given a list of sets F = {S1,...,Sm) that contain at most n elements from (0,...,n-1): what is the largest subset ...
1
vote
4
answers
79
views
Why can I unpack a Python set when sets are unordered?
I am quite used to unpacking sequences in Python like:
my_tuple = (1, 2, 3)
a, b, c = my_tuple
I have noticed that I can also do it with sets:
my_set = set((1, 2, 3))
a, b, c = my_set
Why can I do ...
-2
votes
0
answers
32
views
Python Set&Dict — random probing [duplicate]
I have some working experience with C++ and now I'm trying to master Python. I have a question about Dictionaries and Sets in Pytnon.
First part of my question
As far as I know, dict is a hashmap in ...
-3
votes
2
answers
84
views
symmetric_difference() multiple sets in python [duplicate]
I have three sets and I want to get the symmetric_difference.
primes = {1, 2, 3, 5, 7, 11}
odds = {1, 3, 5, 7, 9, 11}
threes =. {1, 3, 6, 9, 12}
Using the regular way
set(primes) ^ set(odds) ^ set(...
-1
votes
3
answers
88
views
Multiple elements in set with the same hash
I was reading through SymPy 1.13.0 release notes when an entry caught my attention (emphasis mine):
The hash function for Floats and expressions involving Float now respects the hash invariant that ...
0
votes
1
answer
50
views
How can I update certain rows based on a criteria?
I am struggling with implementing two 'flag' columns to show whether an applicant has been through a process called 'Clearing' or not, and whether that applicant had a prior standard application to ...
0
votes
1
answer
22
views
CurrentDb.Execute strSQL - Can't get table values to set to new user input
Access BD, VBA / SQL Newby -- Please forgive my ignorance
I have a form that should update a users password entered in to PWord1, and re-entered into PWOrd2. If they did everything correctly then the ...
-1
votes
1
answer
45
views
CodeForces Contest > 1761 \ Problem C (Set Construction) - How to solve this problem?
Guys I have been working on this problem since morning (4 hours ago) and still couldn't find a proper answer. How can I set the Subsets with these conditions? So for example an A Set is a subset of A2 ...
0
votes
1
answer
50
views
bitmasking for values over 2³²
I know PHP integers are between -2³² and 2³² and unsigned integers don't exist. Would there be a way to bitmask for values over 2³²? I'm looking for a way to implement a effecient Set class using bit ...
0
votes
1
answer
30
views
Listing all sets of 5 teams that has one element of each rank
This will be used for a fairly-ranked team-picking (each team must have exactly one element of each rank). One example of elegibe players would be:
Rank 1:'Liam', 'Emma', 'Noah', 'Olivia', 'Ava'
Rank ...
1
vote
2
answers
80
views
How to find duplicates in a text file in python and create a new text file with out them
I am trying to remove duplicates from text files to make a current process more efficient
Example input:
1 1
1 1
2 1
3 1
4 1
Example Output:
1 1
2 1
3 1
4 1
my issue is when ...
0
votes
2
answers
58
views
Why it Kotlin's Set implementation mutable under the hood?
I just noticed something interesting about Kotlin's Set data structure and its interaction with Java.
Consider a List object first. If I have this code in Kotlin:
private val aList = listOf(1,2,3)
...
1
vote
1
answer
43
views
How do You Convert a List of Strings into a Frozenset and Add it to a Set of Frozensets?
I have a variable with n words, separated by whitespaces. str.split() returns a list of these words, which is then converted to a tuple with tuple(), which is finally converted to a frozenset and ...
0
votes
1
answer
86
views
reference_wrapper in c++ containers
Consider following snippet:
#include <bits/stdc++.h>
using namespace std;
int main() {
int x=3;
int y=1;
int z=2;
cout<<(&x)<<' '<<(&y)<<' '<&...
0
votes
1
answer
28
views
Data rolled back after 5-7 minutes of running the update on table successfully
I ran an update on the SQL table using the below code, and it updated the table correctly. But after 5-7 minutes, the data rolls back. Why does this happen? I don't see any logs or errors in the SQL ...
-2
votes
1
answer
57
views
Why could I allow a duplicate on Kotlin's sets? [closed]
It is known that the set in Kotlin prohibits the content of duplicates. But I was able to create such a set:
var c = Card2.`2c`
var cards3: Set<Card2> = setOf(c, c)
Why is this acceptable? Or ...
0
votes
0
answers
58
views
set c++ own comparator function find could not find an already inserted element [duplicate]
I wrote an comparator function for my set which will store an vector of 3 elememts.
Those 3 elements will be sorted always.
Now i insert the 2 elements in the set. But when i try to find the 2nd ...
0
votes
0
answers
38
views
Conditional Classname with Tailwind React Not Updating Style
selectedTopics.has(topic) is not returning True when it should in this case to display the conditional styling. When I replace selectedTopics.has(topic) with true, the conditional styling is applied ...
4
votes
3
answers
109
views
searching performance in list is better than in set
Searching an element in a set takes O(1) time complexity while searching in a list takes O(n) time complexity. The n is the number of elements in a set or list.
In my test on the real searching time ...
0
votes
2
answers
96
views
TypeError: unhashable type: 'numpy.ndarray' in array to set
in this def i get TypeError: unhashable type: 'numpy.ndarray' in line retrieved_indices_set = set(retrieved_indices)
def evaluate_retrieval(query_idx, retrieved_indices, relevant_indices):
# ...
1
vote
1
answer
116
views
Julia equivalent for MatLab ismembertol
I have two different datasets, say A of dimension (N1,3) and B(N2,3).
I want to identify the rows in A which are approximately equal to some rows in B with tolerances tol = [tol1, tol2, tol3].
In ...
0
votes
0
answers
39
views
How to add/remove an element from a set in Java while iterating [duplicate]
I know there's a way to do it with ListIterator, but I can't find a SetIterator. Is doing something like this even possible?
1
vote
1
answer
59
views
Overloading Set in Swift
Some background
I am very new to Swift and MacOS and trying to learn the Swift way to do things. This started because I realized that tuples are not hashable so I rolled my own:
struct XY: Hashable
{
...
0
votes
0
answers
7
views
Can I update value of the private member in another package by using Java encapsulation concept?
Input:
Name:
PAN:
Phone:
Account_no=987452
For all users account no should be updated in increasing order.
I tried encapsulation concept
Getter and setter method
And taken all input from the users
But ...
0
votes
1
answer
21
views
How to force DynamoDB to use List<Sting> instead of Set<String>
When I insert a string array column the AWS SDK insert a sring set.
Is there a way to force DynamoDb to use List instead?
{
"pk: "test",
"tests": ["a", "...
2
votes
0
answers
99
views
Why is there no java.util.stream.Stream.toSet() method in Java [closed]
There is a java.util.stream.Stream.toList() method in JDK but there is no java.util.stream.Stream.toSet()?
So if I need to convert some stream to List I can use stream().toList() or I can use stream()....
0
votes
3
answers
62
views
How to recursively join subsets into a list in python?
I have a list of sets:
my_set = [[1, 2, 3], [1, 5], [4, 5, 6], [7, 8]]
I want to join all subsets that have elements in common (at least with one subset) in this list, into a single subset:
...
-2
votes
1
answer
47
views
why does jupyter notebook print such an output?
enter image description here
I used a set to assign values to names.
jupyter notebook gave this output. Can anyone explain this?
I expected {"aaa", "bbb", "ccc"} as the ...
-1
votes
1
answer
118
views
Define a variable and "return" an expression all within a single C macro
NOTE: I am not interested in using GCC statement expression!
I am implementing a set data structure using a Red Black Tree and to make it work for multiple types I am using macros.
This is a ...
1
vote
1
answer
61
views
Compute largest subset of a set such that all the elements of the subset would pairwise respect a certain condition
I have a set S consisting of natural numbers and a function that when given two natural numbers as an input it returns either true or false. Let's call the criteria based on which it computes the ...
1
vote
1
answer
280
views
Set Type Typescript has no isSubsetOf
I would like to use sets like they are implemented in MDN with typescript.
I have the latest typescript installed in my package:
"typescript": "^5.4.5"
and in my tsconfig I have:
&...
1
vote
2
answers
64
views
Scope of an entry added to a c++ set?
Let's say I have a globally scoped set defined as follows:
std::set<Person> people;
I also have a function where I create an instance of the class Person, and add it to the set as follows:
void ...
0
votes
0
answers
20
views
Can someone explain why I cannot swap_ranges between std::set and std::vector?
int t[] = { 210, 90, 8, 0, 52, 53, 23, 34, 91, 88 };
set<int> s1(t, t + 10);
vector<int> v1(s1.rbegin(), s1.rend());
swap_ranges(s1.begin(), s1.end(), v1.begin()); // error here
I've ...
-1
votes
2
answers
93
views
SEGV in c++ std::set erase [closed]
I am getting segmentation fault in c++ std::set erase function. I don't know the reason of SEGV. please check the code below and help me know the reason of this SEGV.
#include <iostream>
#...
5
votes
1
answer
95
views
Why `set` objects do not use `__newobj__` function to unpickle like other built-in container types?
I am recently writing a batch of customized container classes which are mostly inherited from built-in list, dict and set types, and I surprisingly encountered an error that the interpreter will raise ...
0
votes
1
answer
108
views
Time Complexity For "Longest Consecutive Sequence" Leetcode problem solution
SO I had question regarding the time complexity for my solution for the LeetCode problem "Longest Consecutive Sequence". In this problem, we're given an unsorted array of integers, and need ...
0
votes
0
answers
38
views
deepcopy fails with object that contains objects that contain sets that point to each other with __hash__
This MWE builds a Network class and a Node class. A Node has attributes called predecessors and successors, each of which is a set that will contain other Nodes. Functions in the two classes manage ...
0
votes
2
answers
50
views
How to induct on mapped sets or...?
Working on verifying a version of the counting inversions algorithm. I feel like pairMapSize has everything it needs but it times out instead. I could try to do induction on slices of the array but I ...
2
votes
1
answer
54
views
get group of sublists that share common elements but those elements are not the same in all sublists
I have to group sub-lists with a common element in set "p", using python. p elements are not always in 1st or las position on the sub-list. Grouped (result) lists is list r.
Result list r is ...
0
votes
1
answer
46
views
Function that constructs a Set of all elements that statisfy a given condition in Isabelle
I am trying to learn set construction in Isabelle but I am failing.
Consider you want a function that gives you all natural numbers that are smaller than a given number. I thought this should work:
...
0
votes
1
answer
99
views
In JavaScript, what is the difference between a map, a Map and a Set?
This concept probably wouldn't confuse me except that two things have the same name and seem to do completely different things. There is the array method aka Array.map() which is basically (I know ...
0
votes
1
answer
47
views
Rust BTreeSet insert unique values with duplicate ranking field
I need an ordered set so I'm using BTreeSet. I have an Item struct which contains a unique id, and a rank field which may be duplicated. I only want uniqueness to be considered for the id field and ...
-2
votes
3
answers
71
views
About the sets in python
import string
alphabet = set(string.ascii_lowercase)
def is_pangram_alternative(s):
return not (set(alphabet) - set(s))
input_string = 'The quick brown fox jumps over the lazy dog'
if ...
0
votes
2
answers
104
views
Why is the "set.union()" function much slower than the set union operator "|" in this code?
I have been revisiting my solution for https://adventofcode.com/2023/day/16. Here is my old code:
from functools import cache
from helper import directions_2d
# [(0, 1), (-1, 0), (0, -1), (1, 0)]
def ...
0
votes
0
answers
18
views
Sets and Constrains in Pyomo
I have the following problem:
I would like to define multiple Constraint in Pyomo.
I have an indexed Set, where every row has an index (1,2,3..n_generators) and they corresponds to different time ...
2
votes
2
answers
95
views
How to Enumerate Pandigital Prime Sets
Project Euler problem 118 reads, "Using all of the digits 1 through 9 and concatenating them freely to form decimal integers, different sets can be formed. Interestingly with the set {2,5,47,89,...
1
vote
1
answer
42
views
How to assign a name to values within a set of IDs so that a Python Algorithm will run through them
I will try to not be too lengthy. I will include what I believe is necessary to help me solve my issue. There are some algorithms referenced that I won't include. Just know that they do work as ...
0
votes
0
answers
16
views
How can I copy and paste a value from a column to the same column
I am trying to take a value in a column. (An ID) and paste that same value in all the rest of the rows in that column that are null (the ID is missing). Can someone explain how I can do that? Thx
...