instruction stringlengths 71 95.1k |
|---|
This is my first time doing a code review so I expect a ton of criticism on this from all you professionals.
What am I doing?
I'm using python with flask to create a service for my web server. My web server has a login prompt for passing login info into the python service. The request is received as a JSON string eleme... |
I know this is horrible code. This program is for performing modeling, view and projection transformation.
The program reads input from scene.txt and outputs the modeling transformation in stage1.txt, view transformation in stage2.txt, projection transformation in stage3.txt. The files are added below.
I haven't utili... |
I am creating a database to store house points for our school running events. I would like to be able to tally all the points for the houses and it is working fine, however, I think it may be a bit verbose at this point.
Is there a simpler/better way with maybe more efficient code?
Races are stored in a races table (co... |
Please refer to this problem from Hackerrank
HackerLand National Bank has a simple policy for warning clients about
possible fraudulent account activity. If the amount spent by a client
on a particular day is greater than or equal to the client's median
spending for a trailing number of days, they send the clien... |
Challenge from Hacker Rank -
Monica wants to buy a keyboard and a USB drive from her favorite electronics store. The store has several models of each. Monica wants to spend as much as possible for the items, given her budget.
Given the price lists for the store's keyboards and USB drives, and Monica's budget, find and... |
The problem statement: The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
This code takes 9 seconds!, is there a better way?
from time import time
def is_prime(number):
for divisor in range(2, int(number ** 0.5) + 1):
if number % divisor == 0:
... |
This is the current .htaccess configuration for one of the website projects that I am working on, just as a learning exercise. This is working code and everything in it seems to be ok, My hosting company helped me set up a lot of these rules, While others where taken from various different blog posts. I'm looking to ge... |
Introduction
I've found a clever and fun thing to do after solving a n2 × n2 sudoku puzzle. I can take
a grid as such as this one and hard-code its indices as constraints to output other 4 × 4 latin squares in poly-time
Now, I took each successive row and hardcoded as indices with successive print statements.
Indices... |
I want to populate columns of a dataframe (df) by iteratively looping over a list (A_list) generating a dictionary where the keys are the names of the desired columns of df (in the example below the new columns are 'C', 'D', and 'E')
import pandas
def gen_data(key):
#THIS FUNCTION IS JUST AN EXAMPLE THE COLUMNS ARE... |
Is there any room for improvement? Your feedback would be helpful.
Problem Statement:
The four adjacent digits in the 1000-digit number that have the
greatest product are 9 × 9 × 8 × 9 = 5832. Find the thirteen adjacent digits in the 1000-digit number that have the greatest product.
What is the value of this product? ... |
I've been working on my first Python library which provides different utilities for a set of bioinformatics tools. I am looking for feedback on this module I made for parsing configurations needed for each tool run.
To give a little more context, users are prompted with a text box to edit the default parameters that a... |
I wrote this program recently to generate random passwords for myself. It works well but it's been a long time since I wrote any java and am just looking on ways to clean up the code. I'm also not sure how truly "random" the password generation is or if it is too excessive.
import java.util.Random;
import java.util.Sca... |
Project Euler #9, Pythagorean triplet is
A Pythagorean triplet is a set of three natural numbers \$a < b < c\$
for which \$a^2 + b^2 = c^2\$.
For example, \$3^2 + 4^2 = 9 + 16 = 25 = 5^2\$.
There exists exactly one Pythagorean triplet for which \$a + b + c = 1000\$. Find the product \$a b c\$.
Here is my implemen... |
I have written Pycharm plugin for integrating pycharm with tidyimports. I have followed steps mentioned in Simple Pycharm Plugin Example.
Below is the code that I have written, it works but I need this to be reviewed.
1.Tidy Import
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSy... |
I have done some code-refactoring of my console-based BlackJack in C#. Finally found a better solution to solve Ace problems (double Aces should be value 22 and third Ace should be value 1).
I still find it hard to split the UI and the program logic although I have created a static Screen class for that. Secondly, I st... |
First of all I just started learning OOP.
My priority is to make safe code. I think my code is safe, because I use GD to make a copy of the uploaded image and I use an image proxy to make sure nobody can access the uploaded file directly and it's uploaded outside of the webroot. But if I was 100% sure that it's safe I ... |
I wrote this simple code for evaluating the π using Monte Carlo method. This is the serial version:
long double compute_pi_serial(const long interval) {
srand(time(NULL));
double x, y;
int i, circle = 0;
for (i = 0; i < interval; i ++) {
x = (double)(rand() / (double) RAND_MAX);
y = (double)(rand() /... |
Consider a struct:
struct RawData{
pub a: HashMap<String, String>,
pub b: HashMap<String, String>,
}
which should be converted in a struct with more concrete members:
struct EncodedData{
pub a: HashMap<String, MyStruct>,
pub b: HashMap<String, MyStruct>,
}
and there is a function which tries to parse String i... |
As a followup to this question, I removed the Repository class and do the copy in the Folder class.
Suppose I have the following image directories under the Pictures directory of a Windows user profile:
C:\Users\Kiska\Pictures\Computers
- comp-amd-21343.jpg
- 12345.jpg
C:\Users\Kiska\Pictures\Cars
- car-ran... |
I have $fruits_arr:
Array
(
[0] => Array
(
[id] => 213
[fruit] => banana
)
[1] => Array
(
[id] => 438
[fruit] => apple
)
[2] => Array
(
[id] => 154
[fruit] => peach
)
)
And $ids_arr:
Ar... |
I am trying to implement throttle function in vanilla JavaScript. I have seen other implementations on the web, but the way I have implemented it is more understandable for myself. I was wondering if any of you experts can take a look and let me know if I am missing some thing. It seems to be working fine but I am not ... |
I created a simple quiz in HTML/CSS and plain Javascript. There are three questions with two options each, so there are eight possible combinations of answers, and therefore results. You can only pick one option per question.
This is how I am currently assigning a result to each combination in Javascript. The input is ... |
To improve my knowledge I am trying to make a bool class from scratch, or derivative of. I am using MinGW g++11 compiler on a Windows 7 laptop.
#include <iostream>
#include <bitset>
class Zeroth{
uint8_t* MEM = nullptr;
public:
const static uint8_t NullSet; // if data is declared sttic it is shared ... |
I wrote this function to count the syllables in a word using Python to complete an exercise.
The exercise's text is:
Return the number of syllables in the given word, according to this
rule: Each contiguous sequence of one or more vowels is a syllable,
with the following exception: a lone "e" at the end of a word ... |
I'm working on a vue.js / nuxt.js project, applying the Atomic Design methodology, I need to do one to set the grid layout and using CSS Grid Layout.
I already did the component, but I think I did not do it the best way ... the code is great and not very smart, lots of manual work, I would like your opinion and help to... |
I am trying to create a program to download a long list of websites using Python 3.7. By using multiprocessing for each request, my code runs much faster than when it's run synchronously.
I've added a timer to my script so I can know the execution time for the script. The one I wrote below takes on average approximate... |
Problem statement:
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and fi... |
Problem Statement:
Gary is an avid hiker. He tracks his hikes meticulously, paying close
attention to small details like topography. During his last hike he
took exactly steps. For every step he took, he noted if it was an
uphill, or a downhill, step. Gary's hikes start and end at sea
level and each step up o... |
Preamble
I want to be able to test methods which communicate over a simple exclusively asynchronous two-way stream-like interface which may underneath use any of a number of communication methods (e.g. sockets, named pipe. In order to test these, I need a memory-backed implementation, where I can read and write stuff l... |
I am working my way through "Cracking the Coding Interview" and I came up the question(3.6) to design a data structure to manage an Animal shelter with 2 animals, Cats, and Dogs such that when we dequeue the oldest animal should be removed first (FIFO)
E.g. if the animals were taken in order C,C,D,C,C,D (C- Cat, D- Dog... |
I have this list of paths:
private static final List<String> paths = Arrays.asList(
"assets/css/custom.css",
"assets/css/default.css",
"assets/js/main.js",
"assets/js/old/main-old.js",
"fonts/poppins.woff",
"favicon.ico",
"index.html"
);
That I need to create a s... |
Problem statement:
Lilah has a string, s, of lowercase English letters that she
repeated infinitely many times. Given an integer, n, find and
print the number of letter a's in the first n letters of
Lilah's infinite string.
For example, if the string s = 'abcac' and n = 10, the
substring we consider is abcacab... |
This is a simple boilerplate / template for a bigger program (I hope), either linked to a DB or including a GUI frontend using PYQT or TKinter.
This is just a little tool I wrote to keep track of my own hours.
from datetime import datetime as dt
FMT = "%H:%M"
PARSE = (f"00:00", FMT)
class WorkingTime:
def __init_... |
I have a model called Document, in this I have a method that I use throughout my website to get the full path to the specific document:
public function getDocument($documentName = true)
{
$documentName = $documentName ? $this->name : null;
return storage_path('app/' . $this->getPath() . $documentName);
}
publ... |
I have a list of items I pull from SharePoint and want to filter them in my custom list view page. So my function works exactly how I want, but it seems messy and I'm hoping someone could point me to or explain a better way of achieving this or an "optimized" version of what I did.
I'm using a for loop with if to compa... |
Here is the question from the book of Mark Newman-Computational Physics Exc 5.1
a) Read in the data and, using the trapezoidal rule, calculate from them the approximate distance traveled by the particle in the x direction as a function of time. See Section 2.4.3 on page 57 if you want a
reminder of how to read data... |
This is my first large project, a text based fighting simulator.
It is very clunky, do you have any ideas on how to make the code better?
and how to make the code not get printed at once
from __future__ import print_function
#Zack Ennen 1/12/19
import random
import time
overheadmod = 3
slashmod = 0
jabmod = 1
def... |
An alternative to std::vector<std::function< >> which uses tail recursion to optimize calling the functions sequentially. I'm using this on a real-time DSP thread. Because the code does single-sample processing, dispatch overhead must be minimized, since the functions (which are usually rather simple) are called 44k ti... |
Is this a good compromise between readability and verbosity? Are there any bugs, additional error checking, or extraneous code as well?
// Generate permutations of array of n..n+x
// n must have no repetitions, sorted smallest to largest
// Steinhaus-Johnson-Trotter algorithm
// Results are not in lexicographical order... |
I wanted to measure the performance of Concurrent Dictionary vs Dictionary+Locks in a multithreaded environment. So I created my own SyncDict class of type<int,int[]>. Whenever there is a key match, it adds the int[] array value to itself, it also locks the whole dictionary with ReaderWriterLockSlim while updating the ... |
I've been thinking about the AsyncLazy<T> class that Stephen Toub and Stephen Cleary present in various resources such as this. I am trying to find a way to integrate cancellation with AsyncLazy<T>. Microsoft has a version of AsyncLazy<T> in their Visual Studio 2019 SDK that offers a GetValueAsync(CancellationToken) ... |
This is my third (and hopefully final) time re-writing this program. It was recommended I use Pathlib and it simplified my code, it's easier to read and understand than the first two monstrosities.
I also changed the way it functions, instead of the user providing a text file, the user creates a directory called Repos... |
This is a very simple read-copy-update (RCU)-inspired synchronization class:
#include <atomic>
template<typename T>
class RCU
{
private:
std::atomic<T*> curr;
std::atomic<T*> prev;
std::atomic<int> readers;
public:
RCU()
: curr (new T),
prev (nullptr),
readers(0)
{
}
... |
I've been working on a script which configures newly imaged computers (power settings, installed apps, etc)
This is what I have so far:
echo off
cls
SET WINDOW_WIDTH=100
SET WINDOW_HEIGHT=42
mode con: cols=%WINDOW_WIDTH% lines=%WINDOW_HEIGHT%
Set SOURCEPATH=\\networkpath
Set JAVAPATH=%SOURCEPATH%\Java\
@echo [TASK]... |
I have the below method that is responsible for generating and sending a MailMessage using a SmtpClient object:
public static void SendEmail(
string subject,
string body,
bool isBodyHtml,
List<string> emails,
List<string> ccs = null)
{
if (emails == null)
{
throw new ArgumentNull... |
When working on a large codebase, I often need to switch between deeply nested directories quickly. To make my life easier, I came up with a bookmarking script.
#!/bin/bash
bm_list() {
for i in "${!BOOKMARKS[@]}"; do
echo -e $i'\t'"${BOOKMARKS[$i]}" ;
done
}
bm_go() {
cd "${BOOKMARKS[$1]}"
}
bm_a... |
I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have probability p of being heads.
The algorithm is pretty simple, we loop through the N coin tosses and update the probabili... |
Is this code a good test for a testable Clojure code?
(ns github.amexboy.v2-test
(:require [github.amexboy.v2 :as t])
(:use [clojure.test]))
(deftest test-module-name-default
(let [
repository-root "/some/path/to/git"
project-root "/some/path/to/project"
services [{:input "service|origi... |
I am working on a project that needs to take a .bdf font file and turn it into a Numpy array. I am using the code below to turn the bitmap for the font into a numpy array. It currently works, I just feel that it's nearly impossible to read but I'm not sure if there's a better way to do it.
How the current code works:
... |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example, 342 (three h... |
I want to get table names and column names from queries in a dataframe. The dataframe is like this:
Date Query
29-03-2019 SELECT * FROM table WHERE ..
30-03-2019 SELECT * FROM ... JOIN ... ON ...WHERE ..
.... ....
20-05-2019 SELECT ...
and I run function to that dataframe to get tablename from th... |
I'm one month into self-learning Swift, and I would like some advice to improve my coding skills.
I have listed 2 situations that I think I need to improve. I'd like some feedback focusing on my use of static variables for changing data between ViewControllers and subviews.
1.0 Image 1 shows the app flow (Left = HomeC... |
Update: further succinct versions below (inspired by Haskell)
Quick sort in JS assuming an immutable array:
const reorder = (arr, pivot) => {
let larger = []
let smaller = []
let equals = []
for (let i = 0; i < arr.length; i++) {
if (arr[i] < arr[pivot]) {
smaller.push(arr[... |
I was messing around with ssh and decided to write a python program that scans for any connections that aren't from the system, then terminates them. It works well for many connections from my iMac to my MacBook. A more in-depth explanation of the program is written at the top of the code. I'd appreciate feedback on an... |
This Server handles clients communicating with each other. Because I was not willing to actually give every client a name, they are named by their socket's file descriptor. This is my first application which actually is able to communicate using the INET. It is also my first really multithreaded application.
#include <... |
My code detects if a cycle is present in a graph using Union find algorithm with Weighted tree analysis and path compression.
It works and I have included test cases.
# check cycles in graph using union find
# weighted tree balancing added
from collections import defaultdict
class graph:
def __init__(self):
s... |
I write a lot of TODO's but I never keep track of where they are.
This program will search through files (and recursively through folders if needed) and find any TODO comments and their line number.
The details will be printed to the screen and a file will be generated in the folder which is a csv of the files and TODO... |
We're having a small debate in work about the following piece of code:
private string GetNextFileName(string fileName)
{
int index = 1;
string nextName = $"{fileName}_{index}.png";
while (File.Exists(nextName))
{
nextName = $"{fileName}_{++index}.png";
}
return nextName;
}
Is there a... |
This program opens a file and prints the text out to the terminal 1 character at a time and at a predetermined speed using time.sleep()
Simple and maybe, if you think like me, pretty cool..
GitHub
from time import sleep
import sys
BLINK = 0.2
chars_in_line = 50
def open_file(fn):
with open(fn, "r") as f:
... |
This code computes the Minimum Spanning Tree of a given graph using Kruskals Algorithm.
It works successfully and I have provided test cases within the code.
I would like feedback on code efficiency (Choice of ds and functions/function size) and anything else to improve the code (Aside from pep 8 compliance, that is so... |
As a practice exercise, I implemented a cellular automaton (Conway's Game of Life) in python (with help from this tutorial).
I am very curious, if this code follows common best practices and I am wondering how to improve the code in terms of performance and readability.
import numpy as np
import matplotlib.pyplot as p... |
Issue
Our API returns two formats JSON and this SQL table format. I'm not sure what it is truly called so I'll give a few examples below. Like all API responses, it can be a list or a single response but it is always in the same format. I'm creating a utility function for this SQL table format to be converted into a JS... |
As I explain in my rant, I have been searching for a replacement to hand-crafted POSIX-make-compatible makefiles to manage my dotfiles (which use symlinks). I decided the simplest thing to do would be to roll my own.
Requirements:
written in a language likely to be immediately available on major platforms (I have chos... |
A triangle of numbers path maximized using a greedy algorithm. It's not the most efficient way since I'm a beginner this is the best I could do.
I need your feedback on how to make it better in terms of maximizing the total. It works in a way that it chooses the highest value of the adjacent numbers in the next row. No... |
This is a simple utility, intended to sit on the desktop for when needed, that does the simple ROT13 encoding and decoding.
I am used to coding in VBA, and I am interested in more .Net idiomatic coding styles.
Public Class Rot13Decoder
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txt... |
as a beginner in Python I made a rock, paper, scissors game and was wondering if my code was a bit weird and could be simplified???
print("Rock, Paper, Scissors")
def rps():
userInput = input("Please enter your choice: ")
userInput = userInput.lower()
if userInput != 'rock' and userInput != 'paper' and userInput != 's... |
In my application I have an Interface IEmailNotification that represents an Email and the concrete implementations have nothing to do with MailMessage class so to be able to send it through SmtpClient I used an adapter to let the communication between SmtpClient and IEmailNotification possible and the job of this adapt... |
What kind of algorithm wold solve the following problem from https://www.ohjelmointiputka.net/postit/tehtava.php?tunnus=junar ?
I have been given a positive integer n. Take the n first positive
integers 1 to n and permute those to some order. At the beginning you
can swap the position of two numbers. Each round yo... |
A new function based version of the code from this question as suggested by @Hlib Babii
I write a lot of TODO's but I never keep track of where they are.
This program will search through files (and recursively through folders if needed) and find any TODO comments and their line number.
The details will be printed to th... |
I need some suggestions on how to approach this. I want to allow users to create sections of website. The code so far is working but since I am new to back-end I feel like there is better, more elegant way to approach this. I am open to any approaches, as long as the code is kept as concise as possible.
The user clic... |
Your task is to print all unique ways to climb a staircase of length n where, from each step, you can take steps of size x where x is an integer value from an array
For example: if you want to climb a staircase of length 3 and you can move [1, 2] steps from each stair, the output should be
[1, 1, 1]
[1, 2]
[2, 1]... |
I have this code but it brings repeated results. I want it to generate without repeating the letters
private char[] lettersArr = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
public char generateLetter()
{
return lettersArr[rdm.Next(lettersArr.Length)];
}
The "L" is independent
Result from my code{Lw, Lk, Lk, La}
R... |
I am trying to add two numbers in the form of linked List and return their result in a Linked List as given in https://leetcode.com/problems/add-two-numbers/
Question:
You are given two non-empty linked lists representing two non-negative
integers. The digits are stored in reverse order and each of their
nodes con... |
After finishing my ds and algorithms course I wanted to implement what I've learned through the semester so here is my try for Linked lists, both regular (one way) and double one (two way).
code:
from node import ListNode
class LinkedList():
_length = 0
''' Init linked list '''
''' double is boolean '''
... |
anyone can provide some suggestion about my answer for the questions
987. Vertical Order Traversal of a Binary Tree
Given a binary tree, return the vertical order traversal of its nodes values. For each node at position (X, Y), its left and right children respectively will be at positions (X-1, Y-1) and (X+1, Y-1). R... |
I am aiming to compute the Hurst Exponent of a 1-D signal time series in Python. For now, I have one existing function hurst(sig) which returns the Hurst exponent of sig as a float. Unfortunately, the code runs very slowly even for signals with only ~7500 data points. My main concerns are:
Calculate the computation... |
So I had previously posted this question and asked for some feedback regarding my (now) header-only logging system and figured it would be a good time to go back to the changes I made it and see if it can be further improved before starting a larger project.
#pragma once
/*
Header only logging system.
Should be thread... |
I am implementing the Bellman equation for utilities, in a grid environment as follow. It is an example on Chapter 17 of Artificial Intelligence: A Modern Approach 3rd Edition.
There are some math bended in, I would be extremely appreciate if you can verify the mathematical accuracy of my implementation, but if it tak... |
I am writing a program that allows me to find all possible pairs of square numbers including duplicates. We can also assume the array elements to be of positive integers only.
e.g an array of {5,25,3,25,4,2,25} will return [5,25],[5,25],[2,4],[5,25]
since 25 is square of 5.
Currently, I am using a nested for loop to fi... |
I am sharing my Bowling Game Score Kata made in Java, it is available for whoever wants to code review it.
I appreciate any comments.
class BowlingGameScore {
private int[] pinsKnockedDown = new int[21];
private int currentRoll = 0;
void roll(int pinsKnockedDown) {
this.pinsKnockedDown[currentRoll... |
I use the Laravel API and want make messy code cleaner.
I have a form for registering business and businessOwner.
And stylist who is working under this business registering from same function.
And which case best to use there? if statements or Switch case statements?
public function businessRegister (Request $request)... |
I wanted to experiment with a reusable thread pool that allows to add tasks and execute them repetitively. After going through,
https://github.com/progschj/ThreadPool and another Stack Overflow post I came up with the implementation in https://github.com/dragsu/CPPThread.
The main bit of the code is,
ThreadPool.h
#prag... |
I`m writing a function for small pygame program. The ideas is that I have a 500 pixels square screen and I want to place 5 objects per row with the size of width and height in random order and I need a function to generate and store coordinates.
from random import randint
def gen_coords(width=50, height=50, side_of_... |
I've recently started going through the Head First C book. I'd like to get up to speed in terms of writing good, idiomatic, modern C. I have read the first few chapters of the Modern C book too but found Head First to be a better introduction to the language.
The code below is for the first, bigger, arduino assignment... |
I had a need to group the same dataset in several groups. So instead of repeatedly query the dataset, I made an extension that could do it once. The caveat is, that the result is materialized in dictionaries, because I didn't managed to find an way to avoid that. Maybe you can?
public static IDictionary<string, Diction... |
Today I have dealt with logging in PowerShell as well as with the different streams and the pipeline. Unfortunately, none of these solutions really met my needs.
My requirements are:
I need to output information from PowerShell to a file log.
The file log has a predefined structure. So it's not enough to just redirect... |
I have a JavaScript function to categorize data by their "styles" attribute, and store the key-"unicode" pair.
Here's my current code:
function processMetadata(metadata) {
let regular = {}, solid = {}, brands = {}
for (let icon in metadata) {
let styles = metadata[icon].styles
let codePoint = me... |
I am trying out some Go code examples (while coding a private project) to get more "in-depth" knowledge about the language.
I have come across an exercise from the Go Tour website about displaying correctly an IP number, making use of type method and the Stringer interface.
I found two ways to achieve the goal but I am... |
I developed this CSS Masonry.
It works with a CSS grid with grid-auto-rows: 1px. There is a JS recalc script in there, which recalculates the grid-row-end values (with the span prefix). Apart from that, the layout is totally up to the Browser's engine.
(The --raster property is used to set vertical raster on or off. Wi... |
I'm working on a segment of code where it runs a number of tasks and then combine individual task results to construct a complete task result object, there's no concurrency involved so it's purely a question of the best use of class inheritance/pattern.
Below is the skeleton of the code I've written, it loops through I... |
I've implemented C++'s std::includes algorithm in Python, so that I can use it to efficiently implement a Scrabble "can I make this word" function:
def word_can_be_made_from_rack(word, rack):
return set_includes(sorted(rack), sorted(word))
Here's the implementation, with some test cases:
def set_includes(haystack,... |
I have Ajax function with a callback which fetches all the Patient data however I have some perfomance issues and trying to figure out what it might be, does anyone have idea? That's my Code
var patient = new Array();
function sync(arg, callback){ //ajax result
$('.loader').show();
$.ajax({
method: ... |
About this 2D Arrays HackerRank problem.
The task is to find the maximum sum of a region in a 2D array. Specifically, it is to find the maximum sum of an "hourglass" region, defined as a 3x3 square without the middle entries on the left and right sides, as shown by this mask.
1 1 1
0 1 0
1 1 1
Here's my solution.
I'... |
I've decided to start working on a budget application for the purposes of getting started on Rust. In its current form this program takes given expenses and income and tells the user whether they have a surplus, a deficit, or if they are breaking even. I will add more functionality to this program as I move along in th... |
Recently, I have appeared for coding exercise to design the Shopping Cart which should have following features:
handles barcoded (like Chips) and non-barcoded item (like Banana
400gm)
Can add item, remove item, increment & decrement quantity of
item.
Supports 2 For 1 offer for BarCoded Item.
I have completed the ex... |
I made this little function for flyweighting any type that has operator<. I followed the convention of make_unique and make_shared with make_one. Not sure if that's the best name.
// Create a single instance of an object, using
// operator< to determine equality.
// Note that we take a value instead of a constructor
//... |
I'd be grateful for a review of my AJAX request. If I have taken the correct approach here and especially any security concerns!
I am creating a Purchase Order system for my manager (as part of an apprenticeship I am doing).
There is a select html element where a supplier can be selected. I also have a button to trigg... |
I am making a program that transfers files from one client to another. Right now I am just working on sending the file to the server and then later I will work on transferring it to the other client.
Here is my client class*:
public class Client implements Runnable {
private Socket socket;
private InputStream ... |
For learning Rust I decided to make a 3D .obj viewer. I wrote a simplified OBJ parser without materials that only supports triangles.
Considering I'm completely new to Rust and don't really know anyone who's good at idiomatic Rust I figured I'd ask here :)
use std::fs;
use crate::geometry::*;
use crate::object::Object... |
I am trying to write an integer field in Python with the following attributes:
Minimum
Exclusive minimum
Maximum
Exclusive maximum
Multiple of
Value
Basically, given the constraints and the value, the class will have a validate method which will return the errors if they occur. If the minimum is not null, then the ex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.