instruction stringlengths 71 95.1k |
|---|
How would I go about making this script much faster? Essentially it reads from a file and the slowest part is populating the words. In the words file there are over 100k words and I was looking for a way to speed it up since this script is going to be used to populate the database with over 200 languages.
import os, d... |
I recently created this Income Tax calculator based off your filing status (Single, or Married Filing Jointly) and which tax bracket you fall into for the 2020 tax year, taking into account the Standard deduction. I know the code is a little robust, but the math checks out as compared to several other tax calculators. ... |
I gave an attempt at reinventing the wheel and recreate list methods using my own Array Class to broaden my understanding about lists. I would like advice regarding efficiency, and in implementing negative indexes, since my code only works for positive ones.
class Array:
def __init__(self, List=[]):
self.a... |
So I'm writing a hobby programming language interpreter in C. It works but has serious performance problems.
According to gprof, the following function takes 30% of the running time (after excluding the time spent in the profiler itself). 75% of the 30% is spent only inside the function itself, not including its called... |
While using a JOptionPane, recently, it struck me as odd that the Java Library doesn't seem to have any standard icons for the dialogs. So I decided to create an enum for them. Instead of mapping the icons directly to the enum, I used a map.
import javax.swing.*;
import java.util.Map;
public enum MessageIcons {
... |
I've implemented a singly linked list in Java and would like a code review as I am still learning
and this is a different method I've found to do this. The logic is still fuzzy as well to me and
writing it out took ages and I'm sure I may have messed up a bit but still have time to mess
around with this.
Instruc... |
I have a headers dictionary value being passed to one of my constructors and based on that dictionary value I am extracting individual headers I need and setting all my variables.
public Tester(IDictionary<string, StringValues> headers)
{
int textId = 0;
if (headers == null)
{
ProcId = Generat... |
Is it good practice to give a value to a variable, then change its value immediately after, like that for example?
def get_user_id_from_username(username):
user_id = db.execute("SELECT id FROM user WHERE username = ?", (username, ))
for row in user_id:
user_id = row[0]
return user_id
Basically,... |
I'm learning Rust and looking for better/cleaner ways to list all file names that do not start with filter, given a pathname as a parameter.
fn list_files(&self, pathname: &PathBuf, filter: &str) -> Result<Vec<PathBuf>, Error> {
fs::read_dir(pathname).map(|read_dir| {
read_dir
.f... |
I have this code:
def apply_all (fs, x):
def reducer (acc, f):
(seq, x) = acc
next = f (x)
print((seq + [next], next))
return (seq + [next], next)
return [x] + reduce(reducer, fs, ([], x)) [0]
print(apply_all(f_list,4))
It works perfectly to accomplish... |
(See the next iteration.)
Introduction
Suppose Evil Lottery Inc is interested in not paying millions of dollars back to players. They gather the drawn lottery rows first, after which they mine rows that does not appear in the dataset.
The Evil Lottery Inc's approach is this: it first builds a radix tree of the drawn l... |
I hope you can help with improving my code. I am defining a function which draws out elements of a certain mass, one by one, from a distribution constrained by the function imf(), until I have used up all the mass given to the function. The code takes a very long time between 1 minute to 45 minutes depending on the inp... |
I have written a simple Tic Tac Toe game using some ASCII art. Is there anything I can do to improve upon the logic and structure of the program?
"""A basic command line tic tac toe game"""
import os
import sys
gameBoard = [['' for j in range(3)] for i in range(3)]
displayBoard = [[' ' for j in range(46)] for... |
I am remaking a very obscure old game called Rival Realms.
The full source is here if you're interested.
I come from a Java background so C++ is still fairly new to me.
I recently performed a refactor to move all the textures and sprites into one class. The intention is that I will create a Resources instance when th... |
Idea
Consider the following snippet:
import inspect
from pathlib import Path
def path_relative_to_caller_file(*pathparts: str) -> Path:
"""Provides a new path as a combination of the caller's directory and a subpath.
When creating a Path like Path("resources", "log.txt"), the containing Python script
has... |
I wrote a program which visualizes a doubly linked list in C++/SFML. The code is working as intended, and does exactly what I want. Could you give me some feedback / criticism on some do's and or don'ts?
This Node class represent a node within the doubly linked list. It inherits both from sf::RectangleShape and sf::Ver... |
As I have recently been selected to participate in my country's final preselection to the IOI -- this took me aback -- I have decided to get a bit more serious about competetitive programming.
The Rock-Paper-Scissors Tournament is an old question form the Waterloo Programming Contest 2005-09-17, available on kattis.
Wh... |
I feel like my code has way too much for what it is, this is my first project and would love to learn some tips in making code more efficient for the future, any other tips for my code here would be greatly appreciated.
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
in... |
I am rather new to python and am porting my R functions into python. I have written the functions below and the primary function is called thetaMax. That function minimizes a likelihood function or optionally minimizes a posterior distribution, depending on the option selected by method. The function works exactly as i... |
I am learning Vue after working for some time with Angular and I'd like to hear experienced programmers concerning the implementation of my Progressive Bar service (in Vue it's called Plugin).
The idea behind it is to have a solid service which is responsible for the progress bar indicator.
I've got there a component w... |
I am a recent graduate in computer programming and failed so far to get an internship or a job in the business so I am trying my best to learn from online source.
I am trying to implement a dir-like command on Windows, going through a folder and list all files and folder.
What I've learned is to avoid using namespace ... |
I'm a beginner python programmer..I recently started reading a python book called: "Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming"...And I found an interesting challenge...The challenge is to copy the elements of the list to another list and change the elements to make them be... |
Is my approach to insertion Sort in Python efficient?
What can be improved efficiency wise?
def insertion_sort(array):
sorted_array = []
for elem in array:
insertion_index = len(sorted_array) #insert at end of list by default
for elem_sorted in sorted_array:
if elem_sorted > elem:... |
Here i have javascript code where is 'animals' object and 'people' array of objects. User selects the data from select box and accordingly table fills with selected data(which is array of objects) and when user wants to reset everything to the state before selected data, user just clicks 'backtozero' button.
the code i... |
I am working on this project where I like to PreserveIds once inserted into the database. The id are auto incrementing and I return them once the data in inserted. I like to know if there is a better way using inheritance vs using a for each loop and checking if the value is 0?
class Program
{
static void ... |
I know I never have to reinvent the wheel, but I did because I need speed performance. Also, I need these features:
introspection or metaprogramming
actuate like API backend
private variables interpolation
embedded Perl code inside template like text template
avoid in the minimal no core modules
work with eval in env... |
**
Write the beginnings of a class for a Table implemented with a Binary Search Tree. (done)
Then create a Table class with only one data member for the root. (done)
Provide the following methods:
a constructor that produces an empty table (done)
a method to insert a given item, (done)
Create a separate class for a N... |
So, I am trying to make people interested in my compiler project (in the early stages of development) by making some simple and clear programs in my programming language. Here is my implementation of the Pascal's Triangle in it. Do you think it's clear? If so, what do you think might be unclear to an average programmer... |
I am pretty new to DDD, so any help/ideas will be appreciated. I will explain my initial design and problem below.
The user can ask the system to generate products proposal, proposal is basically something, which has some ownership and set of products, which can be renewed if system evolves, new products should be auto... |
I decided to make my own light DI container.
I know about Zenject, etc. I wanted a very light analog.
I'm concerned about a few things:
1) is it correct to use struct instead of class for reference in this context?
2) every time you access _player.Reference, there is a check for null (in the UnityEngine.After the destr... |
Assume $ is not the browser. Now have to implement $, it will take a string, which is a query, it will use the querySelector to select the element. (Reference: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
$('text')
Now implement jquery like functions addClass and removeClass. (Reference: ht... |
I had an assignment to create a circumference calculator in Java which I've already submitted. I would like feedback on my code.
The program works as intended, but I am not sure whether it's spaghetti code or not after realizing that I only called one method in main which calls all of the other methods. Here is the cod... |
I am trying to create a robust, generic way to parse a bar delimited usr files, now I can read the file in and separate it by | then index with integers.
However, this always feels very rigid in its design and I want to try to avoid it.
What I would like is a way to map any bar delimited file to JSON or at least a Pyth... |
I want to create a list of the different response headers I get when querying an URL, I succeeded in doing this this way:
import requests
l= []
for _ in(5):
a = requests.get("https://google.com", allow_redirects=True).headers['Origin']
if a not in l:
l.append(a)
This is readable but I feel like this i... |
I have the following code, that defines:
A polynomial struct with some useful functions.
The newton Raphson algorithm for polynomials.
and calculates sqrt(2).
What can I improve?
There are some things I am unsure about myself:
Is size_t a good datatype for my purposes? I needed to be very careful when writing the lo... |
Below is a React useEffect hook I used in my application, basically what it does is:
data is an array for objects such as {round:number, date:dateString}.
When the application starts running, data will be an empty array, whenever round gets updated, the useEffect() will be called:
if the data array is empty, we update... |
So, a long time ago, I've made a program that prints all the permutations of digits of a number in AEC. Now I have refactored it a bit, and I would be interested in what you think about it.
;Advanced example: implementing the permutation algorithm.
AsmStart
debug=0
macro pushIntegerToTheSystemStack x
{
... |
My code has mutiple checks for if staments which I think could be optimized into few lines if I take id into varibable. To give some background I want to disable a button based on length of characters in input box. But the thing is out of two buttons only one will be rendered at a time.
Below is my working version of ... |
I'm looking for input on how to improve a powershell script I wrote.
Im especially looking for suggestions, that I might be able to apply to future projects as well. Like (anti-)patterns I'm not aware of and such.
General things like "too many small functions" vs "use more functions" or "better collect all info in a ce... |
I have an almost-JSON document in a file named versions.json. It looks like this:
{
"package_a": {
"sha_darwin": "6d94f041d06670977b2e5604b827f7e8bd46a1d200d14545ba75c17314ec12ad",
"sha_linux": "6daa0fae252dc32e0af6ad89119555b277456349c55dfc9f276ee83718c6a9e2",
"url": "https://github.com/someone/package_... |
Below is a method used in my application that reassigns a vehicle to a depot. Is there a better way of handling these conditionals than the boolean statements I have in place?
Some things to note are Vehicle and Depot are classes and Depot has an ArrayList of Vehicles Inside it. depoNo is set earlier in the program in... |
I wrote a NavigationBar component in React, using hooks, react-bootstrap, react-i18next and css. Now the component works as I expect it, but the code seems ugly. (I'm new with hooks)
Features:
It's transparent at the beginning but if we scroll down it will be "dark" (from react-bootstrap)
If there's no enough space to... |
I wanted to compare radix_sort to quick_sort for values limited to 0..127 so I implemented this :
void bin_radix_sort(int *a, const size_t size, int digits) {
assert(digits % 2 == 0);
int *b = malloc(size * sizeof(int));
for (int exp = 0; exp < digits; exp++) {
// Count elements
size_t co... |
Hi I've written a web scraper for tracking gold price. Can someone please review my code and suggest improvements. It gets the price of gold from a specific url then stores the price against date in a db file further makes a plot then uploads image to firebase. Further this image and gold price is sent to your whats-ap... |
The piston2d-graphics crate provides a trait, Graphics, which allows easy access to some graphics primitives. This would be a nice, easy-to-use API, if it weren't such a pain to end up with something that implements Graphics; for a time, there wasn't even a consistent set of crates that let you get one (that rendered a... |
I have made the solution for this question it is based on backtracking. Can anyone suggest me how to make it work faster, I haven't practiced backtracking that much, although my solution seems to work. Please check it out
class Test {
static int ans = Integer.MAX_VALUE;
static void f(char[] a, String s, in... |
I am replicating this blog post in Python.
The blog post shows that even if you know future stock market bottoms, only buying stocks when the stock market is below future stock market bottoms provides only a modest edge of 22%.
The code below replicates the blog post's result (approximately, I use different data).
Howe... |
I'm writing integration for a project, but our framework doesn't provide any ability to inject dependencies, so I've written tests with a unit testing framework (GTest) and used a mock (GMock) in an odd way simply to leverage its behaviour obverving functions. I have a python script to run it, it all works, but, is th... |
Let's say we train a model with more than 1 million words. In order to find the most similar words we need to calculate the distance between the embedding of the test word and embeddings of all the 1 million words words, and then find the nearest words. It seems that Gensim calculate the results very fast. Although whe... |
I'm happy to present my first Android project, which collects market index data (three Asian indices) and fires a notificaiton every Wednesday, Thursday and Friday at 7:30 AM displaying the data.
I've applied to Computer Science in Lund, Sweden. I am looking to improve my Java through Android development (which I've fo... |
Based on this code found on github and the advice given to me on stackoverflow I made this code for the xor in c.
#include <stdio.h>
#include <string.h>
void encryptDecrypt(char *input, char *output)
{
char key[3] = {'K', 'E', 'Y'};
for (int i = 0; i < strlen(input); ++i)
... |
Background
I worked at a community center where everyday one of my coworkers would spend 20ish minutes trying to organize the day's schedule. The facility had three rooms: The Great Hall, The Club House, and The Sub Cellar. Each of these rooms were open at different times in the day, and when he was organizing the sche... |
Robot Name
Manage robot factory settings.
When robots come off the factory floor, they have no name.
The first time you boot them up, a random name is generated in the format
of two uppercase letters followed by three digits, such as RX837 or BC811.
Every once in a while we need to reset a robot to its factory setti... |
I have a dictionary that I need to iterate efficiently. I already know about the keys beforehand which I need to extract from values dictionary object.
What's the best way to do that? I have around 20 entries in dictionary object as of now.
Below is how I am doing it but wanted to see if we can optimize it by just gett... |
I have a page with multiple menus. Once I hit a certain window width, I use CSS and jQuery to turn them into accordions. I also check the screen size when resizing so the accordions don't stay hidden if the user resizes the window. Since I have two window widths I need to adjust for, I am using two click events to open... |
A stab at Project Euler Problem 11: Largest product in a grid
"""
In the 20×20 grid below, four numbers along a diagonal line
have been marked in red.
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03... |
I'm very new to programming and I don't feel confident about the readability of this program.
This program gets the text you copied then extracts phone numbers and email addresses in the text. Once those are extracted, you can paste them anywhere(Eg: notepad).
Are there any ways that I can improve this code? Any sugge... |
I have an Outlook Module that contains the VBA Code below. The VBA code opens an Excel Add-In called TMAPAddIn.xlam, which then displays a User Form. I exported the Module and gave it to other colleagues so that they can import it to their Outlook, this allowed them to make a custom button on their Outlook Quick Access... |
Introduction
Basic Idea
The Sardinas-Patterson algorithm determines (in polynomial time), whether a code is uniquely decodeable or not.
Example
Code 1 is not uniquely decodeable, because "100" could be "baa" or "bc".
Now let's apply the algorithm to code 2:
It will be checked, whether a codeword is another codeword's... |
const propsSelector = (props:any) => {
let newProps: object = {}
Object.keys(props).forEach((prop) => {
if (typeof props[prop] !== 'undefined') {
Object.assign(newProps, {
[prop]: props[prop]
})
}
})
return newProps
}
const selectedProps:any = propsSelector(pr... |
Another code for exercism, It is to convert Vec of u32 from one base to another base. Please help to make it more idiomatic, Also if this type of question is welcomed here or not.
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidInputBase,
InvalidOutputBase,
InvalidDigit(u32),
}
pub fn convert(number: ... |
Suppose I have a list with N sorted dates and M non-overlapping sorted periods with start date, end date (inclusive), and a tax rate for example. I have to make an efficient algorithm retrieve all tax rates for all dates. If there is not period including this date it should raise an error.
Given the brute-force approac... |
I wasn't able to find a standardized source for a working example of Merge Sort.
Each learning site had a slightly different take on the algorithm implementation, disregarding the bottom-top implementation.
I wrote my own code for this but unsure if it's the most efficient or if efficiency can be improved?
Any other sy... |
I am in the process of converting this code predictor.py located here to tensorflow v2 with Python 3.7. I want to do this conversion part by part. So from the refence repo, I've been going through this example.
For this block:
def resBlock(x, num_outputs, kernel_size = 4, stride=1, activation_fn=tf.nn.relu, normalizer... |
(See the previous (initial) iteration.)
This time, I have substantially reduced the usage of the final and this keywords. Also, I have dropped java.util.(SortedMap/TreeMap) and substituted it with a simple hash table/array, which dropped the running time of the mining phase by half:
Seed = 1588247737638
Data generated ... |
I designed the code and it works quite well for images of lower res. However my program takes a lot of time and ram to display higher res images (occupies 2GB RAM for 4k images and takes 20 minutes). This program currently only processes files in .png format.
#------------------------------------
import matplotlib.pypl... |
I'm trying to wrap my head around JavaScript Functional Programming.
I have created a very basic script that creates a new elements and appends them to the DOM.
If anyone could share any feedback, or great resources on the subject, that would be awesome.
Where does this style of programming lend itself best? Web Develo... |
I need to understand if the way I am modelling data in a Django application is correct. The idea is of a news site that has sources, authors and articles.
I want:
Source to have many Article
Author to have many Article
Article to have many Author
Does the below model do this correctly? I am worried there is a loop ... |
I am a beginner in programming. And I am learning python as my first language. I went on to do some challenges on HackerRank and stumbled upon this problem. The problem goes like this:
There is an array of \$\ n \$ integers. There are also \$\ 2 \$
disjoint sets , \$\ A \$ and \$\ B \$ each containing \$\ m \$
int... |
I am trying to work around the problem Pass-through for IAsyncEnumerable. The best I have so far is to return IAsyncEnumerable<IAsyncEnumerable<T>> instead of IAsyncEnumerable<T>, then to flatten it. I'm not thrilled about it, so I'm asking here for suggestions.
The underlying goal is to allow one to get portions of o... |
I have written a Java program that converts an integer to String digit by digit and concatenate them together using the + operator without touching the Stock Java API library.
I like to have feedback on my code. Where do I need to improve. If I need to deduct something. So please criticize me. Thank you.
import java.ut... |
The permutation matrix is represented as a list of positive integers, plus zero. The number indicates the position of the 1 in that row, e.g. a number zero would mean that the 1 is in the right-most position².
My first attempt is as follows, together with a printing function to help assess the result.
It seems too con... |
A tkinter widget for reading/editing .ini files
Dynamically generates a form based on the contents of the passed .ini file.
Why make this?
I made this as a backend for a larger project; I wanted my user to be able to manage persisted settings in an .ini file without having to find the file or use an external editor.
I... |
I have a questions as to the proper way to structure the code below.
This snippet of code is used within a socket class which is intended to be a high performance socket. Many data handlers subscribe to this sockets OnData event to handle different types of data. Ideally, I'm trying to kick the data handlers off in a t... |
Description
Simply take a JSON file as input and convert the data in it into a CSV file. I won't describe the functionality in too much detail since I have reasonable docstrings for that. As you can see, my solution is not memory efficient since I'm reading all the file into memory.
I'd like to improve the performance ... |
I am working on a custom bot UI with Microsoft Bot Framework. I found a template to create a floating widget with Materialize, however, it was for the "embed" version of webchat UI. My version uses some Divs to add additional elements (header, transcript button). These elements were in conflict with the Materialize CSS... |
I wrote 2 different implementations to find gcd of 2 big numbers. The simple one using Euclid's algorithm always beat the Binary algorithm in term of speed. Is my implementation of Binary algorithm bad?
a = 5**100 - 1
b = 5**120 - 1
def gcd_euclid_recursive(a, b):
if b == 0: return a
return gcd_euclid_recursiv... |
The program asks the user to enter values for items bought, the price of each item, the GST rate, the QST rate. The program calculates the subtotal based on these inputs. For every invalid input entered by the user the program will prompt the user to re-enter that value until it is a valid input. Items bought must be b... |
It is something a bit complex to explain here, but the code bellow takes a 128-bit number and converts it into a permutation matrix, a beast which I have already faced before. The matrix is represented as a list of numbers. Each number is a row.
The way I've found to do the mapping number->matrix was to convert the n... |
I'm new to Clojure but I already know about functions and lists, so I decided to implement Prime Factors Kata solution. For any natural number the function should return a list of all its prime factors, e.g. for 15 it should return (3 5).
It turned out that to implement a stack safe function I needed to use loop and re... |
Introduction
I'm new to Pandas. I'm trying to write a vectorized converter for the situation described in What is an efficient ways to parse a bar separated usr file in Python . All code presented here is my own and the data are synthetic.
For these data:
HeaderG|Header1|Header2|Header3
A|Entry1|Entry2|Entry3
B|Entry1|... |
I'm implementing the closed form of Fibonacci numbers.
I figure using a custom data type I can do so without leaving Integer.
It isn't more efficient than the "standard" approach as I couldn't figure an efficient way to calculate the power of my custom number type.
But sticking to this algorithm I would be interested ... |
I started learning Python and wrote my first program. This is a console game based on guessing the number. Can you take a look and tell me if I'm doing it right or give me any advice? Here is the code: https://github.com/theriseq/GuessTheNumber
Is it a good way of doing this or can I simplify it?
Thank you.
main.py
fro... |
There are many related questions and answers but mostly with JQuery and/or from many years ago.
I prepared a version myself, and my question is whether this is currently (2020, hence ECMAScript 6 or similar) an optimal way to preload images in pure JavaScript. It appears to work (note the tests), although not all edge-... |
Below is a case class and a companion object with a method putRecord which adds a new row into Hbase using Put API. This code has some repetitive parts. Is there a way to abstract away the repetitive code
case class HbaseRow(_id: Option[String], field1: Option[Array[String]], field2: Option[Array[String]], field3: Opti... |
Task
I want to be able to generate the permutation matrix that splits a 1D array of consecutive numbers (i.e. even, odd, even, odd, even, odd, ...) into a 1D array where the first half are the evens, and the second half are the odds. So (even1, odd1, even2, odd2, even3, odd3) goes to (even1, even2, even3, odd1, odd2, o... |
When you use React I think that each page uses the useState and useEffect hooks:
Initiate a GET of data from the server, and render the page immediately without data
Then (asynchronously) receive the requested data from the server, and set the data into the state which re-renders the page
Each page has a different se... |
Firstly, I wrote standard snake game, then I decided to increase difficulty and made game with various snake number. My main point was to try the curses module, the second - to create game with OOP architecture, maybe apply some design pattern.
Questions:
Is curses usage optimal?
Should I split game() function some wa... |
I have an action bar component. It helps do the CRUD operation for different component. Its only job is emit events. The emitted events are listened by the caller component. I am using a switch case logic to emit different events. An input is passed to this component as @Input() itemType: string, which holds the stri... |
Here I go again. I have been finding a fairly common pattern in business logic code. And that pattern looks like this: int sprocketCount = datastore.GetSprocketOrders(parameters).Distinct().Count(); I decided I wanted to build DistinctCount() (again from "first principles") as Distinct() will create a second enumerable... |
I have a small problem with the code below. Although it executes the task perfectly, It's supposed to be more "short" and compact according to the assignment feedback. I was wondering if someone can please help me change my code from its longer version to a more short version that completes the same task...
from math i... |
I have a list of objects and I would like to see which ones are the most common. It is easy to find the or a most common object using python's Counter, but I haven't found a simple way to find all of the most common objects. The code below is working but I would guess there's a better way to do this.
from collections i... |
I am building a MySQL to Realmdb converter app.
I use Entity Framework to deal with MySQL, so below is the code of one of my model classes. I don't want to have multiple classes representing the same object, so instead of creating separate models for EF and Realm, I am using same model for both ORM's.
The question is,... |
The great feedback I got on my first post on Code Review made me wary of code repetition. This code does what it is supposed to, which is to create restrictions for a sprite's possible position on the screen.
Is this a neat looking solution, or can it be considered code repetition?
public void move(int x, int y) {
... |
For practice purpose, I wrote bubble sort in C++ two styles: C-ish and modern C++ compliant. I would like to have your comments on any point on these implementations.
Sorting.h
#ifndef SORTING_ALGORITHMS_H
#define SORTING_ALGORITHMS_H
#include <utility>
#include <vector>
//#include <iterator>
#include <algorithm>
na... |
I have a legacy piece of code and trying to simplify it. It's very tightly coupled. The problem is one method is called from another and other from another and so on this chain continues. Would someone please help me out to make it better by reviewing it or suggesting any approach or design pattern to handle this type ... |
I have class:
export class DayValue {
date: string;
status: string;
}
and statusToPointsMap:
public static map: Map<string, number> = new Map([
['COMPLETED', 100],
['FAILED', -100],
['SKIPPED', 0],
]);
I want to create function which calculates avg result per given period of time, ie:
[
[
"2... |
I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique unrelated to performance is welcome as well!
Here is my main method which gets a string as an input and returns an integer that... |
I'm a Rust newbie. As a pet project, I decided to implement a simple multi-threaded HTTPS proxy server in Rust which uses the CONNECT protocol. I have tested the code below using my browser.
use std::io::prelude::*; // Contains the read/write traits
use std::net::{TcpListener, TcpStream};
use std::str;
use std::io;
use... |
Hi I am pretty new to programming and I would like you to give me some feedback about my code, how does it look, what could be better. Thank you.
A = []
B = []
C = []
PegDict = {'A': A,'B': B,'C': C} #Would it be better to use a two dimensional array?
discs = int(input("Podaj ilość dysków: "))
for i in range(discs, 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.