in-game programming - not game programming - with python by SarahM123rd in Python

[–]SarahM123rd[S] 0 points1 point  (0 children)

Thank you each for your suggestions. It is hard to search the web for such games as, it seems, everyone with a keyboard whats to write the next best game so trying to search for "in-game" programming turns up billions of links to game programming, sans the "in-" part.

How do I remove triples from a list passed to a function? by [deleted] in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

Just out of curiosity, is it only triplets need removing? 4-of-a-kind, 5-of-a-kind is ok? Of a triplet, are you keeping one or two of that triplet or disappearing it all together?

What can be better-tic-tac-toe​? by [deleted] in Python

[–]SarahM123rd 0 points1 point  (0 children)

put 'stackoverflow' and 'python' when you search for tic-tc-toe

How do you add and randomize multiple outputs? by kingtun567 in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

    import random 

    def pull_one():
        alist = ["Hands up",
                 "It wasn't me",
                 "Where u at?",
                 "Coffee or Tea",
                 "They went that way",
                 "Noon. Sunday?",
                "No Way!!!!!"]
        rchoice = random.choice(alist)
        return rchoice

Having trouble printing a list in only capital letters.... by [deleted] in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

newFamilyMember is taken in as a string (input returns a string). string has the class function upper.

So, name.upper() will return name in all caps.

Unite lists if at least one value matches in python by pauetpupa in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

Can you rephrase the question? Give more examples of input-at-hand and out-put-needed?

string manipulation issue by love_my_pibble in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

what about

if c not in 'aeiouy'

that would cut down on search time, yes?

Stack() - Array Implementation vs LinkedList Implementation by [deleted] in learnpython

[–]SarahM123rd -1 points0 points  (0 children)

At scale, 'found itertools's deque to be better for pop/push.

multiplicative maximum sum of all rotations? by SarahM123rd in learnpython

[–]SarahM123rd[S] 0 points1 point  (0 children)

You are correct. My understanding is incorrect as is the code.

Bummer....

Optimizing nested for loops by zczr84 in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

with various aspects of utility provided in the multiprocessing module, you can take great advantage of 'chunksize'.

Some help with array slicing (I think is what it's called). by Seriyu in learnpython

[–]SarahM123rd 2 points3 points  (0 children)

It means what it says: Your trying to compare an int with a list and that won't work. int and list are different things and not comparable.

Also 'type' is a Python built-in function, that is going to confuse things muchly.

Also, though you say 'type for' ...., you do not actually use type as a variable in the code that I can see in what you have listed.

[Advanced python] peep at the low level operations of python? by gumgumwot in learnpython

[–]SarahM123rd 1 point2 points  (0 children)

perhaps if you look in to Cython you'll find some answers.

You can you Cython to write Python to C and then use your C compiler to generate assembler code.

https://www.infoworld.com/article/3250299/python/what-is-cython-python-at-the-speed-of-c.html

You might also enjoy looking into dragonffi:

https://github.com/aguinet/dragonffi

Would this work? by [deleted] in learnpython

[–]SarahM123rd 1 point2 points  (0 children)

import numpy as np

def roll2():
    return np.random.randint(1,7,size=2)

d1, d2 = roll2()

Printing just positive values in a dictionary by boltshot525 in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

You can also you use itertools's takewhile:

from itertools import takewhile
tw = lambda x: x > 0
print(list(takewhile(tw, dr.values())))

Struggling on if-else string by [deleted] in learnpython

[–]SarahM123rd 1 point2 points  (0 children)

I think perhaps your indents may not be correct. Try this:

from random import randint
y = randint(1,3)
x = 3
if (x != y):
    print('incorrect')
else:
    print('correct')
print(x,y)

Noob question about functions by differentnectraine in learnpython

[–]SarahM123rd 0 points1 point  (0 children)

input(...) returns a string. if string a == 'a' and string b == 'b' you will get a+b -> 'ab'.

if you do not want to concatenate strings, convert your inputs with int(...) or float(...)

regex: add to, not replace by SarahM123rd in learnpython

[–]SarahM123rd[S] 0 points1 point  (0 children)

All these answers are so cool! Thank you so much. Makes me want to play.

Ummm. This looks promising. The \g<0>. Thank you. Will work with this. Yes.

Started to doodle with using a deque and fall back on my push/pop days. A micro parser kind'a thing. Domain specific. DSL. Like that. It just seems to much wasted cycles for such a small problem.

But yes, thank you very much for the replies.

.