instruction stringlengths 71 95.1k |
|---|
I have the following tables in MySQL:
create table PostSchema
(id int not null primary key auto_increment,
categories int not null,
title varchar(50),
status varchar(20),
comments bool,
body varchar(255),
filename varchar(255),
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP);
create table commentSchema (
id... |
During development I needed to design a state machine with decision which runs to completion and performs state transition without the need to wait for events. So i come up with the following implementation that I want to share.
So the state machine is described with the following Enum
public enum PnoBarringState {
O... |
Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn't find any implementation both in GSL-Lite and MS GSL libraries.
The SV class stores T value coupled with std::mutex. It implements pointer and dereference operators which create a temporary object ... |
I recently finished chapter 8 of Rust's book, and below is my solution to the third exercise:
Using a hash map and vectors, create a text interface to allow a user
to add employee names to a department in a company. For example, “Add
Sally to Engineering” or “Add Amir to Sales.” Then let the user
retrieve a list of al... |
@Effect()
createQuiz$: Observable<Action> = this.actions$.pipe(
ofType<quizAction.CreateQuiz>(quizAction.CREATE_QUIZ),
switchMap((action) => {
return this.quizService.createQuiz(action.payload)
.pipe(
map(() => {
return new quizAction.CreateQuizCompleted()
}),
... |
This is my first time requesting a code review. This is code I wrote in Python to create a DNA sequence analyzer. This is for the Harvard CS50 course.
I was really hoping to get some constructive criticism on this code I finished for the DNA problem in Problem Set 6. This code passed all tests and is fully functional a... |
I've made a simple food inventory manager in Python3
Please tell me what can be improved
import os
import pickle
import time
remaining_ingredients = {}
dishes = []
class Dish:
name = ""
required_ingredients = {}
def __init__(self, name: str, required_ingredients: dict):
self.required_ingredients... |
I'd like to know how to improve this code because I think that the main_func is too big and I can not split it into other functions or classes.
Also, I want to know if I can or should use classes to make it cleaner.
import random
import string
def starting():
print('HANGMAN')
print('Set game mode:')
print... |
The goal of this code is to allow temporary RHS variables to be used in a span, specifically as an argument to a function, to be deleted later after the function completes, allowing the passing of temporaries to such span accepting functions.
How would I improve this code? Can I make it smaller and more readable? Is th... |
I have made a Snake clone using Java 14 and JavaFX 14. My game uses an anonymous instance of the AnimationTimer class as the game loop. The basic UI for the start screen uses FXML, but all of the UI elements in the actual game Scene were added programmatically.
The game board is stored as both a GridPane and as a 2D ar... |
Given:
G is an arbitrary graph
partitions is a list of its edges divided into (in this case) 3 sets.
Color generation:
Its purpose is to generate one distinct color for each partition.
The function turns a number between 0 and 1 into an RGB color.
For the given example, with 3 partitions, it would be called with 1/3... |
For learning purposes, I have written a small calculator app on Python, tkinter.
I want to check if my design is on best practices for OOP, And seek advice on Nested functions
For easy readability, I have only included the Addition functionality, same logic can be applied to Subtract, Multiply etc..with few changes to ... |
i get an array of authors from json response and i have to display authors name in TextView(android) in proper format like =>Viraj, Chetan and George R. R. Martin
my code work fine, but it's a mess....
public class SeprateAuthors {
public static void main(String[] args) {
String[] authors0 = {"a", "b"};
String[... |
bool is_prime(int num)
{
if(num < 2)
return false;
int sq = std::sqrt(num);
for(int i = 3; i <= sq; ++i, ++i)
if(num % i == 0)
return false;
return true;
}
We only need to check upto square root.
Proof -> https://scienceparv.blogspot.com/2021/07/mathematics-if-one-diviso... |
I want to transform a UCI-move into bitboard.
for example a2a3 -> 32768, 8388608
I need to assign [7,6,...,0] to [a,b,...,h] so that for each letter i have the assigned number(n) to calculate 2^n
Which I can then left shift by the value in uci[1] or uci[3] *8 depending on start- or endfield.
This is my approach and it ... |
I have written a simple expect script to tell me if a passwordless connection is set up.
#!/usr/bin/expect -f
if {[llength $argv] < 2} {
puts "usage: test-nopass user server"
exit 1
}
set user [lindex $argv 0]
set server [lindex $argv 1]
set pwd_prompt "*assword:"
set prompt "*$ "
set rc 0
log_user 0
spa... |
I started reading Robert Martin's Clean Code. I'm trying to "translate" all his examples into Python, so I can understand them better since my knowledge of Python is greater than that of Java.
This class formats a count in into a natural English sentence:
Java original code of the book
public class GuessStatisticsMess... |
The Challenge: Given a string, return a string where each word is reversed individually without changing its position. EDIT: (i.e.: the input "hello world I am a frog?" should produce the output: "olleh dlrow I ma a gorf?")
Thoughts and questions: Perhaps I was cheating the spirit of the challenge by using string build... |
It is a practice from the site edabit.com and you have to check if the input is valid. That is the original task:
Given an RGB(A) CSS color, determine whether its format is valid or not. Create a function that takes a string (e.g. "rgb(0, 0, 0)") and return True if it's format is correct, otherwise return False.
The ... |
I implemented the heaviest stone algorithm, but I am not sure about its time complexity. I'm doing sort which is O(nlogn), but it' inside a while loop.
Problem:
We have a collection of stones, each stone has a positive integer weight.
Each turn, we choose the two heaviest stones and smash them together. Suppose the st... |
This code is designed for my 30 LED NeoPixel clock, the reason for not using the ds3231 library is due to the fact that I use codebender to download programs to my Arduino, I wanted some critique on things that could be improved and any glaring problems that should be fixed.
/*This code is for a 30 LED NeoPixel Clock, ... |
I have a list of 2,888,991 channel objects. Each object has a name and a sample rate. I am trying to put them into a QTreeView. Each channel name is split on ':' '-' and '_'. If the name is H1:IOP-LSC0_DCU_ID and the sample rate is 16.0 then it should go into the tree as:
H1
IOP
LSC0
H1:IOP-LSC0... |
I need some opinions about method naming and single responsibility principle.
First of all, let's talk about method naming. The class below was created to provide a connection pool and whenever a pool is needed the get_pool is called. In the end get_pool will return a pool but the method will do more than only one resp... |
Made an Angular app using Firebase, RXJS and NGRX.
@Effect()
createQuiz$: Observable<Action> = this.actions$.pipe(
ofType<quizAction.CreateQuiz>(quizAction.CREATE_QUIZ),
switchMap((action) => {
return this.quizService.createQuiz(action.payload)
.pipe(
map(() => {
return new q... |
I need some help with making my code run faster. It currently works by going through all cells in a 201x151 table. If the value in a cell is not equal to zero, then it will return the row number, the column number, and the actual value, and put it in a different table.
Here is the code:
function rearranger() {
var... |
I'm solving a problem on HackerRank where I'm required to implement a simple stack.
It's passing all the tests except for the last 4 where it fails due to surpassing the time constraint of 10s. These 4 failing tests are running 200,000 operations on the stack.
How can I optimize my code below:
# operations of the for... |
I just created my first GTK+ 3 app with Python using PyGObject. It is very nice to be able to make GTK applications using Python, as I love that language. I'm not completely sure if the way I designed the code is the most conventional and efficient way, so would like some people with more experience to take a look at i... |
I'm working on some stuff that works better with (immutable async) linked lists such as this:
{ value: 'one', next: async () => { value: 'two', next: async () => null } }
Here next is an async function that returns either null or the next linked list. But I'd also be able to convert from and to iterables. So here is m... |
Task:
Write a function which returns true if a given substring is found within a given string. If the substring isn't found, then return false.
My implementation:
#!/usr/bin/env ruby
def custom_include?(string, substring)
len = substring.size
last_feasible = string.size - len
for i in 0..last_feasibl... |
This is an implementation of a dictionary (hash map) in Rust. It is loosely based on Python's dictionary implementation, using the same "random" probing and capacity/size management. Does it use too much memory or waste too many CPU cycles? Is it documented enough to be easily understood? I tried to mitigate the use of... |
In what way can I improve this? Be that performance, readability, etc.
I'm thinking implementing NumPy would improve performance.
Usage: Calculate* the nth factorial of n 1s in a row.
*No need for a precise calculation. Magnitude and leading digits is enough.
Examples:
2nd factorial of 11. (11 x 9 x 7 x 5 x 3 x 1)
3rd ... |
I started to code in c++ recently and my goal is to develop games using c++. After learning basics I tried to implement my own version of snake console based game in c++ with the help of some online tutorials. I used OOP approach. I would like to hear ideas about this code and what mistakes i have made or ways to impro... |
Based on this question:
Heaviest Stone algorithm time complexity
Problem:
We have a collection of stones, each stone has a positive integer weight.
Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:
If x == y, both sto... |
I started learning programming about a year ago, starting with Python. Half a year ago, I moved onto C++ and this is my first large project with that language. Have I understood the basics of the language?
In Main.cpp:
#pragma warning(disable : 4996)
#pragma warning(disable : 4244)
#include <memory>
#include <stdlib.h... |
I made a random maze generator that is also playable. The performance is crap and I'd like to improve it. I'll be working on this for a few more days to make it run better myself, but just thought I'd leave this here if people want to help.
import random, sys, time, pygame
from fractions import gcd
from pygame.locals i... |
The Huffman-Algorithm
The Huffman-Algorithm, named after David A. Huffman who first published this algorithm in 1952, is a algorithm for lossless data compression. As most encoding-methods, the words for often used symbols are shorter than the ones for not so commonly used symbols. The algorithm returns a binary code-w... |
Looking for a most elegant way to copy dictionary type alias to original collection.
using System;
using System.Collections.Generic;
public class SmallDictionary: Dictionary<string, JToken>
public class NestedDictionary : Dictionary<string, SmallDictionaly>
using System.Collections.Generic;
using System.Linq;
using Mi... |
This code below converts number from decimal to fraction. I don't know if there's a better way or better methods to do this job so any advice would be appreciated.
const toFraction = (inputNumber) => {
// Only two digits after decimal point
inputNumber = inputNumber.toFixed(2);
// destructure number
let [int, ... |
I've been working on my Rust a bit and want to know how idiomatic my rust code is for the following Project Euler problem:
What is the largest prime factor of the number 600851475143 ?
I'm not looking for ways to improve efficiency or how to improve the strategy, but purely what I can improve with my Rust technique. Th... |
So I have been working on this Chess project and for that I need a move generator. I wish to know if I can improve my code for the move generation for the Knight. Here is my current code;
Let me tell a few things so you can better understand it. I am using vector<vector<int>> for the main pseudo moves. I use add the mo... |
I am writing some code that takes and returns interfaces following the patterns in Effective Java Third Edition. I understand the principle - we want to take in interfaces because in many cases we don't really care about the discrete implementation but rather just the features of this interface. We return interfaces fo... |
I have an app whose sole purpose is to seed data files and add the data to different CSVs which are zipped and exported by the user. My application controller is filled with lines that all look like this:
def export_tips
@appointments = Appointment.order('service_id')
send_data @appointments.to_csv_tips, file... |
Wrote this program out of curiosity after initially solving the Word Chains puzzle. Explanation of puzzle in link below.
http://rubyquiz.com/quiz44.html
NWordChains#find_word_chains will take in a number as an arg and return that amount of random word chains from a given dictionary. Initialize NWordChains.new and then ... |
I have just written this code that takes an initial coordinate and returns a new vector depending on a user-supplied range and bearing.
The calculation of the new position is done using Complex Numbers. I am sure there are easier ways to do this, but I wanted to play around with complex numbers. Any thoughts on these w... |
The spreadsheet can be found just above the references section at this link.
https://www.sciencedirect.com/science/article/pii/S1872497316301429
It's a publication for STR DNA locus frequencies to calculate match probabilities. I'd like to build a match probability calculator and scale it up to do hundreds of thousands... |
I've been trying to learn java recently and I finally finish my first code. Any suggestions on where I can improve? Also, is it possible to send an argument to a class using something like an init function in python and are there any good and bad habits that I should keep in mind?
class LIFO {
//Create an empt... |
(Sorry for my bad English)
Hi, I'm interested in getting feedback of my own implementation of Conway's Game of Life.
Some details:
Uses gloss for animation
Uses rio for shorter dependency list
My implementation suffers from performance issue when the population grows larger than 2000 cells.
My code:
Main.hs:
modul... |
I have implemented the following program below for an assignment for practice on STL templates and algorithms. All I'm doing is implementing the code for the printing of empty files, un-empty files, etc.. I would love to know if there is any way to make the code more optimized.
Note: From the requirements of my school ... |
https://leetcode.com/problems/my-calendar-ii/
Implement a MyCalendarTwo class to store your events. A new event can
be added if adding the event will not cause a triple booking.
Your class will have one method, book(int start, int end). Formally,
this represents a booking on the half open interval [start, end), the
ra... |
Description
I have created a darkroom timer, which is used for enlarging and developing film.
It has four separate timers, and can toggle mains via a relay to turn on the enlarger for a specified amount of time. Something like a mix between a triple timer for development and an enlarger timer.
For this project, I used ... |
Is there a way to rewrite these last 2 recursive functions with fewer arguments (preferably 2) while keeping them recursive?
The entire code can be seen here: https://github.com/GirkovArpa/hutton-typescript
Maybe it's perfectly standard to have so many arguments. I don't know.
Also, the encrypt and decrypt functions a... |
I've written a .NET Core console application to monitor the operation of a sensor network and I'd like a review of the task scheduling performed by the main program loop. There are three tasks that are all declared as public static async Task that perform the following operations:
CheckGateways.CheckAll connects to an... |
I am new to python, I made a calculator but I need to make it calculating unlimited numbers and to shorten the code more, how can I improve it?
Any help is appreciated.
while(True):
print()
try:
nums = int(input("How many numbers you want to calculate?\n"))
# x = float(input("Enter the first number:... |
I wanted to do a very little project of a team scrambler. There are two teams of 5 players. Each player has a unique color (in his team) from a limited pool. You can use 2 actions :
Scramble the teams which mix all players between the two teams
Request new color for a team which reassign new color for each player of t... |
I have written a script which does parsing to the input file and take out some values from them with respect to the node and print the data accordingly.
Below is my script, and it works as expected:
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local 'timelocal';
use List::Util qw(reduce);
use POSIX qw( strftim... |
I'm practicing algorithms, and I just can not come up with a faster solution to this problem, but I'm not hitting the benchmark.
Problem: In a large list of large integers, I must find the one element, that is present in odd numbers. E.g. [1,1,1,1, 2,2, 3,3,3, 4,4,4,4].
I wrote several solutions, but I can not increase... |
I am asking this, because after studying I am confused that it is necessary to declare base class object, then declare derived class object and then store reference of derived class object in base class in c++ to use polymorphism.
But what do you think, did I use polymorphism in Accounts, CurrentAccount, SavingAccount ... |
I am still learning PowerShell and I would like your opinion on my folder deployment PowerShell function. It basically check if a defined folder exists and creates it if it does not and writes it actions to log and console.
<#
.SYNOPSIS
Creates folder if it does not already exists.
.DESCRIPTION
This function check if d... |
Here is MIPS code to return 1 if a number is even, 0 otherwise:
isEven:
andi $t0, $a0, 1
li $t1, 1
sub $v0, $t1, $t0
jr $ra
My question is whether this can be done in fewer instructions. I could implement isOdd in two instructions (by eliminating the li and sub), but I don't see a single-instruction way t... |
I wrote this login system in the evening and i would like to know what should I fix / change, if should I use classes and, about readability, if this code is OK.
I'm a begginer in coding so made this small project only for exercising, but good to know wether if i'm things doing right or wrong.
import os.path
credentia... |
Mind that this is my first actual program in C++ and I tried to prepare for any possible input. Also the reason I included static_cast<void>(generator(range)) is to throw away the first random value because I read on LearnCpp.com that throwing away the first is a common practice to produce more random results. Anyway... |
I solved this exercise on jshero.com but I know the solution can be written more cleanly, I just don't know how.
Here are the directions:
Write a function addWithSurcharge that adds two amounts with surcharge. For each amount less than or equal to 10, the surcharge is 1. For each amount greater than 10 and less than or... |
This is my code, which chooses a random number from 0 to 10 for the user to guess.
//guess the number game
//my code
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
unsigned int secretNumber;
int guess;
int maxNumber = 10;
int maxTries = 4;
int nu... |
I reimplemented cat(1) for fun. I followed the Open Group Base Specifications (Issue 7, 2018 edition), not the GNU variant and its command line arguments.
Buffered and -unbuffered behaviour
While the specification defines the behaviour for -u, it doesn't define how the arguments should be concatenated when the -unbuffe... |
Goal
Return a deep copy of a double LinkedList.
Each node also contains an additional random pointer, potentially to any node or null.
Code to start
data class Node<T>(
var data: T?,
var previous: Node<T>? = null,
var next: Node<T>? = null,
var random: Node<T>? = null
class LinkedList {
// TODO: ... |
I'm finding it difficult to decide on the best architectural pattern for a SwiftUI app but, for the moment, I'm sticking with MVVM as I found this a good fit conceptually.
I'm trying to avoid the SwiftUI layer knowing too much about the business logic and navigation structure but am struggling to decide how best to ach... |
For the sections between count=1s and the start and end; combine overlapping positions and output the median of the counts.
Input
chr start stop strand count
chr1 0 13320 - 1
chr1 13320 13321 - 2
chr1 13321 13328 - 1
chr1 13328 13342 - ... |
I have written the following method that allows me to import from another API all the items stored there using Feign.
The only issue is that the external API provides a size limit of 2000 and therefore I need to take pagination into account to get all the records.
I think that my solution is not very clean and maintain... |
I'm using NumPy to find out langrage polynomial interpolation. I'm using 2 for loop to find out langrage polynomial, but I want to reduce 2nd for loop so that my code time complexity can be less. Can you guys please suggest me how I can cut a for loop to increase my time complexity.
import numpy as np
import matplotlib... |
I would like to get any feedback about my implementation of Dijkstra algorithm in Rust following this youtube video.
Please be aware that this my first code in Rust as well as my first Dijkstra implementation in any language.
type Vertex = char;
#[derive(Debug)]
struct Connection {
peers : (Vertex, Vertex),
... |
I am still learning PowerShell and I would like your opinion on my log writing function. It creates a log entry with timestamp and message passed thru a parameter Message or thru pipeline, and saves the log entry to log file, to report log file, and writes the same entry to console. In Configuration.cfg file paths to r... |
I made a project, that scrapes images asynchronously and saves them in container. I have access to them through volume. Scrapy finds images on given web page.
Any tips will be good. But first I would like to focus on docker-compose I would appreciate tips on how to improve it.
files tree
My project looks like that. cel... |
I have a pivot table of approximately 2 millions lines coming from a dataframe with the same structure as below:
raw = pd.DataFrame([[123456,datetime(2020,7,1),'A',10 ],
[123456,datetime(2020,7,1),'B',25 ],
[123456,datetime(2020,7,1),'C',0 ],
[123456,datetime(202... |
This is my first ever c# script. I have played around a little and I think this is some proper c# code. Since it's my very first c# ever, I'm assuming there's a few mistakes, things that could be better, bad conventions and such. If you see any, please let me know so I can improve!
using System.Collections;
using Syste... |
This program will ask for user to insert summoner and base from the last 20 games of said summoner, it will give avg stats and see if good or not by wins in last 20 games(a simple grading system).
import requests
from getId import idcollect
from games import GAME
from wins import win_calc
#Key for riot API
Key = '****... |
I am currently practising using the SOLID principles in C#/.NET
I have made a little example, but i am not sure if i have followed it correct.
Its a simple example where i have an API controller that calls a method to get a list of users from an database and returned as DTOs.
To use the method i need to submit an IUser... |
so I am playing with Rawg.io 's API.
U can sort their game list by their release date, however there are just too many games. In their website, there's an option called "Popular only", which only shows games that are being followed by at least 1 people.
I implemented this feature by sorting the elements I get and creat... |
So I came across this question on SO and I felt like it would be a cool thing to try and write a parser for since I always wanted to try it. So I present to you:
My first time writing a parser.
It converts strings like this:
"a,s,[c,f],[f,t], [[a,c],[d3,32]]"
into list objects
['a', 's', ['c', 'f'], ['f', 't'], [['a',... |
I am fairly inexperienced when it comes to jQuery/JavaScript, so although the following code works, I am just looking to understand if my use of looping, deferred/promises etc could be optimised at all.
Purpose of code
This is just part of a larger script, which I have written to load images and its written details int... |
I needed to dynamically load and instantiate some classes from a generated jar and a generated .class file which depends on that jar. So I came up with this:
package ytm.yajco.translation.util;
import org.jetbrains.annotations.NotNull;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLCla... |
Unity scripts need access to components they will be using, my solution here guarantees that a script will have a valid reference to a component it needs, but is this solution overkill, or hard to discern intention from?
Note: null coalescence operators would be cleaner but cannot be used for unity objects or component... |
Now that my new compiler is capable of compiling programs such as the Analog Clock in AEC, I've decided to share the code of that compiler with you, to see what you think about it.
File compiler.cpp:
#include "TreeNode.cpp"
#include "bitManipulations.cpp"
AssemblyCode convertToInteger32(const TreeNode node,
... |
below vbscript code took me 3hours just to complete trimming whitespaces of a 24MB file any tips to speed up the process below?
dim filename, path \'variables
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(Wscript.ScriptFullName)
strFolder = objFSO.GetParentFolder... |
Here is my code for a move generator function for a chess engine. It's currently working perfectly and returning fully legal moves. How can i improve it.
I am looking to improve this generator function and make it more efficient
Any help is appreciated!
#include <iostream>
#include <vector>
using std::cout;
using std:... |
The goal here is to pull all alerts from a single iterable:
obj = Alerts(db, args)
for alert in obj.alerts()
pass
Now, I need to add a few more sources and I'm not sure if this is a good approach to instantiate all classes in the AllAlerts constructor? I also don't like the fact that I'll have to add them to the s... |
I need help in rewriting my code to be less repetitive. I am used to coding procedural and not object-oriented. My scala program is for Databricks.
how would you combine cmd 3 and 5 together? Does this involve using polymorphism? My notebook first import parquet staging files in parallel. Then it run notebooks in paral... |
I made a chatroom with a server and client python files, using Sockets and Threading as a project. I'm interested to acquire advice, and optimizations i could make to my program. Also please give me tips on sockets and threading in general, because I'm fairly new to the topic, and i would want to learn whatever is rele... |
I created a solution for the car pooling algorithm.
Problem:
You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn around and drive west.)
Given a list of trips, trip[i] = [num_passengers, start_location, end_location] contains info... |
Heres a code that update weekly datas from production reports
Known flaws :
Im copy pasting the old line and replacing the week number in it to fit it to the one we want to update. The problem is that its not taking in account if cell emplacement of the data is changing.
I also tought it was simpler than re-writing al... |
I am trying to create three buckets of objects. Today, yesterday and past. I am wondering can the following be done in a more concise way in pure JavaScript without any libraries?
const [todayBucket, yesterdayBucket] = [0, 1].map(offset =>
recordings.filter(({ createdOn }) =>
moment(createdOn).isSame(moment().add... |
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time!
Problem
Design a Skiplist without using any built-in libraries.
A Skiplist is a data structure that takes O(log(n)) time to add, erase
and search. Comparing with treap and red-black tree which has the same
funct... |
It took me a while to solve this question and there are corner cases i missed hence the 4 unit tests.
please review for performance. and if you can treat this as a review for a 45 mins programming interview.
https://leetcode.com/problems/find-and-replace-in-string/
To some string S, we will perform some replacement op... |
I wanted to know how "dark" each character is when printed. I thought that this may be useful when doing ASCII-art to help with shading. I decided to write a program to objectively measure how much coverage of an area each character provides, which should roughly translate to how dark it appears when printed and zoomed... |
I built a simple infinite scroll using the intersection observer API, would love some feedback on ways to improve my JavaScript and make it more maintainable and reusable, and feedback according to best JavaScript practices.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Infinite Scro... |
For my hashmap implementation, I'm caching hashes for each map element in an array of length NBUCKETS, where each element corresponds to an element in the hashmap. Assuming a hash consists of 64-bits, the first 57 bits decide the position(bucket) in the hashmap and the last 7 bits (i.e H2(hash)) are used as control byt... |
Please review and help me write better codes.
Combining Pictures
We can use a conditional to copy just the non-white pixels from one picture to another picture. We can take this tiny image of the women and put her by the Eiffel tower in Paris, France. I have modified the code so that the code automatically swaps the im... |
I thought it would be fun to write a simple and small bash script which randomly chooses a wallpaper from a given directory of a set of wallpaper images. The code is as follows.
#!/bin/bash
# simple script to choose random image from
# Wallpaper directory and set it as desktop background
# cd into Wallpaper dir
cd /... |
I'm currently using a function to check if a URL has correctly escaped two different characters: . and /.
To escape a character within a string, it requires 2 preceding \'s in the string (i.e.: \\. or \\/).
Here is the code I'm currently using. As you can see I'm matching the string with some regex, and then for every ... |
The code works fine for inputs that have a solution. The goal board is
1 2 3
4 5 6
7 8
I have tried to implement using the A* search algorithm. The code runs for 2 seconds or slightly more time which seems slow compared to the implementation in other languages. How do I optimize the code?
I have included two sample inp... |
I'm building a method that tries to detect whether given information about an object's property to retrieve, a constraint operator and some data to compare it against, whether the result is true or false.
So I'm given is an object containing the type of object to read (File, Folder, RegistryKey, RegistryValue, MSI), th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.