instruction stringlengths 71 71.9k |
|---|
I'm trying to build a ThreadPoolExecutor singleton to use it across my app. I'm very new to this concept and after going through Google docs I have created this:
public class MyThreadPoolExecutor {
// Sets the amount of time an idle thread will wait for a task before terminating
private static final int KEEP_A... |
I have the following input:
newValue = [['men', 'John Doe,Chris perry'], ['women', 'Mary,Anne,Lita']] - list within list
keywords_list = [('MEN', 'john,zack')] - tuple in a list (Dictionary on which .items() is used.)
Expected Output is:
newValue = [['men', 'John Doe'],['women','']]
What I want to do here is extract... |
I am facing performance issues while reading a large text file from the network. The same file is read locally without any performance problems:
int file_no_lines(char *file_path)
{
FILE *fp = NULL;
char line_read[200];
int linecount = 0;
fp = fopen(file_path, "r");
while(1)
{
if (fgets(li... |
I've implemented a quadtree in C++. Ignore any apparent similarity to the pseudocode on Wikipedia, it's all in your head, I swear.
How can I improve it? Algorithm speed/space improvements, any extra functions that I'm likely to want... as well as general practice.
#ifndef _QUADTREE_H_
#define _QUADTREE_H_
#include <ve... |
For a recent lab at the university we had to match the longest prefix for an IP (v4) address by using a Trie data structure. The code works fine, but it takes about 2 minutes to load a 14 million-line routing table. I examined what was causing the slowness, and it was the (String) IP to (String) binary format conversio... |
Most of the C code I have written has never been seen by anybody else, and I wonder if my code follows normal practices, especially how my code performs security-wise. The code is for a library that I have made for working with strings, and it is for use in other programs.
The full project can be found on GitHub.
The f... |
I now use a grid system similar to that of the one created by André Luís located here: http://andr3.net/blog/post/142 and evolved by Lea Verou located here: http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/
Made my first grid system supported back to IE8 if respond.js is used (or another met... |
I am trying to move some logic outside my controller for creating my view models for the view.
I have a lot of queries to fire to make sure the complete view model is ready, so to keep my controllers thin I came up with this design - any feedback, comments or suggestions are welcome!
The interfaces looks as following... |
I had a look on Stack Overflow etc. on how to perform a contains ignore case with n given strings. Most answers suggested using regex for this task. Although it's a valid option, I prefer doing upper-case for both strings and apply a .contains afterwards.
The solution I came up with looks like this:
(defn desc-matche... |
Context:
I am working on the login module of a PHP web-application and I am trying to implement this using PHP/PDO and the DAO pattern. I would like someone to review the code below and let me know whether my understanding is correct or not,i.e, am I implementing it correctly.
The application would require the user to ... |
Generic Headers
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
typedef std::string const BFProgram;
BF Interpreter
class BFInterpretor
{
static const std::size_t MemorySize = 10000;
std::vector<char> memory;
std::vector<std::size_t> openLoops;
BFProg... |
In the last few day, I wanted to sharpen my C skills a bit, so I wrote a math expression interpreter that can handle + - * / ( ) and only integers.
I just want to know how good this code is, if anyone has any comments on any part of the code and if writing such code guarantees that I understand every aspect of the C la... |
Is the following functions implemented correctly for the set class?
Please let me know if any changes need to be made.
# Implementation of the Set ADT using a Python list.
class Set :
# Creates an empty set instance.
def __init__( self, *initElements ):
self._theElements = list()
for i in ra... |
I am implementing a function which searches through a ring queue for a given substring. The function returns true if the substring is found, otherwise false. There is a cell containing null between the tail and head to signify the end of string. Please give feedback on this implementation.
bool SoftwareSerial::contains... |
I had a homework assignment to create a simple hex editor that reads binary files as well as write integers to it. However I enhanced it a bit. Homework is already submitted, but that doesn't mean this code will remain without a review.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#inc... |
Can someone help me furnish my PHP validation class? I want to reduce its size and make it easier to use.
<?php
class validate
{
function check_empty($name,$value)
{
if(!empty($value))
{
$msg="";
return array($name=>$value,$error=>0,$err_message=>$msg);
}
else
... |
This used to be university work now I put it our here for review purposes.
Could this be constructed better?
Is there any easier path, performance-wise?
Could this be optimised?
Which features and functionalities could/should be added to this game?
<!doctype html>
<html>
<head>
<title>Math.floor</titl... |
I'm trying to generate prediction bands for an exponential fit to some 2-dimensional data (available here).
The data (blue points), best fit found by scipy.optimize.curve_fit (red curve), and lower & upper 95% prediction bands (green curves) can be seen in the image below.
I'd love some confirmation that the code is a... |
I have to write a python function that takes a string that contains raw unicode strings (e.g. "u'hello' there") and transform it into a string that strips the u'' identifiers from it. For example:
strip_inline_unicode("u'hello' there") # -> 'hello there'
Without getting into too much detail as to why I have to do thi... |
I'm trying to optimize a nested for loops that compares an element in the array with the rest of the element in the array.
There's two part, the first part is for example, an Array has 3 elements, and each element is a dictionary:
[{"someKey_1":"a"}, {"someKey_1":"b"}, {"somekey_1":"a"}]
1st iteration(1st element co... |
Just another step in my educational Trek. I didn't know when/why I would use the transparent feature and in experimenting with it, I made this.
This one was fun to behold once done. It's an animated flying gif and you can move it around the screen and press keys to alter its speed or add effects to the image itself.
im... |
I implemented most of the suggestions from Version 1. Thanks to all who took time to review and offer really good comments.
namespace NotSystemAndOthersThingsThatIHaveNoPracticalUseFor
{
// This is Version 2.
public struct Rational : IComparable, IComparable<Rational>, IEquatable<Rational>
{
// Ret... |
I am trying to generate a simple map like this. Everything works as I want, but I am new to programing. Is it a good way to do something like this? And if not, could someone explain to me where and why it is bad to do something like this? And how bad is it on performance?
public GameObject cube;
public GameObject cube1... |
Project Euler 12 - Highly divisible triangular number
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be \$1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\$. The first ten terms would be: \$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...\$
(...) 28 is the first triangle number to ... |
After an interview didn't go smoothly, I decided to write my own library so that I would be better prepared if I'm ever asked about matrix multiplication again.
I know that doing it in Java is going to sacrifice some performance (at least I think I do). Also, I know that there are libraries already made for this purpos... |
At a JavaScript test for a job, I was asked the question below. I believe there has to be a better way to accomplish the same result, but I couldn't find any. If some JavaScript geek would take a look and suggest a better approach I would really appreciate it:
Given a positive integer greater or equal to 1, write a fu... |
This code is working fine for me, but I want to simplify it.
Function parents is defining parents of the tree and children function is for representing children. DisplayGraph() function shows the tree in an HTML element.
window.onload = function() {
arr();
parents();
};
var array =... |
After getting the requested controller from the URI request, it checks whether this exists and whether the requested method (default index) exists within that controller, then calls them.
My intention is to have everything running object oriented so I'm trying to remove any procedural/unattached variables that may appe... |
I am using the following code in order to retrieve the index for an object stored in a JavaScript array.
Scripts works fine, but I would like your opinion regarding performance.
Also would like to know also if using [].map() could be more appropriate of [].some().
http://jsbin.com/nasiyiyavi/1/
var data = [{ id: 3 }, ... |
I've implemented generic insertAt function which inserts element into both indexed and ordinary lists. Here are some examples:
-- ordinary list
insertAt 1 5 [1, 2] == [1, 5, 2]
-- indexed list
insertAt 1 5 [(0,1), (1,2)] == [(0,1), (1, 5), (2, 2)]
Here is the code:
{-# LANGUAGE TypeFamilies, FlexibleInstances ... |
We have just started up a new app and we are using React with the Flux architecture. We have done our best to piece together what we think is the best structure for the app and would appreciate any feedback, suggestions etc. The component is essentially a settings page in a much larger system, it basically gets and upd... |
I made this script so that I can scale objects for 3D printing from Maya.
I had fun making it and I'm sure it could be cleaned up or improved. If it can be cleaned up please let me know.
## ((Ax - Bx)**2 + (Ay - By)**2 + (Az - Bz)**2)**0.5
import maya.cmds as mc
def defineParameters():
selPoints = mc.ls(sl = Tru... |
I am burdened with the requirement of interacting with a C based library, which has a bunch of constant sized arrays (e.g. char[17]).
When trying to assign or read those properties from swift, they are represented as a Tuple type of that size..
As far as I know, you can't access tuples with subscripts, and it is not t... |
I have created a custom scatterplot in Qt and am wondering if there is a more efficient way to do it. Here is a sketch of the problem:
The layout of the plotting area consists of a rectangular structure starting at [0,0] in the top left corner and expands by 250 pixels to the bottom right corner [250,250]. So the y-c... |
I put together a function to sort out values that I am getting from a curl request for different 'devices', it works as is, I am only wondering if there is an easier way to to this.
function convert($deviceName, $namesArray, $devicesArray) {
$result = array();
foreach ($devicesArray as $d) {
$result [... |
Introduction:
For a project I'm working on I used a BackGroundWorker to lift some heavy tasks away from the UI thread and report progress. For this I created some sort of modal dialog with a label and progress bar which were updated from the ProgressChanged method of the backgroundworker.
I read a very interesting arti... |
I have written a jquery code, which fixes a navbar header on top of page when a user scrolls down to a certain pixels. But I am not sure whether is this the correct way to do this.
Because this is going to be a majorly used function by all users, it would be better if I can improve it in terms of optimizations and spee... |
I've got a use case for namedtuple that requires some of the fields to be floats. I could require the code that's constructing the namedtuple to supply floats, but I'd like for the namedtuple class to be smart enough to convert strings it gets into floats for me (but only for a specified subset of fields). I have code ... |
The normal boostrap affix doesn't take the items natural offset top position into account, you have to manually pass it in as an attribute. This takes care of that, and accounts for the offset top changing on window resize.
var $attribute = $('[data-smart-affix]');
$attribute.each(function(){
$(this).affix({
offs... |
def user_not_authorized(exception)
message = t('flash.access_denied')
if exception.policy.class.to_s.underscore == 'group_policy' && current_user.students.size != 0
current_user.students.each do |student|
student.memberships.each do |membership|
if membership.group_id == exceptio... |
Here is the function which does exactly what is specified by its name:
sub runCmd_getStdoutStderrAndExitCode(@)
{
my @cmd = @_;
# fork a child
my ($child_pid, $child_stdout, $child_stderr);
eval
{
$child_pid = open3(\*STDIN, # is /dev/null when collectl is a daemon, UPDATE: can pass 'undef' here
... |
I am new to android developement.
Created calculator application.
Want to improve my code quality.
Will be helpfull for any advice to make the code better and more professional
(overall structure, splitting onto logical units, accordance to code conventions, methods and variables names, comments etc).
Here is my code:
... |
I wrote a logging class for several of my applications, but I have noticed that it is fairly in-efficient. Can anyone suggest improvements?
What I am looking for:
Pointers on improving efficiency
Tips for lowering the code-footprint
Suggested functional improvements
Please be as nit-picky as possible, I'd like to mak... |
Just a fun batch file I have made. I wanted an easy way to loop any arbitrary command several times: loopme.bat
@echo off
SETLOCAL
echo LoopMe v1.0
IF "%~1"=="/?" (GOTO HELP)
IF "%~1"=="" (GOTO HELP)
IF "%2"=="" (SET TIMEOUT=1) ELSE (SET TIMEOUT=%2)
SET COMMAND=%~1
SET COUNTER=0
:RUN
SET /A COUNTER=%COUNTER% + 1
CMD ... |
I wrote the below function for doing a variation of bisection search that I came up with. This can be useful when the higher bound is not known. It assumes that as number increases the result of the condition is also increasing.
For example - find the largest classroom size where the probability of two students sharing... |
I am stuck on a piece of code that I have written that uses dcm4che. I have made a whole heap of nested ifs and I want to find a way to convert to a switch-case (problem being I have no way of declaring an int that can distinguish between cases). Is there an alternative to making this code snippet appear less ugly?
imp... |
Given a list of strings, my task is to find the common prefix.
Sample input: ["madam", "mad", "mast"]
Sample output: "ma"
Sample input: ["question", "method"]
Sample output: ""
Below is my solution, I'd be happy for help improving the algorithm (I'm open to totally different approaches) or general code improvement tips... |
I would like to present for review my (much) revised batch templating utility which had it's humble beginnings here in a previous post. As I mentioned there, this program is my entry into python programming. I am trying to grow the simple script from my previous post into a more robust utility.
Questions I am hoping... |
I've written a simple binary heap in C# and I want to know if it has any problems or if I can make it better.
public enum HeapType
{
MinHeap,
MaxHeap
}
public class Heap<T> where T : IComparable<T>
{
List<T> items;
public HeapType MinOrMax { get; private set; }
public T Root
{
get { r... |
I put together a Haskell function for Knuth's word wrap algorithm. A simplified version of the algorithm is described here.
I've already been told that there are certain aspects of my style that are not very agreeable (e.g. lack of comments and type declarations). However, I'd like to get some opinions on where I migh... |
Spent some time implementing a graph as an adjacency list. Looking for suggestions on how to improve this implementation.
#include<vector>
#include<iostream>
class Graph{
public:
//n is the number of vertices in graph
Graph(int n)
{
N=n;
E=0;
//for(int i=0;i < n; ++i)
... |
As an ongoing little side project of mine, I've been working on recording audio in c. You can the code's progression by looking at past versions (V1.0, V2.0).
I've found that my past versions were too limited. They required a certain time frame for which they would record, and then stop. This isn't very practical fo... |
This is my solution for exercise 1-19 of K&R:
Write a function reverse(s) that reverses the character string s. Use it to write a program that reverses its input a line at a time.1
It works, but I'm trying to write good programs. I think the fact that I can't use the length of the vector when already got the line in ... |
I am looking for suggestions on how to improve my mergesort. My teacher explained the recursive mergesort and left the bottomUp one as an assignment. I have implemented it but find it too messy. I thought the implementation would be more simple.
How can I make it simpler and quicker?
MergeSort
void mergeSortBottomUp(in... |
I'm very new to Go (this is my first real program), and I was hoping to see if there was anything I was missing about the language or any ways to make it more idiomatic.
calculator.go
package calculator
import (
"../stack"
"unicode"
"strconv"
)
func Calculate(input string) int {
stack := new(stack.Sta... |
My code is complete. It runs properly and produces the correct output. I did calculations by hand to check and then ran the program and it gives me the same result. I just want a second opinion. Are there ways for my code to be more efficient? Are there small details that I need to change? My professor marked me off fo... |
Is the following MS VS solution structure and classes OK w.r.t. easy unit tests with dependency injection? Would your unit tests look similar?
If you call the calculations below over a WPF module, would you skip a test over the WPF since complicated, or would you still conisder testing it over the WPF module ?
Solutio... |
CodeChef - QPOINT
Given a 2D vertex of multiple countries, find which country contains a certain point.
Input format:
"Number of countries"
"Number of vertex" "x1" "y1" "x2" "y2" ...
"Number of vertex" "x1" "y1" "x2" "y2" ...
...
"Number of query"
"x1" "y1"
"x2" "y2"
...
Please give me any advise on code style or de... |
I coded this algorithm in order to have a generic backtracking algorithm. I expect the user to pass a POD for ELEMENT, hopefully as small as possible. Any idea how I could improve this?
#ifndef BACKTRACK_H
#define BACKTRACK_H
#include <array>
#include <vector>
#include <assert.h>
template< class ELEMENT, unsigned MAX... |
I have a set of Excel data which I read and assign to corresponding columns of an Excel table. In our Excel we have provided the user the option to rearrange the Excel column fields at runtime.
int rowIndex =int.Parse(ExcelSettingManager.ItemLine);
int lastItem = numberOfFilledRows();
numberOfFilledRows();
int maxI... |
I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on improving the efficiency of my code or another more efficient way to handle query results other than parsing PDOs?
This will r... |
I wrote a sample app based on the ReactJS tutorial, and I would like some thoughts on how idiomatic this code is. Unfortunately there's no ReactJS integration with Stackoverflow snippets, but I do have a working JSFiddle.
You have a phases box, and inside it we have a list of phases, and a new phase form to add a phase... |
Summary
VB6 doesn't have a great selection of data structures to work with, so again I find myself creating my own. I have a need to dynamically generate a directory structure on the file system. The natural way to represent this is with a Tree, so I created my own.
There are three classes involved here:
TreeNode - Th... |
I wrote a JavaFX program that contains a list of notes, each having a title and a content.
This is the controller code:
public class MainPresenter implements Initializable
{
@FXML
private ListView<Note> listView;
@FXML
private TextField titleField;
@FXML
public TextArea contentField;
@FXML
... |
I have this code that reads in a "scrambles" and a "words" file. It compares both files using their canonical form and prints out the words from the "words" file that match a particular scrambled word. I'm looking for ways to make this quicker.
public class scramble
{
public static void main(String[] args) throws ... |
This is a very simple class to handle files.
It allows to access, create and modify files in the system or 2 fake files (one in memory and other similar to /dev/null or nul).
Windows has a 'feature' that automatically converts all the line endings to the correct one. That is one of the features included.
The fake /dev/... |
The destruction of the objects are handled by the garbage-collector metamethod.
(Does this make sense? This means that an out-of-scope object will stay visible in game until garbage collection.)
The components of the Entity Component System are not pure-data members,
but instead derived classes of a specific base class... |
The code below shows the pattern I use to manage properties in my classes when I have the following requirements:
Some properties are slow to calculate and are rarely used, so I want them to be lazy
Some methods change the value of a property
The properties are defined the first time they are requested and are delete... |
A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash.
#include <unordered_map>
#include <glm/glm.hpp>
#include "gl_func.h"
#include "gl_buffer.h"
#include "shader.h"
#include "log.h"
class Renderer
{
private:
typedef void (*RenderFunctionPointer)()... |
I come from MySQL type of mind frame but have worked with MongoDB and ElasticSearch type of NoSQL.
I'm using a small use case of Cassandra to able to scale a playlist format for users.
In C* Summit 2013 by Axel Liljencrantz, he states how deletions are messy - and that deletion in Cassandra are actually tombstones (hen... |
I have a UITableview with custom cells, every cell has a button called cellButton. When the user taps the button I present an action sheet which has two buttons, buttonOne and buttonTwo. When buttonOne has been tapped I call a method with some values from the actual cell, when buttonTwo I perform a segue and prepareFor... |
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *reverseBetween(ListNode *head, int m, int n)
{
ListNode *pre=NULL, *cur=head, *front=NULL, *rear=NULL,*follo... |
I have been making a jQuery morphing button type thing.
jsFiddle
$(document).ready(function() {
var morphObject = {
button: $('button.morphButton'),
container: $('div.morphContainer'),
overlay: $('div.overlay'),
content: $('h1, p'),
init: function() {
this.butt... |
I have a short bash script that processes gigs and gigs of data. I am looking for any improvements to make it faster. This is my very first bash script so please be gentle. I am really only concerned about the while loop. The rest of it is fine I think. It's the while loop where the real work is done and could use th... |
I have a code that I'm fairly certain does what I want. Bear with me as I explain what I'm doing:
Imagine that there is 10 houses, where there can be one to an infinite number of persons. Each of those persons sends a number of messages, containing their userid and the house number. This can be from 1 to infinite numbe... |
I was getting sicker and sicker of using an ordinary collection to do a tree's work, so I built a tree. A requirement of the tree are that it needs to contain a key to sort the tree by, so I used a Dictionary<int, T> to store the items. Here is the Tree<T>:
public class Tree<T>
{
public Tree<T> AddItem(int key, T... |
I worked on an exercise from codewars, which is a variation of the popular fizzbuzz game. (If the link doesn't work, you may need to reload the page.)
In this variation, I'm supposed to find the sum of all the multiples of 3 and 5 that are less than the passed in number.
My code works, but it's horribly inefficient. I... |
I have a situation where I'm stitching three different unions into a triplet tuple for building a map/dictionary of strongly typed values keyed on a string.
One of the union cases is very large, the second has three options, and the third has only two. Right now I loop through the large with reflection, and have six y... |
I'm looking for feedback on my atoi implementation here in C. Any feedback would great. I made my own atoi for fun and to learn about it.
I'm not trying to replace the standard library version. Reinventing the wheel is fun to me.
#include <limits.h> /* for LONG_MAX, INT_MAX */
#include <stdbool.h>
#include <stdio.h>
#... |
Are there more optimization possible in this code to achieve better performance and minimal memory usage?
#include<stdio.h>
char * strrev(char* str)
{
int length=0;
char* str1=str;
while(*str++)
++length;
str=str1;
char temp;
for ( int i=0; i< length/2; ++i)
{
t... |
A univariate polynomial is a polynomial over a single variable, and in
the following discussion when we say polynomial, we mean a polynomial
in a single variable. You are given two polynomials – the first one,
M1(x), is called the multiplicand, and the second one, M2(x), is
called the multiplier. Your progr... |
First off, I want mention that this code works well. This is more of a request for suggestions...
We're attempting to program a one-page, recursive, token-based admin shell that is safe from intrusion, and replicable for several DB backend manipulation pages via tokening. We wanted to protect it from SQL injection (thu... |
I have a NumPy matrix C and want create a copy of it cPrime, which has some operation of the original matrix to all non-zero values of it. In the code below, for each non-zero element of C, I multiply by 30 and then add 1:
import numpy as np
size = 6
C = np.zeros((size,size), dtype=int)
C[4][0] = 2
C[4][1] = 5
C[4][2... |
mappingService below is actually just Automapper. I have a wrapper around it so that I can inject it.
I want to refactor the following code to be cleaner:
public class DropDownListService : IDropDownListService
{
private readonly IMappingService _mappingService;
private readonly ICompanyRepository _companyRepo... |
Essentially the Collatz Conjecture.
Challenge requirements are here.
And here is my implementation in Java:
/* User: koray@tugay.biz Date: 21/03/15 Time: 19:40 */
public class ThreeNOneForRangeSolver {
public int solveFor(int inputOne, int inputTwo) {
int maximumCycleLength = 0;
do {
... |
First revision: Minimal webserver in C++
Here's my test question for C++ programmer job:
Servers only static content, no cgi
Single process, multithreaded
1000 concurrent request at least
Valid http status codes and headers
No external libraries, just STL, POSIX and glibc
Here's my code:
#include <cstdio>
#include <c... |
This is a "pain", but I wonder if I can get any real speedup with the follow Python script - it is taking well over 10 minutes to calculate the way it is written now. (And that's only when feeding around 1-2 promille of the data).
I have an with shape (roughly): [260, 300, 300]
Now I am doing a cougar=feldermann analy... |
Challenge
The recent question The 3n + 1 algorithm for a range inspired me to investigate a Java-8 dependent streaming mechanism for solving the programming challenge:
For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j (inclusive).
The cycle length of a number i... |
This is my first program that uses more than just boring ol' if/else statements - I made a whole 246 line game that's still a work in progress simply using if/else - and I'm going to email this to my teacher later tonight.
Please suggest more things I can add and report any bugs (although I've found none so far).
# Sta... |
I am starting to experience frame rate issues in my game and I've tracked it down to my updateMobs function. I would like tips and code examples from you guys to improve the given code below, to make it more efficient FPS-wise. Can you also tell me why this speeds up my code and by how much, if possible?
var updateMobs... |
I am new in R and I have to implement simulated annealing for schaffer function and I did it. However I am not sure about the correctness of the code.
simulated_annealing <- function(schaffer, step, s0, niter) {
s_n <- s0
iter_count <- 0
for (k in 1:niter) {
T <- (1 - step)^k
s_new <- rnorm(2, s_n, 1)
... |
I recently started to do some of the exercises in CodeChef and I did the TurboSort challenge here is it's description. It works fine with smaller arrays but can't pass some of the tests due to the fact it's \$O(n^2)\$, so I need a faster way to sort them.
import java.util.Scanner;
public class TurboSort {
public... |
I have some concerns, like the updateValue function. I was trying to follow the functional paradigm, but I wonder if I could use another approach or something.
My parsing function seems overly complicated, particularly the '[' case seems complicated. Any other comments are appreciated too!
namespace Brainfuck
module I... |
I'm trying to design the classes for the Wheel of Fortune game in Java. The below diagram represents the classes and the interaction between them.
.
Below is the partial implementation of it. I appreciate some feedback on my design and approach. I'm mainly interested in classes and their dependencies. In code I refer... |
The simple but generic timeout class to be used watching for network connections, user input, filesystem events, and is intended to have a very simple interface specific to only our use cases (i.e. no satisfy-all attitude).
Intended steps to use:
Construct
Activate
Potentially react to a timeout, deactivates itself
Re... |
I have a list of Options. From that list:
First I want to get only Drink (the where clause).
Then I want to group them by their SortOrder (range of 100).
I can stop there and loop through the items and create checkboxes for each items. But I got a requirement that if the OptionGroupName=Alcohol then I need to create r... |
I have written this Java snippet to generate all permutations of a given array of integers. Can somebody review it and give some pointers as to how to make it more generic? I.e. instead of dealing with only ints, it should be able to handle a collection of any data type.
import java.util.Arrays;
public class PrintPermu... |
I have an application that provides the user the ability to backup the local SQLite database to another location. I then provide the ability to restore the backup database and overwrite the current database with the backup copy. In my restore command, I make a backup of the database file, which seems redundant. I fe... |
I'm preparing for an interview. I tried implementing binary search tree in C++. I used array but it seems to be complicated to restructure the array while deleting nodes. Is linked list a better data structure to implement BST? Also please let me know if the code has bad coding practice like memory leak, bad data struc... |
I'm currently doing an algorithms course and implemented this version of the quicksort algorithm. I would like to know if it is an efficient implementation. I've seen a couple others where there is a partition function that partitions the list is that a superior method to what I did?
def quickSort(aList):
first = [... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.