instruction stringlengths 71 71.9k |
|---|
This algorithm runs in \$O(n!)\$ time and I wish I could make this a bit faster for larger elements.
Is there a better approach to solving the parentheses problem in shorter time?
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private static ArrayList<String> pathPermutations = new Arra... |
Now I have this fluent API for creating random integer arrays. I can say that I want an array of particular length, having a particular minimum/maximum values and using a particular (or default) java.util.Random. See what I have:
FluentArrays.java:
package net.coderodde.util;
import java.util.Arrays;
import java.util... |
I have a list of keywords and I want to count the number of records in a db which contain any one of these keywords. From each record, I want to consider only title and description to be checked.
Is this correctly written?
self.keyword_list = ['Buzz', 'Heard on the street', 'familiar with the development', 'familiar wi... |
This is my code to print letter 'F' with nested loop 2d array. Are there changes that could be made in it to make it look better or more efficient?
for (int i=0;i<=4;i++){
for(int j=0;j<=4;j++){
array[i][j]='*';
if ( array[1][1]=='*' || array[1][2]=='*' || array[1][3]=='*' || array[1... |
One challenge I regularly face is how to name my service objects in Rails.
I like the advice in this blog post on Gourmet Service Objects, a service object performs one action. It holds the business logic to perform that action. For example:
# app/services/accept_invite.rb
class AcceptInvite
def self.call(invite, us... |
I use the following structure in a web service where performance is critical. It is used for making joins between domain data objects, the key is made of two integers. The idea is to fit the two 32 bits integer in a long (64 bits).
Before using that structure, I used Tuple<int, int> which was really slower.
Is there an... |
I'm trying to reproduce in Lua the mIRC scripting manipulating tokens function:
local function tokenize(C, text)
local char = string.format("%c", C)
local t = {}
for w in string.gmatch(tostring(text), "[^"..char.."]+") do
w = tonumber(w) or tostring(w)
table.insert(t,w)
end
return t
end
lo... |
I tried writing a prime sieve that grows as needed.
I've only just started learning C++ so any feedback on idioms is extra welcome!
The header:
#ifndef prime_sieve_h__
#define prime_sieve_h__
#include <vector>
class prime_sieve {
private:
std::vector<bool> prime;
int upto;
void size_up(int n);
publi... |
This is my ugly code which needs to sort my data. I'm not really familiar with C# since actually I'm a Java programmer.
How could this code be rewritten without loosing performance? I know I could use reflection, but it is bad for performance.
sortings is a list of the fields that have to be sorted and if it has to be ... |
Write a function that returns an array of integers with 1000 elements
containing the values 1 to 1000 in random order. No number can be
repeated or omitted.Your answer should show good programming style,
technique and attention to accuracy and performance.
Hint: use Random rnd=new Random() to create a new instan... |
Most Python "duplicate file finder" scripts I found do a brute-force of calculating the hashes of all files under a directory. So, I wrote my own -- hopefully faster -- script to kind of do things more intelligently.
Basically, it first searches for files of exact same size, then it compares only N bytes at the head an... |
I have an array that might be either one-dimensional, two-dimension, or three-dimensional. I'm wanting to check to see if all values in a given direction are constant.
Here are 3 functions:
# Check to see if all values in the first dimension are equal ... |
I've always wanted to be able to steer stream indentation, so that I could write code like this:
/// This probably has to be called once for every program:
// http://stackoverflow.com/questions/26387054/how-can-i-use-stdimbue-to-set-the-locale-for-stdwcout
std::ios_base::sync_with_stdio(false);
std::cout << "I want to ... |
I've been working on this elevator program for quite some time now and finally finished it and made it work and I'm pretty proud of myself, but I'd like to see ways how to refactor my code so I can learn for the future. By refactoring I mean, making the code look better, maybe by using less lines of codes.
public class... |
I was originally going to write this intro as just being the bare-bones "here's my problem, here are some ideas, what do you recommend" format (which I am still going to follow, mind you), but I've decided to also add some backstory to it.
In high school I would write inefficient programs that generated mathematically ... |
Currently, the code will generate a range of natural numbers from 1 to N and store it in a list. Then the program will iterate through that list, marking each multiple of a prime as 0 and storing each prime in a secondary list.
This is a translation of a TI-Basic program, shown here, so the same description still app... |
I'm writing an AD Termination script for work. I'm new to PowerShell and was wondering if multiple commands within PowerShell switch statement is okay to do:
# Switch statement to start here
$switchTitle = "Terminate User"
$confirmMessage = "Are you sure that " + $fullName + " is the user that you want to terminate?"
... |
I've been trying to learn Haskell on and off for a couple years. I had a project for building a parallel web scraper, and I figured I'd try to use Haskell for it. Here's the part used to schedule tasks: basically, it opens a Chan that can be used to send jobs, which is simply an IO action with the time when it should b... |
I'm trying to write a HTTP Request library for practice with Sockets and C++ in general. I created a seperate function to setup the struct needed to Connect() however it is now breaking and I cant seem to figure out why even with a debugger. Also looking for any code optimization I can be doing better.
#include <winsoc... |
I had a challenge a while back from a friend to try and produce the fastest possible program to compute A(3,16), where A is the Ackermann function.
He wrote it in Java, and it took ~4.4 seconds. The below (very ugly) Haskell program that I wrote took ~1.7 seconds:
{-# LANGUAGE BangPatterns #-}
import Data.Ma... |
I am kind of new to Java and I have tried making a simple calculator. This lets you do different calculations in a row until you type done then you get the answer. It works as I expected but I was just wondering if I could get some feedback on it and how I can improve on it or what better approaches I could have taken.... |
I'm creating a new data type, with the intention of overloading the arithmetic operators. It's for Galois Field arithmetic. The obvious thing to do is create a class, the instances of which will be the variables. There's precious little doc, the maths is a bit agricultural, incomplete and fragile at the moment, it migh... |
Breeding like rabbits
Write a function answer(str_S) which, given the base-10 string
representation of an integer \$S\$, returns the largest n such that \$R(n) = S\$. Return the answer as a string in base-10 representation. If there
is no such n, return "None". S will be a positive integer no greater
than \$10^{... |
I came across this interview question to find water accumulated between towers:
You are given an input array whose each element represents the height of the tower. The width of every tower is 1. You pour water from the top. How much water is collected between the towers?
Any suggestions?
def test(x):
if len(x) <=... |
Three weeks ago I wrote the first version of my chess game in Python and shared on Code Review. Thanks to your suggestions, I improved my code. I would like to know if I am going in good direction with all this stuff.
__author__ = 'Goldsmitd'
class Condition:
def range(x,y):
return x > 8 and y > 8
def... |
The following program is an updated version of this question, an implementation of the Vigenere cipher in C. It has been updated to take input from stdin and pipes, amongst other suggestions made by users answering the previous question, as well as having been significantly cleaned up. The program has been through seve... |
This code is slightly platform dependent but should be pretty easy to port. The goal with this code was to create a circular buffer where the consumer could be limited to read-only access of the buffer (the test uses threads but it could be ported to processes fairly easily.)
I think I probably made at least one mistak... |
I know about apply, but I'm not sure how to write it so that it works for embedded for loops with if statements and so forth. It gets messy. I am a novice so if you can show me how to properly rewrite the following efficiently it should help a lot.
This is an example of what the dataframe inFile() should look like. In ... |
I'm writing a program that takes an input image, and generates a set of unique colors, and repaints the image using only those colors. It takes a long time, and I'm hoping to improve the running time. It's on GitHub, if you want more context.
This is an example of the output, running from left to right:
This is the ma... |
I work in a Windows environment where Scheduled Tasks have never been documented or kept up with, leaving us with about 150 servers that have a random smattering of tasks. I am attempting to construct something that will query specific information about these tasks and output them in a pretty format that I can sort thr... |
In a C++ program, I have the following function to find the length of the longest common prefix between to char arrays a and b. String b is guaranteed to be shorter than string a.
Is there a faster char array comparison code (for example, with some library function)? I wish to optimize this code for speed.
long len_co... |
I picked up python again, and I am proud with what I have without using if/elif statements throughout the whole thing. I have modified this couple of times, since I kept asking how could I make it better or more organized. My biggest complaint is using the if/elif at the bottom, for some reason when I use.
func = optio... |
I would like some insight on this function for sanitising user submitted data into a contact form. No HTML content or anything, just plain text.
Are there any vulnerabilities here that I'm missing? Am I ok to use the flag FILTER_FLAG_NO_ENCODE_QUOTES on the subject line? I'm not sure if quotes are safe to submit.
I'm l... |
I made this C++ doubly circular linked list implementation and it seems to work right, handle everything well, and not have any errors. However, I've been working with it for a while and would like some fresh eyes to take a look and see if I am missing anything large or if my code contains any 'gotchas'.
Side note: I ... |
I made this C++ doubly linked list implementation and it seems to work right, handle everything well, and not have any errors. However, I've been working with it for a while and would like some fresh eyes to take a look and see if I am missing anything large or if my code contains any 'gotchas'.
Side note: I ran valgri... |
I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments.
I clearly have little understanding of C++ templates because most changes I make break it and take around 30 minutes to debug each. So I would like some review especially regarding my use... |
I am trying to read a sequence of random characters, integers and symbols from the standard inputstream, split it into 3 separate arrays (uppercase, lowercase and numeric) and print them in that order using standard Java API and JDK7.
Is there any other(better) way of dong the same?
BufferedReader bufferedReader = new ... |
I'm looking for comments on the use of decorators for the following problem (validating initial guesses for bracketing rootfinding methods), as well as any other comments you might have on the design below.
def bracketing(rootfinder):
def wrapper(func, x0, x1, *args, **kwargs):
func_x0, func_x1 = func(x0), ... |
I wrote this in order to get a list of network interfaces on Linux. In the past, I have used publicly available methods from, say, ActiveState, which uses ioctl and was annoying to get working under Python 3. This version simply uses regular expressions on the output of ifconfig.
The documentation style used here follo... |
So, I did the CodeEval 'Longest Lines' problem and it works fine for any input data I can devise. When I upload it to CodeEval, it says it's wrong.
Because it's a "moderate" problem, input data is not provided. After some System.out.println nonsense I got the test data, and my solution seems to work. Am I missing so... |
I've written some Python 3 code that computes the \$n\$-th prime. I implemented first a naive isprime function that looks for divisors of \$m\$ between \$2\$ and \$\lfloor \sqrt m \rfloor+1\$. Then a loop looks for primes and stops when the \$n\$th one is found.
from math import sqrt
def isprime(n):
for i in range(... |
Inspired by Sam's question (Brute-force string generator) and rolfl's really short version of the algorithm I started to experiment with a different approach and created one that seems to run a little bit faster (about 40-50ms for a string of length 4). As it doesn't really optimize the orginal algorithm but is a compl... |
Problem Statement (from HackerRank)
We have two arrays \$a\$ and \$b\$ of length \$N\$, initially all values equals to
zero. We have \$Q\$ operations. Let's define three types of operations on
this arrays:
1 l r c: Increase \$a_l, a_{l+1}, \ldots, a_r\$ by \$c\$.
2 l r c: Increase \$b_l, b_{l+1}, \ldots, b_r\$ by... |
I'm trying to run a build scripts framework, so build scripts can be configured via yaml file tasks.yml:
---
release: # This is a 'runner' or group of related tasks. They share common initialization needs
config:
repo: ci-repo # Configuration parameters can be set at runner level and overriden by nested tasks/s... |
I've written a smaller version of 15 puzzle in C, using OpenGL 3.3 and freeglut. I've found a place you can play it online to get familiar. I'm new to OpenGL, so I have no idea if I'm doing this in the right way. Nevertheless, this game compiles and works as intended on my 64-bit HP COMPAQ laptop with Intel HD graphics... |
Here's a simple snake game I implemented in Python, which works in a console. It's not complete yet (doesn't generate food yet, and no scoring or difficulty levels), but it works. I would be really grateful if you give me any suggestions on how I can improve my code. Note that I did some of the things I did in a reall... |
A long time ago I found this question and asked about an algorithm here.
My code is also available on GitHub.
Given a self-balancing tree (AVL), code a method that returns the
median.
(Median: the numerical value separating the higher half of a data
sample from the lower half. Example: if the series is
\$2, 7, 4, ... |
I have been playing around with the Io language, and this is my second toy, after the yes program that is just loop ("yes" printl) and on which not much review is possible, I wrote a FizzBuzz program. I like the shortness of it, but any improvement is welcome as I am very beginner in this programming language.
toBuzzWo... |
I have created a simple implementation of the bubble sort algorithm. I have tried to make it as efficient as possible by following pseudocode which I have provided below, making some slight modifications to suit my needs.
The pseudocode:
procedure bubbleSort( A : list of sortable items )
n = length(A)
repeat
... |
I have JSON data:
var data = [ { dat: 'timestamp', val: 10 }, { dat: 'timestamp', val: 20}, (...)]
Data contains objects with timestamp and value, can be more than one in month.
I need to sum values from objects which have the same month and year.
First I use each function to add additional field cat which contains ... |
Is this the simplest way to write this? This code evaluates if a textbox value exceeds 20 characters, and then displays the proper message (essentially truncating the string and then adding an ellipses to the end.)
I've tried using a tertiary operator but doesn't seem to work with appending data to an element as it ove... |
So I'm very much a beginner to Java and Android programming. I've worked a lot more with Python so I might have some quirks from there bleeding into my code here. I'd like a particular focus on pointing out ways I'm approaching the language and any confusing style I might be employing.
What the app does is pretty simp... |
I program in C, and it's my favourite language. I've recently found Rust. I like their ideas. Sometimes looks like a weird mixture of C++ and Haskell, but overall it looks nice.
The for loop in C is very flexible, and I truly miss them in Rust. Just look at my messy beginner Rust code below. Below that there is the equ... |
I have the solution for the problem, but it is taking me 7 seconds to run on a large dataset. I am trying figure out a better way of doing this. It has to run in under 3 seconds.
Problem Statement:
There are N plants in a garden. Each of these plants has been added with some amount of pesticide. After each day, if any ... |
This is a Login Authentication / Sign-up Models for my class project in PHP. I would really appreciate criticisms and any suggestions to improve security, code quality, etc.
Hashing.php
class Hashing{
public static function getHashedPassword($username, $password, $regTime){
//Prepending Username and Appendi... |
I used XML to control the theme of an InputMethod for Android. A theme in XML contains the color and the shape of keys.
XML file
<theme>
<color name="FIRST_LINE_LETTER_COLOR" value="#263238"></color>
<color name="SECOND_LINE_LETTER_COLOR" value="#263238"></color>
<color name="THIRD_LINE_LETTER_COLOR" valu... |
I have written a simple event emitter in Python, which allows subscribing to events and emitting events (along with monitoring events too). I'm rather new to Python, and would like some feedback on the overall style of my code (I tried to follow PEP 0008) as well as how it works.
import inspect
_DEFAULT = object()
c... |
This post goes over how I updated my 2048 merge function code from spaghetti code to being somewhat more readable.
Spaghetti Old Code
I incorporated a few techniques from pretty much all of your suggestions! I realized there were a lot of logical mistakes and redundancy in my code, like why append 0's over and over aga... |
I have written code to add a node to the head of the list. Criticisms and feedback are welcome.
typedef struct sList
{
void *data;
struct sList *nextNode;
}sList;
sList *addNode2Head(sList *psList,void *data)
{
if(psList == NULL)
psList = newNode();
else
{
psList = addHeadNode(psLis... |
I have written a piece of code that notifies if something is added or removed from a folder location:
from PyQt4 import QtGui
from PyQt4 import QtCore
import sys
import os
def xor(lst1, lst2):
""" returns a tuple of items of item not in either of lists
"""
x = lst2 if len(lst2) > len(lst1) else lst1
y... |
I'm starting out with learning how to program in Python and created a Hangman game. I think there is a lot of unnecessary code but I am not sure how to improve it. I wanted to avoid using global variables but was not sure how to save the random word (as every time I called it in another function, it would be a differen... |
This is a C# WinForms program targeting .Net 4.5. I am using it for a movie organizer application that will contact sites like OMDB, MyApiFilms, etc. for data about the movies. At the main application level a new movie list needs to have its movies matched to their info, which means searching these sites via their API,... |
I have that girl whose graph walk I want to intercept, but because I am not good at running algorithms in my head, I had to program my computer to do that for me. I would not consider the problem to be a problem in its own right, but can be thought of as an extension of the shortest path problem.
Edit: I am not quite s... |
I improved the code from my previous question.
At this moment, the 3 entities have not yet a connection with each other. They should only be available for CRUD actions in a SQLite database.
I would like to have a review of this basic CRUD application so I can improve and learn from your experience. The full code can be... |
I have written a jQuery plugin (my first for a long time) that simply cycles through strings of text in a data attribute and uses setInterval to type it out - it's a common effect you've probably seen hundreds of times.
I'm looking for a code review of the JavaScript/jQuery portion of the code mainly because a lot of ... |
I've just wrote my first code, which is basically a calculator. Please rate it and suggest improvements (keeping in mind that I'm a beginner).
import math
#Returns the sum of num1 and num2
def add(num1, num2):
return num1 + num2
import math
#Returns the difference between num1 and num2
def sub(num1, num2):
r... |
I want to get the value of an integer from within a struct pointer. Simply: int cool = *(*(&(coolPtr->map)) + x); can this be simplified? The rest of the code is context. X being the index of the array.
struct Cool {
int map[5];
};
int value (Cool* coolPtr, int x) {
return *(*(&(coolPtr->map)) + x); // Here
... |
This code will print an arrow of asterisks, like:
*
**
***
****
***
**
*
raisingAsterisks, decreasingAsterisks, arrow :: Int -> [String]
raisingAsterisks n = take n $ iterate ('*' :) "*"
decreasingAsterisks = reverse . raisingAsterisks
arrow n = raisingAsterisks n ++ (tail (decreasingAsterisks n))
main :: IO()
main ... |
This code generates an animation that gives the idea of an ever changing network of nodes (each with different impact and possibly more than one color) connecting each other to create something.
I wanted to give it depth perception, so I ended up using two canvases around the title: one in the foreground, even over the... |
I wrote a general purpose library for in-memory cache with custom timeout for each key.
import (
"strconv"
"sync"
"sync/atomic"
"time"
)
type item struct {
value interface{}
expired bool
owner *Cache
timer *time.Ticker
}
//Cache of items which can be expired or cancelled (pulled)... |
This question is a follow-up from Object Oriented Finite State Machine. I vastly improved commenting and followed the suggestions from the answer. Additionally, I improved my tests and did some more refactoring.
At this point, I still want to know what I could be doing better in my code. How could I better follow C++ c... |
The Cardshifter web client is coming along! The game client is a web app written mostly in Angular.js and is hosted at at play.cardshifter.com.
@SimonForsberg (who runs the server) is getting tired of the web people always working tirelessly and updating the code, and asked for a script that can do deployment for him.
... |
Some folks told that a two-dimensional array can solve almost all the problems, but let me disagree with that. That's why I made this Deca dimensional array sort function. The array must be symmetrical, meaning that it must contain elements corresponding to all the existing elements in the other dimensions.
I didn't pu... |
This is the Utopian Tree in F# (from HackerRank)
The Utopian tree goes through 2 cycles of growth every year. The first
growth cycle of the tree occurs during the monsoon, when it doubles in
height. The second growth cycle of the tree occurs during the summer,
when its height increases by 1 meter. Now, a new Uto... |
I have this algorithm for mining frequent itemsets from a database. In that problem, a person may acquire a list of products bought in a grocery store, and he/she wishes to find out which product subsets tend to occur "often", simply by coming out with a parameter of minimum support \$\mu \in [0, 1]\$, which designates... |
I'm newish to C#, being mainly Java oriented. I have a field _config which needs to be a value from 1 to 8, and I have this code which checks to make sure I can only set _config to 1-8. If the value given for set is "invalid", _config becomes -1.
public int Config {
get
{
return _config;
}
set
... |
How good is this algorithm? Personally I think it's over-complicated and needs some improvement. Should I be using iterators here (I think it's "harder" this way) or indexing? Should I stick with a vector or try other containers? Is a vector (array) of pointers generally better than one of objects?
#include <iostream>
... |
We have a round table of n knights, where n is some positive
integer. These have failed to satisfy the expectations of the mad king
and are sentenced to death. However as an act of mercy he goes around
the table killing every other knight (starting with the second)
until only one knight remains.
The question i... |
This accepts text and returns a list of all words which occur with a required frequency (default frequency is 2). It works well, but gets too slow with large texts, more than 1M words. Where can this function be improved to speed searches in larger text?
from collections import Counter
import re
def words_in_text_coun... |
How to make code dry in this example? My program is working, but I want to improve it by shorting my code.
.
parser = argparse.ArgumentParser()
parser.add_argument('--words', '-w', action='store_true')
parser.add_argument('--lines', '-l', action='store_true')
parser.add_argument('filename')
args = parser.parse_args()
... |
Problem
The problem is to build the tallest tower made up of cylinders, respecting all the rules.
Will be arranged on the table, an amount of \$N\$ cylinders.
Each cylinder has one color: Red, orange, green or blue.
Each cylinder has one heigth \$h\$ and a base with radius of size \$r\$.
To the build the tower, the c... |
This is a practice question:
A happy number is a number defined by the following process:
Starting with any positive integer, replace the number by the sum of
the squares of its digits, and repeat the process until the number
equals 1 (where it will stay), or it loops endlessly in a cycle which
does not include ... |
Idea behind the class is same as boost::string_ref or llvm::SrtingRef.
StringRef is immutable and not-owning.
I did not implemented substring() yet, because I will not need it.
Example usage:
std::string name = "xxxx";
void store(const StringRef &s);
void something(const StringRef &s){
//... do something here, fo... |
Here's my assembler for the HACK assembly language, part of the Nand2Tetris course. I'd really appreciate any comments/criticism/help!
If you want to know what input and output files should look like, you can check out the test data in the /tests/ folder on GitHub.
Assembler.c:
/**
* file: assembler.c
*
* usage of... |
I have ASP.NET WebApi project. Some of controller has method SetAsMain(int id) that get information about people then use stored procedure update people. How can I improve it? Should I do check people.IsMain == true in stored procedure?
public HttpResponseMessage SetAsMain(int id)
{
People p... |
I have two different arrays:
var array1 = [
{id: "foo", name: "Foo Smith"},
{id: "caa", name: "CAA"},
{id: "bar", name: "Bar Jones"},
{id: "baz", name: "Baz Apple"},
{id: "boo", name: "Boo Ghost"},
{id: "dah", name: "DAH-123"}
];
var array2 = [
{name: "bar", key1: false, key2: false, key3: ... |
I'm reading a book about C programming, at the end of each chapter it has some training exercise and one of them was to make a program that tells if a date is valid or not, the code below is what I did and I would like to know if it can be improved?
#include <stdio.h>
int main(){
int dd,mm,yy;
printf("write a date(da... |
I recently came across this problem which is as follows:
Given a string S and a string T, find the minimum window in S which
will contain all the characters in T in complexity O(n).
For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC".
Note: If there is no such window in S that covers all characters i... |
Today I encountered something that I have been wondering about in the past a few times before. How can I refactor a method that has this format:
private boolean isRectificationUpgradable(Rectification rectification) {
final boolean validType = rectification.getType() == RectificationType.VH
|| rectific... |
Project Euler 11 Solution in Java.
The problem is at https://projecteuler.net/problem=11
package coderbyte;
public class Java {
public static void main(String[] args) {
int Grid[][] = {
{ 8, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52,
12, 50, 77, 91, 8... |
I need to write 5 crores records with 72 columns into text file, the file size is growing as 9.7gb .
I need to check each and every columm length need to format as according to the length as defined in XML file.
Reading records from oracle one by one and checking the format and writing into text file.
To write 5 crores... |
I'm currently learning C with "The C Programming Language" by K&R. At the moment I'm at the chapter about pointers (since I come from Java, they are new to me). In the book is an example code for a method getint(), which is supposed to read integers from input, but doesn't handle freestanding '+' and '-' correctly.
As... |
I have created keyboard shortcuts menu,same as like this stackoverflow keyboard shortcuts.In multilevel.
Scenario
In first level i have assigned functions for only key A.
In the second level i have assigned functions for B & C keys
I have controlled key events B & c in the first level with a variable.
Its working f... |
Database.php
This creates a connection and executes a query. Although, I think I should make it a static/singleton class.
class Database extends PDO
{
/**
* constant DSN contains database driver, host and database name.
*/
const DSN = 'mysql:host=localhost;dbname=matrimonial';
/**
* @var s... |
In want to implement length prefixed strings in C (not null terminated), with some idiosyncrasies: malloc is prohibited, memory efficiency is important, each string (except for literal-backed ones) is modifiable and can change its length, but it has a fixed (at declaration) allocated length (maximum 255), C code is gen... |
My WinForms application is a bit slow, I'd like to make it faster. It extracts only the power and energy values out of a string in textBox3, and displays the extracted values in textBox2 and textBox4.
textBox3.AppendText(datarecv); // display data on text box
temp = textBox3.Text;
//Regular e... |
This is from Bjarne Stroustrup's C++ Programming: Principles and Practice, Chapter 13 Exercise 2:
Draw a box with rounded corners. Define a class Box, consisting of four lines and four arcs.
I've already defined class Arc and using existing facilities (class Lines) for drawing the lines.
Here is the code that draws ... |
Given a set of overlapping boxes, and a set of points, I'd like to be able to determine which of the boxes contain each point. The number of points is much larger than the number of boxes, and I'd like to do it faster that brute force, so I'm trying to do it with a map-like structure.
My current attempt is below, it se... |
Suppose you are running a business of repairing cars. You know all the parts (graph nodes) and the way they affect other parts (directed edges), and you know the probabilities of each part failing. If the graph of interdependencies between parts is acyclic, it is called a "Bayesian network".
Now suppose a client arriv... |
I've written a Code Review design using Userscripts and CSS.
It works by fetching the CSS from my GitHub repo, and using the built in gm_addStyle function to add it to the page.
The CSS that's fetched is minimised, also.
This is what it looks like:
I was looking at some of the other Stack Exchange sites for inspiratio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.