• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.
K
Reaction score
435

Profile posts Latest activity Postings Albums About

  • Your code is complexity order n^2 for some parts, and n for others (not all that bad, atleast it's a polynomial time algorithm).

    Once you get some of the more complicated things down you'll see where you can make improvements to your own code. It's still pretty good considering you're 16.

    Also, I have a question :P
    Is there a scripting command for me to select the lowest level Pokemon in my party?
    Alrighty then, I don't know C as such I know nothing about those functions either (except print...because well..). I'll take your word for it and assume it's working :)
    I forgot to say you have to build it from scratch. I.E no built in functions. I'm a nice guy, so I'll show you. First you make a comparison if it's binary to decimal or decimal to binary. So:

    def func_name(number, type):
    if type == "d":
    return decimal(number)
    else:
    return binary(number)

    I'm not gonna do both, but since decimal to binary is easier, I'll do that now.

    def decimal(number, x =""):

    if ((number == 1) or (number == 0)): #base case, number passed was 1 or 0
    number = str(number) #convert to a string, don't have to, but I'm returning a string
    x = (number + x) #"append" to x, you do number + x, because otherwise it will be reversed
    return x

    temp = str(number%2) #temporary variable assigned to modulo of number
    number = number//2 #integer divide number by 2
    x = (temp + x) #you'll notice I didn't need temp, but it makes the code readable
    return decimal(number, x) #simple recursion

    def binary(number, x=""):
    Exercise to the reader :P
    This is actually very easy.
    Hmm, I don't know C, but I assume everything is the same outside of syntax. Go ahead, make sure you take into account boundary cases (and if use logic gate commands, know how they work within the language).
    Alright, create a decimal to binary converter. It should work the other way around (binary to decimal, if a paramater "D" is passed along with the binary number).

    This one is easier than anagrams, but it's good for your level :)
    Well, it's obvious that he should be making that decision. If we voted, all the fanboys would vote for their favorite lady. Also, want another warm up exercise :D? I'll give you an easy one this time :P
    Wanna bet on who's going to make leader positions?
    Also, *****es love ego.
    Well, if I didn't descend through the heavens themselves, you would've started to cry. No one wants a grown man crying.
    I don't think you realize that I cannot be contained. Not by ROMs, not be an iso, not by the Universe.
    Maybe because the location of my existence is beyond HUMANLY CONCEIVABLE Unlike many of my predecessors, I'm not limited to the confines of a mere ROM.
    Lesson on permutations:
    A word x, of length y, has y! permutations.

    ex:
    word = "cat"
    length = 3
    # permutations = 3! (factorial)
    permutations of cat:
    atc, tca, act, cta, cat, tac
    I'll give you a free lesson.

    Def function_name(paramaters):
    '''
    Doc string
    '''
    Function body
    return x #Don't need to return anything, but normally you do

    That is all a function really is.
    Well, try this:

    Create a function, given a word x that displays all the permutations of x. No repeats. Must be under 35 lines.

    I'll give you a hint, use recursion.
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Back
Top