instruction stringlengths 71 95.1k |
|---|
I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the game codes. Clients can list the available games via product method. Initiation is the first step of buying process. In... |
I would like to implement a concurrent (multi-thread, multi-process) queue that is backed by file system. Data is pickled over a file, stored in a directory and given a sequential name.
The sequential name is milliseconds since epoch plus a random number that should prevent clashes. The queue will actually serve few pr... |
database.config.php
<?php
class Database
{
private $host = "localhost";
private $db_name = "trial";
private $username = "root";
private $password = "";
public $conn;
public function dbConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("m... |
I decided to implement a Hangman game using an object oriented State Pattern design. This is one of my first actual OOP as I normally write functional code.
Code use:
if __name__ == '__main__':
game = Context('represents', lives=5) # hangman word is represents
game.startGame()
I'm mostly happy with this but wa... |
I have created a custom class (Generic) in C# for the Hanoi problem. and I am not sure I did the correct thing.
[DebuggerDisplay("Count = {Count}")]
[System.Runtime.InteropServices.ComVisible(false)]
public class HanoiStack<T> : IEnumerable<T>, ICollection, IEnumerable where T : IHanoiStack
{
privat... |
I am using this code which works fine, but runs painfully slow.
The code filters an Excel Table and then extracts only certain columns and pastes them into another sheet (in a different order).
Could it be sped up perhaps with a multi-dimensional array?
With Application
.ScreenUpdating = False
.Calculation = xlCalcula... |
I was given the task to write a code that takes inputs from the user that include the following:
length of a certain race
the speed of Achilles (the main participant)
the number of participants excluding Achilles
the head start that each participant will get (a head start from Achilles)
speed of each participant
I th... |
This is a Leetcode problem -
Given an array which consists of non-negative integers and an integer
m, you can split the array into m non-empty continuous subarrays.
Write an algorithm to minimize the largest sum among these m
subarrays.
Note -
If n is the length of the array, assume the following constraints
a... |
This is a Leetcode problem -
Given a list of words (without duplicates), write a program that
returns all concatenated words in the given list of words.
A concatenated word is defined as a string that is comprised entirely
of at least two shorter words in the given array.
Note -
The number of elements of the give... |
The task
Given an integer n, return the length of the longest consecutive run
of 1s in its binary representation.
For example, given 156, you should return 3
My function solution 1
Style 1
function findMaxNumberOfConsecOnes(dec){
const countConsecOnes = (acc, x) => [acc[0] < acc[1]
... |
This is a Leetcode problem:
Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal
word or a regular expression string containing only letters a-z or ..
A . means it can represent any one letter.
Example:
addWord("bad")
addWord(... |
I am writing VBA in Excel to calculate the distance between an employee's home address and work address using Bing Maps API calls. The process follows this general flow:
1) Convert the employee's address to Lat-Long values using the GetLatLong function
2) Convert the employee's work address to Lat-Long values using the... |
A recent question on credit card validation here on Code Review, led me down a dark rabbit hole of check digit algorithms. I took a stop at the Verhoeff algorithm and tried to implement it myself.
That lead to the following piece of code:
class Verhoeff:
"""Calculate and verify check digits using Verhoeff's algorit... |
This is a Leetcode problem -
A password is considered strong if below conditions are all met -
1. It has at least 6 characters and at most 20 characters.
2. It must contain at least one lowercase letter, at least one uppercase letter, and at least one digit.
3. It must NOT contain three repeating characters in a row ... |
I am hoping to find a way to make the process a lot faster. The lists are made of rows of 6 numbers, i.e. [[float] * 6, ...]. The intent is to pass a list of cube co-ordinates (only two 3D co-ordinates, which are opposite corners) and get a shorter list of co-ordinates of 3D quadrilaterals.
# Merging by creating a list... |
I have developed this simple desktop calculator with WPF. Just wondering, what do you guys think of my coding style of this side project and any code refactoring needed to reduce repeat code?
public partial class MainWindow : Window
{
double lastNumber;
string lastNumberString, selectedValue;
LastInputType ... |
I have to load/unload models from a specific URL based on player position. For this reason I am checking player position from model and then load/unload a related piece of model in an Update event which runs on every frame.
Here is the update that validates some checks before loading/unloading. I added this check for o... |
C++11 introduced the new standard library function std::stoi, unfortunately there is no equivalent function to convert an unsigned number inside an std::string to its numeric value. Moreover, there is no direct way to convert a string to a signed/unsigned short and char.
The standard library from GNU uses the function ... |
I'm using a .NET library which uses a pre-async/await type of asynchronicity. That is, it provides asynchronous (non-awaitable) method with a callback parameter.
I'm trying to write awaitable extension methods which will wrap some of those methods to make it easier to use with the async/await fashion but I'm not sure i... |
Task
Find the smallest number of cuts required to break a string into a set of valid palindromes.
For example:
ababbbabbababa becomes a|babbbab|b|ababa (cuts = 3)
partytrapb becomes partytrap|b (cuts = 1)
Note: all strings of length 1 are palindromes as a single character reads the same forward and backward
import ... |
I'm working with some code left from other developers. Here we have several projects we can work with. The project object is instantiated at the runtime. Then it used in other classes. There are no methods in Projects and the class holds pure configuration values.
Is subclassing a proper way to define configuration for... |
As part of job interview, I was asked to write a cli script that takes a list of phone numbers to validate from a file and as an option in the command line.
It will then produce a CSV file with three columns “phone number”, “carrier”, “status”.
The status column should indicate if the phone number is valid or not valid... |
I've implemented a div_by_power_of_2() function, which lets me force the compiler to use left-shifting rather than proper division, in cases when the developer know the divisor will be a power of 2, but does not know which power of 2; and the compiler cannot prove to itself that this is the case.
template <typename P> ... |
I am reading a book call Front end Web Development "The big nerd ranch guide", in which I came across a silver challenge:
Go to your favorite search engine and search for "anything".
Open the DevTools to the console.
With the functions you wrote in this chapter as a reference, attach event listeners to all of the link... |
I have attempted to make a class similar to vectors in c++ (Though, I now know that it's just a (doubly) linked list). Just wanna know, how good or efficient my program is, how well I am as a programmer. What about my coding style. Is it messy to read? constructive criticism is welcomed and appreciated.
#include <iostr... |
A simple code which takes the given number as input and gives all of its prime factors raised to their respective powers. It works well up to 10⁶; after that it slows down greatly for some numbers. But it works smoothly for numbers which don't have many prime factors
Here's the code:
x=int(input("Enter number:"))
c=[... |
I'm making my way through the Intro to Computation and Programming test by John Guttag and he gives these small exercises to practice gearing up into computational thinking. As of Ch.2, we've covered basic input and print commands as well as some simple iteration stuff.
The question is as follows:
Write a piece of c... |
This my solution to this Good Range Coding Challenge
There is a number space given from 1 to N. And there are M queries followed by that. In each query, we were given a number between 1 to N (both inclusive). We add these number one by one into a set.
Good range: A range in which there is exactly one element present f... |
Explaining the idea and first steps
Today, I had the idea to do a website which displays my current position. I searched in the App Store for an App and found one named SendLocation. This App provides an interface for sending GET requests to an server with some geometrical data. This is how the data gets send:
http://y... |
I'm trying to learn javascript (especially the OOP part) and made this simple game. I'm looking for advice and ways to improve my code.
Did I handle OOP well enough?
What's the best way to create a new object of a given class (object.assign, new Object() etc)? There are a lot of them
Which variables should be named u... |
This code uses the Rabin-Karp algorithm to compare two text files. It takes a few minutes when both files contain around 1000 words. How can it be improved?
class RollingHash:
def __init__(self, text, sizeWord):
self.text = text
self.hash = 0
self.sizeWord = sizeWord
for i in range... |
Given the following two interfaces what would the proper way to set up the two actual classes?
public interface IPortfolio
{
string FirstName { get; set; }
string LastName { get; set; }
string Name { get; set; }
int Id { get; set; }
List<IDocument> Documents { get; set; }
}
public interface IDocumen... |
I have a Responder class whose prepare method takes an entity, checks it with a validator, and returns a response or errorResponse based on the results of validator.
class CreatorResponder implements ResponderInterface
{
private $validator;
private $repositoryFactory;
private $httpResponseFactory;
pub... |
Let's take these two objects as an exemple:
let objA = {
key1 : "whatever",
key2 : "whatever",
key3 : "whatever",
key4 : "whatever",
key5 : {
subKey1: "whatever",
subKey2: "whatever"
}
}
let objB = {
key1 : "whatever",
key2 : "whatever",
key3 : "whatever",
key5 : ... |
The following class is a wrapper for Microsoft.Win32.SaveFileDialog. I've implemented the usage of Microsoft.Win32.SaveFileDialog this way because I'm using the ISaveFileDialog interface as a dependency throughout my code base.
public class SaveFileDialog : ISaveFileDialog
{
public bool Save(string content, string ... |
I wish to transpose a square matrix, permanently overwriting it.
This is not the same as creating a 2nd matrix with the transposed contents of the 1st matrix.
I call the procedure with 3 parameters: the address of the original matrix, its rank, and the address of a scratch buffer that is large enough.
First, all the e... |
I have been trying to teach myself C++ recently and would like to have some general feedback and comments on how to improve my code so far. Furthermore, since I am more experienced with other (garbage-collected) languages like Python and Java, I would like to know if I am handling memory correctly or making any fundame... |
I am new to programming and currently learning Python using "Automate the Boring" by Al Sweigart. I've just completed the "Comma Code" task in Chapter 4 and would like some feedback on my solution. The task is:
Say you have a list value like this:
spam = ['apples', 'bananas', 'tofu', 'cats']
Write a function that tak... |
I'm creating an application that requires multiple tkinter windows. The code below works the way how I want it to work, but I'm not sure if I'm doing it in the proper way.
The first window (and in this case, the main window as well) contains three buttons as of now, 1 label which acts as a title, and a treeview.
The "A... |
Overview
This is my solution to the following Coding Challenge - Find Num of Elements in a Range in \$O(1)\$ with Preprocessing -
Given an array and max element in the array, find the number of elements present
between a given range in \$O(1)\$. You can do one-time processing of an array.
Solutions
Solution1
#inclu... |
This is a Leetcode problem -
You have 4 cards each containing a number from 1 to 9. You need to
judge whether they could be operated through *, /, +, -, (,)
to get the value of 24.
Note -
1. The division operator / represents real division, not integer division. For example, 4 / (1 - 2/3) = 12.
2. Every operation ... |
I am doing Kickstart's problem Wiggle Walk. I have tried to code with matrix, dictionary and nested dictionary but the time exceeds the limit in each submition. Can anyone help me optimize it better or is there any algorithm which I may have overlooked.
The problem statement is
Problem
Banny has just bought a new p... |
This is the first time that I have add (I mean, I try) Ajax with Jquery to PHP and Mysql (pagination). This is a link to the test page: testpage1
I think everything works, but is it done correctly?
Thank you in advance for good advice .
1. Ajax(index.php)
$(window).on('load', function () { // makes sure that whole site... |
This is a Leetcode problem:
On a 2 x 3 board, there are 5 tiles represented by the integers 1
through 5 and an empty square represented by 0.
A move consists of choosing 0 and a 4-directionally adjacent number
and swapping it.
The state of the board is \$solved\$ if and only if the board is
[[1,2,3],[4,5,0]].
Gi... |
I should estimate the effect of B fields on particle deflection using \$F=V \times B \times Force\$.
I have a 2D mesh with \$n_x\$ and \$n_y\$ which show the number of points in each direction. \$B\$ is the magnetic field which is a 2D mesh arrays (with dimension \$n_x \times n_y= 1600 \times 900 = 1440000\$) and \$V\$... |
Today I had a simple task: I have products, quantities and a dummy, and I needed to know which percentage of the total quantities of that product the dummy represented. My DataFrame looked like this:
Product Qty Dummy
A 10 0
B 15 0
B 5 1
C 5 0
D ... |
I created a PHP program to generate random phone numbers. A valid phone number:
must be exactly 11 digits in length, and
must start with any of the values mentioned in the $a array, and
How can I improve it? Specifically, how can I improve
its readability, and
its performance, assuming I want to generate millions of... |
The task
Given a string and a pattern, find the starting indices of all
occurrences of the pattern in the string. For example, given the
string "abracadabra" and the pattern "abr", you should return [0, 7].
My solution
function findStartingIndex(T, pattern) {
let S = T;
const res = [];
while(true) {
con... |
I'm a beginner developer, and it's my very first project: a simple math operations calculator in Python 3 using Tkinter for GUI.
Obs: This code is an evolution of my previous code of the same project: initial code.
This calculator, in despite of only process the four basic math operations (add, subtraction, multiplicat... |
There is A LOT of information online stating that you should NEVER catch a NullPointerException. Generally I agree, but I am wondering about this one case.
I have inherited code that requires me to access data that I need in the following way
context.getGrandParent().getParent().getChild().isRequired()
There is no gu... |
Background
An API endpoint that returns phone numbers. I would appreciate some feedback on this very simple service class that is part of the overall solution. Here is its Interface:
public interface IPhoneNumbersService
{
Task<IList<PhoneNumberViewModel>> GetAllPhoneNumbersAsync();
Task<IList<CustomerPhoneNum... |
Currently, I am in the process of optimizing a program that takes a n x n matrix and multiplies it with its transpose. I am trying to optimize my matrix calculation algorithm so that it completes in as few clock cycles as possible.
Here is my pseudo code attempt at creating an optimised algorithm.
// Matrix Multiplica... |
Here is my bash script that I just wrote to count line of code for JavaScript project.
It will list number of:
Comment lines
Blank lines
All lines
Here is my script:
#!/bin/bash
fileExt="*.js"
allFiles=$(find ./ -name "$fileExt")
commentLines=$((perl -ne 'print "$1\n" while /(^\s+\/\/\s*\w+)/sg' $allFiles;\
perl -... |
I wanted to make a Sequence that can do a pre-order traversal of Binary Tree. Doing so provides automatically unlocks wonderfully useful methods, like prefix, map, filter, etc. But doing so requires implementing an Iterator, which conforms to IteratorProtocol.
Implementing next() to vend elements means that the usual s... |
I have a need to convert wire encoding (big-endian) to little-endian in Python.
The conversion needs to happen as a separate function; I am not allowed to change the function that reads the byte stream because it will break a lot of other functions.
The best I can think of is this:
def be_to_le(value: int) -> int:
... |
This chatbot will take the input from csv file and give the output to the user's question...here problem I am facing is when user asks any question, it gives tkenize output of user's text
#Block 1
""" In this block we will import all the required libraries """
import pandas as pd # importing panda... |
I want as an exercise to create an e-commerce application from bottom up. My main goal here is to gain a lot of knowledge. I have experience in web development, but never have been there from the start of the project. The database schema was always already in place and also the server infrastructure (Azure) had been se... |
I currently use the following code to asynchronously create a cimsession to a remote host, query the remote host, return multiple values and finally updated some textboxes on my WPF window. Just wanting to know if anyone can see any glaring issues (I'm new to all things async and c# :) ) or a better was of doing it:
us... |
The task
is taken from leetcode
Given a 2d grid map of '1's (land) and '0's (water), count the number
of islands. An island is surrounded by water and is formed by
connecting adjacent lands horizontally or vertically. You may assume
all four edges of the grid are all surrounded by water.
Example 1:
Input:
11110
... |
I have implemented an AVL tree using shared_ptr. I know that there is an overhead regarding using shared_ptr and instead a unique_ptr could be used. But the thing is that my node contains also a parent pointer, it turns out so each node can be pointed by two/three other nodes at the same time, one pointer from its pare... |
I wrote the script below as my first python program that will be running in a production environment. Essentially this program looks at a source location and moves all the files to a destination location if the file is older than 14 days old and does not exists in the destination. I had a user on stack overflow suggest... |
The task
was initially solved here, but was too buggy:
Given a string and a pattern, find the starting indices of all
occurrences of the pattern in the string. For example, given the
string "abracadabra" and the pattern "abr", you should return [0, 7].
My solution
Tried to solve it using KMP-algorithm:
function ... |
This function returns the number of pairs of the same elements in the array
It takes, array length and the array as the parameter
n: Length of array
ar: Array of integers for example
4 6 7 8 7 6 6 7 6 4
returns 4
fun getNumberOfPairs(n: Int, ar: Array<Int>): Int {
val enteries = HashSet<Int>()
var pairs = 0... |
I tried to create a "guess the word" game. I would appreciate to get some suggestion to improve myself, because I'm new at Python.
from random_word import RandomWords
import random
from translate import Translator
import time
import sys
def hangman():
SENTINEL = 1
lang = input('What language do you choose?\... |
I have tried to develop a simple product listing app in RxSwift with MVVM design pattern. I have managed to achieve it but I need someone to review my code, such as:
Have I followed the proper RxSwift features?
Is binding of TableViewCells item with ViewController's ViewModel correct?
Anything I am missing here?
Note... |
I've written a function in Haskell for calculating the entropy of a collection. I'd like feedback on how the function could be rewritten to be more flexible/reusable, and also how to profile the function and how it could be tuned and/or modified for better performance.
import Data.List (foldl1')
entropy :: [Int] -> I... |
I'm trying to take camelCase and PascalCase strings into a function and spit them out as Title Case. This function also needs to be able to handle odd PascalCase strings with capitalized abbreviations such as "CDReceiverBox" and return a readable string - "CD Receiver Box".
My current working solution:
function splitC... |
Background:
For several of my workbooks I run Overview sheets with charts in them. When printing the Overview sheet, I put my workbook name as header, where the workbook name includes the criteria for the generating the source data (e.g., date range and time stamp plus non-numeric strings).
To draw attention to these ... |
I've created a generic try catch I can apply throughout my code so I'm not repeating myself.
private HttpResponseMessage TryCatch(Action action)
{
return TryCatch(() => { action(); return "ActionToFunc"; });
}
private HttpResponseMessage TryCatch<T>(Func<T> func)
{
try
{
var result = func();
... |
Problem: https://www.hackerrank.com/challenges/the-birthday-bar/problem
Lily has a chocolate bar that she wants to share it with Ron for his birthday. Each of the squares has an integer on it. She decides to share a contiguous segment of the bar selected such that the length of the segment matches Ron's birth month an... |
I came across a problem on LeetCode.
There is an input array of integers. I need to find out if there any repeating integers, then return true else false.
So, I tried using a hashtable library available in C and wrote the code below.
My run time is approximately 44ms.
How can I optimize this code?
Using hashtable, ca... |
This is a Leetcode problem -
Strings A and B are K-similar (for some non-negative integer
K) if we can swap the positions of two letters in A exactly K
times so that the resulting string equals B.
Given two anagrams A and B, return the smallest K for which A
and B are K-similar.
Note -
1 <= A.length == B.length... |
I am building a web app in Django where one of the form fields is a multiplechoicefield from a many2many object that I use to select users that are allowed to edit the post. In standard form the field displays predominantly while it is only seldom required, hence I would like the field only to show under a dropdown bu... |
I created this shared pointer mainly to use it as RAII for handles that have to be shared between classes or threads.
For pointers:
It supports raw pointers and pointer to classes and arrays and also support classes inheriting from ref_base to save an allocation for the reference counter.
For non-pointers:
They must be... |
Please review how clear my code is and also comment on performance.
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai
< 2^31.
Find the maximum result of ai XOR aj, where 0 ≤ i, j < n.
Could you do this in O(n) runtime?
Example:
Input: [3, 10, 5, 25, 2, 8]
Output: 28
Explanation: The maximum resu... |
I have tried to work out the Frog Jump task on Codility. The algorithm for solving this is rather simple but the maximum score I am able to achieve is 55% (also 44% with modulus operations).
A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a posit... |
Please comment about performance
https://leetcode.com/problems/leaf-similar-trees/
Consider all the leaves of a binary tree. From left to right order,
the values of those leaves form a leaf value sequence.
For example, in the given tree above, the leaf value sequence is (6,
7, 4, 9, 8).
Two binary trees are cons... |
I have written out the following code in the head section of my document,
which should load 3 separate style sheets for each page based on the URL/URI that the user is visiting. It is working as intended as tested with the comment in the code but I am wondering if there is a more efficient way to do this. I initially s... |
I just started reading Introduction to Algorithms and the first algorithm introduced is the insertion sort.
Even though the sort seems to work, I thought I'd ask for feedback right at the start since this is a really new topic to me.
This is the JS implementation I came up with based on the pseudo code:
function insert... |
I never programmed in my life, and I am currently self teaching myself some C++ by reading books, online free classes and googling. After beginning to read about OOP and classes, and after seeing that a Blackjack game would be something simple to implement using the console, I created the following program to play Blac... |
I'm finally learning Haskell this summer and I have a few questions about conventions. I made a simple prime factorization program which is surprisingly fast, much faster than the ones I made in C++ (though to be fair I made those non-recursively).
It consists of three functions: one checks if a num is prime, one find... |
I've got a project where I get product data and need to get the prices which come in, in different formats.
Some examples would be: US$17, USD17.00, 17,00€, 17€, GBP17, Only 17,-€, 17.000,00€, 17,000.00$ etc.
So at the beginning I started with one specific string to float function and kept on adding code for specific... |
Edit
I've added a second pass at this problem based on the answers that have been posted by other users so far: https://codereview.stackexchange.com/a/221525/75659
Context
Before presenting the code for review, I want to be clear that I am not looking for recommendations on how to avoid having to solve the issue that... |
any help with optimizing following code to make it run faster.
Tried making function inline, tried cin.TIE(NULL), tried ios_base::sync_with_stdio(false);
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class gfg
{
public:
bool satisfiable(std::vector<int> a, std::vector<int> b) {
whil... |
Here is my attempt at converting hex strings to byte arrays and converting byte arrays to hex strings:
net.coderodde.util.ByteStringConverter
package net.coderodde.util;
import java.util.Scanner;
public class ByteStringConverter {
/**
* Converts the given byte array to its textual hex representation.
*... |
I have just returned to college to finish my associate's in programming. The language my school uses for all of the programming classes is java, so I've been trying to get used to the language.
The code I've posted below works as far as I can tell, I am hoping some of you can give some constructive criticism to my code... |
I have table which contains different permissions. Currently i am render all those permsion columns into check boxes manually. Like this
global $con;
$sql = "SELECT * FROM `permissionsinpage` where `ETPK` = $id"; //chk allow project name
$result = mysql_query($sql,$con) or die(mysql_error());
$no_result = ... |
I am trying to build object identity in PHP so that when I have a collection of objects, each one can have a string as identifier and all of these identifiers are afterwards combined to form an unique md5 to represent the "identity of a collection".
Why? So that I can choose to skip re-execution of code when it's not n... |
The task
is taken from leetcode
You're given strings J representing the types of stones that are
jewels, and S representing the stones you have. Each character in S
is a type of stone you have. You want to know how many of the stones
you have are also jewels.
The letters in J are guaranteed distinct, and all c... |
I wrote some JavaScript to generate some graphics on a canvas, on a regular HTML page.
I now want the same code to run in a component that is part of a React app. I've done this:
componentDidMount() {
const canvas = this.refs.firstCanvas
const ctx = canvas.getContext('2d')
const bgCanvas = this.refs.first... |
I have solved this exercise, but it looks really redundant. Is there a built-in function in Java or a cleaner way to caluclate mod of a value + deviation without multiple OR statements? If I had to calculate this for a deviation of 5, this would then require a lot of repetition.
Given a non-negative number "num", retu... |
I want to showcase with as minimal code as possible the basic Object-oriented programming (OOP) principles of Polymorphism, Inheritance, and Encapsulation. I know there are many more principles than just these 3 and even different types of the 3 I've mentioned there. I attempted to implement them all below. I think usi... |
So I've been working on a simple little hashing algorithm for Python that I like to call PRBHA-10 for short, or Pseudo-Random-Based Hash Algorithm. This is a hash algorithm in Python that is meant to be simplistic and secure. As you could see from the title, the algorithm implements a system with seeding the pseudo-ran... |
The problem
For any given array, find a corresponding zig-zag array such the each
element (a,b,c,d,e...) follows the rule:
a < b > c < d > e < f
In other words, every other element is greater than both of its neighbouring elements and the remaining elements are smaller than their neighbours.
For example, for the l... |
I have this log file (example below) and I'm trying to find the number of times a particular route is called.
Example log file:
2019-05-29 11:00:00 192.168.1.1 POST /route1 200 100000
2019-05-29 11:00:01 10.1.1.2 POST /route1 200 100000
2019-05-29 11:00:01 192.168.1.2 GET /route2 404 200000
2019-05-29 11:00:02 1... |
So,I was looking for the non-recursive version of Trie data structures deletion in the internet. I couldn't find one. The best I could manage to find was a recursive implementation of trie in this website. Looking at the code for sometime, I thought that I could make the recursive version of the deletion to non-recursi... |
I believe this code prints both the DFS and BFS of a directed graph. As with some of my previous posts, this is mainly to share my code with other people working on a similar issue but I would also appreciate any feedback.
In the code I have written, DFS and BFS use a pre-order technique, as follows:
DFS (Depth first... |
Exercise 7.2 from Python for Informatics:
Write a program to prompt for a file name, and then read through
the file and look for lines of the form:
X-DSPAM-Confidence: 0.8475
When you encounter a line that starts with “X-DSPAM-Confidence:” pull apart
the line to extract the floating-point number on the line. Count... |
This task is taken from Leetcode:
Given n non-negative integers representing an elevation map where the
width of each bar is 1, compute how much water it is able to trap
after raining.
The above elevation map is represented by array
[0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue
section) are bei... |
I have no idea if this kind of lock is called time lock, but I need something for the following scenario: I'm making a lot of concurrent requests with aiohttp, and it's possible that the server at some point returns 429 Too Many Requests. In that instance, I have to pause all my subsequent requests for some time.
I cam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.