instruction stringlengths 71 95.1k |
|---|
I'm writing a sudoku col/row validator, what is does is:
Reads user input on how many Sudoku instances to validate.
Reads the sudoku matrix grid 9x9 (for me, in my specific case 9x9) into a 2d array. Each line read/row should contain something like: 8 2 1 3 6 4 9 7 5.
Validates each row and column by flipping a 9 bit ... |
I am following the Odin Project and building the Library project.
It is very simple, just render a list of Books and we can add and delete books from the list.
However, I feel the code can be improved hugely, as it is getting too messy and I am not sure if I am using the class in the right way.
This is the JavaScript:
... |
I would like some one to review my code and let me know the feedback.
Each Kafka Message is like as follows
[{guid=id.Value1, timestamp=1386394980000, booleanValue=null, longValue=null, floatValue=null, stringValue=value1, source=X, metadata=null}]
This is what I implemented:
ExcelReader
import org.apache.poi.ss.usermo... |
I looking around and not finding anything, I developed a simple function for estimating the area of a possibly cropped circle inside a frame. It uses a very basic MC implementation.
It is pretty fast but I think it could be made simpler. Any thoughts are appreciated.
import numpy as np
from scipy.spatial import distanc... |
Coming from this question https://stackoverflow.com/questions/58131614/how-to-convert-json-string-into-complex-clos-object-using-cl-json-library I've finally come up with the following solution.
I use cl-json custom handle functionality
json::*object-key-handler* to always know the last key (parent slot name) we run... |
I need to use large strings as a dictionary keys, and I want to optimize the repetitive GetHashCode() and Equals() calls in it.
The number of keys will be quite small (<1000), but each string length will be very big (it's generated SQL queries cache), and I expect a lot of hot lookups.
My idea is to make sure that each... |
I built a container that can hold objects of various types, and look up an object convertible to a given type. I wrote something about my intended use-case here:
https://stackoverflow.com/questions/58562173/typesafe-way-to-provide-enriched-dependencies-to-derived-classes-in-c
Basically I want to be able to throw a bun... |
I wrote a small snippet to implement asyncio Pipeline - object that connects together Layers, and lets them create and pass through objects. Each Layer could perform some IO to create/store an object or calculate something to create on object on the go or remove an object. Layers are connected with Queues, and they hav... |
As the title says, this is my first Dockerfile. It won't be published on any registry, just for my internal use at home. I'd appreciate any critique of what I could do better. I'm currently working on a way to not hard-code the password into the docker-compose file...
This image is to run Postfix on Alpine as a SMTP re... |
I have picture in certain cells. When I run following code (With Intersect Method) in smaller number of selected cells, it runs correctly but when the number of selected cells increase - say above 1000, then code slows down a bit (Intersect Method). Can it be optimized? Code without intersect method runs Ok.Can interse... |
This is my first TUI program implemented via the curses module for Python.
I use the program to input some data (numbers only) via the terminal, which are then saved to a .txt file.
Any kind of feedback is highly appreciated, especially regarding the way I input data (I basically catch every character that the user inp... |
I've written a function that takes a list of extensions and recursively finds files of those types, and logs their paths to a text file.
Usage example (finding image files in a home directory):
// set up filestream for unicode
const std::locale utf8_locale = std::locale(std::locale(), new std::codecvt_utf8<wchar_t>());... |
I am trying to create a program where a user inputs two numbers - a base and an exponent, while exponent is a binary number. Then prints out the last two digits of the result. My code is working well, but according to the time execution it is not the fastest way to do it. I read a little about using Horner's method, is... |
Here are ~100 lines of code implementing three classes (ZipRef, ZipIter, Zip) which should satisfy the zip iterator pattern in a STL-compatible way. This means that, unlike boost::zip_iterator, ZipIter can be safely (I hope!) used in various algorithms like std::rotate and std::sort. I tried to embrace the power of C++... |
Hey there guys, I have just completed an exercise for uni and I would really like some feedback as I'm pretty new to using java. Areas that I could especially use some input in this instance: readability of the code, the names of the variables, the javaDoc comments, correct use of error statements AND MOST IMPORTANTLY ... |
Hello and thanks for clicking!
I'm currently studying the relationship between a database and user objects. This is a very simple program and the "database" itself is a dictionary. This will be used in a website (after studying a lot, of course, as I am fairly new to the "programming world", if you will), but I've abst... |
I wrote a function to generate a complicated version of the pascal triangle. The generated triangle should look like that:
┌─────────┬───┬───┬────┬────┬────┬────┬────┬───┬───┐
│ (index) │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │
├─────────┼───┼───┼────┼────┼────┼────┼────┼───┼───┤
│ 0 │ 1 │ │ │ │ │ ... |
I'm brand new and been going through some beginner code problems on checkIO. I finished this one today and am posting because I'm sure there is a much more elegant way to accomplish this, and I think this particular problem has a lot of useful applications. I would like to know what are the 'clean and efficient' ways t... |
To summarize what I've been trying to do, I basically tried to make a safe narrow_cast operator, which casts to the Target type if and only if the value is unchanged (not narrowed) in the process, and throws an exception if the conversation will cause the value to change.
So I implemented this by making two templates, ... |
I want to create a collection (in this case a map due to the extended function 'groupBy') that maps an IntRange to a list of a data class, which members are determined whether an int inside the data class is within the IntRange.
The IntRanges are 0..9, 10..19, 20..29, etc.
Concrete example:
data class Trip(
val (..... |
I'm new to C++ and I'm writting some kind of chat server and client who talk to each other through commands for learning purposes. I serialize and deserialize these commands using a JSON library. My first approach has been to create a base class called Command and have a derived class for each command.
The use case wo... |
I'm trying to write a program where computer attempts to guess a number entered by user. Computer should keep asking until guessed number will be equal to user number.
If you know what can be improved to make this code more readable, if implementation of the binary search algorithm is efficient, let me know!
#include <... |
Left limit, right limit and the digit to be counted is entered. This code works only for whole numbers i. e. from 0 to n. This code returns the number of occurence of the digit n in the given range. Please review this code and suggest improvements.
#include <iostream>
int count_n(int l, int r, int n)
{
if (r <= l)... |
Problem description
Scarpi, who owns a restaurant, decided to remodel
it with his friends because the interior of the restaurant is too old.
The place where the restaurant is located is a very cold area in the
snow town, so it is necessary to check the condition of the exterior
walls periodically during the in... |
The idea about this code is that it's a full replacement of Redux — in 22 lines of code.
let state = null
const beforeSetStateCallbacks = []
const afterSetStateCallbacks = []
export const beforeSetState = (fn) => beforeSetStateCallbacks.push(fn)
export const afterSetState = (fn) => afterSetStateCallbacks.push(fn)
exp... |
I am trying to practice the Observer design pattern in Golang, here is my code. I would be pleased to receive your comments, improvements, etc.
package observer
import (
"container/list"
"fmt"
"math/rand"
)
//interface that receive updates
type Observer interface{
Update(s *Subject)
}
// interface th... |
I have computed the Daubechies wavelet and scaling filters in float, double, long double, and quad precision, and now want to expose these filters in a usable API. My problem is as follows: I want to make sure that these filters are correct to every single bit, so I wrote them as hexadecimal floating point literals. Th... |
Just wondering how I can go about doing this more efficiently/make it more visually appealing to the user?
switch (this.state.selected) {
case "all":
styled = this.state.allKeywords.map(keyword =>
<div style={{display: "flex", flexDirection: "row"}}>
<Input key={Math.random} style={{height... |
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
The MessageBroker Class
Contains thread-safe structures to hold mappings of message types to handlers. Dispatches messages
t... |
I am currently creating a website for an artist (my grandfather). My main concern with the code below is readability, as for the most part I have not worked with others on a (programming) project. I use a few external modules but hopefully their purpose is obvious/irrelevant.
I have been programming with javascript as... |
I wrote simple code that let users log in, see what items are available in "shop", and make a purchase if he/she has enough coins.
Because the code uses csv file, if you want to test the code, you will need to create one. Run following
import csv
#Path to the folder + file name
file_path = input()
#Each sublist cont... |
I implemented a simple solution to the Producer–consumer problem
that I'd love for you to take a look at.
The producer simply adds random numbers to a queue and the consumer (from a separate thread) pops numbers off the queue and prints them. I'd specifically like feedback on the concurrency aspects of this implementa... |
I'm working with one environment which allows me to execute node.js code from single file without installing additional modules. My task is to write simple ssl socket client which will send protobuf message, receive response in same format and decode it.
What I developed in this code example:
protobuf decoder/encoder ... |
I have made a multithreaded command runner that works, just wanted to share the code and see if you guys can see any pitfalls. Comments are not part of actual code
protected async Task<bool> PollQueue(CancellationToken cancellationToken)
{
async Task<Batch> SyncQueueTask(CancellationToken token)
{
await... |
This a fairly basic script I made for use in some other projects, nothing too complex or sophisticated and obviously lacking in some features (Password/Username encryption, Missing file contingencies etc.).
It loads a text file (formatted as USERNAME, PASSWORD\nUSERNAME, PASSWORD\n) into a 2D array, then checks the inp... |
Problem: We read a complex json-file which grants us a tree in terms of a python "dict of dicts". We're then requested to retrieve a specific path from the tree, represented by a list of elements. The list (i.e. the path) may have any, arbitrary length.
Simple Example:
# The dict-tree:
d = {"a":{"1":{"aa":"a2", "aaa":"... |
I'm working on a custom puppeteer script which converts dynamic generated HTML to an A4 PDF.
This script converts HTML to a near perfect A4 PDF file, the only issue I have is speed. Document conversion is anywhere between 1-10 minutes.
I have tracked the slowness to the part where we calculate how much vertical space n... |
I'll have to move a large network directory with many sub-directories and thousands of files. A number of users work on these files on a daily basis. OS is windows.
The move itself (copy and delete) I'll do using robocopy.
Before starting the batch process of moving, I would like to check for locked files. In case some... |
I'm just starting in Go.
Please review the below code, and let me know what I can improve in this code.
//BubbleSort takes an []int {7,5,6,9,8} and returns {5,6,7,8,9}
func BubbleSort(arr []int) []int {
keepRunning := true
for keepRunning {
keepRunning = false
for i := 0; i < len(arr)-1; i++ {
... |
I took a crack at solving the problem of finding the averages of all subarrays of length k. Here is what I came up with. I would greatly appreciate your feedback on my code.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
vector<double> findSuseqAverages(size_t k, ... |
Users can have a Cookie called lang that contains either the value "default=1" (English) or "default=2" (French). This cookie is used to determine their preferred language. I have a function that needs to take the cookie and return the language has an Enum. If the cookie doesn't exist, I want to return English. I canno... |
I'm currently working on a procedural generated terrain.
I've written the Chunk script, and it works great. When I generate a few chunks in Unity, it runs alright, but it could definitely run better!!! Currently I am not instantiating new chunks at runtime, but when I do, it starts lagging.
I've been looking at multi... |
I want to compare two solutions to the following question from Cracking The Coding Interview by Gayle Laakman McDowell :
1.7 Rotate Matrix - Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image
by 90 degrees. Can you do this in place?
We will be ... |
I'm writing a decryption algorithm using GA with crossover and mutation. My performance is (very) poor, often stagnating early or converging to the incorrect solution. I just want some other people to look at my crossover and mutation methods to see if something is amiss.
Note: crossRate and mutatRate are the crossover... |
I'm facing the problem of needing to instantiate lots of cars, and I'd like to recycle the cars no longer used.
Each one of my car types, which define how each car should be created, are treated as singletons and there will never be two instances of the same type. I could program this in the example, but lets just ass... |
I would like to speed up the following code in R. This is a loop to define new individuals (column newID) when the variable change is equal to 1. Any idea on how to improve the loop will be greatly appreciated.
Here is the code:
## Build the data frame
dat <- expand.grid(x = 1:1000, ID = as.character(seq(0, 4000, 1)... |
I have been learning C++ for 3 months now. I decided to make something by myself, so I've made this little integer-based TIC TAC TOE console game.
I need some advice
on how to improve my code for better structure and and better readability.
#include <iostream>
#include <stdlib.h>
using namespace std;
int arr[9]={0,1... |
I have a code that turns all comments size to autosize, however as I have quite a few cells with comments, this code runs a little slow, to the point where it will become non responsive for awhile.
Sub AutoSizeComments()
Dim c as range, ws as worksheet
Set ws = ActiveSheet
'Loop through each comment on wo... |
I have the structure Corporation/Company/Facility/Storage and only Storage could be part of Facility, and Facility could be part of Company, and Company part of Corporation. My main problem is for the code to work I need to add the Corporation to itself.
public class BusinessEntityData
{
public Guid ID { get; set; ... |
I want to manage the Excel Styles in a more flexible way with bulk actions and at the same time improve my newly acquired OOP concepts.
Objectives:
Load the current Styles list (name and type=builtin or custom) in an Excel Structured Table (ListObject)
Allow users to:
Delete
Duplicate (create a new style based on ano... |
I am currently learning Java programing by building real life business application for repair shops. I am posting this code so I can get critical review, and change my application architecture if necessary. I would like your opinion on my approach to MVC pattern.
This is a GUI swing class for one of the dialogs.
public... |
Problem Link- https://www.hackerearth.com/challenges/competitive/october-circuits-19/algorithm/ap-1-f43562f4/
Problem Statement :
You are given an integer array of size A. You are also given queries Q. In each query, you are given three integers L, R, and D respectively.
You are required to determine the length of ... |
I had this S3Helper class before such that, every time I called a function to any of its methods (which I haven't shown here, but which do things like upload files to s3 or get temporary s3 links), it called the getClient() method and it would make a new client every time.
Now I don't know about the performance hit on ... |
I wrote a minimal implementation of the MD5 algorithm. Comparing to the established MD5 crate, the crate has a 35% better throughput than mine. I'd like to know why.
In reviewing the crate's code (relevant section here), I see that it essentially does the same thing as I do. I don't see anything algorithm differences. ... |
I have to write a code which takes (integers) numbers from Command-line and keeps reading the terminal until it gets a word END
So I wrote the following; I feel its really bad. Is there any way I can improve below code
I updated my code from previously to below
func main() {
buf := bufio.NewReader(os.Stdin)
lin... |
Updates: I kept the original code here, while performed some changes on my machine, including:
fixed the incorrect return documentation for clear()
made the closing functions recursive too (to be more clear and order-safe)
moved the static inner classes into separate files
extracted the API into an interface
use .addS... |
Write a function that returns a string length N of alternating strings: "A" and "B", starting with the 1st string. How could this be improved for be more performance or efficiency?
Eg: num = 5, should return "ABABA" & given num = 2, should return "AB".
function solution(num) {
const str1 = 'A', str2 = 'B';
let res ... |
I am verifying certain codes that work well and I don't know what else to optimize in them or what other tests to do: in this case it is a php script that takes the data of the $_POST variable analyzes them and converts them into an array, this is since in some cases the post field may contain a JSon string.
I leave a ... |
I have multiple inputs that each one has an increment and decrement button
The buttons will be pressed multiple times so i am looking to optimize my selector:
So should i keep the first one (which selects by attribute) or the second? Or anything more optimized.
$("[data-id-col="+thisID+"]")
$("input:tel#"+thisID+")
... |
My database:
Class:
Class Category {
function __construct($db) {
$this->db = $db;
}
public function groupByUnderCategoryName() {
$query = $this->db->prepare("SELECT categoryName, id, title FROM test2");
$query->execute();
return $query->fetchAll(PDO::FETCH_GROUP);
... |
I like to request a review of the code below, which is my attempt at answering the question here on LeetCode site. The code passes 43 tests, but it times out on the next one. I copied and ran the test on my machine using visual studio and it seems to give me an answer. I wonder if there is something about the site Leet... |
I have an application which requests data from a REST endpoint 50 items at a time and displays results in the UI. I would like to paginate each API response into smaller arrays for display and then request a new API resource when the user reaches the end of the children arrays.
I have a working CodePen demo using the S... |
I'm new with Ruby and am trying to improve my coding skills. This program gets personal information for three people, and then prints them.
It works, but I'm sure it's not the best and certainly not the fanciest way to do it.
I was hoping to get some advice here on how to do it faster/shorter/better/smarter...It is re... |
I am trying to get equal number of records in both columns, even if that means that first column doesn't fill page to bottom on the second page. The only way I was able to do this was by using a maxrow count and breaking when it is equal to the max row count.
public List<DataForExcelExport> GetData()
{
... |
So I'm trying to implement the following problem in a couple of different languages to get a rough idea of how different languages work & feel. I'm completely new to C, and this is the first code I've cobbled together using the C reference and Google/SO.
The problem is this:
Generate a list of n random doubles in (0, ... |
I have the following code:
member this.ProcessEvent(sourceStream: OrderResponse) =
match sourceStream.Action with
| Action.Partial
| Action.Insert ->
sourceStream.Data
|> Seq.iter (fun x -> this.orderState.[x.OrderId] <- this.ConvertFullOrder x)
| Act... |
At the company i work we have a system where an user is presented with a question and some alternatives to choose from. The question and answers are generated at runtime. In order to simplify the process among the sent payload is an encrypted JSON string that contains some "sensitive" (but not that much) information an... |
I'm trying to filter items from an ecommerce site.The project on the local server was running smoothly.However, I noticed significant delays since the project was published on the global server.Most often happens when changes are made to the price range.
Here is the Ajax code:
productFilter = {
catId: $... |
The purpose of the code is to allow the user to select directories that will be crawled recursively in order to find particular files or file types to analyze en masse. The thing to bear in mind is that if C:\ is already selected, then any child path of C:\ that the user tries to select will be discarded. The entire pr... |
This is a follow up to this question
Code incorporates Mathieu's comments and it works. As some parts of the review left some code to my knowledge, I ask for another review to see if I implemented them correctly.
Objectives:
Load the current Styles list (name and type=builtin or custom) in an Excel Structured Table (L... |
This is the task's description. My code gets 100% task score. Is it good code yet? (I think I'm getting a lot better, since I started solving this codility's exercises and posting here, but I always get important things to improve -which help me A LOT!- from reviewers)
N voracious fish are moving along a river. Calcul... |
I'm new to R and have created a dictionary function. A user will input a phrase into a text field and the server will read it and see if there's a match in a back-end data table and if so, output the abbreviation of the phrase.
This dictionary data table does not have a 1 to 1 mapping. The dictionary has logical_word a... |
I am trying to build a fast cryptography algorithm. The algorithm works fine, but I am worried if there are any potential flaws that might make the algorithm vulnerable to any kind of attack. Here is my code.
Encryptor.cpp
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace st... |
I have these queries written in Entity Framework where I try to get:
Name of the customer
Most Recent Invoice Ref
Most Recent Invoice Amount (£)
Number of outstanding invoices (#)
Total of all outstanding invoices (£)
I use these two tables:
CREATE TABLE Customers
(
CustomerId INT,
Name NVARCHAR(100),
Add... |
The following code is designed to cache a (UTCTime, Text) value that keeps the Text token around until it expires, preventing needing to re-fetch the token each time this third party API is called. I feel like this duplication in APIDefaults and APIEnv could be removed, perhaps through a type parameter, though there ma... |
I have an attachment uploading feature in my web app.
File can have type- image/png or image/jpg or image/jpeg or application/pdf
For images, I need to return Photo, for pdf Document.
Documents will be only pdf, but images can be extended to images/ico, etc.
Now my code looks like this.
getAttachmentType(attachmentType... |
I solved an online judge problem named Jollo.
The full description of the problem can be found here:
https://www.urionlinejudge.com.br/judge/en/problems/view/1321
It's a card game between 2 players.
Each player is given 3 cards.
Each round a player shows one card and removes it from hand.
The player who shows the highe... |
I have a program that returns the following:
PS4 Modern Warfare (2019)
Xbox One Modern Warfare (2019)
PS4 Grand Theft Auto V (5)
Xbox One Grand Theft Auto V (5)
I want to remove the parentheses from the end of he strings so they would look like the following:
PS4 Modern Warfare
Xbox One Modern Warfare
P... |
I am learning dynamic programming. I read articles for the rod cutting problem and I applied it in cpp, and I got a doubt, does the below code solves the problem through memoization (say, previously rod(3) was solved, then if same function was called with same parameters) has the answer, or will it use tabulation (rodM... |
Looking at back at the C++ projects I've developed, the Makefiles are a mess. To tell you the truth, I copied one a long time ago and basically have been cutting and pasting it haphazardly ever since. I've decided to change that so I've been reading more about how Make actually works and some best practices for using... |
This code basically just does a Caesar cipher on the contents of the variable "s" with a shift of 1.
Sorry if the comments on the code don't explain it well. I'm quite new to Python and I'm not very good at explaining.
Can this be code be improved?
# Imports the lowercase alphabet as a whole string.
from string import... |
Answering a question on S/O about type annotations led to me writing a little decorator that adds type checking to functions with annotated arguments. It supports the meta types Any, Optional[], and Union[], as well as combinations such as Optional[Union[...]]. It takes no arguments itself, for ease of use.
I'm fairly ... |
I am working on an angular stack that has n amount of services that hold data in stores of this type:
fooStore$ = BehaviorSubject<FooStoreType>({})
accessing properties in these have generally been done like this:
export wantedPropSelector$ = fooStore$.pipe(
map(store => store.wantedProp)
);
Now I'm working on impr... |
I am a beginner who just picked up Java (2 months ago) and I am solving some questions. For this question, the overall problem wants me to choose the cheapest price plan, so I listed out the possibilities of every plan and 'hardcoded' the logic by inputting the number of services, as the services is more important than... |
I have got 2 working codes, where one is a bit longer and another a bit shorter. Is it some way to bind all these layers as a one group?
The first one is:
map.on('zoomend', function() {
if (map.getZoom() <6){
map.removeLayer(job);
}else{
map.addLayer(job);
}
if (map.getZoom() <7){
map.r... |
I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string.
I have seen other questions on this problem that successfully solve it but I am unable to improve my own code following their strategy.
This, approach 3 is the strategy that I want to imple... |
I wrote cat program in x86 NASM and I would like to know if there is anything that can be improved.
This implementation of cat supports:
Reading from stdin.
Multiple arguments.
I checked few cases and program behaves exactly like original cat command.
I was thinking if I should add labels like write even if I wouldn'... |
I have a code that will delete the row if the entire row is exactly the same. So if in row 1 I have 100,200,300,400,500,600 in column A,B,C,D,E,F respectively, and in row 3 I have the same thing, it will remove row 3.
Sub remove()
Dim a As Long
For a = Cells(Rows.Count, 1).End(xlUp).row To 1 Step -1
If ... |
Please take a look at this little snippet of code and explicate on whether there are an efficiency enhancements that you'd make for it. It standards a row of a pandas.DataFrame by adding zeros to it so that the total length of the datum is the same as the longest datum in the column
Sample "solubility.csv" file for tes... |
I am comparing the index of the current component displayed in the viewport against an array of all the components on the screen to determine to direction the user in scrolling.
Does this function have too many concerns? and can the if statements be reduced to something cleaner?
function getDirection(component) {
l... |
This is my first C++ program (not counting "hello world") and I'd like to know if there are some semantic mistakes or if I could rewrite the code in a more simple way.
It performs brute-force factorisation of the number provided on standard input.
Here is the code:
#include <iostream>
#include <cstdio>
using namespace ... |
I need to extract the dimensions (width and height) of a jpeg file for inserting in an html document. According to the JPEG image compression FAQ, cautions against what's commonly out there,
Some people have recommended just searching for the byte pair
representing SOFn, without paying attention to the marker block ... |
I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way staticRef.scpRefGui.CLDropDown_Ref.Dropdown_ref.value
And sometime I see this kind of function calling staticRef.scpRefGui.CQAScrollViewPOI_Ref.ShowExcelObj... |
I made a program to attempt to find all palindromes in the danish language. Words.txt contains about 50.000 lines of danish words. Palindromes.txt is empty initially.
Im running the program on a Intel® Core™ m3-7Y30 Processor - which has a base frequency of 1.00 GHz. Seeing as the program - as it currently stands - has... |
Below are two ways to calculate an element of the Fibonacci series. Can someone please help me understand why fib1 is so much faster (over 60x) than fib2 ?
fib2 is just an assignment and a decrement whereas fib1 involves a dictionary and recursive calls.
Thanks.
import timeit
def fib1(n, lookup=dict()):
if n == 0 ... |
The original question is as follows:
Consider the leftmost and righmost appearances of some value in an array. We'll say that the "span" is the number of elements between the two inclusive. A single value has a span of 1. Returns the largest span found in the given array. (Efficiency is not a priority.)
maxSpan([1, 2,... |
I want to create a very simple banking application where (i) predefined accounts with a positive balance can send money (ii) requesting balance and a list of transactions can be found.
I have created API for those operations. All the operations are persisted into the database. I also wrote test cases to verify.
I alw... |
I'm trying to create a way to clock in and clock out at work using python and tkinter. There are several features to be implemented.
Change the Employee Name
Clock In button
Clock Out button
Export file with the information
I have all the components and they work when I run the different features individually. Whe... |
I just finished a full minesweeper clone which is based on Minesweeper for Windows 95.
I used C++ and Qt to realize it. The full source code can be find in my git hub.
Since this is too much code too review, I want to focus on the logic of the cells. For that I created the following classes:
Cell: Represents a singl... |
I wrote a simple lighter version of std::shared_ptr<T> called res_ptr<T>.
std::shared_ptr<T> is somewhat heavy due to all the nuances of its control block: support for safe deleting without virtual destructor, support for std::weak_ptr<T> (I am not certain on all details of the implementation... but I believe that it e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.