All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
2k views

Circular Queue using Linked List

I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code. This is what I came up with: ...
Mike's user avatar
  • 33
7 votes
4 answers
636 views

Classify values depending on predicates

I've to do a generic method Classify<T> that, given a sequence of elements of type T and an arbitrary number of predicates,...
Sanci's user avatar
  • 113
2 votes
1 answer
64 views

Returning the next node

What is considered to be a good programming practice for returning value from the function? For example, if we have a function in C named ...
OldSchool's user avatar
  • 153
4 votes
1 answer
147 views

Strategy to reduce duplicate code in many similar modules

The Situation I have created some code in the form of modules that each represent a medical questionnaire (I'm calling them Catalogs). Each different questionnaire ...
The Worker Ant's user avatar
8 votes
5 answers
1k views

Assembling a user agent descriptor, implemented using StringBuilder vs String

I think performance won't be a big issue here as the concatenation only happens once (2-3 at worse because of multiple threads). Out of the two methods, which one would you prefer, in terms of ...
Neeraj Gupta's user avatar
2 votes
2 answers
5k views

Find Missing Numbers in an int list

I have an alternative algorithm to the same problem as Finding missing items in an int list. My implementation includes optional min and max bounds to selectively fill in the list. The linked ...
kmr159's user avatar
  • 31
6 votes
2 answers
895 views

Text-based Snake game on Window

How can I improve this game? ...
MORTAL's user avatar
  • 3,278
1 vote
2 answers
7k views

Replace CASE WHEN statement with something more sensible

While checking my SPs today I found that I have, ...
Imran Qadir Baksh - Baloch's user avatar
7 votes
1 answer
607 views

Making prime (sieve) code faster and able to run on big numbers

For an input triple (a, b, c), the task is to count the number of integers in the inclusive range [a, b] which have c distinct prime factors. This entails factoring each of the numbers in the range [a,...
CPlusProgrammer's user avatar
3 votes
2 answers
212 views

Simple self-made encrypter

The following code: ...
riyoken's user avatar
  • 165
3 votes
2 answers
405 views

Communicating messages to objects

In my MUD game engine, I built a messaging api that allows objects to subscribe to concrete implementations of an IMessage interface. Is there anything glaringly ...
Johnathon Sullinger's user avatar
5 votes
1 answer
259 views

Handle Settings in Windows App

So, I fixed my problem with a public ViewModel for my MainPage like this: MainPage.xaml.cs: ...
user avatar
19 votes
1 answer
445 views

Order a delicious pie here

For a quick summary: I've created this internal web application, and I've hit a point where I can really see the mess I've made. I need some help separating the logic, the view, and the data. More ...
Alex L's user avatar
  • 5,737
6 votes
1 answer
2k views

C++11 lock free collection similar to std::forward_list - follow-up

This question has been superseded by C++11 lock free collection similar to std::forward_list - follow-up 2 Thread safe and lock free collections are very hard to write, so I'd appreciate any feedback,...
Brent's user avatar
  • 451
3 votes
1 answer
299 views

Generic publisher class

The code below is a publisher base class. I've never really liked the way I implemented this class. Are there any improvements/simplifications I can make to it? Background: The execute(...) method is ...
munyengm's user avatar
  • 133
5 votes
2 answers
3k views

Snake game for C++

This is my first game that I made. How could this be improved? ...
Marko's user avatar
  • 93
3 votes
2 answers
419 views

Project Euler #14 solution takes quite a long time

Can anybody give me suggestions for making it faster? (Project Euler #14) ...
sid-maddy's user avatar
3 votes
3 answers
10k views

Inserting persons in file into SQLite

I've just started working with SQLite in C# to test various features of an application. In building my first SQLite example I wanted to insert a large .csv into a table (Person) with two columns, A ...
JAS's user avatar
  • 213
1 vote
1 answer
2k views

Prompting the user for employment information

I have created a simple program in which the user is prompted for various details about their employment. In my Employee.java file, I have all the methods. Employee.java: ...
Mr Chasi's user avatar
  • 111
3 votes
1 answer
74 views

Parse data into three logs

In the bit of code below: How can I make add_day, add_ week and add_month work as a single ...
f.rodrigues's user avatar
6 votes
1 answer
7k views

Class for easier to read IProgress<Class> handling

The recommended way to report something as "progress" back from a async function is to use IProgress<Type> or ...
Tex Hex's user avatar
  • 185
3 votes
1 answer
170 views

Execute startup method asynchronously

The goal is to call startManager on application start so that the manager is initialized in background without blocking application main thread. Is it a safe ...
Michele Mariotti's user avatar
3 votes
5 answers
386 views

Function "between" for "Everything in One Line" library

This is a function to determine if a number is between x and y. It is part of a library of mine called EOL or "Everything in One ...
Edenia's user avatar
  • 1,568
4 votes
2 answers
8k views

Query results with many to many and some parameters using Entity Framework in a more efficiënt way

I've created a working query in Entity Framework and I'm curious if there's a better way to do this. Since there's a lot of field on my models, I will only publish the relevant ones here. My Models ...
annemartijn's user avatar
1 vote
1 answer
70 views

Memory searcher function test

This is part of the project I started just now. It is a function that returns the offset address of a first occurrence of a string match into a given range of memory blocks. ...
Edenia's user avatar
  • 1,568
3 votes
1 answer
1k views

"Sharing CANDY" on SPOJ

How can I improve it and its running time efficiency? Problem (SPOJ/CANDY) Jennifer is a teacher in the first year of a primary school. She has gone for a trip with her class today. She has ...
Himagra Chawla's user avatar
2 votes
1 answer
87 views

Recursive material name printing logic

I have a function which goes through every name in an object. This object has an array parameter materials which holds other objects. Those objects have the same ...
WillacyMe's user avatar
  • 129
3 votes
0 answers
185 views

Graphical editor with geometric intersection

If it is possible I would like some comments on the overall style of the program. It feels like I am writing the whole program as one big script and I'm not sure how to break it down into several ...
KRC's user avatar
  • 143
-1 votes
1 answer
2k views

Merge sort optimization and improvement

How to optimize this merge sort code to make it run faster? And how to call merge_sort function without user input by declaring necessary array in the code? ...
Marci's user avatar
  • 89
8 votes
4 answers
142k views

Quick Sort - implementation

Can anything be improved in this code? ...
Software Engineer's user avatar
3 votes
3 answers
131 views

Returns the year for each month by period - nested case statements

...
notaceo's user avatar
  • 227
6 votes
1 answer
179 views

Classes to manage perks to be added and removed

I am looking for code correctness and design usage as I think I might be over doing it in the class department. There are two things I'm mostly concerned with. The possible redundancy of classes ...
steve's user avatar
  • 169
3 votes
2 answers
2k views

Simple DRY Rails - check if a model belongs to a user

I can clearly see I'm repeating myself, but I don't know how to refractor this without making it really ugly. What I have: ...
Jeff's user avatar
  • 459
12 votes
2 answers
3k views

Basic duel fight with OOP

How would you improve on this? It's been fairly long since I last did something slightly more extensive in C++, so I'm looking for ways to be more compatible with modern C++ ways, and this style of ...
Juha Untinen's user avatar
10 votes
3 answers
4k views

Brute force MD5 password checker

I'm trying to create a C# brute force MD5 password checker. If I run it with "test1" without MD5, it completes in 15 seconds. I would like to make it faster, but I'm a c# beginner, and don't know how ...
n32303's user avatar
  • 293
8 votes
1 answer
71 views

Managing initialization for a vector abstract data type in C

As an assignment, I was to create an \$n\$-dimensional vector type for \$n \le 20\$. This vector only has to support addition and scalar multiplication. I tried to write good code, with proper memory ...
amon's user avatar
  • 12.5k
2 votes
2 answers
45 views

Product matcher refactoring regarding scopes and arrays

I know I have seen this before and I can't remember how to fix it or find where I saw how to fix it: ...
Mike Riley's user avatar
1 vote
3 answers
490 views

Converting text to colored pixels and back again

Any suggestions for improvement or critiques are welcome! ...
sdin3dspace's user avatar
5 votes
3 answers
11k views

Vertical Histogram

I've been been working on a vertical histogram that prints an asterisk in place of a number in a certain range (say 1-10... and so on). My code is working as required. Is there a better, simpler or ...
kfcobrien's user avatar
  • 289
2 votes
1 answer
140 views

Rewriting linked list function without a NULL variable

This is how my LinkedList class looks like in PHP. I am trying to figure out if I can rewrite my reverse_list_recursively() ...
CodeCrack's user avatar
  • 297
5 votes
3 answers
8k views

Powershell script to create folders on remote servers

This is pretty much the first Powershell script I've ever done and I am here looking for a quick review of it. Is there something I could have done better? Is the format okay? I don't know much about ...
user3029809's user avatar
4 votes
3 answers
88 views

Displaying sorted results of a web crawl

The issue I have with this class is that most of the methods are almost the same. I would like for this code to be more pythonic. Note: I plan on replacing all the ...
Ricky Wilson's user avatar
  • 1,695
6 votes
2 answers
1k views

Palindromes without character

You are given a string of lowercase letters. Your task is to figure out the index of the character whose removal will result in a palindrome. There will always be a valid solution. Here is my quick ...
user2405469's user avatar
4 votes
1 answer
153 views

How should I name a function which shows or hides an element?

I have a function to display or hide some elements. What I want to do is to manage the display of those elements regarding a value. How should I replace the term ...
long-lazuli's user avatar
4 votes
1 answer
80 views

Executing a list of tasks from a database

I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly. Currently I have implemented this in the following way: ...
Schoof's user avatar
  • 185
1 vote
2 answers
265 views

Future in f# is this an unavoidable use of a mutable variable?

I have this type: ...
albertjan's user avatar
  • 113
1 vote
1 answer
33 views

The block should return the user's current_active_role

def current_active_role user_roles.each do |r| if r.is_active_role return r end end return nil end The block above returns ...
notaceo's user avatar
  • 227
5 votes
1 answer
2k views

Copy Cell on Worksheet_Change event if some criteria is met

This code is working fine, but it looks awful (yes, I am a rookie on this thing). How can I improve it to look better? ...
user avatar
7 votes
1 answer
411 views

2D Platformer Collision Detection/Resolution

I am working on a 2D tile based platformer and was hoping to get someone to review my collision detection. I've only included the X collision check since the Y is essentially the same. Any suggestions/...
Reyer Swengel's user avatar
-2 votes
1 answer
713 views

Clojure koans 14 - converting a map to a string

The koan is at the end of this snippet. It requires you to write a function to convert a map to a string, and then prepend a full name to it. The following solution works fine. I am just wondering if ...
qed's user avatar
  • 1,419

15 30 50 per page