instruction stringlengths 71 95.1k |
|---|
I'm trying to test and implement an exercise on receiver method from here.
This basically states the following:
Cars start with full (100%) batteries
Each time you drive a car, it covers the it's speed in meters and decreases the remaining battery percentage by its battery drain.
If a car's battery is below its batt... |
Hello fellow developers,
I have written a function called max_product that aims to find the product of the largest two integers in a unique array of positive numbers. However, I believe there might be room for performance improvement in my current implementation. I would greatly appreciate your suggestions and feedback... |
I recently developed a hangman game with HTML, CSS and JavaScript and I would like to get your feedback and tips to improve it. The goal of the game is to guess a secret word before 6 incorrect guesses are completed.
I would like feedback on how I can improve the readability, efficiency and overall structure of the cod... |
I have recently been exploring React and Spring Boot, and I would greatly appreciate your feedback on a practice application that I have developed. The application consists of a Spring Boot backend utilizing an H2 database, along with a ReactJS frontend implemented in TypeScript. These layers communicate with each othe... |
I hope you will tell me tips to ask good questions regarding checking my code. Here it's the code and thanks in advance!
const checkPalindrome = str => {
str = str.toLowerCase()
let reverse = str.split('').reverse().join('');
return reverse === str ? true : false;
}
console.log(checkPalindrome('Madam'))... |
C++23 is going to add multidimensional array subscript operators to the language, yippee!
Alas, I have not yet come across a way to adapt them to types where the number of dimensions is templated, so I came up with this, using variadic templates, fold expression and concepts:
#include <cstddef>
#include <concepts>
// ... |
I have a csv file that looks like this:
,age,department,education,recruitment_type,job_level,rating,awards,certifications,salary,gender,entry_date,satisfied
0,28,HR,Postgraduate,Referral,5,2.0,1,0,78075.0,Male,2019-02-01,1
1,50,Technology,Postgraduate,Recruitment Agency,3,5.0,2,1,38177.1,Male,2017-01-17,0
2,43,Technolo... |
This is a follow up question to Date Checking in C++
I have these two function prototypes:
void CovidDB::add_covid_data(std::string const COVID_FILE)
void CovidDB::add_rehashed_data(std::string const COVID_FILE)
both essentially do the same thing except that one re_hashes the data before logging it to a .log file. I've... |
Using Sieve of Eratosthenes, I created a function that returns a vector of primes up to given limit.
fn prime_until(limit: usize) -> Option<Vec<usize>> {
if limit <= 1 {
return None;
}
// limit + 1 because of zero based indexing
let mut nums = vec![true; limit + 1];
nums[0] = false; // zero... |
Background: I'm planning to call different endpoints of a website's API quickly, but the usage policy implies that I may only make five calls in a second. I can't rely on the calls taking 200 ms on average, so I wrote the following.
The plan is to have any other threads that want to call an API submit a bulk of Callabl... |
I'm currently learning brainfuck as a challenge for golfing, and I'd like a code review to make sure I'm understanding things properly. For starters, here's my snippet:
[
The purpose of this program is to add two
predetermined values together and print the result.
For this program the values 15 and 20 have been
... |
I have created a BigFraction alternative to BigInteger and BigDecimal. Name for this class is not quite hammered down yet.
I recently finished a class that taught us about OOP and documentation. We learned about Preconditions and Postconditions, LSP, State Representation, and more. I built this project to show (some of... |
See code from this question about the advantages of Enums.
def print_my_string(my_string: str, mode: Literal['l', 'u', 'c']):
if mode == 'l':
print(my_string.lower())
elif mode == 'u':
print(my_string.upper())
elif mode == 'c':
print(my_string.capitalize())
else:
raise Va... |
The following code is my lab which focused on implementing any 3 known sorting algorithms out there. Since the professor gave us a choice to pick any of them and compare their execution time I chose Quick Sort, Selection Sort, and Heap Sort. I had the option to choose bogo or bubble sort but I think that's boring and d... |
This is a Part2 to this question where the task was to plot the data that I got from my time measurements.
I've never worked with Jupyter Notebooks (ipynb) since most people I talked to were critiquing (in a bad way) them.
A lot of repetition is noticeable, that's because I haven't gotten the hang of how the code block... |
The following code implements a package, which can be used to execute functions in the correct order based on dependencies.
Example:
package main
import (
"my/setup"
"fmt"
)
func main() {
// a depends on nothing
a := setup.Add(func() { fmt.Println("a") })
// b depends on a
b := setup.Add(func(... |
Here I have implemented a priority queue, with the addition of the raise_priority (also known as reduce key) operation. The reason I have effectively reimplemented std::priority_queue is because the STL implementation does not have a raise_priority operation, nor can it be implemented (No access to the underlying conta... |
Purpose:
I want to accept the value of a checkbox or database field and make a Value Object out of it. The input could be any of y, Y, n, N, Yes, No, yes, no, 1, 0, true, false, or NULL.
In the case of NULL (from the DB), I want to be able to distinguish between 'no' and 'no choice has been made', so __toString() repo... |
In multiple parts of my program, user input needs to be validated and categorized. As these "validation trees" can get pretty unwieldy, I've started splitting them out in different functions, for example like this:
from enum import Enum, auto
class InputCat(Enum):
INVALID = auto()
HELP = auto()
SELECT = a... |
The complete script works as expected. I am able to download and verify the files. If the file is all ready present verification is retested and downloads if necessary.
I'm in the process of teaching myself bash/sh scripting. Is there a cleaner way I can implement the following section of sh script?
The files reside at... |
someone can help me with this code? I'm trying to compute the average speed every 100 m, starting from a list of spans that contains [distance, time, avg speed].
This is what I've tried to do, and seems to work pretty well (can you confirm?). The problem is that the code is a little bit bulky, and I would like to strea... |
This is my first Go project. I've written a CLI app to provision a database cluster on docker containers. Since it's a distributed database, you can configure per-node services. For example: to configure a 3-node cluster (version 7.1.4) with kv on node1, query/index on node2, and analytics on node3, run the following... |
This was simply practice to touch on somethings I have learned. I have also tried to take into account Pep 8 formatting practices to my best ability and applicable advice from my previous posts. It was difficult to keep the indents to 2 levels in. Constructive criticism much appreciated.
main.py
from time import sleep
... |
I'm writing my own "standard library". It relies on nothing but syscalls, so I've had to make my own implementations of everything, including getline (renamed to getl).
The functions used, though renamed to avoid annoying lint messages, should be pretty self-explanatory; zalloc is calloc but with malloc's signature, cr... |
I have recently become interested in simulating logic circuits because of a electronics class at school. I have created a functioning simulator for logic gate circuits in Python. My implementation works, but I was wondering if it could be optimized or improved in any way? The project code is too big to fit in this ques... |
Looking to get some feedback on a simple non-multithreaded circular buffer.
Ideally, I'd want to have a logic to prevent the data from getting overwritten but couldn't find a reasonable way.
For instance, if the buffer size is 3 and Write is invoked, it shouldn't proceed until the buffer is no longer full.
class Fifo
{... |
I have a Tokenizer doing lexer thing.
It is used like
String line = "class Main {"
ArrayList<String> tokens = LineTokenizer.tokenize(line)
The overall logic of LineTokenizer.tokenize is like below and tokenize method is static
for ( char c : line ){
if (condition){
doSomething1(); //like arrayList.add(c)
... |
I read data from Excel into a Pandas DataFrame, so that every column represents a different variable, and every row represents a different sample. I made the function below to identify potential highly correlated variables within a DataFrame, with 'high correlation' being determined by the given "threshold" input when ... |
The expected behavior of the script is to download a file from a URL if the file is not present in the current directory and compare the md5 checksum of the file against the md5 checksum from the server. If the file is present then perform the verification again and download the file if the verification fails. As I hav... |
I am running a web application with a price table that would allow front-end users to bulk add the distribution markup to the items prices and then select a different currency by clicking the appropriate buttons and entering the value in the prompt. The values entered should appear on the buttons, after which it preven... |
I have a JavaScript library jQuery Terminal and I have internal formatting that is used to change colors and style of the text that look like this:
[[b;red;green]this is bold red text with green background]
I have a main function that is used to process strings with formatting. The main function used by other function... |
I come across a problem and I solved it. The solution works but I have some feelings that there is something wrong with my solution/code.
To be clear, let's assume that cars on the race track transmit
their velocity periodically. I want to store only the final velocity data of each car in a std::map where the key repre... |
I need to apply the coint function from the statsmodels library to 207 times series with 1397 points each, two by two.
Currently, it takes between 35-40 minutes on my computer with an Intel 24 Cores CPU, last generation.
I tried to use Cython, or Data processing hacks from this article but I get the exact same processi... |
I recently tried to implement the decorator design pattern in C++. Here is the code in full:
#include <algorithm>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
//Interface for items of food
class Food {
public:
virtual float Price() const = 0; //The price of the food ... |
I am taking beginner steps into DE and was tinkering with writing an ingestion script which does the following tasks:
Reads data from a source (in this case a remote parquet file)
Writes it to local for now, this can be changed to a remote location like s3 or other any database.
For this task I chose to use NY taxi d... |
[edit] I realised why everyone does this with loops; my plan was to use .SpecialCells(xlCellTypeVisible).EntireRow.Address to return the row(s) of the results of the results of the filter, but that returns a string. Strings have a limit of 256 characters, so with even moderately fragmented data some will be truncated. ... |
Here's the description:
Please write a Java Program for managing parking fees. each hour is
$3.
The invoice has to contain: ID, amount, and subtotal.
The maximum fee of the day is $30, and give out a 5-dollar coupon.
The total parking Cars has to >0. If the entered cars is less than 0, the error message will show.
Th... |
I have recently created the Money class with a helper class Currency. What do you think about the following code? I created unit tests for my class using very nice pytest library.
Is it a good idea to put code tests in the if __name__ == '__main__' or should I always use dedicated libraries like unittest and pytest?
Is... |
I've been using Guava Closer for non-trivial resource life-time management.
It is not thread-safe, and occasionally there is a need for a multi-threaded resource allocation. I could not find a library solution, so I've wrote one myself.
I've done my best to handle exceptions and concurrency and my tests are passing.
I'... |
As a personal side project I started building a graph library in C++ (I know, very original). The code is open source, but for the purpose of this question I will provide the relevant details and the to-be reviewed code below.
Architecture overview
What I want to achieve
The goal of the project is to make a lightweight... |
I've already started to creating apps in JS with OOP.
I made simple TicTacToe Game in OOP and I want to ask you to review my code and point out everything that I can change about OOP. What is bad practice and what should I pay attention for?
Thank you!
class Game {
constructor(figures, boxes) {
this.firstPl... |
Intro:
Need some feeback on my Javascript (I mostly do C++).
Purpose: I find google docs hard to organize in google drive (it takes more effort than it should).
So I started created "note" documents. A "note" document has links to all documents related to a particular subject and some notes about the combined documents... |
I've recently written a Vulkan library for creating 2D applications with ease. The catch was I need std::lock_guard for my window resize event to resize resources related to the window on a secondary render thread (separate from the main GLFW window thread).
While testing on an AMD machine (running on an AMD APU 5600G)... |
In the picture below there are some regions which are very bright (i.e. more white). Some bright regions are wide and some are narrow or thin. The red box covers one such wide bright spot, and blue box covers one thin bright spot. Thin bright spots are called edges and wide bright spots are called hot-spots.
I want to ... |
The asm function strlen receives the link to a string as a char - Array. To do so, the function may use SWAR on general purpose register, but without using xmm registers or SSE instructions.
The function checks with the bit manipulation: (v - 0x01010101) & ~(v & 0x80808080)in 8 byte steps, whether the quadword contains... |
Background: I am somewhat new to programming and only two weeks into learning Python. Currently trying to improve my understanding of recursion, which has been a tough concept for me to implement.
Question: Is this a proper implementation of recursion or just an iterative approach with recursive flare? Or maybe neither... |
I had a Tic Tac Toe assignment for class and the program seems to work fine but I feel like the exception/input handling could be done in a much better way. Is this a good way to approach the structure of the app? Is it okay to use try/catch a lot like in here or is it better to try and avoid it?
Really newbie question... |
First version of code here: Tampermonkey Note Taker for Google Docs.
I think I have made it better by splitting on the "StorageInterface".
Code
// ==UserScript==
// @name Google Docs Note Taker
// @namespace http://LokiAstari.com/
// @version 0.9
// @description Link a private google doc to any web pag... |
I am new to programming. I picked up a C# course from freeCodeCamp.org a few days ago and today I created my first code from scratch. I know probably it's not the best optimized but it works. Some things still don't make sense to me completely but I hope in the future it will all click.
However, I am making this post t... |
Hardware: Raspberry Pi 3B+, Elecrow touchscreen, DFR0660 Barcode Scanner, ADS1115 ADC
I would like any bad practices/possible failure points pointed out specifically in the loop(), read_adc(), and catheter_test() functions. The write_to_report() and measure_single_catheter() functions were removed. The system is fully ... |
My attempt at an Awaiter for sending scatter-gather data over an open file descriptor. Tested only on gcc-13.1.1
Micro-optimizing by suspending the coroutine only when actually needed. No perf measurements done. I hope to build on this to create a write_all coroutine.
#include <coroutine>
#include <ranges>
#include <co... |
This is the first time I made a quick program, which is a game "paper, rock, scissors'. I am looking for any advice, and information if it is done in proper way or it is not.
I did my code by myself, and I would like to know is it a good part of code or I have to focus on something.
Here is a code I did:
import random
... |
I have a task which runs sequentially. If I have hundreds of thousands of tags, it is very time consuming. Can this be modified to run the task in parallel? Works fine upto 100 tags
(:require [content :as db-content]
[impl.content-tag :as db-content-tag]
[story :as db-story]
[tag :as d... |
I originally posted this question here, but was told a code review was needed first.
This class is used to call an API that creates/updates groups in an Identity Provider.
I'd like to unit test the following class.
How can I mock the HttpClient when it's used as a static readonly field in a static class?
This question ... |
I am in my first week of programming and I created a currency converter. I want to use real time exchange rates through an api when sending the result. This code itself works just fine. But, being new I am always skeptical if it's done the proper way.
I found this method working:
var client = new WebClient();
var usdTo... |
I am trying to accelerate an algorithm where I am computing a 2D variance of many complex matrices stored as pages of a 3D array in Matlab. My implementation uses a Mex function with the C++ Matlab Data API. I perform Toeplitz convolution along both dimensions of the matrix with a simple kernel of ones to compute a new... |
Intro
Suppose we are given a queue of waiting times \$\langle t_1, \ldots, t_n\rangle\$. The first "person" \$(t_1)\$ leaves the queue immediately. The persons \$(t_i), i > 1\$ all have to wait \$(t_1)\$ units of time, which contributes \$(n - 1) t_1\$ to the total waiting time. For the \$t_2\$, it contributes \$(n - 2... |
I have a handful of files containing simple configuration in which I need to modify values. There are some useful constraints that simplify my implementation:
The file consists of single lines of the form key=value (no multi-line values).
Key names are written using letters, digits and underscore only (no regex meta-... |
In mathematics, the Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is the binary sequence (an infinite sequence of 0s and 1s) obtained by starting with 0 and successively appending the Boolean complement of the sequence obtained thus far.
Wikipedia Page
I wanted to create images using the Thue–Morse sequence, m... |
I have been developing a program with C lately, its purpose over the top is to reconstruct meshes from point clouds which are generated by finding the intersection points of numerous rays fired at the image which had previously been preprocessed by a HED neural-network.
I'm doing this for a school project and I haven't... |
I have used the below code Loop through cells of a range and convert to a hyperlink and change (Text To Display) to an ascending number per each row.
it works, but for the point of ascending number I have to use two loops (r and i).
I wish to replace these loops with column index with reference to range rngFinal as thi... |
Related
This is a Python script that generates images using prime numbers up to a given positive integer, it generates prime numbers using the Sieve of Eratosthenes with some rudimentary Wheel factorization optimization, and then converts each prime number p to a polar coordinate (p, p), which is p unit distance away f... |
I have created my first personal project - tic tac toe game. It is my first time approaching code using Object-Oriented paradigm and I would like to get feedback on it and on aspects where I can improve.
class Game:
game_over = False
players = []
grids = {"Top left": " ", "Top": " ", "Top right": " ", "M... |
I implemented a simple CLI based rock-paper-scissors game in Rust.
The player plays against the computer.
Each game has three rounds, not counting draws.
Cargo.toml
[package]
name = "rps"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html... |
Suppose I have a list of hashmaps (<String, Object>). Values can be either scalar types or a nested HashMap with the same type.
I need to merge a list of this maps into a final HashMap, each map in the list has higher precedence than the one before. Also the merge has to be deep: i.e.:
map1 = {root: {a: a, b: {c: c, ... |
First. If this question is not allowed, I am sorry. Please, tell me so, and I will try to delete this. If it is, I will delete this paragraph.
Personal-ish note/Motivation
I was studying assembly because of Tanenbaum and C, and decided to make a "graduation" project from the book: a C compiler for AVR and x86 ISAs, usi... |
I am just beginning to learn coding and decided to create a text based tic tac toe board as my first solo C++ project. My goals were as follows:
be able to test if there is a winning state on any given board
be able to call the board state
have the computer play O's for any possible position
cleanly close out the game... |
I modified a code from for an accurate timer from Stack Overflow to create a countdown timer:
countdownTimer(5); // seconds
function countdownTimer(duration) {
duration *= 1000; // convert to ms
let interval = 1000; // ms
let expected = Date.now() + interval;
setTimeout(step, interval);
function step() {
... |
This is my attempt at a terminal based blackjack game. Currently, the game does not support betting, although I intend to add it in the future.
I would very much appreciate general feedback, but I am especially interested in the following:
Comments on docstrings and type hints, as this is my first time trying to prope... |
The problem involves the fastest possible method to generate a list of combinations which repeats from all the possible combinations with repetition allowed. I know there needs to be a way to calculate n from gamma(n,r)=v given r and v in order to get the fastest possible approach, but it's probably not solvable, so to... |
I have some matrix multiplication code I am writing for a linear algebra library I'm working on. The goal is to emulate BLAS (and achieve BLAS-like performance) without using a BLAS library, as my use-case only needs 2 or 3 BLAS operations and using a BLAS library would be pulling in too many unnecessary dependencies. ... |
I am working on a Haskell problem from exercism, which is a learn-to-code website.
The problem statement is as follows.
Write a function to solve alphametics puzzles.
Alphametics is a puzzle
where letters in words are replaced with numbers.
For example SEND + MORE = MONEY:
S E N D
M O R E +
-----------
M O N E... |
import random
def guessNumber(guess):
if guess == randomNumber:
return 'Good job!'
elif guess > randomNumber:
return'That is to high!'
elif guess < randomNumber:
return 'That is to low!'
guesses = 0
randomNumber = random.randint(1, 20)
# print(randomNumber)
print('Im thinking of ... |
I've written the A* search algorithm in C++. My goal is primarily writing concise and understandable code, while making use of some new features of modern C++ (where appropriate) and having generally good performance (importance of these goals in the order they were mentioned).
The goal of the algorithm is to find the ... |
I want to download an XML and check to see if it can be parsed at all, no schema validation.
I was thinking to write two free functions, to separate concerns and wrap them in a third, public API:
enum PlistFirmwareFetcher {
static let firmwarePlistURL = "https://mesu.apple.com/assets/macos/com_apple_macOSIPSW/com_a... |
The Collatz Sequence
Write a function named collatz() that has one parameter named number.
If number is even, then collatz() should print number // 2 and return
this value. If number is odd, then collatz() should print and return
3 * number + 1.
Then write a program that lets the user type in an integer and that
keep... |
I'm new to python and pandas.
I would like to use pandas groupby() to flag values in a df that are outliers. I think I've got it working, but as I'm new to python, wanted to ask if there is a more obvious / pythonic approach.
Given input data with two groups, two variables X and Y:
n=10000
df= pd.DataFrame({'key': ['a'... |
Being a big chess fan, I finally started developing my own chess tool, however I'm already quite dissatisfied with where it's going...
folder structure:
E:.
| index.py
|
+---static
| | script.js
| | styles.css
| |
| \---pieces
| bb.svg
| bk.svg
| bn.svg
| bp.svg
| ... |
First of all, if you're unfamiliar with the Collatz sequence, it recursively applies the following function to an integer:
$$ f(n) = \begin{cases} n/2 & \text{if } n \equiv 0 \pmod{2}, \\ 3n+1 & \text{if } n \equiv 1 \pmod{2}. \end{cases} $$
What I wanted to do was to make a program that would:
Quit if 0 was inputted... |
I have the situation, where I have to methods in my api calling class that do basically the same thing. I have a profile that contains multiple account objects. These objects have their own UUID as a string and the profile has a unique Integer value as an identifier. I want to get the object once by its profile id and ... |
I wrote a short function whose purpose is simple: Print the binary representation of number to the console. I also aim to be as portable as possible, hence my use of CHAR_BIT and + instead of | in case the character encoding for '0' happens to be odd. Is my code as good and portable as I intended?
#include <stdio.h>
#i... |
Here's a suite of integration tests for my REST controller. Among other things, it reflects my efforts to reduce code duplication
First, I introduced some class fields. token was initially a class field initialized in the constructor too (the fact that you see an explicit no-args is a relic of that), but for some reaso... |
This function may compute the amount of unequal elements of two char-arrays of the length n:
size_t difference(size_t n, const char a[n], const char b[n]) {
size_t res = 0;
for (size_t i = 0; i < n; i++)
res += a[i] != b[i];
return res;
}
How can I make the iteration faster regarding the memory all... |
I am using abstalg, because I wanted to learn more about how to do this with generic fields, (So you can implement LU decomposition not just for floats). I used Matrix2D to wrap my behaviour and data (essentially like a view of the vector, the reason it is used is because MatrixRing from abstalg just uses vectors), but... |
This is a simple class in Kotlin that handles three basic Bingo-related functionalities: Specifying the numbers, generating a card, and calling one random element. Additionally, it should support an empty constructor, and support Discord Emoji output, in which there should be no spaces between any elements. I personall... |
I often find myself working with files I get from other users that mostly work on Windows machines (I, myself, am on a macOS) and they tend to name their files in all sorts of (weird & difficult to handle) ways.
For example, the files I get may contain any or all of the following:
a space
a dash
a comma
one or more do... |
could you review my below code to train a machine learning model to classify movie genres? I've used the data from Kaggle
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
import numpy as np
import ast
import joblib
from collections import Counter
from sklearn.model_selection import train_test_split
from skle... |
Motivation
Recently, Buzzfeed released a browser-based puzzle game called "Pyramid Scheme." It is available at the following link. The puzzle in an initial state looks like this:
To solve the puzzle, you have to find sequences of adjacent nodes in the pyramid that form valid words (3 letters long or longer) in English... |
Comma Code
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns a
string with all the items separated by a comma and a space, with and
inserted before the last item. For example, passing the previous spam
list to the func... |
I want to ask how to improve this code. Is it well-written or should anything be changed? Please let me know. And is it a bad thing to use arguments to store some info, such as the argument value here?
Here's the problem:
Write a recursive function that will receive an array of integers as an argument and as a result ... |
I'm using Django and Wagtail 5.x to build a blog. At this point, I'm trying to increase my understanding of query optimization and decrease the number of necessary db queries by implementing select_related. To my knowledge, I can use select_related to essentially chain related queries. In other words, when I'm accessin... |
Previous Versions of this Question:
V1
V2
OK. Not much response on the previous questions (but it was a lot of code so that may have effected it). I have quite a lot of changes since then so worth another go.
I have reached a point where the code is now in github and Greasy Fork.
I am breaking the code down into smal... |
Previous Versions of this Question:
V1
V2
V3 P1
OK. Now I need some help with the testing.
I have done my best. But there must be a better way.
I am writting regular expressions to extract attributes from html tag elements etc.
I also don't know what I should test for in HTML. What is best practive.
UIBuilder.js
clas... |
This is the second version of code reviewed earlier.
Comma Code
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that takes a list value as an argument and returns a
string with all the items separated by a comma and a space, with and
inserted before the last item. Fo... |
This is a solution for a workshop which gave me some problems. This solution also available via git: https://github.com/skaunov/6991_ws09/. After the code there also couple of theory questions which complimented the workshop, and then also text of workshop exercise duplicated.
A few notes/comments on the solution
I fee... |
Character Picture Grid
Say you have a list of lists where each value in the inner lists is a one-character string, like this:
grid = [['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O', '.', '.', '.'],
['O', 'O', 'O', 'O', '.', '.'],
['O', 'O', 'O', 'O', 'O', '.'],
['.', 'O', 'O', 'O', 'O', ... |
I have a list of functions whose parameters in the signature should be validated with the same criteria each time.
def sum_first_positive(a=1,b=1,c=1):
assert a > 0
return a + b + c
def sum_second_positive(a=1,b=1,c=1):
assert b > 0
return a + b + c
def sum_third_positive(a=1,b=1,c=1):
assert c > ... |
The provided code represents an implementation of a Binary Search Tree (BST) in C++, specifically tailored for a "Pet Shelter program" that has been the focal theme in a data structures class for an extensive period of six months.
This BST structure serves as a container for nodes that hold Pet* objects, with the utili... |
I have implemented a breadth-first search algorithm to find the distance from a point to an edge of a grid. The grid consists of spaces that may have walls between them, effectively blocking certain paths. Currently, I have a solution that performs well, but I am looking for ways to optimize it further. If you have exp... |
I've never had my code reviewed before, so I am taking this opportunity to see what can be improved with my coding style. I am still somewhat "new" to PHP, in the sense that I'm an old dog finally learning new tricks.
Here is a MySQLi wrapper I've coded in PHP. Overall, this code is part of an API project. I'm making a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.