instruction stringlengths 71 95.1k |
|---|
I'm disturbed about the line value.word = removeSpecialCharacters(value.word);. Is there a elegant way to develop this line?
function checkWords() {
var listOfWords = { word: "abc!!??deftest" };
listOfWords.word = removeSpecialCharacters(listOfWords.word);
}
function removeSpecialCharacters(param) {
return pa... |
Overview & Motivation
This project manages and displays sensor data (temperature, humidity, Air Quality Index). The sensor data is displayed by the sensor manufacturer, PurpleAir, but their tool is hard to navigate (e.g. can't look at data more than a few days old) and slow to load.
I've aimed to make a tool that addre... |
This is a follow up to my previous post as it contained a lot of errors and wasn't accurate.
I am using the Bubble sort algorithm to sort an array of integers and I would like to know whether I could optimize it in any way.
#include<iostream>
void printarr(int *arr,const int siz){
for(int i = 0;i < siz;i++) std::... |
I've written a program that does three things:
Take an equirectangular image and ...
... cut horizontally-overlapping image areas.
... fill the image from the bottom with black so it has a ratio of 2:1.
... create each face-texture of a cubemap from the image.
... do interpolation optionally.
The algorithm is the fol... |
I took it as a challenge to write a C++ program to find the first 10 amicable-number pairs.
Amicable numbers
Let's take 4. What are the proper divisors of 4?. They are 1 and 2. Their sum is 3.
Now let's do the same thing for the number 220. The sum of the proper divisors of 220 is 284.
The sum of proper divisors of the... |
Hide email characters:
When email only has one letter then just cover that letter with the * symbol e.g. *@gmail.com
When email has two letters then cover second letter with the symbol * e.g. t*@gmail.com
When email has three letters then cover second and third with the symbol * e.g. t**gmail.com
When email has fou... |
I'm trying to determine best case round-trip times to a redis server. Particularly, I am trying to determine exactly how low I can get the latency on a local instance.
On a technical level, this is pretty easy. However, profiling is always a bit of a dark art, doubly so when network/IPC is involved.
Is this method reas... |
This is a Java program I implemented to encrypt a string using the ADVGVX cipher. It takes in the message, the passphrase used to generate the Polybius square, and keyword for the transposition part of the encryption. It prints the encrypted string. What would you suggest fixing and improving?
import java.util.*;
publ... |
Here is a custom class I use to handle different types of orders in Laravel. This question includes the code regarding Order Type A. I want to know whether I can simplify the code. I have different Order Types with the same functions but different in behaviour. That's why I'm using an abstract class to extend all order... |
I have created a DFS backtracking maze generator (non-recursive) using C++ and SFML. It works great but the final results of creating a 9000 x 9000 with cell size 2 is around 1 min and 46 seconds <-> 1 min and 30 seconds, to directly store the generated maze as an image without any kind of GUI.
I'll try to explain my c... |
I'm trying to solve this problem on HackerRank, which basically requires the solution to read an input like this (comments are mine)
3 # the number of cases, each of which consists of a pair of lines below
9 2 # case 1, the two numbers are N and K
4 5 2 5 4 3 1 3 4 # case 1,... |
In Shopify a product can belong to a collection.
I have written a method which accepts an organisation. It would then get a list of collections that this organisation has from Shopify. Finally, it has to loop through each collection to get the products that belong to this collection.
I don't want to overload Shopify se... |
I would like to find the best way to access function variables that are being used as parameters in other functions in another module. The parsefile.js is a Node.js script that is exported as package module and two functions. getfirst and getsecond need to access the variables that are passed from index.js like 'a', 'b... |
ERROR: type should be string, got "https://github.com/BingXiong1995/react-flv-player/blob/master/lib/wrapper/ReactFlvPlayer.js\nimport React, { Component } from 'react';\nimport flvjs from './flv.min';\nimport PropTypes from 'prop-types';\n\n\nclass ReactFlvPlayer extends Component {\n constructor(props) {\n super(props);\n this.myRef = React.createRef();\n this.flvPlayerRef = element => {\n this.flvPlayerRef = element;\n };\n }\n\n componentDidMount() {\n\n const {type , url, isLive, enableStashBuffer, stashInitialSize, hasAudio, hasVideo, handleError, enableWarning, enableError} = this.props;\n\n // 组件挂载后,拿到Ref进行操作\n if (flvjs.isSupported()) {\n const flvPlayer = flvjs.createPlayer({\n type,\n isLive,\n url,\n hasAudio,\n hasVideo\n },{\n enableStashBuffer,\n stashInitialSize\n });\n\n\n flvjs.LoggingControl.enableError = false;\n flvjs.LoggingControl.enableWarn = enableWarning;\n\n flvPlayer.attachMediaElement(this.myRef.current); // 将这个DOM付给第三方库\n flvPlayer.load();\n flvPlayer.play();\n flvPlayer.on('error', (err)=>{\n // console.log(err);\n handleError(err);\n });\n }\n }\n\n render() {\n const { height, width, isMuted,showControls } = this.props;\n return (\n <div>\n <video\n controls={showControls}\n muted={{isMuted}}\n ref={this.myRef}\n style={{height, width}}\n />\n </div>\n );\n }\n}\n\nReactFlvPlayer.propTypes = {\n type: PropTypes.string,\n url: PropTypes.string.isRequired,\n isLive: PropTypes.bool,\n showControls: PropTypes.bool,\n hasAudio: PropTypes.bool,\n hasVideo: PropTypes.bool,\n enableStashBuffer: PropTypes.bool,\n stashInitialSize: PropTypes.number,\n height: PropTypes.string,\n width: PropTypes.string,\n isMuted: PropTypes.bool,\n enableWarning: PropTypes.bool,\n enableError: PropTypes.bool,\n handleError: PropTypes.func\n};\n\nReactFlvPlayer.defaultProps = {\n type: 'flv',\n isLive: true,\n hasAudio: true,\n hasVideo: true,\n showControls: true,\n enableStashBuffer: true,\n stashInitialSize: 128,\n height: '100%',\n width: '100%',\n isMuted: false,\n handleError: (err)=>{console.log(err)},\n enableWarning: false,\n enableError: false\n};\n\nexport default ReactFlvPlayer;\n\nWrote some wrapper a long time ago. I am wondering if I could have done it in a better way. What are some of the improvements I could make or issues with the code. Thanks.\n" |
The problem is to design an structure which generates "uniformly" the next one in an initially zero matrix. Taking an arbitrary index i in the range [0,m-1] for any j where a[i,j] == 0.
It is, for example:
\begin{gather}
\begin{bmatrix}
0 & 0 & 0\\
0 & 0 & 0\\
0 & 0 & 0\\
0 & 0 & 0\\
\end{bmatrix} \to \begin{bmatrix}
1... |
So I have a text file filled with old onion links and its incredibly messy:
1 Dark web Link– Deep Web Links – Hidden Wiki http://dwlonion3o3pjqsl.onion/ online
2 Darkode Reborn http://darkodevasbv5yof.onion online
3 Arm’s Factory http://gunsfact2f6oz7cw.onion/ online
4 Dark Web Hackers Zone http://... |
My chess game is over, everything has been finished, except for some special (like en passant)moves.
The main part of the game is its engine which I have coded using the Minimax algorithm with alpha-beta pruning
currently, It is searching at a depth of 4 moves ahead. this takes less than 4 seconds at most times to sear... |
I have the following code (in php) that calls the open weather api with my credentials, and returns data for me.
Know I'm returning some data I pick from that response, I'm wondering if it's good practice to create a dedicated class for that? Is this something that's commonly used and does it have a name?
try {
$re... |
This is exercise 3.1.34. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
The Shannon entropy measures the information content of an input
string and plays a cornerstone role in information theory and data
compression. Given a string of n characters, let f(c) be the frequency
of occur... |
I have written a Python script whose purpose is to read logs from CloudWatch and then post them to ElasticSearch. It is not quite finished but I've progressed far enough that I could benefit from feedback from Python experts, specifically:
Is the use of Python Generators correct and idiomatic
Is the use of Class Compo... |
I have a MongoRepository:
@Repository
public interface GooglePlayGameRepository extends MongoRepository<GooglePlayGame, String> {
Optional<GooglePlayGame> findByTitle(String title);
List<GooglePlayGame> findByTitleContainsIgnoreCase(String title);
@Aggregation("{$sample: {size: ?0} }")
List<GooglePla... |
I'm trying to implement a palindrome check for each element in a vector and return a vector with only the palindromes. This should work for different type .e.g strings int vector of ints.I have done a templated solution but I feel like this doesn't take full advantage of templates.
//main.cpp
// Checking palindrome w... |
I'm trying to solve this challenge on HackerRank.
In short, given x and n, I have to determine how many ways I can pick numbers from the nth powers of the natural numbers such that their sum is x.
So my first reasoning was to compute the list of the nth powers that I need as a first step. This list is
list = takeWhile... |
I have implemented Dijkstra's algorithm for my research on an Economic model, using Python.
In my research I am investigating two functions and the differences between them. Every functions takes as input two parameters:
F(a,b) and Z(a,b).
Every cell of the matrix is defined as: $$M[a][b]=|F(a,b)-Z(a,b)|$$
The purpose ... |
I have a problem that I solved in 2 different ways and I would like to know which one is better, cleaner and easier to read.
Problem:
Write a while loop that starts at the last character in the
string and works its way backwards to the first character in the string,
printing each letter on a separate line.
Example 1:
c... |
I've written something (i.e. frankensteined from stack exchange) that appears to work but I haven't done much testing on the edge cases. Signed up here for some feedback on what optimizations or other functions/methods I could have used, and whether or not I've missed something critical -- this is my first time dealing... |
Here is my solution for the Quiz game exercise from https://gophercises.com/. The goal is to write a program that will read questions and their correct answers from a CSV file, ask them from a user one by one, and print the number of correct answers. The interesting part is that a user has a limited amount of time for ... |
This is exercise 3.1.39. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
Write a program that takes the name of an image file as a command-line
argument and applies a glass filter: set each pixel p to the color of
a random neighboring pixel (whose pixel coordinates both differ from
p... |
Please review my System information class.
Systeminfo can be used to retrieve system management data from the BIOS. This data is mostly strings.
Is the code easy to understand and maintainable?
Is the code efficient?
How could it be improved?
systeminfo.hpp:
/*
SystemInfo class is a C++ wrapper for the System Manage... |
Background
The basics of this project are already covered here.
I received the suggestions to:
not create the exercise with JavaScript.
use pictures instead of plaintext.
I tried to implement the suggestions like this:
The code
Example-form:
<form method="POST" action="../php/send.php" class='input'>
<label>Your ... |
In pandas lot's of methods have the keyword argument inplace. This means if inplace=True, the called function will be performed on the object itself, and returns None, on the other hand if inplace=False the original object will be untouched, and the method is performed on the returned new instance. I've implemented it ... |
I wrote a login system for an app I am developing, but I'm not really happy with the code I have at the moment. I feel like there is a better way at tackling a problem like this. In particular I'm not happy with the way my callback method has to be called specifically on the ui thread, I thought maybe there is a better... |
I wrote this log function and it works but is there a better way to write into the file stream and console at the same time?
//The function
void log(int lvl, const char * format, ...) {
va_list args;
va_start(args, format);
//If lvl < 0 the prefix will not be used
if (lvl>=lINFO) {
time_t now ... |
technical interview question i got from daily interview pro
A palindrome is a sequence of characters that reads the same backwards and forwards. Given a string, s, find the longest palindromic substring in s.
Example:
Input: "banana"
Output: "anana"
Input: "million"
Output: "illi"
i was wondering if there is any way... |
For my first Raku program, I thought it might be a fun challange to port over a program I'd written in C# about two years ago, and I was right: it was.
There's just one problem: while the C# program runs in 5 seconds, the Raku program takes nearly 5 minutes. I think the Raku program is doing more or less the same as th... |
This is web exercise 3.1.41. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
The scytale cipher is one of the first cryptographic devices used for
military purposes. (See The Code Book.) It
was used by the Spartans in the fifth century BCE. To scramble the
text, you print out every k... |
This is web exercise 3.1.45. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
Write a program that reads in a list of words from the command line
and prints true if they form a word chain and false otherwise. In a
word chain, adjacent words must differ in exactly one letter, e.g.,
HEA... |
I'm in the process of making my first GUI with Python. I'm trying to make something for work, so I've replaced all the info with fruits. It just lets the user tick some boxes, then creates a word doc
It's quite messy, and the variable names will be renamed later. But what I wanted to ask about was the functions I've de... |
Here is the raw data
anycasestr = "<div style="color: rgb(51, 51, 51); background-color: rgb(253, 246, 227); font-family: Menlo, Monaco, "Courier New", monospace; font-size: 12px; line-height: 18px;"><div>refinement</div><div>decent</div><div>elegant</div></div>";
to extract all the textcontent to an array l... |
I am currently going through and implementing basic algorithms and data structures as I feel I didn't learn enough about this during my Data Structures and Algorithms unit. So far I've done the following algorithms, yet to get to data structures.
Sorting
Bucket
import random
#toSort = [round(random.uniform(0.10, 0.99... |
Introduction
I've improved, IMO, Laravel's base Model and FormRequest. It's working as expected. But, before actually implementing this any further in my application, i want to have my classes checked on any problems i did'nt oversee. Also any suggestions for improvements are welcome. And feel free to use it in your ap... |
I have a situation when there could be and could not be values in database, which is why i return optional, so the response object that goes back to the UI could be different depending on the existing or not values.
Examples :
new UserLogsResponse(auditEntity.get().getTimestamp(), latestRetrievedDocumentDateAndTime.g... |
I am studying algorithms and I did this "Union Find Like" algorithm.
I have one array of objects with a reference and I make the union pointing to the same reference instead of have two int[] with numbers and weights.
Its not necessary to initialize the array.
You will have a maximum of N/2 extra objects ( if you do a... |
Hello I've just finished coding one of my first websites.
And I would love some feedback. I know that I really need to improve my design and improve my code and for that I need some tips from you guys
The webiste (hosted on github.io) can be viewed here, and the code itself is also available on Github.
*,
*::after,
*... |
Below is my Code, I want to know ways to improve it.
const findOdd = (A) => {
newObj={};
A.filter((cur,index) =>{
return A.indexOf(cur)===index;
}).forEach((cur) =>{
newObj[cur] = 0
for(let i = 0; i<A.length; i++) if(cur === A[i]) newObj[cur] +=1;
});
const keys = Object.keys(newObj)
key = k... |
I have below code for implement toggle button.
After including below code, processing power consumed over 90% in my embedded application.
Is there any way to reduce this processing power.
ToggleButton.h
#ifndef TOGGLEBUTTON_H
#define TOGGLEBUTTON_H
#include <QtWidgets/QAbstractButton>
class QPropertyAnimation;
cl... |
So I made a game during the pandemic, and I really enjoyed seeing it grow and learn a ton of stuff and implement it.. The game is about small moving circles that cross a line and when they intersect with the line they start to drag the line with them, until a new circle is born again. You can play and see the source co... |
I've just implemented a search box, so I can search on employee object by (name, part of the name, phone, email ...).
Ex. if the name: Moamen Abdulraouf Mansour, I can search with ( moamen | moa | moamen mansour ...).
The Idea I've followed is:
split some values from the object to be not included in the search.
conver... |
This is web exercise 3.1.63. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
Write a program that reads in a command line input N and plots the
N-by-N Thue-Morse pattern. Below are the Thue-Morse patterns for
N = 4, 8, and 16.
Here is my program:
public class ThueMorse
{
pub... |
I have written a little program that converts a CSV-File to an HTML-Table. It works for my purposes. But are there parts in my code that can be written more clean? Can you improve maybe the performance? Are there maybe any bugs? I searched for bugs and fortunately I did not find some.
Postscript
Maybe I should have pro... |
I'm quite new to web development. I want to implement basic session ID authentication. Here's the implementation
package httphandler
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
"github.com/satori/go.uuid"
log "github.com/sirupsen/logrus"
"github.com/yura-under-rev... |
I am trying to write a function which execute the given command with given number of retry and delay. If the return code is 0 and output string have expected_output(partial) have to break the loop and return the return code and output. Is there any better to write this code?
cmd check_output_and_retry(cmd, expected_out... |
I am passing a in as a parameter and want to return b.
This works, however I feel like it is wrong because I shouldn't have to pass a in at the return. Also, if I don't include the type for a, I get an error that says Parameter 'path' implicitly has an 'any' type.
async function exampleFunc(a: string) {
const b = a... |
I need an encryption system with a super simple API. I'd prefer something as simple as the following. The output should also be browser-friendly and ideally url-friendly.
$encrypted=encrypt(data);
$decrypted=decrypt(encrypted);
I'm not a cryptographer, however I have come up with the following to achieve this.
<?php
d... |
I have a function that adds a class name to a DOM element is met. The script provided works.
function rm_row(){
var chk_inherent = arcapi.dataResult().columnNameToIndex('Inherent Risk');
var chk_residual = arcapi.dataResult().columnNameToIndex('Residual Risk')
var chk_perf = arcapi.dataResult().columnNameToInd... |
I have implemented the following code which works as intended. However, I would like to improve my code in terms of performance and efficiency
Code in Question
import pandas as pd
from scipy.stats import norm
# data frame of length 40,000 rows, containing 25 columns
for indx in df.index:
matrix_ordered_first = df.... |
I am making a simulator game "BEE HUNT SIMULATOR" and in that game we have bees and we have to collect pollen from different fields,this is fully command line game that means a typing game so i have made all things that should be there but the main thing is of collecting pollen out of specific storage for that i had tr... |
This is web exercise 3.1.14. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
Set pixel (i, j) to the color of the most frequent value among pixels
with Manhattan distance W of (i, j) in the original image.
Here is my program:
import java.awt.Color;
public class OilPaintingFilter
{
... |
I'm practicing back-end programming and NodeJS. As an exercise, I'm attempting to build a REST API for a MongoDB collection. I'm also learning to use the Express and Mongoose middle-wares, so that's what we'll use for the server and database respectively. Also practicing async / await to handle promises.
The requiremen... |
I have a pandas dataframe, my_calculation, that is a Cartesian product of 4 different categories (Name, Freqset, Formula, and Location) and two additional Address categories. There are 3 different names, 12 different frequency sets, 14 different formulas, and 13 different locations making 6552 rows. There can be any nu... |
I am trying to write a program to get the count of the maximum number in an array of integers. The below code is what I have written. Is there any better way to write this code in Ruby?
def max_number_count(my_array)
max_num, max_num_count = my_array.inject([0, 0]) {
|arr, age| age >... |
I created a library with two CLOS class to implement a deque structure similar to the one available in C++, plus a few Lisp-ian twists. The two classes are node, which implements a doubly linked list, and deque, which uses node to implement the actual deque.
The main deque operations are available, including push and p... |
I am pretty new to assembly I would like criticism on two "methods" I have written. One converts string to int and the other prints an int to stdout. Any advise helps out.
bits 64
section .data
endl db 10, 0
endlLength equ $ - endl
section .bss
string resb 100
section .text
global _start
global _strToInt
global _... |
I'm relatively new to python and coding in general, and I decided that this would be a good little practice project. This was also my first project involving classes and objects so I kept their implementation a little basic just to get the feel of it. I would appreciate any constructive criticism on how I could improv... |
I've written the following data analysis code (using just a couple lines from CERN's ROOT data analysis framework). It's designed to find coincidences in three sets of data (timestamps from an experiment for a given year) by pairing up each timestamp in one dataset with the closest possible timestamp in both the second... |
I'm after some constructive criticism on my code and maybe some ways to simplify before I expand it to include other sites. I am new to R and coding and have been working on this problem for weeks now.
I need to graph the last 10 days of data from 20 remote sites. There are 3 csv files from each site that I bring in vi... |
I try to implement the features of the js Promise using Go.
Currently, I had implemented Promise.all(), Promise.allSettled() and Promise.race() static methods.
Code here:
package go_promise
import (
"sort"
)
type Promiser interface {
AllSettled(iterable []Workload) []Result
All(iterable []Workload) []Resu... |
I recently reviewed a PR and saw the following.
const parts = someString.split('.');
return parts[parts.length - 1];
was changed to
const [last] = someString.split('.').reverse();
return last;
I commented that I am against the change for the reasons that it is harder to read and not performant.
The answer was that it... |
I have created a module that validates the credentials against different databases.
module Authentication
DATABASES = %w[mysql mssql oracle].freeze
DATABASES.each do |database|
define_method("#{database}_connect") do |args|
client = case database
when 'mysql' then Mysql2::Client.new args.... |
I'd like to know what you think of my insertion sort version. I tried to be pythonic and avoid while loops with "ugly" index-management:
def sort(a):
for i, x in enumerate(a):
for j, y in enumerate(a):
if y >= x:
a.insert(j, a.pop(i))
break
On lists of 1000 rando... |
i am rather new at python and this is my very first project i did myself. i am wondering if there is anyway i can improve this or give me advice on making this better. thank you
import sys
valid = ["+", "-", "*", "/"]
invalid = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '... |
The following microservice is just handling loan application and response the result of the application is accepted or rejected. It is part of my assignment for an interview.
The project description is that; A user sends them Id, username, surname, and monthly salary via REST API. Assuming that you have got already cre... |
I wrote a dynamic stack in C that uses an array as a structure. I tried to maintain O(1) for push and pop and believe I have done so. I want to know what can be written in a cleaner way and if there are any non-trivial bugs.
#include <stdio.h>
#include <stdlib.h>
int push(int val, int *c);
int pop(int *c);
int *sta... |
I've been tasked with adding RTL support to Material UI project. I've stripped non-essential code down to a simplified version of the UI/Theme module. My solution involves the following:
a language module which has a list of RTL language identifiers and some methods for determining language directionality;
a theme-spe... |
I started learning Django and now I want to write some tests for my application. After reading some blog posts and watching youtube tutorials I wrote tests for URLs. Look at below.
urls.py
from .views import HomeView, ArticleDetailView, CreatePostView, UpdatePostView, DeletePostView, StatisticcsView, CreatePostCatego... |
This is my first project using Python. I made a simple password generator that checks user input. How can I improve it?
import random
def password_generator():
password = []
letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
"v", "w... |
So, I am learning Swift and as a little exercise I tried to implement a BruteForce algorithm. That algorithm is pretty simple however it is a bit slow too... Well, I am new to Swift, so maybe some optimisations are possible ?
Let's start with some useful prerequisites:
extension String {
var digits: String { r... |
My program tracks betting odds for the given list of events and sends notifications when odds reach specified value.
The odds are in the database collected by another program. The required odds are in the same database.
Each N seconds the required odds are retrieved from the database, compared with the actual odds and ... |
I hope that the word "decompose" is correct, but the problem is simple:
I got two lists after an operation and I want to know what change happend from one list to the other.
As such I want to "decompose" the two lists A and B into "Both", "Only A" and "Only B".
template <class T>
void decompose(std::vector<T*> &a, std:... |
I'm working on a data analytics dashboard in Node.js as a portfolio piece. I've built a pipeline that gets the data where it needs to be for more processing, however, I feel the below code can be improved but it overlaps with my inexperience with Node.js and async/await.
The below code looks redundant to my eye. I trie... |
This code tries to solve the sudoku board using the rules of sudoku. When it does not make progress in solving, it assumes a cell value and tries again. Please review my code and help me understand how I can make it better.
import math
import copy
import sys
# GLOBALS
reccursion_depth = 0
dead_end_counter = 0
assumpti... |
I have the two following algorithms. My analysis says that both of them are \$\mathcal O(m^24^n)\$ i.e they are equivalent for big numbers (more than 32 bits). Is this right? Note that m and n are the bits numbers for x and y
def pow1(x, y):
if y == 0:
return 1
temp = x
while y > 1:
y -= 1
... |
I solve projecteuler.net Problem 2 deferent way
Generate number from 1 to range ex 100 and get the even number
Get Fibonacci numbers from list
Reduce array
I have one problem with a large set of numbers like 1000000 or 4000000.
can I ask how can I optimize the code? I am trying to solve the problem as a collection ... |
For continuity, my last question was with adding numbers together with a function call: Example x86-64 program. In this one I've tried to apply the lessons pointed out in the previous answer (stack alignment, using edx instead of rdx where the results will fit). I've tried to comment inline with the code:
# We are goin... |
Id like feedback on my code. Specifically the parts where i use graphemes. I use cloned strings because the grapheme functions eat my strings. But feel free to comment about anything else that looks like it could be improved.
https://github.com/MonkeyToiletLadder/Hangman
Dictionary
pub mod prelude {
use std::io::... |
I am working on a text normalizer. It works just fine with small text files but takes a very long time with large text files such as 5 MB or more.
Is there anything to change in the code to make it run faster on large text files? My guess would be something in the __preprocess(tmp) and __prenormalise(text)?
# -*- codin... |
I built an auction site with a dynamic caching layer after I seeing how expensive a dbaas is. The site is now done, but like any site that grows, my caching solution grew too. The cache currently caches every page on the site so I made sure everything gets invalidated appropriately, but the amount of stuff I'm invalida... |
I'm looking into fixing some obvious performance-related issues in my code but I tend to employ bug-introducing tricks as I do so.
My code uses a library which defines Field<scalar> and uniformField<scalar>:
template<class T>
class Field
{
List<T> v_;
public:
explicit Field(const Mesh&); // There are more args,... |
I want to get exactly n unique randomly sampled rows per category in a Dataframe. This proved to be involve more steps than the description would lead you to believe.
n = 4
df = pd.DataFrame({'category': [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 1],
'value' : range(12)})
category_counts = df['category'].va... |
I am trying to solve the "Ransom Note" problem on hackerank.
Why isn't my code getting submitted?
What can I do differently?
is my total time complexity, in this case, it is O(n^2)?
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the checkMagazine function below.
def checkMagazine(m... |
I am new to writing java code and I would like to improve my skills. I would like someone to review and critic me on where I can improve on. Here is a small program I wrote in java about matrices and a few arithmetic methods applied on it.
import java.util.*;
public class MatrixArithmetic{
private static Scanner i... |
So I recently applied to this job for iOS Developer and was invited to complete the following code challenge:
As a next step, please complete this coding exercise in order to proceed with our interview process. If you do well & pass, you will be connected to a Software Engineer to discuss your exercise for an hour zoo... |
I'm a hobbyist programmer(just having fun) created a small script that takes a photo and
resizes it, then cuts it up into 24 pieces. The chunks are transposed and made into buttons. Your task is to get it back to it's original state without out going negative on points. My questions are: was it fun? Could you play it o... |
I need to calculate the value for the following function:
$$f(n) = -1 + 2 - 3 + ... + -1^n$$
The time limit to calculate a given value of \$n\$ is less than 1 second. My approach does not meet that requirement at large sizes, for example \$f(1000000000)\$.
My code:
program A486;
uses wincrt, sysutils;
var
n: LongI... |
While I know that Shaders are often made with glsl or hlsl because that is want those languages were made for I wanted to see if there was another way to accomplish Shaders while also using the GPU. as a result I decided to use CUDA for the Shaders and win32 for the actual window. also most of the Shaders were ported f... |
Any one can help me optimise those three functions? I did profiling and timing of my original python file and found that most calls and time duration was because of those three functions.
The three functions are from a text normaliser for text processing. The full python file is available if anyone wants to have a look... |
This is my first modeling exercise on the particle flow. Recently, I read a paper https://acp.copernicus.org/articles/20/3181/2020/. After reading the paper, thought of modeling it in Python. It seems like that the model came out well but I am not entirely sure.
Since I don't know how to fit the parameters alpha and be... |
I have this code that gets a CSV string from a list of objects where the first row in the string is the object's properties and the rows underneath are the properties values. I then create a MemoryStream of the string so it's about the same as reading from an actual .csv file into a Stream. Is there any way to cutdown ... |
After blowing up my environment again messing around with installing random programs and packages I decided to write a bash script I can clone from github and use to reinstall everything like I had before
The idea is that I'll be able to keep adding to it as I find more programs to use so that it will always be a stabl... |
So i wrote a program with the documentation for my fx cg50 calculator's micropython to calculate various items, each of which are:
Pascal Triangle Entry
Pascal Triangle Level/Entire Row
Binomial Expansion
Binomial Term Finder
First num of terms
Combinations
if you look at the code below, you'll notice, I haven't used... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.