Hi guys, I have written a program which currently accumalates different pairs and their frequency from an excel spreadsheet. (1280 pairs) Want I want to achieve is from the top 20/30 pairs, if I can find pairs that link e.g. Pair 1 [1,33] and Pair 100 [1,232] so i would expect that to be a link. With that link i want to be able to merge it so the the value becomes e.g. [33,1,232] before continue to find any more. My find outcome should be a set of 10 numbers which are linked together by thier pairs. Anyone one have …

Member Avatar
Member Avatar
+0 forum 3

I am doing a school project which is an airplane collision detection system. Can anyone show me a few examples or pseudocode of implementation of closest pair algorithm O(n^2), O(n log^2 n), O(n log n)?

Member Avatar
Member Avatar
+0 forum 10

I am trying to print out a chess board on the console. The data structure i am using is a set of pairs. I am having trouble accessing the pair's elements. I do realize a map is probably better in this case but i am using somebody else's code so I don't want to mess with it. Thanks in advance! error i am getting says: error: 'struct std::_Rb_tree_const_iterator<const char*>' has no member named 'second' Here is my code: [CODE] set< const pair<char, pair<int, int> >* > chosen; for (int row=0; row<8; row++){ for (int col=0; col<8; col++) { for (typename …

Member Avatar
Member Avatar
+0 forum 1

This I did also after 'spying' discussions in other forum. Of course you would use sieve prime generation for bigger numbers, but I proved other simple way for a change. Slightly more advanced primes list generator would use primes % 6 in (1,5) property: [CODE]def primes(n): """ primitive non-sieve prime finder """ p = [2, 3] candidate, step = 5, 2 while candidate <= n: if all(candidate % pr for pr in p): p.append(candidate) candidate += step # consider only number % 6 in (1,5) ie 6*n +- 1 step = 2 if step == 4 else 4 return p …

Member Avatar
Member Avatar
+0 forum 1

I have string like: 'par1=val1,par2=val2,par3="some text, again some text, again some text",par4="some text",par5=val5' I have to split it to parts like: par1=val1 par2=val2 par3="some text, again some text, again some text" par4="some text" par5=val5' I use this code: [CODE] a = 'par1=val1,par2=val2,par3="some text1, again some text2, again some text3",par4="some text",par5=val5'.split(',') newList = [] for i, b in enumerate(a) : if b.find('=') != -1 : newList.append(b) else : newList[len(newList)-1] += ',' + b print(newList) [/CODE] I'm looking for better solution, can anybody give me it. Thank you in advance!

Member Avatar
Member Avatar
+0 forum 4

The End.