instruction stringlengths 71 95.1k |
|---|
Possible improvements I see are take lastdigit_num and implement arr_{lastdigit_num} since the math behind this is common for most (integers with cyclicity 4 or 2 common to them) integers and reduces repetitive if statements.
For example if num = 23423, then lastdigit_num = 3 and arr_{lastdigit_num} is directly linked ... |
I just completed my second python project which is a chess game.
At the moment I have included a mechanism for pieces to lock onto a square based on the nearest square when moved. And I have introduced a mechanism to take pieces. I haven't yet checked for legal moves but I plan on doing that soon.
If anyone could sugge... |
This is the code that joins the list with another one. Also makes use of a static utility to makes use of hashmap for id and name.
I've added null checks to safeguard the code with NPE.
The key purpose is to make this readable. Could someone help code review this?
public List<PGRatingResponse> collatePGRatingsbyVendor(... |
I am working on some claims data, where I have features such as
The descriptions of the columns are: (A) the year of claim, (B) who's the insuring company (C) whether the vehicle is driven, (D) circumstance code (E) delay in raising claim (F) Vehicle age (G) Damages (H) Savings.
Damages and Savings columns are empty: ... |
Here is my example structure:
.
├── App.jsx
├── index.js
└── src
└── components
├── Button.jsx
└── Header
└── Header.jsx
Question:
Should I name Header.jsx inside Header folder? (I personally prefer this way insteade of Header/index.jsx because I though it would be better to identify i... |
I do research and compare different numeric models to each other. Therefore, I want to easily switch out the numeric models in my simulations and evaluation code.
Some models work in cartesian coordinates, some in cylindrical coordinates. Some don't have a z-coordinate (yet), since they are primarily two-dimensional; s... |
The following code works fine to generate an array of 6 random values (or however many are specified by iterations). I'm wondering if there's a more concise way than using a while loop to achieve the same result.
const seedValue = 31;
const iterations = 6;
let i = 0;
const results = [];
while (i < iterations) {
re... |
Create a Time class.
Time is on my side
Specification
Basic attributes: hour, minute, second and day (default is 0), + getters, + setters (using a decorator)
If you try to initialize an incorrect value of seconds or minutes, i.e. greater than or equal to 60, raise an exception from your own WrongSeconds or WrongMinut... |
If the validation in RestController fails, I need to handle MethodArgumentNotValidException and provide an errorMessage, that contains
info about all rejected fields of passed object. If any rejected field has @JsonProperty annotation with non-empty value, then I need to replace field name with this value in errorMessa... |
I am learning Rust and I would like to know what is the idiomatic way of writing a function that could run into multiple error types. For instance, in the function get_account_with_creds I am trying to return a struct AccountForResponse if the credentials match. The function could possibly run into a database error, so... |
So I'm currently learning about networking between a client and a server and I decided to try to write my own client and server.
I implemented a way of receiving data and it goes as follows..
The server expects a packet that is structured like this.. [ packetSize(2bytes), [data] ], so the first two bytes is the entire ... |
So far I have this:
const rand = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
// rule:
// if an even number of nodes are touching
// the center node, then flip
// else skip.
// rule:
// for the start nodes (top row),
// they are randomly turned on and off.
const cellularAutomaton = [
... |
This code represents logic used to retry failed calls to a crypto exchange:
let retries =
[
TimeSpan.FromSeconds(1.)
TimeSpan.FromSeconds(3.)
TimeSpan.FromSeconds(5.)
TimeSpan.FromSeconds(10.)
TimeSpan.FromSeconds(30.)
]
let rec retryAsync (retryAttempts: TimeSpan list)... |
I have created a rust program to create https://mail.tm accounts, but I think there are things I could have done better. Are there things I can do to improve performance? Are there any unnecessary things I have done? I am new to rust, please give examples of what you mean when you suggest improvements :) Thank you.
use... |
While learning about python tkinter, I decided to make a digital clock:
from datetime import datetime
import tkinter as tk
from threading import Thread
import time
class clock():
def __init__(self):
self.display = tk.Tk()
def start(self):
def get():
self.display.geometry("... |
All this does is safely and reliably opens, writes to, and closes the file. Yet there are so many gotos and the code is quite verbose. I am not even sure that all of what I am doing is necessary.
int WriteConfig(void) {
FILE *ConfigFile;
RetryOpen:
if (!(ConfigFile = fopen(Config, "w"))) {
if (errno == ... |
I want to share a little app I made that logs tracks I play on Spotify (running in the background on my DigitalOcean droplet server). It uses Spotipy, a lightweight Python library for the Spotify Web API. With Spotipy you get full access to all of the music data provided by the Spotify platform.
Any suggestions for imp... |
This script solves a simple problem:
Input two strings differ one character or zero characters in length, return true if the following conditions are met:
1, They must start with same character and end with same character.
2, One string can be obtained by changing one character or zero characters in the middle of the o... |
This is a follow-up of my last question over here.
Following @Reinderien's suggestion in that previous post, I've managed to furnish my web-scraper code as follows:
fudan.py
from dataclasses import dataclass, asdict
from itertools import count
from typing import Dict, Iterable, Tuple, List
from bs4 import BeautifulSou... |
Problem statement:
I have the following access log, get the count by timestamp(hh:mm) and sort the count based on minute. And write it into the CSV file.
access.log:
172.16.0.3 - - [25/Sep/2002:14:04:19 +0200] "GET /api/endpoint HTTP/1.1" 401 80500 "domain" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/2002082... |
For a job in company I had to do a code assignment. My assignment performs all the required tasks needed to be done. But after one month the company provided me a feedback and said that we have reviewed your exercise, very sorry for the delay. Unfortunately, while working, the structure and readability of the code are ... |
I'm currently writing a game of life with small extra features but I ran into a problem - in my first try i decided to use simple list of Cell objects:
class Cell:
def __init__(self, x, y, is_alive):
self.is_alive = is_alive
self.x = x
self.y = y
self.will_be_alive = False
se... |
This is a follow-up of my question over here.
I have been working on my web-scraping techniques by trying out different approaches and rewriting code for a handful of online databases.
I've recently seen for myself that requests is definitely way more efficient than selenium, as demonstrated by the scripts below. reque... |
I've found pretty simple problem on Numberphiles channel: suppose we have a recursive function
$$
\begin{equation}
\begin{split}
f_0 &= Z ^ 2+ C \\
f_i &= f_{i-1}^2 + C \; | \; i = 1 \dots
\end{split}
\end{equation}
$$
What values of \$ Z \$ and \$ C \$ should be \$ |\{ f_i | \; i=0..5\}| = 6 \; \cap \; f_5 = Z \$ so... |
I am working on a project, neurodecode, which uses a logger based on the logging library. As I am not very familiar with logging, I don't know how to further improve this aspect of the project.
The project is constructed as:
neurodecode
|_ __init__.py
|_ logger.py
|_ folder1
|_ script1.py
|_ script2.py
...
The... |
I made simple scripting language (interpreter) in C and now, I want to make my code better.
Here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE (1 == 1)
#define FALSE (1 == 0)
#define FUNCTION_NAME_COUNT 2
#define FUNCTION_ARG_FUNCTION_NAME_COUNT 1
#define MAX_FUNCTION_NAME_LENGTH... |
So I've just started teaching myself C++ a few weeks ago and I've decided to work on an implementation of Tic Tac Toe, using the command line. The program allows a human to play against a bot, which simply selects a random location on the board. I'm requesting a review because I'm not sure about a few things that I've ... |
I'm writing a (compile-time-)fixed-width unsigned big integer. To implement subtraction, a subtract-with-borrow primitive is required. When efficient platform-specific implementation isn't available (e.g. x86_64's _subborrow_u64 intrinsic), it needs to be implemented in Standard C++.
I've been able to come up with the ... |
This code scrapes www.oddsportal.com for all the URLs provided in the code and appends it to a dataframe.
I am not very well versed with iterative logic hence I am finding it difficult to improvise on it.
Code:
import pandas as pd
from selenium import webdriver
from bs4 import BeautifulSoup as bs
browser = webdriver.... |
This project is the natural extension to my attempt to make a templatedgenerator coroutine. This time, I tried what I called a "task" (may be not the real term for this) : it generates a value or not, and is recursively awaitable. It can call other coroutines which each pause will also pause the main coroutine. It was ... |
I have two lists, I need to make another list with the same elements than the other lists. But elements on this list need the next sequence.
list1[0], list2[0], list1[1], list2[1], ... and so on
for that, I made this code.
List<string> list1 = new List<string> { "rabbit", "dog", "cat", "shark" };
List<string> list2 =... |
These are the scripts I wrote to generate valid ngrams, the output will be filtered manually then used in Markov chain style pseudoword generation.
You will need PowerShell 7 and gcide_xml to make these scripts work.
I wanted to find an English corpus/dictionary library for Python, and didn't find one with enough numbe... |
I've tried to make a little library in C++, to gather all useful and necessary functions. I wrote the code(in one file, to make it more portable). Unfortunately, it works on Windows only.
#pragma once
#ifndef NEWCPP
#define NEWCPP
#include <iostream>
#include <windows.h>
#include <string>
#include ... |
This is a simple practice problem. The task is to write a function getLR that receives an Integral, n, and returns a list representation (LR) of n. For example: 73847 -> [7,3,8,4,7]. Negative numbers return the LR of the absolute value, for example: -837 -> [8,3,7]. In the following code I use three helper functions ge... |
Any help with my code. I think it's kind of hard code where I want to extract links from a page and download them.
It's going to scrape some links from websites (but the Scraper function that I've written is hardcode) and download the videos if they exist and I'm sure it's not good at all and it's more of a smell code.... |
I have a list of files that conform to a template like this:
XXX_{project}_{variation}---XXX.html
and
XXX_{project}_{variation}.html
The variation is not always present, so there are also files like this: XXX_{project}---XXX.html and XXX_{project}.html
What I want to do is to check if all these files have the same pr... |
I have some code I've written which I need a review of (if possible) as I know I have a bug somewhere. Most likely due to my (lack) of understanding of some concepts in ElasticSearch and Spring.
For context:
I have a simple Spring boot API which allows students to add their college projects. These projects are stored i... |
I share an algorithm that I have written myself. It is useful for incrementing any digit of a decimal number. That way, a conversion to decimal is not necessary.
Please excuse the mistakes. I am learning assembler and x86 architecture. I am sure that it is possible to improve and optimize it (thank you). This code obvi... |
This is only one of the first apps I've built with Node, React and TypeScript. I was wondering what could be made better. This is at this point the best I've been able to come up with, but I'm not sure if there's code here that could be difficult for another developer to read, could be improved, or anything else really... |
I am writing a Settlers of Catan server in Haskell for fun. Currently I am passing around state manually. I want to learn more about the State monad and want to incorporate it into my project.
However, my GameState has multiple data constructors that I pattern match on to yield different functionality. Three of such da... |
As a part of coursework, I had to build an UPGMA tree from a given distance matrix and a list of species names. As a beginner/intermediate in python I saw this as a good opportunity to learn about classes. The code is as follows:
"""
UPGMA - Unweighted pair group method using arithmetic averages
Takes as input the dist... |
This code calculates the probability of a runner finishing 3rd and it works like expected. I'm pretty sure though that is woefully inefficient. How could this code be transformed in a much more cleaner and performance efficient way?
My focus is the nested fors and and the if handlings.
def Trd(mylist=[]):
third=[]... |
Problem
A function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a grid w blocks wide, h blocks tall and s possible states.
Equivalency is defined as above: any two grids each with same state where the actual order of the rows and columns do... |
This is a follow-up question for Two dimensional bicubic interpolation implementation in C++ and Two dimensional gaussian image generator in C. Based on user673679's answer, another file image_operations.h is created for those non-member helper functions for image operations implementation. Moreover, the two dimensiona... |
I have written some javascript code for a multilanguage site. The code works great but I feel like I have a lot of duplicate code. I was wondering if someone can explain how I can make this simpler or minimized. I have tried to use a forEach(function (item, index) but it does not seem to be working.
This is the origina... |
Put together a RadioMenu class that can use a Enum to generate a Single-Selection Radio Button Menu. My main question is about whether there's a way to remove the need to pass in the Class of the Enum to the generateButtonsFromEnum() method. Otherwise, would appreciate any general pointers on ways to improve this syste... |
I have a function which checks for a profile name and determines if it is in a tagged profile name.
def check_profiles(request):
try:
# get all individual profiles
profiles = Profile.objects.all()
# get all individual tagged profiles
tagged_profiles = TaggedProfiles.objects.all()
# ids to exclude in... |
In order to reduce time complexity, instead of loading (and then dumping to use it for later) the whole file into an array (It would be O(n) with n=number of lines), I have saved it as array into a PHP file and included it
index.php
<?php
include "english.php";
$test = new English("false_friend.php");
?>
english.php
<... |
In a recruitment process, the company gives me a project to do in react native. I finished all the tasks. But company gave me a feedback and said that your project was good, but you did not apply best practices for using rest api. So we are not proceeding further with your application. I used redux with rest api. Below... |
This is a scraper written to do most of what had been attempted by another user in this question:
How can I optimise this webscraping code
I did the rewrite because I felt bad that the new user didn't get an opportunity to talk about their code (even though the off-topic closure was correct). Also the site, as with so ... |
This is my first C program. The code works, however I'm not yet familiar with how to write idiomatic C. How should I improve this?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define UNCLICKED 0
#define CLICKED 1
#define FLAGGED 2
#define NOT_BOMB 0
#define BOMB 1
struct piece {
char user_state, gam... |
Below is my implementation of a persistent red black tree in Rust.
I have a few questions about potential improvements.
Currently the data and nodes are stored in referenced counted pointers. Is this the best way to do it?
On a similar note, the pattern matching statements for the balance functions are quite verbose be... |
In the code below, the primary purpose of class MyRNG is to create a single method getMyRandom() that will return a random number from any of several very different distributions and generators. The actual distribution and generator will be determined by information read from a file, although in the test program below,... |
This is a follow-up of my question over here.
I am extending the functionality of @Reinderien's suggested code to enable the automatic looping through of pages in the search result.
I've mainly modified the final search() function (originally cnki_search) and added a number_of_articles_and_pages() function to the Searc... |
You can only kill off a given number of heads at each hit and corresponding number of heads grow back. The heads will not grow back if the hydra is left with zero heads. For example:
heads = [135]
hits = [25,67,1,62]
growths = [15,25,15,34]
Then you can kill off hits[i] heads but growths[i] heads grow back. My approac... |
Sum of 2 numbers, represented with linked lists, where digits are in backward order or forward order.
Backward order Example
INPUT:(7->1->6) + (5->9->2) = 617+295
OUTPUT: 2->1->9 = 912
Forward order Example
INPUT:(7->1->6) + (5->9->2) = 716+592
OUTPUT: 1>-3->0->8 = 1308
I'm starting with this method. I'm giving it ... |
This is my implementation of the classic "Hangman" word-guessing game.
Class LePendu :
public class LePendu {
// Variable
public static int NB_ERREURS_MAX=10;
static ArrayList<Character> playerGuess = new ArrayList<Character>();
static ArrayList <String> wrongGuess = new ArrayList<String>();
stat... |
I am building a WPF (Windows Presentation Foundation) application. And I'm trying to use the MVVM (Model–View–ViewModel) design pattern. It's fascinating and rewarding, even though it seems overly complex at times. I am new to programming, and I've only really dabbled in WinForms (Windows Forms) before.
I've been throu... |
This is a Python 3 script that statistically analyzes 105,230 words with a total of 913,935 characters, its results will be used for pseudoword generation purposes.
You will need this file for it to run.
This script analyzes the following things:
1, How many words contains each of the 26 letters.
2, How many times ea... |
Second day coding so I'm new to this. I have made this simple calculator but I repeat the code in order to use the previous answer in the next calculation. I've been trying to simplify it but I can't seem to figure it out. Whatever I try breaks the code. Any feed back helps.
Here is the code
# Beginning calculator code... |
Let's say I'm implementing a method that calculates the number of hours I'm billing a client. I only work in blocks of K hours:
public static int billing(int hours, int k) {
return hours / k + (hours % k != 0 ? 1 : 0);
}
Is it possible to simplify this? I often find myself writing this same pattern of code but it ... |
I'm not sure if the problem here is how I'm wording the question or going about finding an answer, but I have what I think is a relatively trivial task: getting fact-check claims from the Google Fact Check API, saving them in a database and then using that database to get the counts of fact checked claims & who claimed... |
This is a simple Java program I made that takes in any number, and when it gets to 0, it returns the quantity of the numbers, the min, max, sum, and average of the numbers. Are there any ways how I can make the code more readable or improve the performance?
import java.util.Scanner;
public class Stats {
public sta... |
I'm starting to learn React/NextJS and find the way to write conditional CSS very ugly compared to VueJS. I'm curious if someone could look over this code snippet and guide me in the right direction towards a cleaner way of designing my React code.
<Link key={link.text} href={link.to}>
<a className={`border-transpa... |
I am currently developing a terminal-based listview control, that uses ncurses for rendering.
The main goal for the listview was to be intuitive, performant, and reusable for other projects.
An example, is shown below:
listview.c
#include "listview.h"
#include <ncurses.h>
#include <string.h>
#include <stdint.h>
#inclu... |
I need to know if there is any way I can optimize my code so that it does not use 0.6% of my total memory - which is approx. 22.4MB. This is a really small script that runs for as long as the raspberry pi is ON. 22.4MB for this basic, simple, light code is too much. If less or no optimization is there, then please let ... |
I wrote this simple app for creating a Stock Exchange platform.
It is written with a flask framework.
My main concerns are regarding the user_page route which feels too long and not DRY enough,
But on the other hand, I can't find a pythonic elegant way to clean it. I would really appreciate your comments.
I am not sure... |
This is a follow-up of my group of scraper questions starting from here.
I have thus far, with the help of @Reinderien, written 4 separate "modules" that expose a search function to scrape bibliographic information from separate online databases. Half of which use Selenium; the other Requests.
I would like to know the... |
This is my first post. I'm switching from Python to Java and I've been practicing on HackerRank for some time. Today I solved this problem in which you have to count the pairs of occurrences of the numbers in the ArrayList, symbolizing socks, and you have to count the pairs.
Can this be optimized in any way? Maybe I'm ... |
I have a table containing two versions of results for some predictors, one by human labeling and the other by machine predicting, and I want to calculate some metrics.
CREATE TABLE log_table (
`id` VARCHAR(5),
`version` VARCHAR(15),
`result` FlOAT
);
INSERT INTO log_table
(`id`, `version`, `result`)
VALUES
(... |
I'm learning Vue and I would like an opinion to improve the form validation that I have implemented. This is my component:
<template>
<section class="p-0 d-flex align-items-center">
<div class="container-fluid">
<div class="row">
<!-- Right START -->
<div class="col-md-12 co... |
I'm trying to replicate std::array but with modifications that I should put the private data member to the public so the class template fixed_array will be a structural type that will be qualified as a non-type template parameter.
My goal here is to use the string literals and brace-init list as non-type template param... |
I want to compare 2 images using numpy. This is what I have got so far.
One of the outputs should be a white image with black pixels where pixels are different.
I am sure it's possible to make it more efficient by better use of numpy, e.g. the for loop can be avoided. Or maybe there is a function/package that has imple... |
I'm trying to write a function that tries to read a config and if fails, creates a new one and writes to the file "settings.ini". This feels really chunky and not particularly concise. Is this the supposed way of reading a configparser file?
from configparser import ConfigParser
def getSettings(self):
try:
... |
In my application, I only show users their own data. For that, I need to know in the backend, which user is requesting data. I use the username for that and therefore, I need to send the username as part of the GET request.
The method in question, located in MVC-controller:
public async Task<IActionResult> Index()
{
... |
class Person {
constructor(firstName, lastName, email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
returnObject() {
return { "firstName": this.firstName, "lastName": this.lastName, "email": this.email };
}
json() {
return JS... |
I'd like to plot an animation of Lissajous curves using Python and matplotlib's animate library. I really do not have a lot of experience with Python, so rather than performance increasements, I'm looking for best practices to improve (and/or shorten) my code.
The following code produces a .gif file when evaluated as a... |
Basically I made this completely useless program that generates triangles inside triangles. Its not perfect yet but my question is about the structure. I am generally happy with it but I want to know if it could have been better. There are six files and here they are.
main.cpp
#define OLC_PGE_APPLICATION
//Link to pix... |
I am building a little helper for the card game Bridge. The aim is to generate a "hand" of 13 randomly-dealt cards, and then to run various calculations on the hand to help a player with the "bidding" phase of the game. (I'm hoping knowledge of Bridge is not required for this code review!)
You will see that after creat... |
I've written a C# program to generate a random maze, and then draw that maze in the Console mode using box-drawing characters, e.g. ─ │ ┌ ┐ ┬ ┼ etc. It works fine, as below, but I'm not convinced that the code used is remotely efficient, or that it couldn't be done better.
I have a Maze class with the following member... |
Background
This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained
You can only kill off a given number of heads at each hit and
corresponding number of heads grow back. The heads will not grow back
if... |
For context, I wrote a function, get_servers, for the game Bitburner which is usually played by writing JavaScript code. Instead, I used PureScript to write the function which is an implementation of something like the breadth-first search algorithm to get a list of all the servers in the game:
module Main (main) where... |
Basically, I'm trying to create a generic way to check if two shapes are colliding.
I think this is kind of a "double-dispatch" problem, but I'm unsure if there is a better way to solve it in Typescript / Javascript. This is the best I could come up with. Just assume the static helper functions are defined.
abstract cl... |
import axios from "axios";
import { useEffect, useState } from "react";
import "./styles.css";
export default function App() {
const [count, setCount] = useState(1);
const [titles, setTitles] = useState([]);
useEffect(() => {
async function fetchData() {
const URL1 = `https://jsonplaceholder.typicode.c... |
My hobby is Unix-like operating systems.
Recently I began writing my own sel4-based Posix compliant OS. Here's the code for internal signal handling functions which presents a kind of backend to help implement functions such as do_kill or do_sigsuspend.
I would like to know what you think about code quality, and any p... |
I have been working on this project for a little bit and it's my first major python program. It downloads information about current and upcoming weather warnings for Ireland and displays them with tkinter. Would be grateful of suggestions or critique!
https://github.com/Sn4u/met-eireann-status/tree/master
met_eireann_s... |
I have a class that is importing a CSV file into a Pandas DataFrame. However, this CSV has a multiline header that changes length seemingly at random. Sometimes it is 27 lines, sometimes 31, sometimes something else. It is just dirty data in so many other ways as well, look at the header separator.
As a result, the cod... |
I'm a beginner in programming and I'm figuring out what is the best approach for my mini e commerce site project.
My current approach is
{% for i in item %} <!-- where item = database fetchall -->
<h3> {{i[0]}} </h3> <!-- product name -->
<p> {{i[3]}} / kg</p> <!-- product price -->
<form action = "/send" method = "po... |
This is a problem-solving code for LeetCode 1632.
Given an \$m \times n\$ matrix, return a new matrix answer where
answer[row][col] is the rank of matrix[row][col].
The rank is an integer that represents how large an element is
compared to other elements. It is calculated using the following
rules:
The rank is an int... |
The following command series is used to gather every bit of valuable information from Exodus trackers. The ultimate goal would be to get this all into one jq statement, and if that's not possible then to just simplify as much as possible.
I'm aware of the sub and gsub functions available in jq, and tried to use them in... |
This is my function that uses recursion to recursively delete a directory. I like my way of skipping entries . and ...
But should I be casting the name lengths to unsigned int because I am quite sure there will not be file paths longer than 4 gigacharacters? Or is storing the result of strlen in any type other than siz... |
Here is another one of my simple beginner projects I did in my free time in under 30 minutes, a Rock, Paper, Scissors game in Python against a Computer (random module). As usual, I would like to know if there are any improvements/suggestions/criticism/feedback that you guys have about my code. Thanks in advance.
import... |
I've written a simple text-based (can be run in terminal) snake game in python. This is a personal project and also one of my very first projects in python. I appreciate any advice or suggestion that make my code more efficient and professional.
main.py
from game import Game
if __name__=="__main__":
game = Game()
... |
Playing on leetcode coding problem: "Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses."
I realized that my understanding of Python was not so good. I always thought that: since list are mutable object they are kind of passed by reference; so i always try to make a ... |
I just want your opinion about that code! :)
import random
class Error(Exception):
def __init__(self, error=None):
self.error = error
def __str__(self):
return str(self.error)
class HashTable(object):
def __init__(self):
self.length = 20
self.keys = []
self.table ... |
I have this function:
import re
def check_and_clean_sequence(sequence, alphabet):
"""
Function to check and clean up all ambiguous bases in a sequence.
Ambigous bases are bases that are not in the sequence
alphabet, ie. 'ACGT' for DNA sequences.
Inputs:
sequence - a string represe... |
I created a fairly simple hangman program as a little side project. Could you please tell me of any improvements/suggestions/criticism/feedback that you have about my code? Thank you in advance.
import tkinter as tk
import turtle
import string
from functools import partial
from draw_hangman import drawHangman
from rand... |
I am inserting data from a dict type object into three different tables in the SQL database. I am using Sqlalchemy as my ORM. My code is working but I think it is not very readable, is it any way to make it more readable or maybe simpler? I am using a lot of try except because I don't want my code to fail in the middle... |
For a Metal application, I would like to create and initalize texture object globally so it will not have to be optional, and will already be ready to use once viewDidLoad is called. To do this, I need a MTLTextureDescriptor with the correct values inline. It has to be inline because I do not want to create a global de... |
I'm currently trying to implement a c shim which sits between the open function from the c standard library and a program.
the shim should transparently write all file paths being opened to a log within a directory defined by the environment variable IO_SHIM_PREFIX
I have this working relatively well, but in order to a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.