anyone here good at python? DM me please I have a question

D

Deleted member

Lurker
title

my uncle will give me £20 for a correct answer niggas I need it to book hotel with jb :feelswah:
 
  • JFL
Reactions: Deleted member 6403 and Deleted member 9003
just ask here
 
just ask here
okay I’m tryna make a python program

so you enter a number let’s say: 9

there is a sequence of numbers that are set

7 - 3 - 1 - 0 - 4 - 2 - 5

the program then takes the input: 9

and outputs 7 + 2 from the list

can anyone make this into a python code pls? :feelswhy:
 
okay I’m tryna make a python program

so you enter a number let’s say: 9

there is a sequence of numbers that are set

7 - 3 - 1 - 0 - 4 - 2 - 5

the program then takes the input: 9

and outputs 7 + 2 from the list

can anyone make this into a python code pls? :feelswhy:
does it need to outpue every possible combination that adds up to 9 or just one

can numbers be used more than once
 
  • +1
Reactions: Deleted member
okay I’m tryna make a python program

so you enter a number let’s say: 9

there is a sequence of numbers that are set

7 - 3 - 1 - 0 - 4 - 2 - 5

the program then takes the input: 9

and outputs 7 + 2 from the list

can anyone make this into a python code pls? :feelswhy:
So it’s supposed to find the smallest amount of numbers out of that set that make up that given number? Or what is the point ?

Let’s say it’s 19 we would get 7+7+5?
 
So it’s supposed to find the smallest amount of numbers out of that set that make up that given number? Or what is the point ?

Let’s say it’s 19 we would get 7+7+5?
yes bro exactly that but I need a python code to send
 
Idk the python language but I would do it like this:

Array setOfNumbees = {7,3,1…}

sort that array so you have {7,5,4,3…}

input number x
String Erg=„“
for I in setOfNumbers

—— If{setOfNumbers i !=0}

————— While x-setOfNumbers i >=0:

—————————- x=x-setOfNumbers i
—————-————Erg+=setOfNumbers i
—————————-If{!x==0}


————————————Erg+=„+“

Return erg
 
Last edited:
  • JFL
  • +1
Reactions: Deleted member and DivineBeing
Idk the python language but I would do it like this:

Array setOfNumbees = {7,3,1…}

sort that array so you have {7,5,4,3…}

input number x
String Erg=„“
for I in setOfNumbers
If{setOfNumbers!=0}
While x-setOfNumbers=0:
x=x-setOfNumbers
Erg+=setOfNumbers
If{!x==0}
Erg+=„+“
Ah shit it’s not formatted correct on phone
 
can u send it in a better format? Thanks btw
Nah cba I need to wake up in 5 1/2 hours.

would need to do some googling how to write python language and that shit. But that’s the basic algo
 
  • WTF
Reactions: Deleted member
@DivineBeing why are u such a useless nigga? Help me out u cottonpicker :feelswah:
 
  • JFL
Reactions: ropemax and DivineBeing
okay I’m tryna make a python program

so you enter a number let’s say: 9

there is a sequence of numbers that are set

7 - 3 - 1 - 0 - 4 - 2 - 5

the program then takes the input: 9

and outputs 7 + 2 from the list

can anyone make this into a python code pls? :feelswhy:
that just looks like the problem called 2-sum but returning the numbers instead of the indices, look it up
 
  • JFL
Reactions: Copeful
Idk the python language but I would do it like this:

Array setOfNumbees = {7,3,1…}

sort that array so you have {7,5,4,3…}

input number x
String Erg=„“
for I in setOfNumbers

—— If{setOfNumbers i !=0}

————— While x-setOfNumbers i >=0:

—————————- x=x-setOfNumbers i
—————-————Erg+=setOfNumbers i
—————————-If{!x==0}


————————————Erg+=„+“

Return erg
too high runtime/big O, would fail in an interview :feelshehe:
 
  • JFL
Reactions: Copeful
fucking send me the money and ill write a solution 3 different ways
 
  • JFL
Reactions: sytyl and Deleted member
 Findtheuncle


Copy this down, forum formatting is fucked
 
Last edited:
  • JFL
Reactions: thegoat
Idk the python language but I would do it like this:

Array setOfNumbees = {7,3,1…}

sort that array so you have {7,5,4,3…}

input number x
String Erg=„“
for I in setOfNumbers

—— If{setOfNumbers i !=0}

————— While x-setOfNumbers i >=0:

—————————- x=x-setOfNumbers i
—————-————Erg+=setOfNumbers i
—————————-If{!x==0}


————————————Erg+=„+“

Return erg
bruh what
this doenst even work
the second while loop would just repeatedly subtract the same number while its gerater than 0?
 
  • JFL
Reactions: sytyl
bruh what
this doenst even work
the second while loop would just repeatedly subtract the same number while its gerater than 0?
No. First while loop is 9-7=2 which is greater than 0 so it goes into it.
Then you have 2-7 in the next Loop but that isn’t allowed by the condition since that would be below 0 so it jumps to the next index of setOfNumbers

tho it might not work. I just thought about it then wrote it down idk
 
Last edited:
  • Woah
Reactions: Copeful
okay I’m tryna make a python program

so you enter a number let’s say: 9

there is a sequence of numbers that are set

7 - 3 - 1 - 0 - 4 - 2 - 5

the program then takes the input: 9

and outputs 7 + 2 from the list

can anyone make this into a python code pls? :feelswhy:
This is the exact solution. It will find the first pair in the list and print it.


Screenshot 6




Average western coder asking the chinese man for help.
@Collagen or rope @Jamesothy
 
Last edited:
  • +1
  • Love it
Reactions: Deleted member and Jason Voorhees
This is the exact solution. It will find the first pair in the list and print it.


sequence = [7,3,1,0,4,2,5]
number = int(input("Enter an integer dumbass: "))

for x in sequence:
compare=number-x
for c in sequence:
if compare == c:
print(x,"+",c)
exit()



Average western coder asking the chinese man for help.
@Collagen or rope @Jamesothy
bruh i thought u were kazakh
 
  • +1
Reactions: Toth's thot
Season 5 Lol GIF by Real Husbands of Hollywood


dude just wrote an entire essay
hombre just wrote a phd

looksmax niggas really be putting more effort in their posts here than on their university degrees :ogre:
 
  • JFL
  • +1
Reactions: Toth's thot and Magical Apple
We peaked permanent virginity on this thread today
 
  • +1
Reactions: sytyl
This is the exact solution. It will find the first pair in the list and print it.


View attachment 1502443



Average western coder asking the chinese man for help.
@Collagen or rope @Jamesothy
would also fail in an interview :feelshehe:

there's an O(N) solution that isn't too difficult
 
  • +1
Reactions: DivineBeing
This is the type of shit you learn at first semester I want 20 dollars to solve this :feelswah::feelswah::feelswah:
 
  • JFL
Reactions: Deleted member
would also fail in an interview :feelshehe:

there's an O(N) solution that isn't too difficult
My solution is O(n^2) and I'd guess yours is also cause I see a nested loop, although I've never used python before so I'm not sure exactly what you did.
 
Last edited:
Kazakh by ethnicity, proud 中国人 by nation.
China must be praised for its treatment of ethnic minorities. Its achievements in human rights in Xinjiang are to be lauded. Xi Jinping should be awarded the Nobel peace prize
 
  • +1
Reactions: Toth's thot, DivineBeing and Magical Apple
  • +1
Reactions: Magical Apple
My solution is O(n^2) and I'd guess yours is also cause I see a nested loop, although I've never used python before so I'm not sure exactly what you did.
I didn't give a solution.

The O(N) solution is to use a hash table/dictionary
 
Tho I would like to see it

hashtable = {}

numbers = [1,4,6,7,9,2,3]
target = 8 (so answer would be 1 and 7)

for x in numbers:
~~~~~complement = target - x
~~~~~if complement is in hashtable :
~~~~~~~~~~return target and x
~~~~~else add x to hashtable t

something like this
 
  • +1
Reactions: Magical Apple
hashtable = {}

numbers = [1,4,6,7,9,2,3]
target = 8 (so answer would be 1 and 7)

for x in numbers:
~~~~~complement = target - x
~~~~~if complement is in hashtable :
~~~~~~~~~~return target and x
~~~~~else add x to hashtable t

something like this
Nigga That doesn’t do remotely the same as what astatine said it should do.

Fckin idiot trying to be a smartass. Love it when people act like this instead of being helpful and than are brutally wrong
 
  • JFL
Reactions: Deleted member, ropemax, Magical Apple and 1 other person
Nigga That doesn’t do remotely the same as what astatine said it should do.

Fckin idiot trying to be a smartass. Love it when people act like this instead of being helpful and than are brutally wrong
????
he literally described the 2-sum problem

given a target number, find two numbers in an array that sum to it
 

Similar threads

optimisticzoomer
Replies
4
Views
68
chadhamed
chadhamed
iWantToBeLoved
Replies
6
Views
140
iWantToBeLoved
iWantToBeLoved
Ovioid
Replies
14
Views
176
Ovioid
Ovioid

Users who are viewing this thread

Back
Top