instruction stringlengths 71 95.1k |
|---|
list = int(input("Enter the first 15 digits of your credit card number without spaces and dashes: "))
checkDigit = int(input("Enter the last digit of the credit card number: "))
numbers = []
for elements in str(list):
numbers.append(int(elements))
def main():
n = None
total_odd = 0
total_even = 0
c... |
spam = ['apples','dogs','tofu']
try:
def comma(items):
if range(len(items) >= 2):
for i in range(len(items) - 2):
print(items[i], end=', ')
if range(len(items) > 2):
print(items[-2] + ', and ' + items[-1])
elif range(len(items) <= 2):
... |
A kata is an exercise. In martial art is form. In software development is a way to practicing. For example in TDD.
Mars rover kata aims to solve some problem in the context of the mars rover. Here you can find a list of kata. kata-log.rocks/mars-rover-kata Kata are exercises you can use to practicing in tdd, in pair or... |
I made an assembler for the "hack" assembly language, here's an example of what it looks like:
@16
M=1
@17
M=0
@16
D=M
@0
D=D-M
@18
D;JGT
@16
D=M
@17
M=D+M
@16
M=M+1
@4
0;JMP
@17
D=M
Currently it only works with predefined symbols, I want ... |
This is my attempt to load shared library on linux (and may be mac - did not test yet)
I am interested if I am implementing everything correctly and if I can really use my function in a loop like that.
I deliberately use iostream, because it is part of the C++ library and it wont work unless library is linked (-lstdc++... |
This is my first Scala program, so I'd appreciate any feedback but especially feedback specific to Scala, for example situations where I could have utilised a feature better or where I've done something unidiomatic.
import scala.collection.mutable.HashMap
object Main extends App {
// Type alias to shorten the Teams ... |
This post is less of a question and more of a hope for people to see my code which I know is far from great and give me some direction or simple tips on improving the quality of it.
Normal Stud:
Active Stud:
The program is a small simple class which inherits tkinter's Canvas object and uses it to create a 'for purpos... |
I started learning assembly some days ago and I wrote my first program today. Nothing exceptional here: some user inputs, strings manipulations, integer to string conversion etc... The only purpose was to test some things. I would like to have your reviews and advices to improve my code. Also if i didn't make big mista... |
I am looking for a solution with fewer lines of code. This is code that is working perfectly, but I think I typed too much for this algorithm. If I did something wrong, feel free to tell me the error.
Code
<?php
function Clearstring(string $string)
{
$string = strtolower($string);
$string = preg_re... |
I'm working on an optimization code using differential evolution to solve. However, it is taking a long time to get the solution. See that I have a variable called number_of_iterations that must equal 1000000. When I consider this decision variable equal to a smaller value (eg number_of_iterations=100), the result is p... |
I would really welcome any hints on making this code more concise please.
In this example we have some experiment results.
For each planned experiment We have predicted results based on 4 temperatures and we have 4 forecasted results, 1 for each of the temperature.
For each experiment when the actual experiment is rece... |
I've been trying to create a piece of code which consists of looping through each element of a list of questions, preprocess it, and then calculate the Cosine similarity with the rest of the elements (questions) not including the same element. At the end of each iteration of the main_question, the code will then add th... |
I need to compute a deterministic hash for a JSON-serializable dictionary.
This answer almost does the job, but there are a few problems.
If dict1 == dict2 then I expect hash_dict(dict1) == hash_dict(dict2). However, in Python integers and floats with the same value are equal, but don't have the same string representa... |
My code is already doing what I want, so it's functional, now my concern is, if there is a way to make it easier to read or even better and shorter my code, it's supposed to check if 3 'X' or 'O' are continuous in 3 cells in a row, column or diagonal, code for the string 'O' is the same as 'X' only changes classList.co... |
I created this bash script to make it easy to publish your files to a GitHub repository.
#!/bin/bash
echo "Welcome to the GitHub File Publishing Tool (GHFP for short)"
read -p "Continue? " yn
case $yn in
[Yy]* ) echo "Continuing the program...";;
[Nn]* ) echo "Stopping the program"; exit;;
esac
echo "Your remote wil... |
The following bash script is intended to be run on a freshly installed digitaloceans ubuntu 20.04 droplet by root in its home dir.
The purpose is to setup a ready to use webserver with SSL (certbot), PHP 7.4 support (fastcgi), an Apache2 fileserver and nginx as reverse proxy. DNS is managed by Cloudflare.
My main quest... |
Question: What do you think about this design and the implementation?
This is a simple networking framework for IPv4, IPv6 TCP client and TCP server for Linux and MS-Windows in C. It uses a single-thread solution around the system call select(), that is IO-multiplexing. Connect and network read are asynchronous, networ... |
Question: What do you think about this design and the implementation? This is a simple networking framework for IPv4, IPv6 TCP client and TCP server for Linux and MS-Windows in C++14. It uses a single-thread solution around the system call select(), that is IO-multiplexing. Connect and network read are asynchronous, ne... |
I need to store the data in three different ways:
storing the data to a std::string
writing the data to a given file descriptor
both of the above
And I hope to use a uniform interface for these three different methods.
How to make it better?
Here is the code snippet:
#include <memory>
#include <string>
#include <i... |
I have a below struct where I have a nested map for CustomersIndex which allocates bunch of internal maps causing memory increase. I profiled it so I noticed this. I am trying to see if there is any way to redesign my CustomersIndex data structure which doesn't uses nested map?
const (
departmentsKey = "departments... |
Each animal type will call reactToOwner() and exhibit its own behaviour. So simply define a reactToOwner() override for each
animal type, right? But in this case reactToOwner() has many common parts for each animal type, e.g. lookAtOwner(), doNothing(), goAboutOwnBusiness().
So simply define hook methods between them... |
I'm writing some small programs to practice Rust, and this one's a string compressor for the golfing language Jelly (unofficial spec). It involves some non-ASCII stuff and bigints (from the num-bigint crate).
use std::io;
use std::io::Write;
use num_bigint::{BigUint, ToBigUint};
use num_traits::cast::ToPrimitive;
use s... |
I'm relatively new to c++ programming. I have a few years of experience writing simple Arduino programs, but I always kept to the basics. I also have some more experience with Python.
I set myself the challenge of writing a non-recursive quick sort algorithm. I'm wondering if anyone has feedback on style, best practice... |
I've recently had a technical interview where I had to identify code smells and refactor an existing code by applying the SOLID principles and implementing unit tests.
It is a small shopping cart application with a small set of eCommerce/shopping cart rules. Rules include calculation of total price, discount and loyalt... |
I am writing an insertion sort code in C. This code is perfectly working. But I am a bit confused if my implementation is correct or not for insertion sort.
//insertion sort algorithm
#include <stdio.h>
#include <stdlib.h>
void insertion_sort(int size, int *arr);
int main(void)
{
int *array;
int size;
pr... |
I am learning Python and wrote this code to check (every 10 mins) whether a product is available at a retailer, since it usually runs out of stock pretty quickly. It's working as expected, but can someone provide feedback if this makes sense or how to write it best?
import time
import requests
from datetime import date... |
I'm using fiber and mongodb. Field "field" is needed to obtain certain data to unload the load on the database. If field "field" is empty, then needs to output all the data from the database to make work easier to frontend. I don't like this crutch. Is there a much better solution?
func GetUserById(c *fiber.Ctx) error ... |
I recently made a simple hangman game in Haskell but soon wanted to explore the state monad, since it could possibly simplify the code. The result was this (see below), which is exactly 30% more lines than not using the monad. My question is therefore: am I using the feature correctly?
{-# LANGUAGE LambdaCase #-}
{-# L... |
I am trying to use Dijkstra to find the cheapest path between two pixels in an image.
Implementation:
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numbers>
#include <array>
#include <algorithm>
using vec2i_t [[gnu::vector_size(16)]] = int64_t;
using vec2f_t [[gnu::vector_size(16... |
I have been using a website called 'CSNewbies' to learn Python and one of the tasks was to create a way for a user to check how many days a country has been independent. The countries are limited to Fiji, Samoa and Australia.
I actually was really proud of the code I wrote because it ended up working. I tried making it... |
I am a C# beginner, and I wrote a program that parses the weekly menu of a German delivery service. It works fine and I think the code quality is okay. Can anyone with more experience than me review my code?
using HtmlAgilityPack;
namespace FMReader
{
internal class Program
{
static void Main(string[] args)
{
... |
This code has the function of removing worthless borders from the original image and then:
Generate a 1080x1080 image (Instagram default) to be used as a
blurred background.
Generate an image with a width of 1080 and the height adjusted
accordingly to maintain the correct aspect ratio.
Superimpose 2. on the blurred ba... |
import java.util.HashMap;
import java.util.Map;
public class LRUCache {
private static class DoublyLinkedHashMap {
private static final class Node {
private final int key;
private final int value;
private Node next;
private Node previous;
privat... |
I spent some time implementing a generic stack in C using macros. Apart from general bugs and bad practices in my code, I was wondering about the viability of an implementation like this that uses macros. Note that the use of assert is only for this code; if I were coding an actual implementation that would be served t... |
I wrote an interpreter for Scheme which includes stop and copy garbage collection.
DefInt A-Z
DECLARE FUNCTION hash (s$)
DECLARE FUNCTION READOBJ (depth)
DECLARE FUNCTION READTOKEN (depth)
DECLARE FUNCTION STRTOATOM (s$)
DECLARE FUNCTION CONS (car, cdr)
DECLARE FUNCTION READLIST (depth)
DECLARE FUNCTION ALLOC ()
DECLAR... |
If you would like to download some grib data for yourself, the script below will pull girb data from the google api over a date range at an hourly interval.
Extract some hrrr grib2 data
from pathlib import Path
from typing import Iterator
from datetime import datetime
from shutil import copyfileobj
import warnings
fro... |
I'm running this in release mode. Currently, the following function takes around 6.7 seconds to run on my computer vs 3.7 seconds on Python. I know that Numpy is just calling to C, but I'm trying to reach faster performance on the Rust version. I would appreciate any help. I've been trying for a week to do this, with n... |
Libraries might need to return "context" objects to the caller, and then require the same object in subsequent calls. In some cases, the user is not required to know what's the concrete type of the "context" objects. In these cases, it is beneficial not to require the user to include the declaration of the context obje... |
If you aren't aware, if you hand-code a GUI with the Windows API you will find your controls look quite ugly by default due to their font. Running this code:
#include <Windows.h>
#include <windowsx.h>
#include <CommCtrl.h>
#include <strsafe.h>
#include <sal.h>
#pragma comment(lib, "comctl32.lib")
#if defined _M_IX86
... |
Starting from this answer I thought I would show a fully worked example of how to create a data-driven version of the assembler for the Hack assembly language. As I noted in that answer, having things data driven also provides the opportunity to create a disassembler using the same data structure. This code implement... |
Would like to know if I could have done anything better with the code that I wrote. Want to also know if I could have avoided using a static variable.
private static int numberEntered;
public static void main(String[] args) {
int quit = 0;
int sum = 0;
userPrompt();
while(numberEntered != quit){
... |
As the question already says, my code returns a list with the index's that don't exist inside another list.
For this I currently create two lists joining the objects of each index, then filter the values not found and finally I do a loop searching in which index I will find this value within the initial list:
function ... |
I am learning Typescript and created a straightforward to-do list project to practice some basic concepts.
I am able to
Edit the todo
Delete the todo
Mark the todo as completed
I want to how can I better structure my code and what typescript best practices I am not using.
index.ts
import { v4 as uuidv4 } from 'uui... |
I don't know JavaScript and it's safe to say this is my first code ever written in JS.
I just needed to animate my GIFs when user hovers over them only.
Googling separate concepts such as "string functions", "catch element mouse hover", "set element attribute", "get element attribute", "get elements by class", "var vs ... |
We're using Sigrid as our code analysis tool and one of the metrics it uses to measure code maintainability is the well-known "unit size". Units between 1-15 lines of code is deemed to add "no risk to maintainability".
I know it should never be a goal to stay within those limits for 100% of the code base, but even so i... |
I have a Theme class for storing themes for my javaFX application. I created a serialize method that stores its information as a String and a constructor to create a Theme from a serialized Theme. I had to do this because I can't make Theme implement Serializable, because its fields can't, and I need to store Theme obj... |
Wrote a simple brainfuck interpreter that supports nested subroutines ([ ] commands).
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#define MIN_MEMORY_SIZE 30000
typedef struct
{
uint8_t *memory;
size_t pointer;
} BrainfuckState;
static void init(BrainfuckState *bf, size_t si... |
I created cache management structure for Asp.Net Core and Redis. But i dont know is this best practices or bad.
My Github Repo
First one is Store my entity keys class is
public class CacheKeys
{
#region User Cache Keys
public const string GetUserKey = "user__{0}";
public const strin... |
This is interview question
Reverse string with identical spaces as in original String using Java
For example
Original String :
best in the world and is greatest and is making sure the world goes
well
Output:
llew se ogd lrowe hte ru sgnikams idn at setaer gsid nad lrowe htni
tseb
The code I have written is as below... |
In my fast implementation of Non-negative Matrix Factorization (Rcpp Machine Learning Library, RcppML), about 40% of the runtime is spent solving Non-negative Least Squares (NNLS) systems (the rest of the runtime is spent calculating the left and right sides of the NNLS systems, a and b, simple cross-products). I'd lik... |
So, I have completed a Minesweeper program in Python using Tkinter.
A few questions:
I feel I should convert this to Object-Oriented Programming. Any starting tips?
Expanding on the above, I have way too many global variables. What methods to reduce these?
Any basic styling and convention issues?
All feedback is acce... |
How could I improve this code? It's a little game. If you run it, instructions will appear.
In particular, I'd like to know whether I can
make it considerably shorter
any trick :) ?
whether I can get rid of the repetition in 130-150.
import keyboard
import random
from threading import Thread
from time import sleep
#... |
I've recently tried to write my functions by using composition. But this one, renderCross' is especially difficult to convert fully. How would I write this composition point free? It's the n that I'm trying to make disappear. I've tried using <*>, and pointfree.io uses liftA2 (but this results in very ugly code) so I ... |
I've created a JobManager class that manages the execution of submitted Jobs on periodic intervals. While the JobManager is running, the API allows the user to:
Add or Remove a Job to/from the JobManager
Change a Job's interval, function parameter, and function
Signal a Job to run if it is waiting
The testing I have ... |
After getting the code review I refactored the code and the updated version is below.
I tried implementing the suggestions but because I am still learning I might refactor again after learning how to implement classes.
previous post: Created a todo list in TS
index.ts
import { v4 as uuidv4 } from 'uuid';
const addTask... |
A doubly linked list contains elements that include pointers to the previous and next element along with a value. This data structure is implemented with methods similar to what you would find in an array: insert or remove elements, read the value at an index or find an index that contains a value.
Just looking to see ... |
After a substantial amount of programming experience in high level languages like Javascript and Python, I decided to try learning a low level language for once, so I did C++. As my first project I made a graphical connect 4 game, which also has a computer ai implemented in it, using the Monte Carlo Tree Search algorit... |
Despite my experience with Java, I am not well-versed with concurrency. I wrote this thread pool that has a queue of tasks. Please ignore any signature choices, such as overuse of final. Thank you for your feedback!
public final class ThreadPool {
// Logging
//--------------------------------------------------
... |
Similar to my previous post in R All permutations of a linear model given all predictors, I have attempted a Pythonic version. However, a few issues that I have with my version is that I cannot select for multiple predictors beside when using all.
For example, if I wanted:
perModel(savings, response='sr', predictors=['... |
A doubly linked list contains elements that include pointers to the previous and next element along with a value. Being able to search and iterate through the list in both directions is an important feature.
This is my improvement over the previous version. I implemented it with classes, added a forward and reverse ite... |
I'm not sure if this is the correct place for an optimization question like this, but I'm not even sure where to start looking. So here it goes.
There's this game I play that has very simple rules. You start with some of a resource and a single worker. This worker collects said resource and you can buy one of two upgra... |
Currently from my sheet2, I wanted to copy the column C36-N36. However, each of these cells has one formula that is generated from the numbers within sheet2, i.e. C36 = A1+A2/2 something like this. Therefore, simply copy & paste code cannot work well when I transfer to sheet 1, as the specific link of each cell will be... |
Here is a program that processes 2 grayscale images. Both represent the position of objects, in the form of multiple masks per image. Each mask is a shape with one color delimiting it, with 0 (or black) for the background. Each object uses the color available in order when created, so if there are n object, the color f... |
I wrote a working code and was wondering if it could be shortened as I saw a lot of similarities in my loop and if statements. I hope it's possible as I want to make it a bit cleaner.
I had to print a list of license plate numbers of all cars that went over the speed limit, as well as the average speed of each of those... |
I have a cost function Cost_Func(pt,STRING) that calculates value in a specific way based on the given pattern string pt and main string STRING.
A mathematical expression ( y := y-11*int(STRING[i-length]))/6+ int(STRING[i])*pow(11,length), this is the main calculation ) is used,
and the intuition is, it will be faster ... |
As part of my current employment, I've been working with TCP/TLS in NodeJS for about 2 years. My colleagues and I are using a proprietary binary protocol, for communication between a proprietary hardware device and servers.
Throughout my time working on this project, I wrote functions that handled the conversion and va... |
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 am writing a nodejs program that adds some data into a buffer, before it is streamed. The data types are listed in the comments of the code, and there are fixed places in the buffer that these data-types will appear. Is there any way I can optimise this code to run faster, or for the buffer to be smaller?
/*
`symbol... |
In a non-negative 1D array x, we wish to find the shortest slice such that x[start:end] > threshold, with constraint that start <= argmax(x) < end. Must work with floats and integers.
Below is my approach, validated using a greedy search. Can it be improved in terms of speed?
Update: my motivation was not having to res... |
I am working on library project in which I am reading and writing binary files that have own file format structure. In that structure there are variable-length and fixed-length elements. My approach is to parse byte stream of such files, create corresponding objects, and then get current byte stream and write it back t... |
I've attempted to remedy the issues outlined in the answer to my previous question. I've added several hundred blank lines to better illustrate the grouping of functions and generally make things look less dense. I've trimmed all the lines to 80 columns except for one 83 character line in ppnarg.h which was inside the ... |
I'm learning C and I got a task to make 3 function.
The first get 3 addresses of string, get 3 words from the user, and enter into the addresses.
The second get the 3 addresses of string and combine them to a new large string.
The last should get the new address and print in reverse the string.
I wrote this and will ha... |
After encountering a suggestion that monitoring a log file for a webserver could allow for the implementation of automatically analyzing and handling of certain events (that might require altering firewall rules etc.), the following example application was written as a simple beginning point for processing the availabl... |
Do you think this code is good if I want to do a simple SQL query? Is it safe to use? Or am I doing something wrong?
class DBconnection {
private $dbusername = "testtest";
private $dbpassword = "testtest";
protected $conn;
public function __construct(){
try {
$this->conn = new PDO("... |
I have this function in my code, this way I validate if a new movie session can be inserted, it works, but I wanted to find a better way to do it.
public static function validateSession($newSession)
{
$sessions = Sessions::get();
foreach($sessions as $session){
//Validates if the time and date of sessi... |
Take this basic component using state:
export const InputChild = () => {
const [count, setCount] = useState(0);
const updateCount = () => setCount((prev) => prev + 1);
return (
<>
<h1>Count: </h1>
<h2>{count}</h2>
<button onClick={updateCount}>Click</button>
</>
);
};
And this test t... |
This is a revised version of the JobManager class originally posted here. The revisions made were centered around:
Encapsulating the Job class within the JobManager class.
Removing the use of std::shared_ptr(s) from the Job class.
Moving most of the Job member method logic into the JobManager class.
I have a few ques... |
I want to implement this in a SQL database schema, but am doing it in JavaScript first to make sure I have the logic right. Basically, I would like to track "actions" a user performs. If they perform a certain amount of actions within a period (a day for now), then they hit the goal for that day. Then if they do this f... |
I need to store some math terms. Originally I would use a tree to do it, especially if parsing strings was involved. However, since the expressions are built within the code and need not be parsed, I thought of doing it with nested lambdas and overloaded operators instead.
Since these expressions will probably be run a... |
I am working my way through a React tutorial on Scrimba (I am not finished yet). I got to a certain part that inspired me to try a project on my own. I made a game of Lights Out. If you've never heard of it, it was a handheld electronic game where you have certain buttons lit up at the start and you have to have all th... |
I wrote the following JS function to check if a date comes in the right format and can be used further down in the application
const getInvalidDay = day => {
const date = new Date(day);
const dateToMoments = [date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds()];
return dateTo... |
Background
I am a relatively new developer(> 2 years coding) working as an intern for a smaller company, as part of a now 4 person team. We had two other team members, one our system admin and the other our IT manager, fired less than a month after I was hired on. I was hoping to use our IT manager as a resource for re... |
Google Sheets maintains an identity for each column that follows this pattern:
col 1 = A
col 26 = Z
col 27 = AA
col 52 = AZ
To know the column number according to the id I do it like this:
import itertools
import string
col_values = 'AA'
def col_letter_to_num(col, col_abs=False) -> int:
col_num = col
if col_... |
I could not find an implementation of the IPv4 header checksum calculation. So, I decided to made one as defined in RFC 791.
I made use of the "newer" ReadOnlySpan<T> classes to optimize things a bit. Appreciate any feedback!
Extension Methods
Note: These are two extension methods to illustrate the only two use cases t... |
I am wondering if there is a better way to traverse a list of trees.
Here is my current algorithm:
Collect the parent IDs in a Map
Traverse all the groups and find ones where their ID is not in the map
Calculate each of those groups overall status, based on their data
Go through them again and find their parent
Check ... |
I have a web application, as part of it I regularly have to send out "overviews" of records in a database, which contain shortened excerpts of a description-text of that record.
What the code is supposed to do:
Take an HTML string
Remove the HTML brackets so that only text remains
cut it down to SHORT_DESCRIPTION_WORD... |
Iterative dfs Maze generation program in C.
Details about the algorithm:
Example run of the program:
In my implementation:
Each cell has:
4 neighbors [left, right, top, bottom]
2 walls [right, top]
and a visited field obviously
Here is the code:
cell.h
#ifndef CELL
#define CELL
#define LEFT 0
#define RIGHT 1
#defi... |
There are x distribution centers each with y number of products. Each day only an equal amount from all x distribution centers with remaining product can be shipped. Calculate how many days it would take to ship all product So, for an array [3, 2, 6] it would go:
[3, 2, 6]
[1, 0, 4]
[0, 0, 3]
[0, 0, 0]
== 3 days to s... |
For a Miller-Rabin primality test I need a fast way to compute a^d mod n.
Where a is one of 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 with decreasing probability and increasing n. E.g. for n < 2047 only a = 2 is used. And tests are run in order until one says n is not a prime. Most non-primes are detected early.
The o... |
This script first looks through a specified folder path for image files that have a given extension and removes any periods that might be in those file names. It also adds those sanitized file names to a list. It then converts the files in that list to the desired image type. Finally, if the dimensions of any of the im... |
I'm learning Java and I did one exercise that consists in reading the input of the user (name of the network and date of the report) and return the csv that was inputed by the user. I know that the code is far from clean but I dont know how to make it cleaner and is so far working. So I basically need help and suggesti... |
I've created a simple logging library in C which I can use in my other projects. I wanted to get started in software development using the C language, and this is my first attempt at writing something which comes close to an actual software. Looking for a code review/feedback for this library, especially about reusabil... |
(See the next and second iteration here.)
I have this toy implementation of the diff utility in Java:
com.github.coderodde.diff.Diff.java
package com.github.coderodde.diff;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java... |
To collect the list with the data from an API, I need to do these steps:
trading = betfairlightweight.APIClient(
'email',
'password',
app_key='app_key',
cert_files=('./certs/bf.pem'),
session=requests.Session()
)
trading.login()
hours_limit = 12
limit_hour = (datetime.datetime.utcnow() + datetime.t... |
I have some diagrams I'm drawing using tikz and I'd like to make a macro to draw them for me.
I will describe it fully but here are some examples so you can follow along:
The diagram has a number of nodes which we can be split into two groups, "main nodes" and "detour nodes" main nodes are drawn in a column the left a... |
Motivation
I'm making an emulator. It has its own software framebuffer of size 320x240. Each frame is prepared internally from the emulator, and I just need a way to display it on a window, scaled to the window size while maintaining the ratio (with black bars on each side if necessary).
My first try was using SetDIBit... |
Maze generator in C. This is part 2 of this
I changed everything I was told I should in the part 1 of the review.
I also added functionality to be able to step through the generation of the maze, or just generate the whole maze instantly.
main.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time... |
I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out with optimizing this code? The code is already running for 3500 minutes so far... When picking a smaller loop (100 x 91), ... |
I am working on a code that will minimize the number of ingredients necessary to make some dishes.
Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. The result is a tuple of recipes.
I have a code that works, but if there are a large number of items, it is very slow a... |
AVL trees and red-black trees are most famous balanced binary search trees.
I've always wondered "Why do all major C++ standard library implementations use red-black trees as their ordered associative container? Why? Are AVL trees that bad?"
So I wrote mine!
AVLTree.h
#ifndef __CLRS4_AVL_TREE_H__
#define __CLRS4_AVL_TR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.