Welcome, Guest

Author Topic: how to . py  (Read 3750 times)

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
how to . py
« on: November 02, 2012, 07:20:35 PM »
need help with:

finds all the possible products of an array

examples:

[2,3] > returns 2*3, 2, 3 in an array form [6,2,3] (order not necessary)
[3,7,13] > returns 3*7*13, 3*7, 7*13, 13*3, 3, 7, 13 in an array form [273, 21, 91, 39, 2, 7, 13] (order not necessary)

how to do?

i was thinking to assign all values of the array with True or False

like len(array) > gets 3 for [3,7,13]
and then assign a True or False value for array(1), array(2), and array(3)
if array(1) is True and array(2) is True and array(3) is False the multiply array(1) and array(2) together
repeat until all 8 possibilities are complete
000
001
010
011
100
101
110
111
remove 0.

but i'm not sure how to decide whether to multiply the array indexes or not based on the array() so i'm not sure how to do so someone tell me their brains.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: how to . py
« Reply #1 on: November 02, 2012, 07:24:22 PM »
same here,

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #2 on: November 02, 2012, 07:32:28 PM »
Are your array sizes going to be fixed?

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: how to . py
« Reply #3 on: November 02, 2012, 07:38:14 PM »
ok nvm i figured out a better way to do it

if i can figure out what means

and http://en.wikipedia.org/wiki/Divisor_function
« Last Edit: November 02, 2012, 07:43:26 PM by mudkipz »

Hellpotatoe

  • *****
  • Posts: 230
  • JooJ
Re: how to . py
« Reply #4 on: November 03, 2012, 05:08:52 AM »
ARGH, MOAR PYTHON THINGS!
orno.

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: how to . py
« Reply #5 on: November 03, 2012, 05:12:41 AM »
kol

Hellpotatoe

  • *****
  • Posts: 230
  • JooJ
Re: how to . py
« Reply #6 on: November 03, 2012, 05:21:48 AM »
OH NO, ONE MOAR KOLPOST!

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: how to . py
« Reply #7 on: November 03, 2012, 06:19:06 AM »
whee i just noticed nue had a new pic

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: how to . py
« Reply #8 on: November 03, 2012, 07:23:57 AM »
Are your array sizes going to be fixed?

fixed? no i need a way to do this no matter the array size.

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: how to . py
« Reply #9 on: November 03, 2012, 08:09:37 AM »
edit: never mind i figured it out with

f = lambda x: [[y for j, y in enumerate(set(x)) if (i >> j) & 1] for i in range(2**len(set(x)))]

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #10 on: November 03, 2012, 11:23:57 AM »
that looks very scary

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: how to . py
« Reply #11 on: November 03, 2012, 12:20:30 PM »
^
no idea how it works either but it does

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: how to . py
« Reply #12 on: November 03, 2012, 01:08:56 PM »
dictionary(antidisestablishmentarianism^hydrocinnamyl(sugg/dictionary))-integrate(chauvinistic-x)
solve for x

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #13 on: November 03, 2012, 01:25:21 PM »
x = -integrate(dictionary(antidisestablishmentarianism^hydrocinnamyl(sugg/dictionary)))-chauvinistic

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: how to . py
« Reply #14 on: November 03, 2012, 02:39:33 PM »
ok now teel me what -integrate(dictionary(antidisestablishmentarianism^hydrocinnamyl(sugg/dictionary)))-chaunvinistic is in base 10

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #15 on: November 03, 2012, 02:46:40 PM »
-234076011209926115340

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: how to . py
« Reply #16 on: November 03, 2012, 02:59:33 PM »
if it is a legitimate maths the brain has a way to show all the work

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #17 on: November 03, 2012, 04:52:52 PM »
for x in list:
    len(x)

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: how to . py
« Reply #18 on: November 03, 2012, 07:48:31 PM »

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promo-code '87952'.

« Last Edit: March 22, 2021, 02:26:26 AM by FiahOwl »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3849
  • caught in the river turning blue
    • Paladin of Storms
Re: how to . py
« Reply #19 on: November 03, 2012, 08:04:24 PM »
KOlyesw.