instruction stringlengths 71 95.1k |
|---|
I am trying to implement a simple raw queue in C++. This is what I have come up with
#include <queue>
#include <cstdint>
#include <array>
#include <cstring>
class simple_queue
{
private:
static constexpr uint32_t max_msg_size = 4096;
using char_msg = std::array<char, max_msg_size>;
std::queue<char_msg> cha... |
I'm trying to embed YouTube video's on a website in a privacy-friendly way.
The code doesn't load the iframes by default but shows a preview
thumbnail overlayed with an info message instead. The user can load a
single video by clicking the button in the info message. The overlay
also contains a checkbox that, if... |
This is the latest version of my Blackjack game and I did a quite big update to it. Now you can make an account that is saved in the MySQL database and you can bet money that are also saved in the database.
from random import shuffle
import os
import cymysql
from getpass import getpass
import sys
def shuffled_shoe():... |
I'm trying to solve ECOO 2018 round 2(regionals) question 2 to prepare for the upcoming contest. Basically, in the question George has to achieve the maximum possible grade by completing the right assignments. Each assignment has a deadline and a weight value. I've came up with two solutions yet both only work for 7 of... |
I was trying to solve a problem which stated:
Calculate the first 10 digit prime found in consecutive digits of e.
I was able to solve the problem but I did it by using some 10k digits of e available online. So I tried to write a program which calculates digits of e. The problem is that it simply gives the incorrect... |
Please see the code below, which I have taken and adapted from here and here (RPCServer and RPCClient):
public RpcClient()
{
var factory = new ConnectionFactory() { HostName = "localhost" };
connection = factory.CreateConnection();
channel = connection.CreateModel();
... |
The Standard C Library consists of various headers files. Often only a few select ones are needed for given code.
Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.
Including all standard <*.h> is useful to help detect naming collisions of ... |
I am working with closures and want to confirm that I do not have any memory leaks in my code. Below is my current code:
// in ImageGalleryController.swift
class ImageGalleryCollectionViewController: UICollectionViewController {
var images = [Image]()
func dropInteraction(_ interaction: UIDropInteraction, performDro... |
I'm trying to teach myself Clojure by reading the Brave Clojure book online, and at the end of Chapter 7 there is an exercise to parse a mathematical expression written as a list in infix notation to s-expressions, following operator precedence rules.
To do this I implemented the shunting-yard algorithm in Clojure. How... |
The task:
Given a list of numbers L, implement a method sum(i, j) which returns
the sum from the sublist L[i:j] (including i, excluding j).
For example, given L = [1, 2, 3, 4, 5], sum(1, 3) should return
sum([2, 3]), which is 5.
You can assume that you can do some pre-processing. sum() should be
optimized over t... |
I am building a calculator and I'm aware of what these functions do.
What I basically want feedback on is: Do I need to comment this or is there sufficient information to ascertain its purpose:
function percentOfValue(percentage, of) {
return (percentage / 100) * of;
}
function whatPercentOfValue(small, large) {
... |
I wanted to write a commandline scipt to generate diceware passwords based on the EFF diceware list.
The script (diceware_password.py) can be found below. It was originally developed for Python 2, but I want it to be compatible with Python 3 as well (both versions have been tested on my machine).
Running it with no arg... |
what I am loading a yaml file and updating it with argparse. what is your feedback on how to update yaml parameters automatically without checking if a argparse parameter is None.
There are almost 20 configuration parameters that with this current version I have to put 20 if conditions.
the output of yaml.save_load is:... |
As part of a personal project, I wanted to make a stopwatch with Python. I wish to show my friend but at the moment it is a little messy and long. Is there any way to make it more compact or easier to read?
#stopwatch
from tkinter import*
import time
root=Tk()
root.configure(background=("black"))
root.title("stop... |
I have been reading about passwords and hashing algorithms and what not and decided to write a program.
Overview: The user should be prompted to create a password the first time the program is executed. They should enter a key and confirm it. If they have executed the program previously, then they should just enter the... |
public class Model extends TicTacToe
{
public static boolean hasWon( int [][] matrix )
{
boolean retVal = false;
//Check for horizontal win
for( int row = 0; row < matrix.length; row++ ){
int sum = 0;
for( int col = 0; col < matrix[0].length; col++ ){
... |
I built a web scraper to pull a list of jobs on Facebook and other websites but want to break up the code into functions that I can reuse for other websites. This structure is working but I think it can be more efficient with functions. I'm getting stuck on how to structure the functions. It's only pulling two pages fo... |
Introduction:
I am working on a javascript plugin AutoSuggest, My aim is to create an IDE like autocomplete experience in web applications using JavaScript.
One of the features I have implemented is focusing a particular portion of inserted snippet after insertion. This is how I am asking input for focus.
focusText: [... |
So I just completed this project for my java programming class and was wondering if there was any way I could streamline it to really impress my professor. Here were the instructions, followed by my code.
The University of Miami's "Band of the Hour" needs a program to organize where the musicians will stand when they... |
I have created a simple C# console app to display an Address Book using Dictionary. I would like to present it in a interview but I am not sure if the code is "interview" worthy. Given below is the Main() method that calls the methods as required.
public static void Main(string[] args) {
while (true)
... |
How do I find the number of unique digits in a given number.
e.g
if 'input1' is 252 it must return 1, since 5 is the non-repeating digit;
if 'input1' is 25000 it must return 2, since digits 2 and 5 are the only non-repeating ones.
Is there a better way to solve this problem?
// COUNT UNIQUE DIGITS
int nonRepeatDigits... |
I have this function where it queries through the database and returns a random user if the requirement is met if not then try it again. It works and all but I feel like the code could be better/shorter/faster but I'm running a blank.
It's all done through Firestore, where the Serivces.crud.reads() is a Firestore .getD... |
I was looking for a thread safe implementation of the observer pattern. I read https://xinhuang.github.io/posts/2015-02-11-how-a-multi-threaded-implementation-of-the-observer-pattern-can-fail.html and was thinking about point 4 "Don't reinvent the wheel, use Boost.Signals2 instead". So I tried the following code and wa... |
I've written a function to remove empty or "" value elements from an array or in other words return an array consisting only of elements containing a value.
Option Explicit
Public Function RemoveBlanksFromArray(ByVal TheArray As Variant) As Variant
Dim temp As Variant
ReDim temp(LBound(TheArray) To LBound(Th... |
The following codes generate table row dynamically. I wonder if there are better ways of generating the same data. Also instead of manually coding the heading and the table itself, is it possible to code them with less codes without using the innerHTML function.
<table>
<thead>
<tr>
<th>ID</th>
... |
I've implemented a self-organising map in Tensorflow's low-level API. After testing with sklearn's Iris data, the results seem correct. I did implement the algorithm also using NumPy before converting it to tf, because I'm new to Tensorflow, and had no idea whether it would work or not. So of course I tried out which w... |
My Sudoku solver is fast enough and good with small data (4*4 and 9*9 Sudoku). But with a 16*16 board it takes too long and doesn't solve 25*25 Sudoku at all. How can I improve my program in order to solve giant Sudoku faster?
I use backtracking and recursion.
It should work with any size Sudoku by changing only the de... |
I need to find the sum of the digits of the given number and repeat the process until the value lies between 1 to 9.
e.g
if the input is 72457 then,
7+2+4+5+7 = 25
2+5 = 7
so , the function should return 7.
Also, if the input is a negative number like -72457 the function should return -7.
Here's what i tried,
int di... |
In the codebase I support, I found the following code. I am interested in your opinion about its expediency and especially the expediency of redefining the operator().
template <typename KEY, typename VALUE>
class MyUnorderedMap {
std::unordered_map<KEY, VALUE> map;
public:
template <typename T>
auto... |
To practice my c++ I decided to implement a simple Kafka producer to wrap the producer in c in librdkafka library. I just want to get your opinion on the way I have implemented teh default, copy and move constructors and make sure what I'm doing is safe.
Default constructor:
kafka_publisher::kafka_publisher(const std... |
I am making a library which can use different auth mechanisms. I have abstracted the code within an interface:
interface Authenticable
{
public function getName(): string;
/**
* Based on auth type, return the right format of credentials to be sent to the server
*
* @param Authenticable $credenti... |
I am interested in learning how I can improve the speed of the code in this pygame file. I iterate over 6400 * 1800 * 3 or 34,560,000 elements of various numpy arrays here to apply noise values to them. The noise library I'm using can be found on GitHub here.
I am calling static variables from a class called ST here. S... |
I've created code in JavaScript for a form validation in a variety of different ways, including if the field is empty, if it contains special characters, if it has numbers/letters when it shouldn't have, and if it exceeds a certain limit. There's also some special cases when the field asks for a year/price. My code doe... |
I created a math quiz/game called "Factions". In the game, there are 2 teams. Red team and Blue team. They take turns answering questions relating to fractions. If they get it correct, they gain points equal to the round number * 100. If not, then they lose points equal to the round number * 100. Each team starts off w... |
I wrote a program in pygame that basically acts as a physics engine for a ball. You can hit the ball around and your strokes are counted, as well as an extra stroke for going out of bounds. If I do further develop this, I'd make the angle and power display toggleable, but I do like showing them right now:
import pygame... |
Trying to script a simple command line tool for ingesting media to a target location following a structured naming convention.
It's functional in its current state but I'd like to know if there are things to improve.
#!/usr/local/bin/bash
#make target directory for transfer
make_directory(){
echo -e "\n\nFollo... |
I use a dummy solution to solve the leetcode 3Sum problem.
I employ the set data type to handle duplicates, then transform back to list.
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
The solut... |
I was given this problem in an interview.
Given two words source and target, and a list of words words, find the
length of the shortest series of edits that transforms source to
target. Each edit must change exactly one letter at a time, and each
intermediate word (and the final target word) must exist in words... |
I have implemented two related shortest path algorithms for unweighted graphs in C89. My attempt was to learn some more idiomatic C constructs such as genericity (a client programmer should be able to plug in his/her graph data structures to the algorithms). Some questions:
Is it a good idea to embed the unit tests of... |
In this post, I present a hash table -based set data structure written in C89:
unordered_set.h
#ifndef UNORDERED_SET_H
#define UNORDERED_SET_H
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct unordered_set {
struct unordered_set_state* state;
} unordered... |
I'm using jQuery to create a (hidden) form that redirects people to another page using JavaScript.
// redirect the user to another url
function redirect(options) {
// create the form
$("<form>").attr({
"hidden": true, "action": options.url, "target": (options.new_tab === true) ? "_blank" : "_self"
// create t... |
I've written a program and it needs a review by skilled programmers.
The programs goal is to change 0-s to X and X-s to 0. The rule is X or O can move only to an empty place and x or o can only "jump" over one X or O. Program looks like:
------------------
|x|x|x|x| |o|o|o|o|
------------------
User input
move from? (... |
I am trying to find out if a column is binary or not. If a column is only having 1 or 0 then I am flagging it as binary, else non binary. Since I have a database background, I tried to achieve it through a SQL like statement. But when the file is big, this code is not giving me good performance.
Could you please sugges... |
Trying to learn coding in my 30s.
Could anybody review my code and give me some feedback if possible? It works, but I am sure there are better ways to solve this problem.
The problem:
A text is given. Write a program that modifies the casing of letters to uppercase at all places in the text surrounded by <upcase> and <... |
I created a program in python that generates an image of the mandelbrot set. The only problem I have is that the program is quite slow, it takes about a quarter of an hour to generate the following image of 2000 by 3000 pixels:
I first created a matrix of complex numbers using numpy according to amount of pixels. I a... |
I implemented a word n-gram model using a character ternary search tree. It is intended to be passed a generator that yields a long sequence of words (from a corpus) and its requirements are that it
can return frequencies and probabilities for word n-grams
allows providing a vocabulary, such that n-grams containing wo... |
The task
Given a variable of type long with the number of milliseconds from January 1, 1970 until a later date (CurrentDate). Build a class for get the year, month, day of year, day of month, hour, minute and second of the CurrentDate.
Solution 1:
public class MilisecondToDate {
public final long MILISECONDS_PER_Y... |
I am Displaying mask images & allowing user to upload the custome image inside mask image, now i want to give an option for user to Edit & Delete the Uploaded image....
Video link : https://drive.google.com/file/d/158RCO_NaXUg9KWOKSX6_SQ5r0CYF40oK/view
For that I need to create Pop up box once user click on Edit butto... |
I did a job application to a Unity developer position and i was given a coding challenge which was implementing a Rock Paper Scissors game or a variation of it. I have implemented the game using Unity and C# and the feed back I got was my implementation being "too mathematical" and "lacking object oriented principles".... |
I have a function find_all_intervals_below that iterates through a vector and finds all the index intervals of at least a given length where each element within the interval is below a given threshold.
struct Interval {
int start;
int end;
};
std::vector<Interval>
find_all_intervals_below(const std::vector<int... |
The task:
Given a list of points, a central point, and an integer k, find the
nearest k points from the central point.
For example, given the list of points [(0, 0), (5, 4), (3, 1)], the
central point (1, 2), and k = 2, return [(0, 0), (3, 1)].
My solution:
const lst = [[0, 0], [5, 4], [3, 1]];
const center = [1,... |
I'm debating with my colleagues which code is better:
user_agent is a class instance. The class itself comes from a third-party library so we don't have any control over it.
1.
def _get_ua_device_type(user_agent):
property_to_type = {'is_mobile': 'mobile', 'is_tablet': 'tablet', 'is_pc': 'pc', 'is_bot': 'bot'}
... |
I created simple quicksort algorithm using iterators. I'm happy with implementation but not with its speed. Profiler tells me that the slowest operation here is std::iter_swap. I don't really know how to improve this code. Note that I am not asking for different kind of quicksort algorithm but about improving this one.... |
I'm building a web app using Flask to offer surveys to users. The number of questions on the survey and the type of questions isn't known until runtime. I finally have the code working properly, and would like some feedback on how pythonic the code is and what I can do to improve it.
To account for a single form page t... |
Take this controller for instance. Is there a way I can rip out the constructor and property, extend a base controller class and still have $twig? I feel like this repeitive behaviour can be removed.
I understand that I need to extend a base class, but I'm not 100% sure where to go from there.
namespace App\Contr... |
This is my first Go program. I would like to know what could be improved, what is done wrong, and anything else that I should know. The CSV contains 10 questions with the 10 answers separated by a comma. For example:
10+10,20
4+5,32
If you want the full context this is from gophercises which are some exercises to prac... |
I started learning Java not long ago. Quite often, assignments require me to print output in a table. I had some spare time last week, and I wrote a separate class for printing tables. It is working as intended, but I'm not confident the code is "clean". I would like to hear some opinions on what I should improve.
impo... |
I just recently started using AWK and I'm still learning about it. I have solved the problem I'm about to show but I feel it's not the best solution and I'm trying to find a solution to fit within an AWK command rather than keep piping.
I have a bunch of .txt files ending for which I read the header (1st line only).
he... |
link to original question: Simple media ingest script
As per answers I have refactored my code and would like to get feedback on the current structure.
The purpose of this tool is to allow someone to copy media from cards (SD cards, CFast, etc) using rsync and to also allow someone to complete incomplete transfer that... |
The following code copy a complete folder (that has 3 folders inside), then check if errors are generated and send email if there's errors, the it proceeds to create 3 different tar files and finally move this tar files to a mounted network drive, every name has been changed or somehow altered in order to comply with m... |
I am new to python3 and tried to solve the task in a very basic way. Please critique my code. I appriciate any suggestions for improvement.
Here is the question:
The four adjacent digits in the 1000-digit number that have the
greatest product are 9 × 9 × 8 × 9 = 5832.
731671765313306249192251196744265747423553491949... |
Please review my code for parking lot design.
I am new to OOD concepts, It will be great to have some feedback on OO Structure of the solution.
Requirements considered:
The parking lot can have multiple levels.
Each level can have 'compact', 'large', 'bike' and 'electric' spots.
Vehicle should be charged according to ... |
Problem: Training
As the football coach at your local school, you have been tasked with
picking a team of exactly P students to represent your school. There
are N students for you to pick from. The i-th student has a skill
rating Si, which is a positive integer indicating how skilled they
are.
You have decided... |
I got this problem during a mock interview, and I would like to get code review for the backtracking solution. I include 7 test cases, and my solution passes 7 out of 7 test cases. See the online code compiler here
Robot Paths
Prompt: Given a matrix of zeroes, determine how many unique paths exist from the top left... |
I decided to play with F# and found simple task on Codewars.
The task is sounds like "Calculate Sum/Mean/Avarage for selected City".
I decided to calculate only Sum. My solution is horrific. I would be grateful for your advice's how to do this in a right way. Thank you!
let d0 =
"Rome:Jan 81.2,Feb 63.2,Mar 70... |
LeetCode Problem
Reverse digits of a 32-bit signed integer. When the reversed integer overflows return 0.
Feedback
Optimized from beta code in the original question here. Based on this LeetCode problem.. I'm trying to come up with a good approach that just math operations to iterate a serious of digits using division... |
I would like any constructive comments regarding the structure of this simple App that takes an API response and then displays on a table view.
The URL is written in a ConstantsAPI file
let baseUrl : String = "https://haveibeenpwned.com/api/v2"
let breachesExtensionURL : String = "/breaches"
Displayed on a tableviewco... |
Validate IP Address
I got this problem during an interview. And would like to get some code review. I also wrote several tests with the expected output, and they all passed as expected.
Validate an IP address (IPv4). An address is valid if and only if it
is in the form "X.X.X.X", where each X is a number from 0 to 255... |
I tried to solve a merge two sorted list problem in leetcodes:
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
class Solution:
def mergeTwoLists(self, l1: ListN... |
I'm currently in the process of refactoring an old poker game which violates many of the SOLID principles.
I was trying to use the TDD approach to refactoring and I found myself having to hard code a player's hand every time I wrote a unit test for a specific poker hand check.
For example, here are the unit tests for ... |
I have this update method which decides whether to update or recreate(same as update but resets the approval_status and create_date) of the building_approval object. I have the on_progress? method on building_approval class to check whether it needs to be updated or recreated so no flags are being passed from the view,... |
I've tried to implement integer partition algorithm as described in blogpost below (author implemented it in Python):
Generating integer partitions
I'm still trying to learn best practices in producing clean code. I would also be thankful for any performance tips.
My code:
struct NumberPartition {
a: Vec<i32>,
... |
I have to create a client-server JavaFX application using MVC which does many operations consisting mainly in messages exchange.
I'd like to know if this way to handle client acceptance and client requests is good or not.
public class ServerOperations {
// other code
public void serverConnection() {
Runnable runn... |
Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters.
For example, given s = "abcba" and k = 2, the longest substring with k distinct characters is "bcb".
I found few solutions online like. I felt they were bit too complex. I have tried to simply the so... |
I'm looking for an optimum way to join two Dataframes where the same record exists in both. Examples would be:
dat1 = pd.DataFrame({"id": [1,2,3,4,5], "dat1": [34,56,57,45,23]})
dat2 = pd.DataFrame({"id": [2,3,4], "dat2": [19,19,20]})
dat1
id dat1
0 1 34
1 2 56
2 3 57
3 4 45
4 5 23
dat2
... |
I would like to have a function Chain-Paths to accomplish the following: given a base directory (Base) and a location, possibly relative to that given Base (Chained), output the result of joining both paths. If however Chained is already an absolute path, just return that. If both paths are relative, keep the result re... |
I'm a student and this is my first application/project that I made and finished today in C++ using OOP and I want to hear your opinions and suggestions, what I did wrong, what I did good, what should I improve, what should I exclude, about comments, anything that can help me getting better and improve my code.
To test ... |
I have this bash script that adds users to NextCloud from a csv file. It expects to be run from the same directory as the docker-compose.yml file.
I'm pretty new to bash scripting and I'm wondering if I am doing things correctly or if there are pieces that could be improved in terms of efficiency, correctness, style? A... |
I wrote a program that animates the Recamán sequence. It is in uses HTML canvas and JavaScript. I was hoping for some feedback on how it could be improved.
"use strict";
function getMousePos(evt, can) {
var rect = can.getBoundingClientRect();
return {
x: evt.clientX - rect.x,
y: evt.clientY - rect.y,
... |
I am currently developing a Django Rest Framework API with TDD. I have 15 tests and counting for two views, which doesn't seem right to me. It takes me a lot of time to write the tests and a lot of the testing logic seems redundant to me, especially because I have to check permissions for each test request. Furthermore... |
I have one following question and write a function for it. can anyone give me some suggestion how my code can be better and better way to handle to build up return list with even frequency?
One message system contains two device type message that each message is formatted with device type identifier with
device id a... |
I have created a simple CRUD method using Web API project which consumed by 2 platform: Console App and MVC Web Application. The EntityModel project is mainly the entity and the DAL layer. Is my architecture/structure okay in regards to implementing Web Api? Should I have this DTO thingy or do without? There is only on... |
I have the following very simple class:
class accusation
{
private:
std::string murderer;
std::string weapon;
std::string place;
public:
accusation() = default;
accusation(std::string, std::string, std::string);
friend std::ostream& operator<<(std::ostream&, const accusation&);
friend std::i... |
I want to reduce some repeated code in my Java 1.8/Spring Boot application, and to that end I tried to make a reuseable asynchronous utility module. In essence its an async List.forEach that takes a List and a consumer for each item of the list. Output is optional.
AsyncUtilImpl
import org.springframework.beans.factor... |
I was told to code a board game app using React for a job interview.
They told me they chose other candidates to move forward with, so I was wondering on what I could improve.
The full code can be viewed here.
Here are the more interesting components:
TicTacToeGame
import React, {useCallback} from 'react'; // useCallba... |
I have a simple app, which is something like a launcher for my macro enabled excel workbook. I made it for easier distribution, to be able to check if excel installed and also to make it look and behave like a standalone application.
I am using Office Interop which, according to MS, has many performance issues. But sti... |
Calculating many remainders for each prime and composite consumes more time.
I use a factoring function to find factors of single values.
When I use a factoring function to find lists of primes, I use a wheel.
A wheel exploits composite values punctuating an otherwise prime sequence.
The primary advantage of a wheel is... |
I just wrote this template to detect if a given element is found inside a container:
template <typename Iterator> bool is_contained(Iterator begin, Iterator end, decltype(*begin) object)
{
for (; begin != end; ++begin)
{
if (*begin == object)
{
return true;
}
}
return... |
I implemented a standard quicksort and I have a project where I need to improve it. I am trying to make quicksort faster by implementing median of 3 partitioning. I copied codes from trusted educational sites and the code is working, everything is being sorted. The issue is that, the median of 3 partitioning is taking ... |
I'm writing several local servers which have almost the same code in main.cpp. Appreciate your comments, improvement suggestions and especially notes on potential memory leaks since the services are supposed to run 24/7 and process large requests. Thanks!
#include <iostream>
#include <thread>
#include <mutex>
#include ... |
I created my brainfuck interpreter and I would like to know what can be done better and is the code clear and readable. I will be very thankful for opinions and suggestions.
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#define ALLOCATION_ERROR 1
#define FILE_ERROR 2
#define OTHER_ERROR 3
#define TAPE_SIZE ... |
I made code for signing in users and storing data about them. Everything is fully encrypted and secure also, it is meant to be imported into other code. I'm looking for ways to improve it and to fix any bugs people might find.
import pickle
import base64
class user():
def __init__(self, username, password, user_da... |
An extension to array functions I am building for my snake game. This one allows you to remove / insert particular elements.
https://github.com/Evanml2030/Excel-ArrayFunctions
API CALLS
Private Declare PtrSafe Function VarPtrArray Lib "VBE7" Alias "VarPtr" _
(ByRef Var() As Any) As LongPtr
Private Declare PtrS... |
Source: HackerRank & ProjectEuler.net
Problem: Largest Product in a Grid
In the 20×20 grid below, four numbers along a diagonal line have been marked in red.
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88... |
The following function is accepting PUT connection to a server API, checks authorization to write and then performs write to a database.
The eslint linting tool complains saying "avoid nesting promises" and "Each then() should return a value or throw". I'm new to promises and I am not sure how to improve my code.
app.p... |
I have three getters in my store:
getActiveTournaments(state) {
return state.tournaments.data
? state.tournaments.data
.filter(tournament => tournament.state_value === 'in_progress')
// sort tournaments by date of creation
.sort((tournamentA, tournamentB) => tournamentA.created_at - tournamentB.cr... |
I am working on the problem removeDuplicatesFromSortedList
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Example 1... |
This is a follow-up to my ex-posted Blackjack game that uses a MySQL database to store the accounts and user's money. I tried splitting display_info() a bit, I also added a check for validating the Email address and the passwords are now hashed.
from random import shuffle
import os
import cymysql
from getpass import ge... |
I want to reduce the big time it needed for my mandelbrot set generator to work. I'm working this for already a week.
I tried to reduce the canvas size from 400 by 400 to 200 by 200 and the speed increased a bit. Tried using multithread.js but still slow...
Here's the JavaScript code:
//Create the canvas, then collect... |
I have an assignment to solve this problem.
Problem Description
Bob the Cat is building a new system, dubbed the Cats Transmission
System (CTS). This horribly inefficient system utilises cats to help
transfer information. In this system, there are N cats lined up in
a line from cat 0 to cat N-1. If a message nee... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.