instruction stringlengths 71 95.1k |
|---|
I have created a simple Activity Planner that allows adding tasks and associated sub-tasks. It is mainly based on the Treeview widget. This being my first GUI-based project, I would like to know:
If this is a good design pattern
If this could have been better broken down
About any typical features to be added
How it ... |
I've some Metal buffers which I populate with geometry data. Most data consists of Floats, but the buffer also contains custom structs for the tessellation stage.
I get the UnsafeMutableRawPointer for the Metal buffer in this way:
let origin=geometryBuffer.contents()
Which I then supply to the following function:
... |
I was looking into SOA to better utilize SIMD instructions. I implemented a generic wrapper object that lets you chose the amount of individual vectors each structure consists of. I am using xsimd and boost libraries if you're interested in testing it out.
Next step would be to make initializing the buffer easier, like... |
I have a dictionary that looks like this:
Counter({(1, 9): 3, (4, 2): 2, (3, 0): 1, (5, 4): 1})
I would like to convert it to an array that would look like this:
[[1, 9, 3], [4, 2, 2], [3, 0, 1], [5, 4, 1]]
Help appreciated!
import itertools
import collections
import numpy as np
a = [1,5,1,1,3,4,4] # First column
b ... |
As I'm learning c++, I decided to implement my own sorting algorithm. As I'm a beginner I didn't use any template to be able to use them for different types of variable and they can only sort item in a vector. I implemented bubble sort, selection sort, insertion sort, merge sort and quick sort. I'm not asking you to re... |
LINQ Select usually works like this:
IEnumerable<Task<int>> res = new[] {1,2,3}.Select(async i => i);
I would like to have the following though:
IEnumerable<int> res = new[] {1,2,3}.Select(async i => i);
This extension method helps to get it:
static class SelectAsync
{
public static IEnumerable<TResult> Select<T,... |
So my question is the cleanest way to do #product_panels_for below:
class ProductPanel < Struct.new(:product)
end
class ProductPresenter
def product_panels_for(selected_products)
selected_products.map do |product|
product_panels.find { |panel| panel.product.to_s == product }
end.
compact
end
... |
My Solution
What I am looking for:
DRY Code - in my handleDeleteBook and handleToggleStatus methods I felt that I couldn't find a way to share the id between the methods. Furthermore, what other sections of the code need to be DRY?
MVC Pattern - this was my first time using the MVC pattern so I don't know if I did it ... |
I'm trying to optimize my code or see if there's a better way to do it. Given values for acctData and balances below, I need to return an array of accounts filtered by the user name.
const acctData = [
{
acctNum: "AAA - 1234",
user: "Alice"
},
{
acctNum: "AAA - 5231",
u... |
ERROR: type should be string, got "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/\n\nGiven a non-negative integer num, return the number of steps to reduce\n it to zero. If the current number is even, you have to divide it by 2,\n otherwise, you have to subtract 1 from it.\nExample 1:\nInput: num = 14 Output: 6 Explanation: Step 1) 14 is even; divide by\n 2 and obtain 7. Step 2) 7 is odd; subtract 1 and obtain 6. Step 3) 6\n is even; divide by 2 and obtain 3. Step 4) 3 is odd; subtract 1 and\n obtain 2. Step 5) 2 is even; divide by 2 and obtain 1. Step 6) 1 is\n odd; subtract 1 and obtain 0. Example 2:\nInput: num = 8 Output: 4 Explanation: Step 1) 8 is even; divide by 2\n and obtain 4. Step 2) 4 is even; divide by 2 and obtain 2. Step 3) 2\n is even; divide by 2 and obtain 1. Step 4) 1 is odd; subtract 1 and\n obtain 0. Example 3:\nInput: num = 123 Output: 12 \nConstraints:\n0 <= num <= 10^6\n\n public int NumberOfSteps (int num) {\n int count = 0;\n while( num !=0)\n {\n if(num %2==0)\n {\n num = num/2;\n count++;\n }\n else\n {\n if( num == 1)\n {\n return count+1;\n }\n num = num-1;\n count++;\n } \n }\n return count;\n }\n\nPlease review for performance\n" |
I am trying to find missing positive integer in an. array.I don't know where my function not working ?
question given
Given an unsorted integer array, find the first missing positive integer.
Given [1,2,0] return 3,
[3,4,-1,1] return 2,
[-8, -7, -6] returns 1
my function works on following above cases works fine..
... |
https://leetcode.com/problems/sum-of-two-integers/
Calculate the sum of two integers a and b, but you are not allowed to
use the operator + and -.
Example 1:
Input: a = 1, b = 2 Output: 3 Example 2:
Input: a = -2, b = 3 Output: 1
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MathQuestions
{
///... |
In rust fp-core crate there is a compose function, but it is very limited for my liking.
So I made a macro which uses the function composition syntax of Haskell.
I would like to know why fp-core didn't do something like this in the first place?
What advice would you give me since this is the first macro I ever wrote i... |
I'm looking for some fresh ideas on how to optimize a couple of functions in my C++ code. I run the code through a profiler and it shows that they take 20% and 40% of the time respectively. The functions are called many times as they live inside a triple nested loop (cannot be avoided).
The blip3_inner(args...) (20% of... |
This is my first static web project made from scratch without any external js libraries.
please review and let me know the improvement areas.
1, are my js functions upto mark? any performance issues are there?
2, are css styles properly refactored?
3, are html tags used fine? etc..
/* dark mode code */
const darkMode... |
Current OBJLoader:
Using pygame's obj loader as a base, I created a new obj loader for Python OpenGL. The loader includes the following functionality:
Collect vertices, normals, and texture to draw
Divide objects based on materials
Store each material's vertices, normals, colours and textures in
separate VAO's
Have an... |
I stumbled across the 100 prisoners problem on Rosetta Code. I thought it would be fun to add a Common Lisp solution, see below.
Before I publish my solution I would like to have some feedback on my code. I have used lists for the task because I think it is most natural in CL and performance isn't an issue here.
Thanks... |
I have three methods that I need to call multiple times only varying the date parameter of each. The natural solution to avoid code duplication is to put the three methods in a loop and iterate over the varying dates.
The problem with that approach is that I need to keep track of the results of each method call along ... |
The question is from Automate the Boring Stuff with Python and asks us to find the number of streaks of six heads or six tails that come up when a coin is tossed 100 times.
Coin Flip Streaks:
For this exercise, we’ll try doing an experiment. If you flip a coin 100 times and write down an “H” for each heads and “T” for... |
Background
Traversing the file hierarchy, going through files and sub-directories from a directory, is a quite common task when doing file system search operations of some sorts. I have already encountered multiple applications where I need to do this as a part of my solution, so I figured I should put this code in a s... |
I've written a function which should generate an ISO 8601 duration string, given two Dates as input.
import {
differenceInYears,
differenceInMonths,
differenceInWeeks,
differenceInDays,
getDaysInYear,
eachYearOfInterval,
} from 'date-fns/esm'; // v2.11.0
/**
* Given a start Date and an end Date, returns a... |
When I was not sure about how to do this, I asked this question on StackOverflow, the body of which is the following:
As regards line numbers, when doing normal file editing, I prefer to
have the following setting
set number
set relativenumber
because the former tells me where I am, the latter helps me using
j an... |
I have the following working code
import numpy as np
r = np.loadtxt('CoordUnwrapped/ParticleCoordU.5000',skiprows=9,usecols = (4,5,6))
rcom = np.loadtxt('hexaCOM/COMA/COMA.5000',skiprows=10,usecols = (4,5,6))
N = 50
Sx1= []
Sx2 = []
Sx3 = []
for i in range(0,N):
S_data_1 = (r[i,0]-rcom[0,0])**2)
S_data_2 = (r... |
My problem is I'm having a table and 7 child table. I'm fetching details using querying the main table first then querying the child tables one by one sequentially. To improve performance I decided to execute all the seven queries parallely using completable future.
StoryDetail storyDetail = new StoryDetail();
C... |
Design a class called Post. This class models a StackOverflow post. It should have properties
for title, description and the date/time it was created. We should be able to up-vote or down-vote
a post. We should also be able to see the current vote value. In the main method, create a post,
up-vote and down-vote i... |
I'm relatively new to Python and learned, that function cannot return nothing, not even None. In my application I want to iterate over a list and keep all non-None results of a complicated function:
def complicated_function(x):
if x < 0:
return "a"
elif x == 3.6:
return "b"
elif x == 4:
... |
I made a calculator a few days ago and posted the code here. I got some very helpful feedback. So I remade the calculator and learned a lot in the process. Here's my new code:
In the header file:
#include <string>
template <typename NUMTYPE>
std::string calculate(const std::string&);
template <typename NUMTYPE>
std::s... |
I have written a very basic algorithm, that counts the amount of times sub-string appears in a string.
The algorithm is given:
seq - a string sequence
k - length of a sub-string
L - a window of a string to search in
t - times that sub-string, length k has to be present to be added to results
from collections import ... |
I've created a function that generates an <ul> of my wordpress custom taxonomy terms, displaying parent > child > second child heirachy. Functionally it is working perfectly and replaces my old hard-coded menu.
The problem is I'm inexperienced and recognise it as an ugly, inefficient function but could not figure out ... |
For work, we have to use Atlassian Jira, which is depressing. To make my life a bit easier, I decided to write a cli application to get ticket summaries, and I thought it would make a good first project in rust. The code below works, but I would be grateful for any tips/improvements. I'm a python programmer, so it's al... |
In my web API, the client wants me to implement logic in order to control/block concurrent requests in a specific time period. I added RequestInterval which is 10 seconds in the appsettings of web config. I added the Authorization filter into my project. I tested, it looks working but I wonder if you can check and give... |
I have had an attempt at the Mars Rover Kata and would very much appreciate a review and any suggestions to improve.
MessageParser to parse incoming messages and create the domain models:
public class MessageParser
{
private static readonly Regex GridDetailsRegex = new Regex(@"\d\s\d");
private stat... |
I've made a simple brainfuck compiler, I feel like my code is unreadable and messy, how can I improve it?
src/core.clj
(ns brainfuck-asm.core
(:require [brainfuck-asm.parse :as parse]
[brainfuck-asm.optimize :as optimize]
[brainfuck-asm.generate :as generate]
[clojure.java.io :as i... |
sudoedit_enhanced written POSIX-ly challenge
While creating sudoedit_enhanced POSIX (apart from readlink I have been pointed out) shell script snippet, I face two challenges:
check if all the files exist, it does not make sense to create a new file this way
sudoedit does not work with symlinks, so translate symlinks ... |
I have some code that is slow because it loops over every row in an input matrix Y. Obviously, this code does not scale with the number of rows. I don't think it's critical to understand what the code does, but for the curious, it is a Gibbs sampling step for sampling the dispersion parameter r for the negative binomia... |
I designed a game with trying to use solid principles. What changes should I do for making program more extensible, readable. Thanks in advance.
Cell class
public class Squares
{
public int NumberOfAdjacentMines { get; set; }
public bool IsMine { get; set; }
public bool IsFlagged { get; set; }
// show i... |
New to coding/Javascript. Writing a basic Tic Tac Toe game.
I'm writing the game to be dynamic, so it won't always be a three-by-three grid, but rather any size grid larger than 1. I have a completely functioning game and win checker function, but the win checker is very, very wet. I've tried several way to dry it up, ... |
If I have a list that contains True and False values, how can I find the start and stop indices of where there are blocks of True values?
x = [True, False, False, True, True, True, False, True, False, False, False, True, True, False, True]
The output that I am looking for is:
[[0, 0],
[3, 5],
[7, 7],
[11, 12],
[... |
I recently wrote the following code:
def freq_progress
user_flashcards = input_flashcards.includes(:term)
terms_unicos = user_flashcards.map(&:term).compact.uniq
freq_1, freq_2, freq_3, freq_4, freq_5 = 0, 0, 0, 0, 0
terms_unicos.each do |term|
case term.ranking
when nil
next
... |
I (a junior back-end Java dev) decided I wanted to learn some front-end development skills; in particular, I wanted experience with React and websockets. I decided to write an app that would allow for remote play of a 9X9 variant of tic tac toe one of my college friends made up. The rules are:
The board is divided int... |
I've written the following function in C which shall take as input a character array (decayed to a char * of course), and mutate the string into a title-cased string in the form "this is a string" -> "This Is A String".
void title_case(char str[])
{
assert(str);
size_t i;
str[0] = toupper((int) str[0]);
... |
I am trying to write a sql storeprocedure that basically returns a derived value from an outcome of a function call. The derived field returns the difference in days and if the difference is less than 24 hours then returns hours. It is working as desired but just need to ensure if the approach is right.
Storeprocedure... |
I want to remove the mail contact from all Groups in the "Member Of" tab. I am able to remove all MemberOf for mail contact. How can I improve the speed of the script?
Get-MailContact <name> | ForEach-Object { Get-ADObject $_.distinguishedname -Properties memberof } | Remove-ADPrincipalGroupMembership -Identity $_ -Mem... |
I am trying to solve ProjectEuler.net problem #50, Consecutive Prime Sum. Here is the problem:
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below one-hundred.
The longest sum of consecutive primes bel... |
This is one of my first projects in C++, and I would call it a program for storing, displaying data and prognosing numbers.
I use following compiler: g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
I will try to explain my code starting with the main method which is located at the bottom of the code. The main method in my prog... |
In helpcovid git commit e27dd3b123c18300665 we have a stupid bug related to Linux GNU glibc argp program argument parsing.
void
hcv_parse_program_arguments(int &argc, char**argv)
{
struct argp_state argstate;
memset (&argstate, 0, sizeof(argstate));
argstate.input = &hcv_progargs;
hcv_progargs.hcv_progmagic = H... |
I recently implemented a Bloom Filter in Haskell and, although I am not new to functional programming, I am a beginner when it comes to Haskell itself.
I'll gladly take any feedback regarding the implementation or the code style. I tried to stick to the Haskell conventions regarding function and variable naming, but I ... |
The code starts with 128 bits of 0 (size of md5sum checksum) then brute forces to find checksum matching regex (all characters of checksum in hex are digits). I know that there may be collisions and that not all 2^128 possible checksums will come out.
I know that if the code is run, that it will not finish any time soo... |
PHP coder here. Learning JavaScript this week. I made a sudoku game for practice. Features:
Import puzzles by pasting a text string.
Imported squares are gray. Your squares are white.
Program doesn't let you make a clearly illegal move. It will blank your number and color the square red for 2 seconds.
The sudoku puzzl... |
ERROR: type should be string, got "https://leetcode.com/problems/sliding-window-median/\n\nMedian is the middle value in an ordered integer list. If the size of\n the list is even, there is no middle value. So the median is the mean\n of the two middle value.\nExamples: [2,3,4] , the median is 3\n[2,3], the median is (2 + 3) / 2 = 2.5\nGiven an array nums, there is a sliding window of size k which is\n moving from the very left of the array to the very right. You can only\n see the k numbers in the window. Each time the sliding window moves\n right by one position. Your job is to output the median array for each\n window in the original array.\nFor example, Given nums = [1,3,-1,-3,5,3,6,7], and k = 3.\n\n\n\nTherefore, return the median sliding window as [1,-1,-1,3,5,6].\nNote: You may assume k is always valid, ie: k is always smaller than\n input array's size for non-empty array. Answers within 10^-5 of the\n actual value will be accepted as correct.\n\nPlease review for performance. also I am not sure about GetID function is there a smarter way to get the same result of unique number and sorting for median? \nusing System;\nusing System.Collections.Generic;\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\n\nnamespace TreeQuestions\n{\n /// <summary>\n /// https://leetcode.com/problems/sliding-window-median/\n /// </summary>\n [TestClass]\n public class SlidingWindowMedianTest\n {\n [TestMethod]\n public void ExampleTest()\n {\n int[] nums = { 1, 3, -1, -3, 5, 3, 6, 7 };\n int k = 3;\n double[] expected = { 1, -1, -1, 3, 5, 6 };\n double[] res = SlidingWindowMedian.MedianSlidingWindow(nums, k);\n CollectionAssert.AreEqual(expected, res);\n }\n\n [TestMethod]\n public void ExampleTestFailed()\n {\n int[] nums = { 1, 4, 2, 3 };\n int k = 4;\n double[] expected = { 2.5 };\n double[] res = SlidingWindowMedian.MedianSlidingWindow(nums, k);\n CollectionAssert.AreEqual(expected, res);\n }\n\n [TestMethod]\n public void ExampleTestOverFlow()\n {\n int[] nums = { 2147483647, 2147483647 };\n int k = 2;\n double[] expected = { 2147483647.0 };\n double[] res = SlidingWindowMedian.MedianSlidingWindow(nums, k);\n CollectionAssert.AreEqual(expected, res);\n }\n\n [TestMethod]\n public void ExampleFailed2()\n {\n int[] nums = { 5, 2, 2, 7, 3, 7, 9, 0, 2, 3 };\n int k = 9;\n double[] expected = { 3.0, 3.0 };\n double[] res = SlidingWindowMedian.MedianSlidingWindow(nums, k);\n CollectionAssert.AreEqual(expected, res);\n }\n }\n\n\n\n public class SlidingWindowMedian\n {\n public static double[] MedianSlidingWindow(int[] nums, int k)\n {\n var res = new List<double>();\n var med = new SortedList<long, int>();\n for (int i = 0; i < nums.Length; i++)\n {\n med.Add(GetId(i, nums), nums[i]);\n if (med.Count > k)\n {\n med.Remove(GetId(i - k, nums));\n }\n\n if (med.Count == k)\n {\n if (k % 2 == 0)\n {\n res.Add( ((long)med[med.Keys[k / 2 - 1]] + med[med.Keys[k / 2]])/2.0 );\n }\n else\n {\n res.Add(med[med.Keys[k / 2]]);\n }\n }\n }\n return res.ToArray();\n\n }\n\n private static long GetId(int i, int[] nums)\n {\n return Convert.ToInt64(nums[i]) * nums.Length + i;\n }\n }\n\n}\n\n" |
I've taken up code streaming and I'm concerned that as I do so, I'll leak an API token somewhere.
It was suggested that I use something like "a secrets.toml or secrets.yaml or secrets.json file." But I don't want it all in one file. If I did have a leak, I'd likely lose all my tokens at once.
So I considered a secrets ... |
I'm learning python and for educational purposes I implemented tar archive parser. I'm not beginner programmer. I would like to receive some feedback and tips about code, what can I improve, what could be done better and so on.
Implementation:
tar.py
#!/usr/bin/env python3
import io
import os
import sys
import math
i... |
I have made a 2 player Tic Tac Toe game in C++. I have put in some error checking also (like if the players enters an invalid position). The code is working absolutely fine.
This is what my program output looks like.
| | |
| | |
| | |
Where you want to ma... |
i'm trying to create a url router system, for educational purposes, that has a similar usage like Laravel has, but i'm curious about how i can register the routes like laravel does (with single calls to static methods), here's my "conceptual" code that i made using a TDD approach:
$Route = new Route;
$R... |
The goal of my code is to implement a web scraping routine to obtain the name and the price of a product. I want to put this routine separated from the main program file. Sample url to scrape: https://www.amazon.co.uk/Samsung-MZ-76E1T0B-EU-Solid-State/dp/B078WST5RK/ref=sr_1_1?dchild=1&keywords=samsung+860+evo+1tb&qid=1... |
I am building an ad-hoc text-editor. I have two functions which use a cache, provideHover and provideCompletionItems.
"use strict";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
const $ = require("jquery");
const urlResolve = require("url-resolve");
const AUTOCOMPLETE_ENDPOINT = "http://localhost:... |
I have created a Snake console game using object-orientated programming methods. This is the first time I have ever used OOP so I just wanted to know if I was using the method correctly as well as hear any other advise I could possibly receive as this is my first time doing this. There are 4 header files and 4 .cpp fil... |
This was one of my friends' Java OOP class assignments. They were tasked with writing a polynomial class in Java with multiplication functionality. I did it in C++ as a challenge and for improving my programming skills. I also added a little bit of extra functionality.
Header File
polynomial.hpp
#include <vector>
#incl... |
I implemented the following Tron cycle game so that it can be run on GameCube / Wii devices (quarantine...). Indeed, there exist many tools (I rely on devkitPPC) and I thought a Tron game would be an easy starting point for this kind of development.
I have no experience in C, neither in enforcing "classes" in C, or in ... |
I'm implementing Sieve of Eratosthenes by working with multiples of 30 and comparing it to multiples of 3 from a previous answer
code for multiples of 30:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
const unsigned int res[8] = {1,7,11,13,17,19,23,29};
const unsigned int N = 1000000000;... |
I've been experimenting with Hooks lately and looking more into how can I replace Redux with useContext and useReduer. For me, Vuex was more intuitive when I first got into stores and I prefer their state management pattern, so I tried to build something close to that using the React Context.
I aim to have one store/c... |
Disclaimer: This is my first post here, so I'm not completely sure if this is on-topic.
I recently added a decorator that wraps a context manager in pyfakefs (I'm a contributor), which has some optional arguments. In order to make the usage more convenient, I allowed both the usage with and without parentheses (mostly ... |
This is the solution for a simple challenge from Hackerrank.I am just trying to solve Sorting: Bubble Sort Problem on HackerRank.
We are asked to count the number of swaps performed during a bubble sort and to print the first and last item of the ordered vector.
Sample input
3
3 2 1
First line is the number of element... |
I wrote a simple antivirus in Python and would love feedback for additional ideas to implement, as well as general code review.
So far it has a FileScanner that checks against a database of known virus hashes and a network scanner that checks against a database of potentially malicious IP addresses.
I'm very curious ab... |
The following is a c++ source code to get a matrix (std::vector<std::vector<T>>) transpose in parallel.
The span is \$\Theta(\lg^2(n))\$ while the work is \$\Theta(n^2)\$
Any suggestion to improve will be appreciated.
#include<vector>
#include<iostream>
#include<future>
#include<iomanip>
template <typename T>
void para... |
I'm trying to play around with Godot to learn C# and I was trying to creating pure functions to do the velocity, but I found I was repeating myself.
public override void _PhysicsProcess(float delta)
{
base._PhysicsProcess(delta);
Vector2 moveVelocity = velocity;
moveVelocity = Run(moveV... |
I have the below code that helps me do some formatting. But I want to increase the efficiency of the code by making it faster. Below are the formatting steps of the macro.
Convert "Q" and "S" column to number format.
Replicate the "I" column to new column by inserting a column next to it.
Cut the column "AD" and paste... |
This is regarding code quality and coding standards with respect to Spring Ecosystem. Here there are two methods:
isRecordExists is using a class level static constant String query. (Definitely suggestable for old way where we use prepared statements)
isRecordExists2 is using method level String query
Which method is... |
https://leetcode.com/problems/network-delay-time/
There are N network nodes, labelled 1 to N.
Given times, a list of travel times as directed edges times[i] = (u,
v, w), where u is the source node, v is the target node, and w is the
time it takes for a signal to travel from source to target.
Now, we send a signal ... |
I have the following:
#include <string>
#include <string_view>
#include <vector>
#include <unordered_map>
#include <iostream>
namespace utils
{
void replace_all(std::string& string, const std::string_view from, const std::string_view to)
{
std::size_t start_pos{ 0 };
while ((start_pos = strin... |
I have these following controller functions for registering a user and login, in my app, and I want to make it more clean and maintainable.
Probably by using async/await and exec(). Also, the validations do not look not good. It would be great if you suggested me good practices to refactor this.
registerUser: (req... |
I sped through the 5hr F# pluralsight course this week-end and thought I'd sement my learning by going through as many Advent of Code puzzles I could with this new learning. However, already on day 2 I'm starting to question whether I'm too biased from C syntax and imperative coding to do it "right".
I really really mi... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class List<T>
{
private T[] arrayList;
private int arrayLenght = 5;
private int arrayIndex = 0;
public List()
{
arrayList = new T[arrayLenght... |
What I'm trying to achieve
From a list of lists of elements (one element can be in multiple lists, but only once in each list), I want to generate a map whose keys are each elements and the values are the collection of elements that appear at least once with the key in the first lists.
Example
This is the input :
List<... |
I am a beginner with C++, I am not learning OOP yet, I will start when I finish this project.
I'm working on "Educational Management System Project".
So I had trouble to code the part of login and sign up,
I am not comfortable with this approach, I wonder if there is a solution to simplify this code and reducing if-sta... |
This is my first project and I wrote it to practice coding. However, I'm wondering if there is an actual practical use for it. What this code does is list the number of times a word occurs in a text entry, either by alphabetical order, listing the frequency of the word or listing the index in the text entry where that... |
Hi I recently wrote some code in python that does the following:
1.) Pulls stock closing data from yahoo finance for x number of stock
2.) finds all possible combinations of x stocks in groups of y size (so all combinations of 13 stocks in groups of 10)
3.) applies some calculations to each of these groups
4.) returns ... |
The goal of this code is to remove subnets from the list that are redundant (included in the larger ones)
It is VERY slow. Wondering how it can be sped up.
At present, I’m not looking to optimize the “CheckSubnet()” function, which isn’t my code... It MAY be slow (or not) but I’m hoping that a critical analysis of the... |
I have tried to write a simple 3 x 3 tic tac toe program. Please I need a code review on this program, whether it is readable, maintainable or not. Judge it as much as you can.
Here is the source code:
#include <iostream>
#include <string>
#include <vector>
void draw_board(std::vector<std::string> &board) {
/**
... |
I'm creating a small library of Python utilities, and I'd like feedback on a function which allows iterating over an arbitrary iterable in a sliding-window fashion.
Relevant parts of iteration.py:
import collections
import itertools
def sliding_window_iter(iterable, size):
"""Iterate through iterable using a slid... |
I have a Predicate which takes employee object.
Predicate<Employee> getPredicate() {
return emp -> filter(emp);
}
Now the filter method is very complex, it calls four other methods which returns true/false if all the conditions are true, the predicate will return true.
private boolean filter(Employee employee) {
... |
I've got a function which takes a screenshot of a particular window. It's important that the screenshot works whether the window is focused/covered by other windows or not, hence why I've used PrintWindow.
This function takes 45ms to complete, and I was hoping to decrease that. The end goal is to:
Take a screenshot of... |
Please download the file and save in home directory and extract it:
https://www.dropbox.com/s/swtw8bk35zr1i6d/analyse.7z?dl=0
I can get some warrants info.
import analyse
df = analyse.warrants.get('0788')
Now we got 0788's warrants info. It output df with better format:
analyse.tabulate.tabulate(df)
I want to simply ... |
I want a feedback on my code for the below known problem from Daily coding challenge:
You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a wall. Each False boolean represents a tile you can walk on.
Given this matrix, a start coordinate, and an end coordinate, re... |
This problem is tested against 3 sets of input data to see if the submitted solution gives an incorrect answer, if the solution exceeds the time limit, or if the solution exceeds the memory limit:
Test set 1 (Visible):
1 ≤ N ≤ 1000.
Test set 2 (Visible)
1 ≤ N ≤ 10^6.
Test set 3 (Hidden)
1 ≤ N ≤ 10^18.
My solution (belo... |
I've decided to implement Python's any in C++. I've gone about this using templates to allow multiple types of data to be passed, instead of overloading the function multiple times. This is my first time using templates so I would really like feedback about my usage of them. I'm also fairly new with references and poin... |
I'd like some feedback on code I wrote to obfuscate text on-disk. The basic idea is the same as ROT13 (which is implemented in the Python standard library), except instead of rotating the English alphabet by 13, the underlying byte representation is rotated by 128. The use case is to hide data from a string-search.
Bec... |
This is a follow-up question to eCommerce Mockup App in JS.
How do I implement the 'observe' pattern for the cart to regenerate html? So that, it will keep refresh its own. And any review on my coding style and code structure design?
"use strict";
// Bugs
// 1. UI bug for cart item count. Non responsive.
// Initial... |
I am a beginner using R and I am trying to solve some simple statistics problems and print the output. The following code takes in two datasets, computes the mean, variance and standard deviation. Finally it computes a 95-confidence interval for the standard deviation.
This is just a sample and my real data consists o... |
This code is a purely for-fun project and it comes from this challenge at freeCodeCamp. This is simply an algorithm challenge which is usually meant for JavaScript, but I decided to perform in C. It will not be used for any production reasons. Please leave any feedback you see fit, with special attention to the loops a... |
Songs Class:
public class Songs {
//-----------------------------------------------------------------
// Creates a SongCollection object and adds some songs to it. Prints
// reports on the status of the collection.
//-----------------------------------------------------------------
public static v... |
Problem Description:
The purpose of this function is to take a list of sorted numbers and split it into two evenly balanced lists. By evenly balanced I mean the numbers in the two lists have as close as possible to an equal average while as close as possible in length. Put simply, the resulting lists should have the sa... |
I just created a BinarySeachTree class in c++ which is supposed to store words read from a txt and the number of occurances of those words and i would just like some feedback from you. I think it works correctly and i used valgrind to check if it creates any memory leaks (and it doesn't). I am just worried for some thi... |
I've put together a simple CRUD application to keep track of my library of books in an effort to learn the model-view-controller pattern, as well as better myself at PHP. Everything I have works so far, but I'm definitely looking to streamline/condense/refactor the more verbose parts of it, as well as address any possi... |
I am currently self-studying on Python generator object and use it to generate training data and do augmentation on-the-fly, then feed it into Convolutional Neural Networks.
Could anyone please help me to review my code? It runs properly, but I need review to make it more efficient and more properly structured. Besides... |
I am making a super simple and dumb terminal text game to try out unittest in python. I have ran into a problem. When I run the test, the game loop is ran, and I have to manually insert input to continue to the tests.
Is there a way to not run the game loop when I run my tests, so I can test the class methods only?
An... |
Here is a good article on an optional reference type in C++. They discuss std::optional<T&>, but as that doesn't compile I have made my own.
One purpose of this type is to remove raw pointers from function signatures (where references alone cannot be used), as a raw pointer does not convey any indication of what it wil... |
I am trying to get my head around exceptions, and implement exception handling that ultimately gets logged, since my code runs as a remote job and reviewing a txt log is the best means of reviewing results. Currently I have an issue where "unexpected" exceptions only show up in the console, so my focus right now is dea... |
This is a script I've written to deploy the Elastic Stack.
Can you help me improve it? Especially the parts called out with *** markings.
deploy.sh:
#!/usr/bin/env bash
sudo sysctl -w vm.max_map_count=262144
#use the elastic utility to gen certs
docker-compose -f create-certs.yml run --rm create_certs
# Start the stack... |
An exercise asks that we extend the below random number generator app to print to the console how many times the user guessed before guessing the correct random number.
I first declared what I call a counter variable numberOfGuesses inside the keepPlaying while loop and then inside the continueGuessing while loop I in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.