-1
votes
0answers
5 views
Swap two nodes in a doubly linked list
I am learning Doubly link list. I am trying to swap two nodes (not adjacent) of the list. Tried many times but still cant do it. can anyone help me with the code please?
2
votes
0answers
4 views
finding closest points without duplicates and given distance threshold
Given a bunch of latitudes and longitudes stored as Points, I would like to determine the points that are closest to each point given some maximum threshold in meters. This is my first stab at this:
...
2
votes
0answers
9 views
Storing user settings using LINQ to XML
I want to store some user settings into a file, so that the users get the same experience on all machines they're working on.
The built-in user.config turned out to ...
1
vote
1answer
8 views
1
vote
1answer
12 views
Synchronizing scrollbars, scrollTop and scroll event loops
(This comes from Stack Overflow, where I was sent here)
I've been playing around synchronizing two scrollbars on a web application using JavaScript and jQuery (1.11.3). So far what I've been doing is ...
3
votes
1answer
9 views
Weighted choices
Is there a more efficient way to do the below without two for loops in actionscript 3? In java there is NavigableMap or something like that where dont need to loop.
...
8
votes
1answer
337 views
Simple RPG skeleton - Part 1
I've been on a quest to learn C++, and to learn, I've started building a small RPG skeleton to help myself learn the language. I've tried to make sure that I've followed C++ styles/standards ...
1
vote
1answer
23 views
ArrayBlockingQueue - blocking drainTo() method
This is a follow-up question to this question.
Is this a reasonable implementation for a blocking version of method ArrayBlockingQueue.drainTo(Collection)?
...
2
votes
1answer
13 views
Menu driven program to represent polynomials as a data structure using arrays
Write a menu-driven program to represent Polynomials as a data
structure using arrays and write functions to add, subtract and
multiply two polynomials; multiply a polynomial with a constant, ...
-1
votes
0answers
15 views
PDO object directly in while-loop instead of from a variable [on hold]
I thought this should work:
...
1
vote
0answers
15 views
SQL Query Count Records and Pull Distinct
So I need a little help. It is currently working but I might have over complicated it. So maybe someone has a better idea. Now let me try and explain it.
I am trying this query, and it currently ...
0
votes
1answer
15 views
Indexing columns to make a MYSQL query faster
I have this query here that I am trying to make more efficient as it is taking an extremely long amount of time, about 40s on 3 million records.
The query basically takes X amount of rows per company ...
6
votes
1answer
15 views
Implementing a van Emde Boas tree in Rust
I wanted to implement a van Emde Boas Tree in Rust, to start learning the language. Much of my implementation is derived from the pseudo-code on wikipedia, with the exception that empty subtrees are ...
4
votes
1answer
29 views
Sprite cache and Directory reader
I have been fiddling around with creating my own Sprite Cache.
Currently, I am using the C header file, dirent.h, to open up a directory and load all .bmp files. I ...
2
votes
2answers
59 views
Number to Word Application in C#
I've created a Windows Form Number to Word converter application in C# which converts any number from 0 to 1 million. I would love a review based on efficiency and best practices.
MainInterface.cs
...
-4
votes
1answer
31 views
Converting from one collection to another [on hold]
Is this a good practice in Java 8? Do we have better way of doing this?
...
3
votes
1answer
23 views
Limiting the number of text fields created
I need to make sure that the max of text fields created is limited to 10 at most.
It's a script that I've ripped off elsewhere, and have modified it via help from StackOverflow on a couple of other ...
2
votes
2answers
48 views
Hangman game school project
This is a school project and took me a while to write the code. Any help to improve my code is welcome!
...
3
votes
2answers
37 views
JavaScript solution for diagonal difference
hackerrank.com - diagonal difference:
Problem Statement
You are given a square matrix of size N×N. Calculate the absolute
difference of the sums across the two main diagonals.
Input ...
0
votes
0answers
19 views
C++ Multithreaded Ip Range Port Scanner [on hold]
Been working on creating a multi-threaded port scanner that can scan an IP range. However my results are being skewed. I feel as if I have a race condition in my code but I cant seem to find it.
All ...
4
votes
1answer
53 views
Rock, Paper, Scissors, Lizard and Spock - Improving my answer
Today I saw an extremelly interesting question on the Rock, Paper, Scissors, Lizard and Spock game.
And I've decided to take my swing at it. And I've written the following OOP implementation:
...
1
vote
1answer
61 views
Function to rebalance portfolio
I wrote a small code in Python to conduct a backtest. My 'rebalance' function is very slow and I would like to improve it. I need to profile it but I would welcome any opinion on how to refactor my ...
7
votes
1answer
86 views
Count number of isosceles triangles in a set of points
Given a set of points, what is the number of isosceles triangles that can be formed with the combinations of all points in the set?
It is certain that 3 collinear points never exists in the set.
...
3
votes
1answer
15 views
Updating an inventory with R using apply functions
I have created an inventory that works via QR codes. Briefly: the QR code codes for an email with the book/student checking it out. The email is downloaded into R using the gmailR package (code not ...
14
votes
4answers
197 views
Numbers, pairs, and a difference
Problem statement:
Write a function which returns the total number of combinations whose difference is k.
For example, ...
4
votes
2answers
37 views
InfixDictionary: Data structure for Infix string lookup
I needed a data structure to quickly find all previously inserted values, that have the given string as key or substring (full text search).
At first, I tried out some tree structures (infix ...
1
vote
3answers
50 views
Showing the path of a projectile
I'm trying to dive deeper into C#, and so I've been experimenting with some code. I'm creating a console application that shows the path of a projectile depending on the angle, and it works great! You ...
10
votes
1answer
55 views
Racetrack plotter
My Racetrack is just that. A Racetrack. You can't race it (yet) because I had trouble with collision detection, but I wanted to share it anyway.
It creates a base polygon by using ...
2
votes
0answers
47 views
Tic Tac Toe algorithm
I made a Tic Tac Toe game, but I think there's a lot of hard-coding and useless variables. Can you check it out and tell me what I can improve on? It works, but it has a couple of bugs.
...
5
votes
2answers
29 views
Join strings with different delimiters and some possibly empty strings
I want to construct a string from several substrings, each one of those with a different delimiter. If the string is present, the delimiter and the string should be added, if not, none of them should ...
-3
votes
0answers
31 views
-4
votes
0answers
14 views
Code for Accessing a function from Unmanaged dll [on hold]
The following code accesses a function from an unmanaged dll.
...
1
vote
1answer
24 views
Retrieving creation date from Parse.com data
I got to show the createdAt date in a message timeline, I tried to make a separate array only for dates, but don't know if it is the right path to follow. It seems ...
4
votes
1answer
61 views
Curry function with function constructor
Shall I make a curry function this way, or is it best to avoid Function constructor in all means? What I want to know is if this is "bad practice" and how else currying can be done. For instance, one ...
4
votes
1answer
44 views
Unit Testing and good use of matchers
I been having discussion with colleagues recently about good use of matchers. Consider the following sample:
...
5
votes
1answer
27 views
Basic Java Swing Calculator
I am new to Java Swing and have decided to create a calculator to learn some of the basic. I would like someone to look over my code to see if they can give me any improvements.
I have 6 classes and ...
15
votes
6answers
2k views
Rock, Paper, Scissors, Lizard and Spock
I am currently done with this little Rock, Paper, Scissors, Lizard, Spock game in JavaScript. The game is working fine, but I am not pleased with the code. Is there a way to refactor these ...
6
votes
1answer
47 views
Cleaning up HTML created by users
I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of HTML. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I ...
9
votes
5answers
892 views
5
votes
2answers
56 views
Project Euler #10 - sum of primes below two million
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
...
5
votes
1answer
28 views
Hiding and Expanding Menus
I've created code for a menu system that can show / hide menus and submenus. Now I wonder if the structure of the code is good enough or if you find something that can be done better?
...
3
votes
1answer
22 views
Calling functions with different variable types
I need to call the function that will get the value of a datatable cell with the ColIndex, either a text (column name) or an integer (...
4
votes
0answers
19 views
Perl pie alternative
Running on Cygwin, I cannot easily use perl -pi -e because it will always produce .bak files even though I don't want them. I ...
5
votes
2answers
270 views
2
votes
3answers
90 views
Checkout (page) backend
I am developing an e-commerce site and am confused about this.
Customers come on the site and add some products to the cart.
Customers click on the checkout link if already logged in, then will go ...
0
votes
1answer
33 views
Calculation of image offsets for performing cropping
I am using the java.awt.Rectangle class to construct subsets of a GEOTIFF file. In order to do this I would need to specify the x,y offsets, height and width of ...
3
votes
2answers
47 views
Encode a string using Caesar's Cipher
My program is complete and running, but I would like second opinions on how I can make it more efficient. The program prompts the user for the message and the amount s/he would like to shift the ...
2
votes
1answer
22 views
Create an array of categories from comma-seperated text input
This code works just fine, but could obviously be more elegantly written.
The basic idea is to create an array of categories from a text input. The code splits up the text input by commas to create ...
3
votes
2answers
39 views
Calculate pairs in a Set (“Sherlock and Pairs” HackerRank challenge)
Here is my second attempt at writing clean code for "Sherlock and Pairs" challenge. For my previous thread please look here: Calculate pairs in a Set ("Sherlock and Pairs" HackerRank ...
4
votes
4answers
518 views
DuplicateDictionary - A dictionary-like class which allows duplicates
Since I couldn't find any good answers I made my own class called DuplicateDictionary for personal usage. I would like some tips to improve it.
...