Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 153917

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

2 votes

A simple word embedder only using jax

As @J_H pointed out in a comment, there is no more information other than your code to base these improvements upon. Thus, take it with a grain of salt. Use Direct Embedding Lookups Right now, your _ …
Linny's user avatar
  • 10.4k
4 votes

Calculate optimal game upgrades, v2

Function call overhead in Python can be significant. Code Suggestions This: Uses a bottom-up pre-computation approach for get_max_dollars and get_max_dimes before answering queries. …
Linny's user avatar
  • 10.4k
3 votes
3 answers
99 views

Determinant of matrix Python

This is an addition of my previous question Python matrix class. I've added a determinant function using Laplace expansion to my Matrix class. …
Linny's user avatar
  • 10.4k
8 votes
5 answers
1k views

Python matrix class

To prepare for my studies in linear algebra, I've decided to write a simple matrix class. This is the initial program, with functions to find the determinant and decomposition(s) to follow. I wanted t …
Linny's user avatar
  • 10.4k
2 votes

Mapping an API's setting IDs to setting names with class methods, enabling clearer utilization

Dynamic Method Creating Instead of creating a method for each setting, you can dynamically create methods based on the setting names. This makes it a lot easier to call specific settings without havin …
Linny's user avatar
  • 10.4k
2 votes
1 answer
111 views

TUI Slot Simulator

Wrote a slot machine for a larger casino TUI project I'm creating. Would like some general feedback, along with some specific things: Coloring: Currently I have three loops that are almost identical, …
Linny's user avatar
  • 10.4k
2 votes
2 answers
80 views

Dictionary additional function implementations

I've written a utility class BetterDict to help me on some of my other projects. I've implemented the &, +, and - operators. It extends from the base class dict so I can use all the builtin functions …
Linny's user avatar
  • 10.4k
2 votes

Account signup/login program in Python

Help the user! When I ran your program for the first time, I wanted to create an account, but I got an error that the file did not exist currently. Now, you wouldn't want your users to create their ow …
Linny's user avatar
  • 10.4k
4 votes
1 answer
156 views

AutoComplete-Esque Tree

I've written a tree data structure that takes in input from the user, and stores the each letter based on the previous letter in the text. I'm not sure what this is called, but the closest I can find …
Linny's user avatar
  • 10.4k
9 votes
Accepted

Optimizing a function to find the closest multiple of 10

There is a very easy solution to this problem. The algorithm is: Get remainder of number with modulo by 10 If remainder is less than 5, return number minus remainder Else, return number + (10 - remai …
Linny's user avatar
  • 10.4k
1 vote
2 answers
341 views

Find the shortest distance between two letters

I've been tasked with finding the distance between two letters in the alphabet. Below is my solution. My main concerns are if there is any shorter way to do this, and if there are any edge cases I'm n …
Linny's user avatar
  • 10.4k
2 votes

Rock Paper Scissors with file save/load

When saving a file with just a name and no specified file path, Python automatically used the current working directory. …
Linny's user avatar
  • 10.4k
2 votes

Advent of Code 2022 - Day 3

Disclaimer: These type hits are written using Python 3.11, so you might need to update your python to run with type hints. If that's not possible, simply remove them. … Reading lines from files Instead of checking yourself if you've reached the end of the file, let python do it for you def read_inputs_from_file(filepath: str) -> list[str]: with open(filepath, 'r') …
Linny's user avatar
  • 10.4k
1 vote

Text based chess game in Python

Just one thing I wanted to point out regarding magic methods. Position.abs This method can be replaced with the __abs__ magic method, allowing you to call the abs function on the object, instead of ca …
Linny's user avatar
  • 10.4k
1 vote
2 answers
294 views

Generate a string that is not present in a list

For a college assignment, I was tasked with the following (excerpt from provided code file): Find one string of characters that is not present in the list. You are provided a function that loads the …
Linny's user avatar
  • 10.4k

1
2 3 4 5
13
15 30 50 per page