instruction stringlengths 71 95.1k |
|---|
My effort to write async methods for copy/move a file in C#
public static class FileHelper
{
private const int _FileStreamDefaultBufferSize = 4096;
private static bool HasNetworkDrive(string path)
{
try
{
return new DriveInfo(path).DriveType == DriveType.Network;
}
... |
I have created a small library for use by beginner C++ students who are forbidden from using std::vector in their projects. Because of this, I would like you to review my code from the viewpoint of:
Is this code readable, usable, and accessible by beginners in C++?
I see a lot of questions on stackoverflow by students ... |
I have been using this quarantine time to learn "Modern C++" (constructs, move semantics, smart pointers, etc, etc) via implementing basic data structures from scratch. As a first step, I've put together a simple (but, hopefully somewhat complete) linked list as one of the foundational pieces.
linked_list.h
#pragma onc... |
Today I learnt the basics of OOP. I have tried to apply them to this coffee machine project. However I'm still a beginner, and so I feel my code can be improved. Are there any tips, trick or other other advice I can follow to improve the look, runtime, readability or take full advantage of OOP?
This code is simulating ... |
It's been a while I program in ANSI C, and helping my brother with a school project I ended up revising my C gift (or lack of) :)
the idea was to create an inverted V process using fork() and I ended up with the code that you can find in GitHub
I was wondering if there's an easy way of accomplish it, as I see that I mi... |
I am trying to prove the famous "Monty Hall Paradox":
The Monty Hall problem is a probability puzzle named after Monty Hall, the original host of the TV show Let’s Make a Deal. It’s a famous paradox that has a solution that is so absurd, most people refuse to believe it’s true.
private static void suffle(ulong numbe... |
Below is my honest attempt to write thread safe queue using C++11 features. Please review it and provide your comments.
#include <queue>
#include <condition_variable>
#include <atomic>
#include <iostream>
template <typename T>
class ThreadSafeQueue
{
std::queue<T> m_queue;
std::mutex m_mutex;
public :
vo... |
I've always found the boilerplate needed to use getopts correctly fairly fiddly and verbose, and was motivated to try to abstract it away. I wanted to try dynamically writing the parsed arguments into local variables accessible to the calling function, and I came up with this:
main() {
local _usage='foo [-a] [-b] [-f... |
What do you think of using struct Board(Vec<Vec<Cell>>)? It's nice that I can attach the Display trait, and just print the board.
But on the flip-side, we have things that seem wrong, like:
fn next_step(b: Board) -> Board {
let Board(mut board) = b;
// ...
Board(board)
}
And I couldn't find a way to pass a... |
The script calls the sunrise-sunset API to get one of the possible values, then converts it to 24-Hour format and MET time (as the times from the API are 12-hour and UTC). At the end, it joins the list to a string and prints it. I know this isn't commented very well, but are there any significant flaws in this code? I ... |
I am writing a custom allocator for my educational game engine project where I need to iterate through a collection of components(similar to Unity3D) every frame. There are game objects and every game object is composed of these components. Components are classes like Transform, Camera, Light, Mesh Renderer and so on w... |
I am currently reading Uncle Bob's Clean Code and wonder what would be the "cleaner" implementation of the following:
Let's say I want to implement a HTTPRequest class which handles the execution of (well, obviously) http requests.
This was my initial implementation:
class HTTPRequest(object):
def __init__(self, u... |
Would like to have a code review so I can improve my knowledge and expertise in VBA more specifically with Dictionaries as this is the first time I used one.
For context I have duplicate data and need to consolidate creating a unique list. To achieve this I used a Dictionary concatenating 2 fields to make a unique key.... |
I use React with material-ui.com and I love them both, but I'm tired with writing the boilerplate handlers like
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setEmail(e.currentTarget.value)}
again and again. Especially when stopPropagation is needed (AFAICT it's always either needed or harmless), it gets prett... |
I've been studying C for a while, as a programmer coming from a C++ background, I'm used to the standard library, STL, etc., and I quickly realized that I need some kind of a containers library/data structure implementations in C. So as an exercise decided to write one!
I also intend to use it on my personal C projects... |
I've implemented a method to solve the following problem:
Given a dictionary and a text string, find all words from the
dictionary that are present in the text. One important point is
that if the string is in double quotes, I should treat it a "single"
value. If no matches found, the method should return 0.
So ... |
I just started studying data structures and being the std::vector the container that I most use in C++ I decide to try to implement it mimicking its behavior the best I could.
#ifndef VECTOR_H_INCLUDED
#define VECTOR_H_INCLUDED
template<typename T>
class Vector
{
T* values;
size_t v_size;
size_t v_capaci... |
I've implemented the following Fibonacci iterator:
lib.rs
// lib.rs
// num-traits = 0.2.11
extern crate num_traits;
use num_traits::PrimInt;
pub struct Fibonacci<T> {
curr: T,
next: T,
}
impl<T> Fibonacci<T> where T: PrimInt {
pub fn new() -> Self {
Self { curr: T::zero(), next: T::one() }
}... |
(Last Post) Mail Crypt CLI encrypted email wrapper for Gmail
I've spent the past few days re-writing the logic of my program as a library to improve the structure and readability of my code. The idea behind MailCrypt is for it to be a python based client/library that allows you to locally encrypt messages and send them... |
I've just learned the OOP concept of abstraction, and I was wondering if I was implementing it correctly in my code and if you guys can point out any bad practices.
test1.java
package OOPConcepts;
import java.util.Scanner;
public class test1 {
static public Scanner input = new Scanner(System.in);
public static... |
My codes are not good, I want to konw how to solve my problem efficicently and learn writing some elegant R codes.Thanks in advance!
"r" is the starting value in matrix[loop,T], I want to use it to do the simulation for 45years in 10 times,which means that I will get a new matrix[loop,T] also name "r" after first for-l... |
I wrote these lines of rust yesterday. It turns 27 bits from a 32 bit integer into a 3x9 byte array, but my gut feeling is this should be done without having a mutable variable ans.
pub fn u32_to_preformated_vector(image:u32) ->[[u8;9];3] {
let mut ans:[[u8; 9]; 3]= [[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0... |
As you can see here, I wrote the methods public static int romanToArabic(String number) and public static String arabicToRoman(int number) to convert roman numbers to arabic numbers and vice versa.
I now wrote a unit-testing-class to test these methods. It is my first attempt to write a (real) unit test, so I would lik... |
For the ADMIN: I wrote this tread on S.O. questions/61183026, but I think that is more correct to post this tread here, if you think no, please scuse me and delete this message.
Hi, I've one xls table with the stock values of goods into my warehouse, in the same file are the stock values from last 3 years.
The Product ... |
With much of the world in lockdown at the moment, my friends and I wanted a way to play our favourite game, Celebrity, over video chat.
This seemed like a fun coding project, so I put together a little web app. The functionality it would need to provide would be the ability for everyone to put names into a virtual hat,... |
As working on a little private programming challenge, I tried "Rock Paper Scissors" without arrays or if-statements. It works as intended, though, I am sure this can be done a little bit more optimized. Especially in the context of Math/Programming.
What I try to achieve:
Create 2 Players, one Computer one Human.
The... |
Problem
Perfect forwarding is known to be imperfect when it comes to list-initialization; I'll use std::construct_at as an example:
std::vector a(3, 9); // OK: [9, 9, 9]
std::construct_at(p, 3, 9); // OK: [9, 9, 9]
std::vector b{3, 9}; // OK: [3, 9]
std::construct_at(p, {3, 9}); // error: can't ded... |
Right now I'm studying Java, and as a part of understanding arrays, I've implemented a Tic-Tac-Toe game based on two-dimensional array.
Any suggestions/comments are much appreciated!
Source code will be below, also available in GitHub repo.
Main.java
package TicTacToe;
import java.io.BufferedReader;
import java.io.IOE... |
I have a dark theme toggle switch for my React component that works well, but I know the code could use some work. First I am checking to see what the users' preferences are for light/dark. Then I am setting in local storage what the user has chosen as a preference and then also checking for that value. I'm still learn... |
I have written this code for bellman-ford algorithm. Please review and suggest improvements:
This code takes input graph as an adjacency matrix, and stores it the same way with additional info as
a graph object. It then finds the shortest path to all vertices from the vertex at location [0][0] in
the adjacency matrix.... |
findPairs produces the Integer pairs so that the numbers from 1 to N and the pair of numbers have a sum less than 50 and have more than 3 common divisors.
Could the complexity of this code be improved?
public class foo {
static void findPairs(int N) {
for (int i = 1; i <= N; i++) {
for (int j = ... |
Can this logic not be simplified more, the code works, but it has become too much of a spaghetti. The requirements are that there should always be one connection if possible in available state, but I need to take all the available states down and re-create them.
these paths I have to cover:
if both vifs down, call cre... |
I'm not a very experience python programmer. But I want to make my code as fast and efficient as possible as well as write it clean and therefore got the advice to share it here. So I'm having the following code, which works well but isn't very fast as I have dirs bigger than 4TB and I'm executing that code in my netwo... |
I've created an application to predict emotions. But I think the application is being over fitted. And I cannot figure out how to solve the overfitting. I'm using a small data set of 107 images spread across 6 emotions.
Train.py
#Adding Seed so that random initialization is consistent
from numpy.random import seed
seed... |
1.11 Arranging the derivative of a function
The derivative of any function f (x) at x0 can be estimated according to the following formula:
Write a program that prints three columns of numbers: x, f (x) and the derivative f '(x) for some simple functions, e.g. sin (x) or arctan(x).
public static class Derrivative
... |
I'm trying to reduce nested JSON data using Haskell and Aeson without creating data/record types.
The following code works, but seems ugly and unreadable.
Any advice on cleaning this up would be great.
Thank you
import GHC.Exts
import Data.Maybe (fromJust)
import Data.Text (Text)
import Data.Aeson
import qualified Da... |
I've been writing code for some time but never had the need (or opportunity) to
write C/C++ code. Did a small project to learn some C++ and would appreciate feedback on code, testing, project structure and building.
Project Layout
.
├── CMakeLists.txt
├── src
│ ├── personnummer.cpp
│ └── personnummer.hpp
└── test
... |
I started a simple OOP GUI project with tkinter in Python since I've been studying the basics for a while, but I'm not sure if my code is properly structured and following the programming conventions. I haven't finished it yet but the sooner I learn the good practices the better. My goal is to make a mini game. For now... |
I am using flask with sqlAlchemy to connect with a postgresql database with two tables
Users table (id, name)
Admissions table (id, userId)
Admissions table with a foreign key (userId) connected to Users(id)
I want to get Users if user.id is found in admissions userId
This is what I am doing
users = [i for i in Users.q... |
I am given the following problem to solve (This text is translated from Russian. So, there may be some translation issues):
... Another method to draw from the normal distribution is to draw two independent random numbers from the uniform distribution x1, x2 ∈ [0:0, 1:0). Then apply the following transformation:
\$n... |
This is my code I wrote completely on my own. Its one of my first real programs that I have written using booleans, functions, and loops if anyone could give me some feedback about how its structured and how it runs when executed. Any feedback or constructive criticism would be greatly appreciated!
# Imports random fun... |
I just started learning C fundamentals and started to write a List that is limited to integers for the beginning and has dynamic memory allocation according to its content.
I've written custom simple assertion functions that revealed, that upon reallocating less memory when shrinking the list, it is still possible to a... |
I simply made this for practice. But I want to know if it can be used in the realworld or not. Please point out any bad programming practices and how I can change them and look out for them next time.
Your advice or tip will be the invaluable rain
on my deadly isolated programming land.
import os
import hashlib
from b... |
I am looking for some review on the code I am about to provide below.
I'd like to improve my coding in general and happy to hear any comments from the community.
The goal of this code is simply load dataGridView1 with some data from MySQL and Refresh it with a click of a button.
I have not yet tried using automatic ref... |
https://www.geeksforgeeks.org/given-sorted-dictionary-find-precedence-characters/
please review for performance, the adjacency list is the problematic part for me.
Given a sorted dictionary (array of words) of an alien language, find
order of characters in the language. Examples:
Input: words[] = {"baa", "abcd", "a... |
I have written a little Paint-Program in HTML. You can also save and load your wonderful paintings. My code works, but my heart says that my code is not so beautiful. I dont use JS/HTML/CSS very often and thats why I dont know how to write clean JS-Code, but I want to know that. Javascript seems to provide a thousand w... |
After a few weeks of searching and learning ajax, pagination php, product filter, I created ajax php product filter with pagination.
1. index.php
<?php require_once('../../../private/initialize.php'); ?>
<?php include(SHARED_PATH . '/staff_header.php'); ?>
<!-- Filtering -->
<section id="filtering">
<h3>Product Fil... |
This is a URI online judge problem (problem no: 1973).
Link : https://www.urionlinejudge.com.br/judge/en/problems/view/1973
After buying many adjacent farms at the west region of Santa Catarina,
the Star family built a single road which passes by all farms in
sequence. The first farm of the sequence was named Star... |
I've progressed with the directory statistics function and want to proceed by making it a class.
Link to the first version of this code: Link
My current state of things:
About my namings:
I first used the name fcount as I wanted to have it stand for files and folders as otherwise, the name would be too long. That's why... |
We have been given a college assignment (Yeah even during lockdown!!) to implement an assembler to assemble the reference instructions given here. The following is my code to implement pass1 of the
assembler. Please review it.
//imperative keywords
std::list<std::string> Mn_imp = { "READ","PRINT","MOVER","MOVEM","ADD... |
Prim's Algorithm
This is an implementation of Prim's algorithm in Python. From Wikipedia:
Initialize a tree with a single vertex, chosen arbitrarily from the graph.
Grow the tree by one edge: of the edges that connect the tree to vertices not yet in the tree, find the minimum-weight edge, and transfer it to the tree.... |
The code below matches a list of features to a large corpus and returns the sub-query match with a score above 80. The challenge is the list of features on the full data-set is > 5,000 and comparing to multiple documents. Therefore is taking too long to work using the fuzzywuzzy package.
Per the Spyder profiler, the b... |
I want to decode a request object before use it in an insert query.
Request object containes the following JSON body:
{
"device":"887B53",
"data":"89582c60",
"station":"B0A6",
"rssi":"-99.00",
"time":"1586121398"
}
That's the way I solved it:
const convert = {
bin2dec : s => parseInt(s, 2).toString(1... |
I have worked on this for quite a long while, and this is my 3rd attempt after completely demolishing 3 other 200 liners, and i really need ideas on how to make my code add more functionality or efficiency, or some python coding tricks, i can implement to make it more compact.
I'm still a beginning with about a month o... |
I am trying to encrypt/decrypt file using source code directly. The issue is how to properly do it after reading the file.
int crypto_aead_encrypt(
unsigned char *c, unsigned long long *clen,
const unsigned char *m, unsigned long long mlen,
const unsigned char *ad, unsigned long long adlen,
const unsig... |
This is a revised copy of the Mail Crypt library based on the recommendations from the last post, as well as reviewing recommendations from the first post that I misunderstood.
[Last post] Mail Crypt Library for encrypted email
[First Post] Mail Crypt CLI encrypted email wrapper for Gmail
Change Log:
Removed try/ex... |
I'm working on an article about encapsulation in OOP, and I'm using the FizzBuzz problem to demonstrate what I think is so great about it. I'm hoping to share this with developers that might also be intermediate, as a way to start building a bridge for understanding common OO principles.
To this end, any feedback, crit... |
Problem statement:
Given a string, look for a mirror image (backwards) string at both the
beginning and end of the given string. In other words, zero or more
characters at the very begining of the given string, and at the very
end of the string in reverse order (possibly overlapping). For
example, the string "... |
For a web application, I have to transform a LaTeX document on the fly into an HTML string, that is delivered to connected clients via websockets. Thus I installed a filewatcher that waits for file updates and whenever the file is modified, I run transformToHTML to parse the LaTeX code with regular expressions and buil... |
I'm primarily a C++ developer, but I find myself writing significant amounts of Python these days. One C++ feature I miss in Python are function-scope static variables (variables which are initialised once, but retain their value across calls to the function). So I wrote a decorator for adding static variables to a fun... |
I would love to simplify my code, with better utilisation of for loop indexes. The goal is to change out all UP once for new UP once, which means take down each UP one and bring it up again. There should always be one in UP state while this process takes place, so I need to cover the following scenarios:
up - up =... |
I have added an object oriented file system. I am looking for suggestions for how I could improve it further.
package oopdesign.fileSystem;
public abstract class Entry {
protected Directory parent;
protected long created;
protected long lastUpdated;
protected long lastAccessed;
protected String n... |
The following C# source code creates a histogram of Maxwell-Boltzmann's distribution:
using System;
using System.Drawing;
using ZedGraph;
public class CommonDistributions
{
public static double Uniform(Random random)
{
return random.NextDouble();
}
static double Gaussian(Random random)
... |
I'm trying to change the GridLayout of my application in runtime, the user can select 1, 2 or 3 columns for his display. To do that I've used a ItemDecoration and I update the display if certains condition are met. I'm wondering if I'm not overdoing it and if there isn't a simpler or better way to do it.
Here is how i... |
i was given a task to write a code to find the nth perfect power number. i wrote the following function to find that number but the runtime is long at high number (above 30).
you can assume that the input number is within the range of 1-100.
here's the code:
def perfect(n: int) -> int:
"""
:param n: enter the... |
Eulerian Tour is a list of nodes that has a specific way to traverse the graph:
it starts at one node, traverses along every edge in the graph exactly once and returns to the starting node.
Here is my implementation of such a graph, please be so kind and destroy it with some constructive critic, or just give me som... |
Can this function simplified?
The goal is return one key from each dictionary (both contain the identical keys), so that the sum of the values that belong to the selected keys are minimal (and also the two keys cannot be identical).
a = {1:50, 2:60, 3:30}
b = {1:50, 2:70, 3:40}
def get_double_min(a, b):
a_sorte... |
I wrote a small program that generates a GUI for a grocery list (any list honestly). The GUI has the capacity to open a file, save a file, and save then exit the GUI from a file menu. The grocery items are added one at a time to a listbox using a popup window. The added items can be deleted as well. The functionali... |
So I want to do some research on the impact COVID-19 is having on businesses. I've managed to generate a database with the company name and the website URLs associated with it. Now I want to scrape them all as fast as possible so I can do some analysis on it. I am new to using parallel programming and am skeptical I am... |
In my code, I need to flatten a two-dimensional std::array into a one-dimensional one at compile time. While writing the code I realized, that I am unsure about several aspects of my implementation (as far as readability is concerned).
Therefore I would really appreciate your input!
I am especially unsure, if
There ... |
Recently I solved a challenge (problem 1 of the 3rd easy problem set of phase 2 of the '19 APL Competition) on abbreviating and expanding IP v6 addresses. For that matter, I had to write two functions, AbbreviateIPv6 and ExpandIPv6. The first function ought to take a character vector of a v6 IP address and abbreviate i... |
Problem Statement:
Store properties with a certain name (key), type and value. The key is always a character literal and the value can be of type bool, int, float, double, char, std::string, Vector2f, Vector2d, Color3f. It should be possible to add new properties and to retrieve the values of already existing propertie... |
I decided to implement a simple smart pointer class in C++ name my_pointer. Please review this code.
#include <iostream>
using namespace std;
class my_pointer {
private:
int *data;
public:
explicit my_pointer(int *p = nullptr) : data(p) {}
int& operator *() {
return *data;
}
~my_pointer() {... |
I'm looking for a review of my backend code on how to keep it more DRY. I see a lot of repetition in validation part of email and password, also I need some advice on if I have used the try-catch and async/await correctly. And most importantly, the thing that I have to clear is the sending of response back. Sometimes, ... |
I am about to graduate with my Associates degree in Math and will soon go for my bachelors. I've decided with two years of school left its best if I start learning to program. I am starting with python.
I recently completed a beginners course on YouTube from free code camp. I completed novice programs that come with th... |
I wanted to have some advice about the code I have.
I managed to get what I wanted done, but I do not think it is the "proper" way of doing it in the programmers' world.
Could you help me improve the code by any means and also if there are any better ways of doing this please share them as well.
I have files named in t... |
I'm trying to implement signed URLs for short lived access to static files.
The idea is:
generate an URL with an expiration timestamp (e.g. https://example.com/file.png?download=false&expires=1586852158)
sign it with HMACSHA256 and a private key and append the signature at the end of URL (e.g. https://example.com/file... |
I'm a beginner currently learning Python. I made a simple program, a random number guessing game, to apply in practice what I have already learned (not much) and hopefully be able to get a better understanding of the basics. Are there any more things or suggestions on how I could improve my code? I would be glad to hea... |
I have a solution for a circular array. How can I improve this?
package oopdesign.CircularArrayNes;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Consumer;
public class ArrayIterator<T> implements Iterable<T> {
@Override
public Iterator<T> iterator() {
return null... |
Since std::latch is not in many standard C++ libraries, I tried implementing my own, is it OK from memory ordering perspective or yielding?
class Latch {
std::atomic<unsigned> count;
public:
explicit Latch(unsigned cnt)
: count(cnt)
{
}
void arrive_and_wait()
{
assert(count > 0... |
I have this code that I am using to update OriginalId using the Id value. I there a better way to do this then using all the loops?
Controller
TemplatesDataService.UpdateRegimenCodeId(template.Regimens);
Interface
void UpdateDosageInstructionsCodeId(IEnumerable<Regimen> Regimens);
DataService
public void UpdateDosa... |
I'm doing some work with optimal design of experiments, related to the Federov Coordinate Exchange algorithm. This considers a candidate set of points and chooses from them to identify the best combination of points. The problem is, there are scenarios where there are 5^18 (nearly 4 trillion) candidates - there's no wa... |
I am new in Application Design. I have use-case as below
As per the above story I have implemented code as below without any Modularity, Extensible and Maintainable. Could someone share the thoughts how to design below bad code to production grade application ?
Based on this story context, there could be other storie... |
I wrote a simple map structure in C:
map.c
#include <assert.h>
#include "map.h"
void map_init(Map *m, int item_len)
{
assert(item_len > 0);
m->item_len = item_len;
m->cap = 0;
m->cnt = 0;
m->buf = NULL;
m->cmpfunc = NULL;
}
int map_setcap(Map *m, int cap)
{
if (cap < m->cap)
retur... |
I am looking for a way to improve the following method or to find out if this is the best way to do it. I have a superclass called Product and then I have Yoghurt, Crisp, etc. extending it. My Lists are declared as private static ArrayList inside of the class where this method is being executed, my main client class. I... |
The code below correctly shifts v256f_stats by one and puts the results into v256f_x3. This is then used to get the delta between n[1..7] and n[0..6]. The undefined element in the output is not an issue.
Is there a more efficient way of doing this?
// create a shift-by-1 copy
v256f_x1 = _mm256_permute2f128_ps(v256f_sta... |
So, I have an ASP.NET Core 3.1 web site that makes occasional calls to a vendor's RESTful API. I use the HttpClient class to perform these calls.
Currently, the web site is relatively low traffic (probably a couple of users per day). The current primary use case will result in 3 calls to the API for the complete workfl... |
I've been working with JavaScript and AJAX a lot in the past, and now I'm moving towards the backend and working with databases more. I want to update my game data in as close to real-time as possible in JavaScript.
Here is what I have been doing to update the data as frequently as possible (I simplified it):
function ... |
I implemented GNU shuf(1) in C using POSIX system calls and some BSD extensions. You must compile it with -lbsd.
shuf(1) shuffles the lines of the files given as arguments or the standard input (if no argument was provided) and print it. If the -n NUM option were given, prints NUM random lines from the files.
It first... |
I came up with this recursive pure-Python implementation of De Casteljau's algorithm for computing points on a Bézier curve:
def bezier_curve(control_points, number_of_curve_points):
return [
bezier_point(control_points, t)
for t in (
i / (number_of_curve_points - 1) for i in range(numbe... |
In my continued venture to teach myself C# I came across an exercise using Dictionary. I created a class that has a method. In that method it creates a dictionary with keys/values. A string is passed into that method. If any matching character in that string correlates with a key we increment the value of that key,... |
In my Ruby on Rails 6 app:
I have a User class built with Devise, and I scaffolded a List class where each List should belong_to a User.
I want Lists created through my app to be automatically assigned to the logged-in user. This should happen on the back end, after the rest of the new List fields have been posted to ... |
I'm new to programming and started with some tutorials about C++ on YouTube. Now I was wondering how I should continue solving below. It does work but already it has been like a lot of code to write. And I have more linetypes to define. So hope someone can point out a better way
std::string filepath = "path/to/file.ext... |
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
A mapping of digit to letters is done just like they are arranged on a telephone keypad.
Looking for ways of making the code more consise and easily readable. Want to learn the C# tricks to make... |
I'm writing a bot, it turns out pretty big (1000 lines).
In code, I often use the "show profile" function. I noticed that I greatly complicate it by adding functionality with kwargs.
I am a newbie, I don’t know if I should create a class instead of a function, break it into different functions or continue in the same m... |
main.cs
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ConsoleApplicat... |
I had a project with repetitive HTML, JS code blocks in which should be ten fields (A, B, C...) with certain functionality. Three fields are already implemented, but I don't want to copy and paste code blocks. I was able to solve some of the repetitions, but majority of that code I wasn't able to fix. I am not sure wha... |
This is the K&R Exercise 1-14 of C. The exercise ask you to print a histogram of the frequencies of different characters in input. How can I improve my code? The main doubt is the part when I have to increase letters in the array.
#include <stdio.h>
#include <ctype.h>
int main()
{
int ch,
nwhite,
... |
I made a code to initialize char vectors with random numbers representing very large numbers with more than 20.000 digits. The additions and multiplications are correct but my code is too slow (1 minute). I know that I can change char by 64 int to make operations with 19 numbers at a time, instead of 1 digit at a time,... |
I need to create a method to debias biased bytes from the method get_raw_bytes(length) using von Neumann debiasing method.
Von Neumann method takes two bits at a time. If the input is 01 it will output 0, if the input is 10, it will output 1, if the input is 00 or 11, it won't output anything.
Example:
Raw : [1101... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.