Posts: 1
Threads: 1
Joined: Apr 2023
Apr-05-2023, 02:04 AM
(This post was last modified: Aug-18-2024, 04:03 AM by Deonvek.)
But the highlight of my blog post was definitely my collection of anal sex sites. From big-name production studios to independent creators, I had it all covered. I gave detailed reviews of each site, sharing my favorite videos and performers. And for each site, I included a link for my best friend to explore on his own.
https://analsexvideos.cc/videos/63378/cu...terracial/
https://analporn.me/videos/16887/love-th...ateur-vid/
https://painfulanalporn.com/videos/60343...-sandwich/
It wasn't just about sharing my collection, though. I wanted to educate my best friend on different anal porn categories such as amateur, BDSM, and interracial. I provided a brief description of each category, accompanied by a few recommendations and a link to a specific video that would serve as the perfect introduction.
Posts: 6,800
Threads: 20
Joined: Feb 2020
What do you mean by "cannot be put together" and "works"? Does [(1, 2), (25, 99), (8000, 9999)] work? Are you looking for no duplicates, or do the numbers also have to be sequential like [(1, 2), (3, 4), (5, 6)]? If sequential, do the numbers have to be in the sequential order, or is [(1, 5), (4, 2), (3, 6)] work?
More details please.
Posts: 4,790
Threads: 76
Joined: Jan 2018
You forgot to tell us what is a «combination that works», I suppose it is some set of non adjacent nodes, or a partition of such sets. In that case, a greedy coloring algorithm could help.
Posts: 582
Threads: 1
Joined: Aug 2019
Deon has two lists: The input list N and a list of forbidden combinations P.
So I guess he wants all permutations of N, but skip forbidden combinations. Am I right @ Deonvek ?
An efficient way of comparing values is to use set(). So I would use this for storing forbidden combinations P.
N=[1,2,3,4]
P={(1,2),(2,3),(3,4)} # Make a set of forbidden combinations.
cartesian_product = set()
# You could also use itertools.product to find all permutations.
for i in N:
for j in N:
cartesian_product.add((i,j))
print("DEBUG ", cartesian_product)
result = cartesian_product - P
print("RESULT", result) Output: DEBUG {(4, 4), (2, 4), (1, 2), (2, 1), (3, 4), (4, 1), (3, 1), (4, 3), (1, 1), (1, 4), (4, 2), (2, 3), (3, 3), (2, 2), (3, 2), (1, 3)}
RESULT {(2, 4), (2, 1), (4, 3), (3, 1), (2, 2), (3, 2), (4, 1), (1, 3), (4, 4), (1, 1), (1, 4), (4, 2), (3, 3)}
Now this is not exactly what you asked for, because you said:
(Apr-05-2023, 02:04 AM)Deonvek Wrote: algorithm that won't test all the possible combinations Well you would have to test the combination at some point. Will the resultset be too large to fit in memory? Then you will have to skip the forbidden combinations in the nested loop.
Posts: 6,800
Threads: 20
Joined: Feb 2020
Apr-05-2023, 05:35 PM
(This post was last modified: Apr-05-2023, 08:32 PM by deanhystad.)
Does order matter? Is (2, 1) the same as (1, 2)?
Are duplicates such as (1, 1) allowed?
When you say you are looking for a combination that works, what do you mean by "combination"? Are you looking for pairs ((1, 3), (1, 4), (2, 4))?, enough pairs that every number in n is represented ((1, 3), (2, 4))?
Based on what ibreeden says and my guesses, are you looking for something like this:
n = (1, 2, 3, 4)
p = ((1, 2), (2, 3), (3, 4))
# Convert p to dictionary
bad = {a: {a} for a in n}
for a, b in p:
bad[a].add(b)
bad[b].add(a)
print("Bad", bad)
# Create a dictionary of numbers that can be paired.
good = {a: [b for b in n if b not in bad[a]] for a in n}
print("Good", good)
# Create all good pairs. Assumes order is not important: (1, 2) == (2, 1).
# If order matters, leave out "if b > a".
good_pairs = [(a, b) for a, c in good.items() for b in c if b > a]
print("Good pairs", good_pairs) Output: Bad {1: {1, 2}, 2: {1, 2, 3}, 3: {2, 3, 4}, 4: {3, 4}}
Good {1: [3, 4], 2: [4], 3: [1], 4: [1, 2]}
Good pairs [(1, 3), (1, 4), (2, 4)]
Posts: 2
Threads: 0
Joined: Apr 2023
my interpreation of this task:
from itertools import permutations
res = []
nums = [1,2,3,4]
not_allowed = [(1,2),(2,3),(3,4)]
for perm in permutations(nums,2):
if perm not in not_allowed:
res.append(perm)
print(res) Output: [(1, 3), (1, 4), (2, 1), (2, 4), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)]
Posts: 6,800
Threads: 20
Joined: Feb 2020
Apr-05-2023, 09:27 PM
(This post was last modified: Apr-05-2023, 09:27 PM by deanhystad.)
The op requested a solution that doesn't test all possible combinations. I don't that meant testing more than all possible combinations. On the other hand, your solution does take the order of the pair into account if order is important.
|