instruction stringlengths 71 95.1k |
|---|
I came across this problem in a programming challenge a few days ago. I came up with the implementation below, however it resulted in a "time limit exceeded" failure for a few of the test cases. The questions were unfortunately not made available after the challenge was over but it went something like this:
There are ... |
My team has been doing some refactoring in an app and we needed to add a buffer to our data pipeline processing. We are working with node.js and javascript.
Specifically, there is an event emitter that can emit many events per second. In our design, we place these events into a buffer, and every x seconds we try to flu... |
I took RosettaCode's implementation and tried to create something useable (editing their wiki as I go to give-back):
#include <stdlib.h>
#include <stdio.h>
struct elem {
long data;
struct elem *next;
};
Insert
struct elem *addToList(struct elem *node, long num) {
struct elem *iter, *temp;
if (node == NULL) {... |
So I started learning how to code about 6 days ago and suddenly realized that I've really only been referencing my book and myself without any outside input. I'm learning python and the most complex thing I've done on my own so far is a simple class that handles 'user' info with a bunch of tests to make sure it works.
... |
I've created a working price toggler, that also has an upsell remover/adder. While it works well, I'd like to understand how I could do it better, because I'm having to essentially run two compound if/else statements to account for the duration toggle and the upsell toggle.
const pricing = document.querySelector('#to... |
I was asked to refactor a class, to make it adhere to SOLID principles, with testability and readability. I thought I had done a decent job, only my feedback was:
a) Unnecessary introduction of AccountExists() method [I thought it increased readability]
b) Breach of SOLID principles using "switch", "new" keywords
c) Ba... |
I often use Inkscape for generating SVG images. However, these images contain data which doesn't seem to affect the visual output, so I want to remove it. To do that, I wrote the following code:
"""
Use: python inkscape-svg-shortener.py [original_file] [destination]
"""
import os
import sys
try:
original_file, ta... |
My goal was to have a logger that does the blocking file I/O in a separate thread.
A few notes:
I made it a singleton rather than having a global "logger" variable, or a bunch of loggers that are passed around. It is used by saying Logger::Log("Hello, this is a log").
Since the class is a singleton, it feels pointles... |
I am building a small framework for e-commerce or blog app using React.
One of the features of this framework is an "Add to Favourite List" function.
The app tree works as follow :
App file stores the selectedItem chosen by the Menu, and then App dispatches this selectedItem to a displayCategoryItems, which is the cent... |
(The entire project lives there.)
This time, I have made the previous version of the GA for TSP run faster by around the factor of 6+. The idea is to cache the tour costs with the actual tour objects and cache the hash codes of each tour.
GeneticTSPSolverV2.java:
package com.github.coderodde.tsp.impl;
import com.gith... |
I have this snippet of code where I add multiple fallbacks if the price value equals a 0 (meaning that it couldn't retrieve a price from a URL)
url = StarCityController.getSearchURLForCard(cardName, cardNumber, set, foil, variantNumber, true, false);
url = url.replaceAll('★', '').replaceAll('†', '');
soup = await StarC... |
Here is a part of my new code replacing the old and deprecated old-school one.
Let's get to business right away:
I document everything with Documentation comments, which are proving very useful so far.
I present you my new tiny class called Validity, of which goal is to indicate if something is valid or not, and if n... |
I want to simplify the repetitive work of creating a DictWriter in a with context manager.
So I created a @contextmanager decorated DictWriter, and yielded that, to use in my code. Is this correct?
This seems to work, but yielding from within a with seems redundant.
#!/usr/bin/env python
import csv
import pathlib
from ... |
I want to improve my algorithms and data structures in C++ understanding and also learn how the standard library containers are implemented. I implemented a std::vector in a previous review and this time have turned to the std::list.
My questions are:
Are there any memory allocation/deallocation errors in this impleme... |
Lately I was creating a loot of flask apps and I was getting a bit annoyed typing each time all the commands (make venv, flask env, pip installing, gitignore...)
So I decided to make a package that I can install with pip and add a command that will make all the files I need and install the packages I want in the venv.
... |
Mainly I am looking for a better way to control the user input in the game loop which is in the first file. Since the nested switch with many case statements are a headache and error-prone.
Also, a way to extract the drawing process out of the Game class.
I am not looking for performance, but extendability.
Minor probl... |
So I have decided to learn Kivy Framework. Did two small apps containing mainly just labels (so that doesn't count) and decided I am going to do a simple music player. Nothing fancy just to learn basics. Right now after learning a few things I already know I should do it a different way. Nevertheless, I kindly ask abou... |
I'm relatively new and self taught in Python. I've written this code which gets a CSV file from a website, plays around with the data then creates an email with information gleaned.
I know this is too long and clunky, I'm just not sure how to bring it down. Not looking for exact code from you, rather a nudge in the rig... |
I've recreated std::string in a way that might be faster.
System Features:
Much faster than std::string.
Easy to use.
It was designed as part of a large database so it is very fast and good at handling memory.
Responsive to all types of data, you can enter characters, numbers, even decimal numbers, boolean values ... |
I wrote a program that implements the mkdir command with the -p parameter to create the parent directly if it does not exist.
My question is, is this implementation optimal? What else could I improve or what problems does implementation have?
code:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <uni... |
I am trying some hands on recent C++ standards. For the purpose of learning, I have implemented a Stack class as below which can hold any type of data member.
I would like everyone to review this class and give their suggestion on how any particular method should have been implement as to to adhere to SOLID principle'... |
I have a list of (potentially overlapping) ranges, e.g [(3, 9), (8, 10), (1, 18), (1, 1000000)]. I need to process them in order and for each range calculate how many numbers from the range have not been seen so far (i.e. not present in previous ranges). For example, for the above list the result would be [7, 1, 10, 99... |
Below is the entire code. I appreciate if, someone with more C++ experience can suggest if this can be improved further and if you notice any issues.
controlblock.hpp
template<class T>
struct ControlBlock
{
int _ref_count;
int _weak_count;
void inc_ref() noexcept { ++_ref_count; }
void inc_wref() noexce... |
I have a guessing game in PowerShell trying to practice the while statement. I found this on the internet on someone's repo. I have a feeling it can be shortened but maybe I am wrong. This is pure for learning purposes.
$ComputerNumber = Get-Random -Minimum 1 -Maximum 11
[int]$Tries = 3
'Please guess the number betwe... |
I'm solving a programming puzzle that requires to transform an input string by replacing pairs of duplicate consecutive characters with an "incremented" character, recursively, e.g. "abb" -> "ac", "cbb" -> "d". "zz" should be replaced by "a". I'm doing this using a stack:
def transform(s):
stack = []
for c in s... |
Source: https://leetcode.com/problems/reverse-words-in-a-string-iii/
I want to know
What better could I do, regarding syntax and idioms
What better could I do, regarding performance
impl Solution {
pub fn reverse_words(s: String) -> String {
let mut v : Vec<String> = Vec::new();
let mut ... |
BasePlayer.h
class BasePlayer {
public:
BasePlayer(int id);
void dealHand(std::shared_ptr<Hand> h);
void addCardToHand(std::shared_ptr<Card> c);
std::shared_ptr<Hand> getHand();
private:
int _id;
std::shared_ptr<Hand> _h;
};
BasePlayer.cpp
#include "BasePlayer.h"
BasePlayer::BasePlayer(int id)... |
This is a Python 3 script that converts any real number (ints and floats) from decimal notation to any positional number system representation with an integer base between 2 and 36 and vice versa, meaning it can convert negative fractions.
Technically it can convert any arbitrary base, but I struggle to find a way to r... |
Display visitor's number on your web page.
The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0.
I know goto should not be used but then the code would be nested if conditions:
if (...) {
if (...) {
if (...) {
.
.
.
// display successful result
echo "Yo... |
While having experience with other languages I only recently started learning Rust and I was hoping to get some feedback on my little beginner project, especially regarding style (stuff like too many functions, should rather be refactored into struct with methods, etc.) and safety (whether there are situations that cou... |
I'm learning to use mypy and the pyproject.toml config
pyproject.toml
[tool.mypy]
# Import discovery
files = ["app"]
ignore_missing_imports = true
python_version = "3.10"
platform = "linux-64"
app/__main__.py
from __future__ import annotations
from typing import (
NamedTuple,
Generator,
overload,
TypeV... |
Following this question on meta TL;DR Not sure whether this question is too general...
The idea is to have a universal (ish) makefile, that can be dropped into any C++ Sublime Text Project and it work with any combination of the GMP,SDL2 and pthread libraries. There is then a choice of how I compile/link through the Su... |
I was working on this problem on leetcode
Question
Your task is to remove the minimum number of parentheses ( '(' or
')', in any positions ) so that the resulting parentheses string is
valid and return any valid string.
Formally, a parentheses string is valid if and only if:
It is the empty string, contains only lower... |
I'm working on a personal project to build an open-source gui for git. I'm hoping to learn a lot from the project, and maybe produce something useful for folks as I do.
I'm making use of libgit2 to interface with git repositories. The library is implemented in C, and any time a new object is created (be it a commit, re... |
Hello all I am using some typescript reactive forms, like this
this.formControls.propertyType.valueChanges.subscribe((value: string) => {
if (!this.currentSelectedType) {
this.currentSelectedType = value;
} else {
if (this.currentSelectedType === CbcPropertyType.Other) {
this.openModal();
this.c... |
I want to understand how to properly nest key/pair values within a struct. My use case is to create a type to return serialized JSON on my API responses.
I'm using rocket, this is my general setup:
// cargo.toml
[package]
name = "api"
version = "0.1.0"
edition = "2018"
[dependencies]
rocket = { version = "0.5.0-rc.1",... |
Version 2: Display visitor's number on your web page (changed code after getting answer for first version).
The first version is here: Display visitor's number on your web page
The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0.
The new code is below:
index.php
... |
This is simple program to calculate working hours in given shift..
It is also return user sessions and presence of user shift.
while this works fine. I would like suggestion to improve it.
from datetime import datetime, timedelta
user_attendence = [{"id": 1, "punch": 1, "date": "22-04-2022 02:10:00"},
... |
Our codebase is full of locks such as:
lock("Something." + var)
{
....
}
This causes issues due to strings not meant to be used in locks in this way. We have a need to lock on dynamic strings, so this is the replacement based on the implementation of the lock object specified here: https://docs.microsoft.com/en-u... |
I wrote a merge sort implementation in C++ today in C++20 way.
namespace frozenca::hard {
using namespace std;
namespace {
struct merge_sort_func {
template <bidirectional_iterator Iter, sentinel_for<Iter> Sentinel,
typename Comp = ranges::less, typename Proj = identity>
requires sortable<Iter, Comp... |
So I've written a Sorting Algorithms Visualizer according to this tutorial, but made some changes and add some features of my own.
The visualization is made with Pygame (Which I never used before).
The interface allows to:
Start sorting by pressing the space bar
Change between ascending and descending order by pressin... |
This is a Trie data structure for mapping strings to integers or pointers in O(n) time. Based on the idea that we never delete anything from the container, we can perform concurrent read/write operations without any locks.
Note that TCMap is initialized separately, its role is to map relevant characters to indices. (... |
I've just started to get into PL design and made a simple Brainfuck interpreter. Although it is functional, I don't feel too confident on the execution, particularly the implementation for loops, I read some other bf interpreters and they generally used stacks for looping, but I didn't knew how to implement one ._.
An... |
Java's largest array length is 2^31 – 8 = 2,147,483,639, which is an int consisting of 32-bits. In the case where we want to store more elements, we are better off creating multiple 1-D arrays or use a 2-D array which is an array of arrays.
A program is coded to accept a length (typically larger than 2^31 – 8) to creat... |
I wrote this code for myself so I can manage my personal to-do list easier. Considering, I spend most of my time in the terminal, it made sense.
I have worked on the project as a way of practising my JS skills. The application works as expected.
I would like feedback on how I can improve the code as a whole. But there ... |
I have a file that has around 440K lines of data. I need to read these data and find the actual "table" in the text file. Part of the text file looks like this.
[BEGIN] 2022/4/8 14:00:05
<Z0301IPBBPE03>screen-length 0 temporary
Info: The configuration takes effect on the current user terminal ... |
This is my "general purpose" makefile that I wrote with the following objectives in mind:
Ready to use (copy/paste in a simple directory and it works out of the box)
Flexible (easy to add compiler flags, link libraries, add other source directories)
Settings to choose by passing them as arguments (optimizations, compi... |
I read about debounce this morning and ended up needing something similar to the concept in real life this evening to build a poll that checks whether a link I receive from an async call is ready to be used in a href element.
But what I'm asking for are
highlights of the risk to my implementation,
to learn if there ar... |
I'm working on a new project with go. So I figured I would give this new feature a run (it's fun!). Although, I'm not sure I'm implementing this the way it's suposed to be.
I've read the following guides before writing my code :
Golang official generics tutorial
Another nice and complete tutorial by bitfieldconsulting
... |
I have the following function written in JS:
if (filterButton.classList.contains("selected")) {
for ( var j=0; j < marker.length; j++ ) {
marker[j].visible = true;
marker[j].hotspot = true;
}
filterButton.classList.remove("selected");
} else {
for ( var j=0; j < marker.length; j++ ) { ... |
I have written a Python script that takes a list of filenames of pictures and generates a photo collage of them. This is my most complex project yet, and I have written it completely by myself (like I always do, but this is way harder than most of my other projects).
It can take images with different aspect ratios and ... |
This is my very first data structure written in Perl for a d-ary heap:
package BidirectionalDijkstra::DaryHeap;
use strict;
use warnings;
use POSIX;
require Exporter;
our @ISA = qw(Exporter);
our $MAXIMUM_INT = 1000 * 1000 * 1000;
# Items to export into callers namespace by default. Note: do not export
# names by d... |
When a user logs in, I save a token (hashed password) to the user's folder on the server and send the token also to the app which is saved in localStorage.
I need to check if the user's login token is valid upon every request made to the server. It's requested via AJAX using setTimeout, so next request is made only if... |
Taking online college course and I'm new to Java. We just learned about input validation. I've used input validation pretty comfortably for strings, ints, and whatnot. But I had to validate a boolean value so I tried using a Boolean object (for a null assignment) and it worked.
Instructor feedback is slow at best and I... |
What is the performance of this program? What should I do differently to optimize performance (O(n))? How would you grade it relative to what defines an optimal, elegantly-written program?
Input: A list l that has a length between 1 and 9 elements, consisting
of the numbers from 0-9. The length of l and the values of t... |
I'm coding a simple websocket chat app. I was wondering if my code is secure and efficient.
I also have a question about the way how I'm sending objects and then checking the type, is there anything better/efficient I can do? Such as making my own events?
Please tell me any improvements I can do.
This is the chat.js (c... |
I'm a beginner in python and my code looks a little cluttered and a lot of lines are being duplicated, so I was wondering if I could get some suggestions on how to declutter and improve?
import time, random
def start():
global user
global character
global shadow
user = {'gold': 0, 'HPP':1, 'EPP': 1}
... |
Is there any way to improve this code:
punch:0 -> in
punch:1 -> out
from datetime import datetime
attendance = [{"id": 1, "punch": 0, "date": "22-04-2022 02:10:00"},
{"id": 1, "punch": 1, "date": "22-04-2022 03:00:00"},
{"id": 1, "punch": 1, "date": "22-04-2022 04:00:00"},
{"id": 1, "pun... |
This is a wrapper for a synchronized data structure that:
Saves periodically
Keeps track of dirty flag automatically (set when a write access is requested)
Maintains a lock on data
Only allows access via a scoped lock object
Works with any data class that has a ::save()
template <class DataType>
class MemDB {
... |
I have close to a hundred classes where I need to get arbitrary properties from them at runtime. The calling class knows which properties it wants at run time, but not at compile time. Looking for any suggestions on a quick way to do this.
My ideas so far:
Option 1: Add "public object Get(string prop) {...}" to all c... |
I'm writing software that trades on the market, keeping order books in sync. I keep wondering about the code readability, as I have written it myself, I am biased. Could anyone please review the code and show where I can improve on code readability?
#include "Market.hpp"
Market::Market(uint32_t mId, bool ime, CsvManag... |
My teacher gave us an assignment to write a function that gets as arguments an x and a y. It returns a list which is of length x and each cell is a list of length y so that the
[i][j] cell equals (i+j)**2.
# example input and output:
# input: x = 4 , y = 5
# output: [[0, 1, 4, 9, 16], [1, 4, 9, 16, 25], [4, 9, 16, 25, ... |
Each datum represents a point in a 1440x720 image of the globe, The values are 0-9. Each new layer is of a higher elevation. I need to structure a DataFrame in a way that allows me to "connect the values" and create geometric shapes.
main.py
from typing import Iterable
import pandas as pd
import numpy as np
INDEX = pd... |
I have written a Python script that converts scripts to png files, entirely by myself without anybody's help.
A picture is worth more than a thousand words so I will let the picture do the descriptions.
Code
import numpy as np
from io import BytesIO
from pathlib import Path
from PIL import Image
from pygments impor... |
I have this Perl module project.
My implementation of the Dijkstra's algorithm follows:
package BidirectionalDijkstra::AlgorithmSelector;
use BidirectionalDijkstra::SourceVertexSelector;
use BidirectionalDijkstra::TargetVertexSelector;
use BidirectionalDijkstra::Graph;
sub new {
my $class = shift;
my $data = ... |
I am trying to throttle SemaphoreSlim (i.e. allow initialization with a negative initialCount). A scenario could be that you're hitting an API and may notice degradation due to a server overload, so you'd want to start throttling requests to, say, 10 concurrent requests. However, you would be keeping count of the concu... |
I am trying to calculate a specific complicated tensor contraction (of complex valued tensors) which appears as part of some other calculation and is called multiple times in a row, about 100 times or maybe later even more. Therefore, performance is the key here.
For a 1D tensor (array) A(N), a 3D tensor B(N,N,N) and a... |
Working on the problem Find Winner on a Tic Tac Toe Game, I took several hours longer than an artificial time constraint the site had for mock interview purposes. This leads me to wonder if my solution is needlessly complex or unclear. Curious to hear from others. The only part that would have to stay the same upon rev... |
https://doc.rust-lang.org/book/ch08-03-hash-maps.html
Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the user retrieve a list of all people in a department or all people i... |
Background
The CSV files being used can be 6+ mill records in size, using a small sample size to proof the methodology.
Why are you doing this on excel? Access or SQL would be quicker
My company has disabled the VBE for anyone who is not recognised as a developer (progressive, I know.....).
I want to submit a third p... |
I have a super simple function that returns a text label for a range of the input
function fn(amount) {
if (amount >= 1 && amount <= 10) return 'small'
if (amount >= 11 && amount <= 20) return 'medium'
if (amount >= 21 && amount <= 30) return 'large'
}
And this is an "over-engineered" version of the function bu... |
I'm trying to create an algorithm that finds the closest pair of points (2D) within a set of points. I'm using a divide and conquer method which is explained here Closest Pair of Points Algorithm.
However, my algorithm is really the best when it comes to huge sets of points, it takes a lot more time than it should.
Any... |
Problem Statement
Every book has n pages with 1 to n pages. The summary is made by adding up the number of digits of all page numbers.
Task: Given the summary, find the number of pages n the book has.
Example
If the input is summary=25, then the output must be n=17: The numbers 1 to 17 have 25 digits in total: 1234567... |
I've created a script to print all periodic table symbolic permutations of a string. As seen in the opening credits of each episode of Breaking Bad:
© 2010-2022 AMC Networks Entertainment LLC.
Aaron Paul contains the symbol for Argon (Ar) which is highlighted green, and overwrites the casing on the original (ar).
I ha... |
This is some code that I wrote for fun because in some of my classes I had to copy and paste between different Google docs I had. So, I decided to write a python script that would let me copy up to 5 different pieces of text and paste them.
I feel like the code is really inefficient and too verbose, though. Specificall... |
Background:
I have made two classes. The first is SharePointHandler, and contains a few functions that I intend on using to automate some actions on SharePoint. A simplified version of this is shown below:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_c... |
I want a cryptographically secure version of array_rand(). Is this it?
/**
* retrieve a random key from an array, using a cryptographically secure rng.
* - it does the same as array_rand(), except that this one use a cryptographically secure rng.
* - relatively speaking, it should be significantly slower and more me... |
I wanted to write a minimal thread pool implementation.
You can submit tasks and get a future.
When the pool goes out of scope, all pending tasks will complete and join all workers.
In an earlier revision, i made a separate join() member function that joins the workers but then it would keep the thread pool in an unusa... |
I'm working on a CLI chat app using Python and I've coded this encryption algorithm.
I used hybrid encryption.
This uses an AES key as the shared key for encryption and decryption and RSA to encrypt this AES key using the client's RSA public keys; sends it to them; and they decrypt it using their private key so all wil... |
I am new to Haskell and took it upon myself to make a simple generic list-splitting (e.g. string-splitting) function:
-- Helper for splitting: reduce into a list of lists, splitting on delimiters
splitInner :: (Eq a) => [a] -> a -> [[a]] -> [[a]]
splitInner c s (x:y)
| s `elem` c = [] : (x:y)
| otherwise = (s :... |
I'm well versed in Python and Java, am just starting out with C++. Am enjoying the language and would really appreciate feedback on this solution.
kata:
Return positions and values of the "peaks" (or local maxima) of a numeric array
For example, the array arr = [0, 1, 2, 5, 1, 0] has a peak at position 3 with a value ... |
I am trying to create a non-generic slice function. I want a 'view' not a copy.
The scan_from arg is so that successive calls know where to start from:
const char *slice(const char *s,
const size_t i,
size_t *scan_from) {
const size_t substr_length = i - *scan_from + 1;
if (subst... |
I made this basic Python calculator. It just does addition, subtraction, division, and multlipication.
I feel like the code is a mess, but it does what I want it to, and I feel like it does it effectively.
import operator
def calculate (first_number, operation_type, second_number):
if operation_type == 'a':
... |
This is my solution to the third exercise (and last) at the end of chapter 8 of The Rust Programming Language book (https://doc.rust-lang.org/book/ch08-03-hash-maps.html#summary).
There are only 3 types of commands: ADD, GET and EXIT:
ADD syntax: ADD name TO department (where "name" and "department" are variables)
GET... |
I made a python analog clock program with turtle. The problem is, it takes about 1.4 seconds to loop, so it only moves the second hand every 1.4 seconds. Its probably cuz my computer is slow...
from turtle import *
import time
from datetime import datetime
screen = Screen()
screen.title("Clock")
screen.setup(425, 425)... |
I have created service to communicate with my backend for user registration and login. I use the JS fetch API and send all data through HTTPS. I use JWT tokens to authenticate queries once I have logged, and this is stored in the window local storage.
The API details are stored in a config.json file.
Two things that I'... |
I'm a newbie in programming, just started about 6 months ago and just finding my way around in C# (clean) code. This is the toy task we have received from our teacher.
This is what it should do:
New article numbers are assigned in your company. They consist of 5
numbers and a check digit.
You are to design a program ... |
I have the following task: Let us have a list (denoted by L, and for simplicity, the elements come from the interval [0,1]). We are given a parameter (denoted by C), and we want to find as many pairs as we cane (without using the same element twice) in our list, whose difference is at most C.
Example: For the input L=[... |
New to using this platform and would like to familiarise myself with it so would just like to ask if I am exhibiting good practice with my programming.
Started the online CS50 course today and thought I would try to write my own program to execute a binary search with the small amount of programming I learnt in school,... |
def arr_func(arr,selected_pixels_list):
rows = 2
m = 0
n = 0
i =0
#Calculate the number of pixels selected
length_of_the_list = len(selected_pixels_list)
length_of_the_list = int(length_of_the_list/4)*4
cols = int(length_of_the_list/2)
re... |
What would make it better?
This is my first Python project. Do help in making it better, for me to learn something new.
secret="12345"
guess=""
count=0
limit=3
limited=False
while guess!=secret and not(limited):
if count<limit:
guess=input("Enter guess: ")
count +=1
else:
limit=True... |
The class "post" only has simple methods like getters for the ID(long) and number of likes(long). Is how I wrote my method below accomplishing anything? Is it doing what I want it to do? I am a beginner so I am sorry if my question is too stupid.
public class PracticeStats {
Given an array of posts, this method finds t... |
I have gathered from around the web a few functions and such to land on this:
const LEADING_ZERO_BIT_TABLE = makeLeadingZeroTable()
function makeLeadingZeroTable() {
let i = 0
const table = new Uint8Array(256)
while (i < 256) {
let count = 8
let index = i
while (index > 0) {
index = (index / ... |
I want to structure this better but don't think I'm handling results well. I'm used to python and I think my flow is way off. Is this bad design?
Should my results be Result<String, Error>?
I'm concerned mainly about structure and less on the usefulness, but happy for any kind of input.
struct SSHE3 {
host: String,... |
Started playing with C and CGI forms.
Is this code ok? Can it be improved/optimized?
If I fill user with "user" and password with "pass" input in takelogin is user=user&password=pass
In the end I want to have user = 'user' and pass = 'pass'
This is the form
#include <stdio.h>
int main(void)
{
printf("%s%c%c\n", "C... |
I maintain a number of projects, and several of them feature Angular front-ends. These projects need to be available in multiple languages, at the very least French and Dutch and preferably also in English. In order to do that, Angular supports Internationalization and in our apps this means multiple JSON files named "... |
On input i get width and height of matrix, string of text and another string of finalText I want to reach. The characters of the first string are assigned to matrix. My goal is to find shortest way to create finalText from characters in matrix, starting at position (0,0), and return number of steps.
So I create a dicti... |
I am wondering if this is written well or not, I am just a beginner and would like some feedback what should I improve on. Thanks.
#define STB_IMAGE_IMPLEMENTATION
#include<iostream>
#include "stb_image.h"
#include "vector"
#define LOG(x) std::cout << x << std::endl
const char* density = "#$lho,. ";
struct Vec3{
... |
I've tried my best to write argument parser to cover all my needs and I won't need to edit the body of parsing loop, never again(:)) to add/remove parsable flags. The resulting code seem to cover's my needs but there are things I don't like about it.
What it does:
It can parse any quantity of positional args, short fla... |
In an application that uses heavily polymorphic classes, I have often the need to downcast a pointer or a reference to the correct derived class. They should always be of the correct derived class, but for verification / unit testing, it would be great if this could be automatically found.
Therefore, I wrote a very sho... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.