All Questions

Filter by
Sorted by
Tagged with
75
votes
5answers
7k views

Guessing a number, but comments concerning

I always get marked down for my comments and I just wanted to see if these comments are acceptable or what I should include/where I should include them. ...
51
votes
2answers
58k views

Class for reducing development time

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (...
90
votes
2answers
10k views

FizzBuzz in Brainfuck

Inspired a bit by a previous Brainfuck question and the recent fizzbuzz invasion, I decided to make FizzBuzz in Brainfuck. The code is entirely my own, except for the inclusion of the Printing a ...
44
votes
3answers
11k views

List<T> implementation for VB6/VBA

Recently I decided VB6's Collection wasn't enough for my needs, so I decided to implement something like C#'s List<T>. ...
75
votes
5answers
23k views

SudokuSharp Solver with advanced features

Even though it's the first time I'm writing something this "big", it feels like I know C# quite well (it is very similar to Java after all). It's been nice to learn LINQ also and I am very impressed ...
63
votes
6answers
2k views

infix_iterator code

I've previously posted this on Stack Overflow, and am considering submitting it to Boost for wider distribution, but thought perhaps it would be best to put it up here for peer review first, and see ...
8
votes
1answer
2k views

My first implementation of a linked list in C++

This is my very first implementation of a full-fledged ADT, which could potentially be use-ready. Now, I'm still learning, therefore I would like to ask you what I can do to further improve the ...
23
votes
4answers
7k views

Sieve of Eratosthenes - Python

I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
32
votes
2answers
6k views

Weekend Challenge - Poker Hand Evaluation

Weekend Challenge #2 - Poker Hand Evaluation Very early I decided to support the usage of wild jokers, even though I knew that this was going to lead to trouble more work. I also wanted to support ...
34
votes
4answers
8k views

A lightning-fast StringBuilder

In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To ...
50
votes
3answers
3k views

Analyzing Minesweeper Probabilities

Calculating probabilities in Minesweeper might sound like an easy task, but I've seen so many probability calculators that's either incorrect, horribly slow, or with ugly code (or all of them) so I ...
66
votes
8answers
9k views

Open, write and close a file

I have a small 10-liner function that writes some data to a file using an std::ofstream. I did not explicitly call .close() at ...
13
votes
7answers
4k views

Project Euler #3 - largest prime factor

I was going through the Project Euler problem #3 and made a program to solve it. The problem is as follows: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the ...
75
votes
4answers
20k views

Function to print command-line usage for a program [closed]

The following function works well to print out a help message for the program I have written. It prints a multi-line string message that describes the command line usage with some examples: ...
18
votes
5answers
4k views

Stopwatch template

It's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated ...
17
votes
3answers
2k views

A CSharpish String.Format formatting helper

A while ago I implemented .net's string.Format() method in VB6; it works amazingly well, but I'm sure there has to be a way to make it more efficient. I'll start ...
27
votes
5answers
13k views

Creating ADODB Parameters on the fly

I have put together a small wrapper class to simplify creating parameterized ADODB queries with VB6/VBA. At this point I'm keeping things simple, so it's only supporting input parameters and from what ...
100
votes
9answers
27k views

'100' is a magic number

Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: '100' is a magic number. Consider this code: ...
15
votes
1answer
2k views

Plot timings for a range of inputs

When writing Code Review answers, it becomes often necessary to measure how long the modified code takes vs how long the OP's code takes. I needed a nice way to visualize this as a function of the ...
36
votes
4answers
6k views

Rainfall challenge

About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb. A year later I actually came up ...
10
votes
4answers
370 views

C++ string Formatter

I had an uneventful afternoon, so I thought I might try and write a string formatter. This is based on the documentation I found here. ...
18
votes
4answers
19k views

Split a string into chunks of the same length

Inspired by this question in chat Is there an easy way in .NET to split a string into an array by pulling chunks of the text in. I.e. I have an 18 character string I would like in 3 6-character ...
14
votes
3answers
618 views

Sieve31, my sieve of Eratosthenes returning IEnumerable<int>

This very fast, simple sieve quickly finds 31 bit primes. It uses a memory efficient BitArray for odd numbers. How a 32 bit int...
10
votes
4answers
2k views

Materializing any ADODB Query

Following-up on Creating ADODB Parameters on the fly and pushing the "wrapping" of ADODB a step further, I have written two more classes that allows me to expose methods that don't require a ...
9
votes
4answers
5k views

Sound manager for Android

I created a singleton class for managing sound effects on Android. This class will only be instanced and loaded once at the beginning, and each activity will use the loaded songs. I don't know either ...
16
votes
2answers
2k views

Recursive and flexible approach to Tic-Tac-Toe

Description This is my code for the Weekend Challenge Reboot - Tic Tac Toe Ultimate. The game can be played here: http://www.zomis.net/ttt (along with some other variations that are also use the ...
6
votes
4answers
14k views

Random walk on a 2D grid

The program assignment: A drunkard in a grid of streets randomly picks one of four directions and stumbles to the next intersection, then again randomly picks one of four directions, and so on. ...
23
votes
1answer
47k views

Snake game using PyGame

I wrote a simple Python snake game which is about 250 lines of code. Can someone give me some advice on how I can refactor/make it better? game.py ...
44
votes
4answers
4k views

ASCII table in Brainfuck

I made my first Brainfuck program today, which prints the numbers 0-255 and the corresponding character. I was wondering if I could improve my program, as I'm repeating myself a lot (e.g. 3 x copy &...
24
votes
5answers
3k views

Automagic testing framework for VBA

Building on @RubberDuck's recommendations, I now have something I find... beautiful. I'm sure there's a couple of things left to polish - this site is about making great code out of good any code, ...
8
votes
3answers
13k views

Linked list implemented as classes, not imperative code

As an update to previous code I've submitted: Improvements this time are mainly having everything moved to a class, before I plough on and add more functionality (I've come back to C++ after a few ...
42
votes
1answer
3k views

Charmander Brainfuck interpreter in Haskell

I just started learning Haskell and this is my first big project (ie not factorials, fibonacci or graphers). This is kind of a gift for somebody so the language is a bit different. The program works, ...
18
votes
1answer
1k views

Compile-time sieve of Eratosthenes

There are many instances of prime number sieve implementation both here and other places on the web, but I wanted something a little different. In particular, I wanted to create a static array of the ...
17
votes
3answers
4k views

RPSLS Game in C#

I went with what I know and can use well, not what I know and can't figure the syntax out to make it look good. So please enjoy the code and prepare to school me (probably in the basics) in C# ...
13
votes
1answer
1k views

Comparing std::vector<bool> to std::vector<char>

A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over ...
10
votes
1answer
2k views

VBA Class to persist and restore Excel Application properties

Very often on Stack Overflow, and even on Code Review, I've seen questions and answers that have code that begins by persisting Excel properties like DisplayAlerts ...
11
votes
3answers
5k views

Project Euler Problem 12 - triangle number with 500 divisors

I've just done Problem 12 of Project Euler: What is the value of the first triangle number to have over five hundred divisors? The \$N\$'th triangle number is the sum of all natural numbers ...
9
votes
1answer
3k views

Z-Algorithm for pattern matching in strings

I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings. ...
1
vote
1answer
172 views

Updating register_globals code for importing $_GET and $_POST data

I'm updating a bunch of PHP code that relies on register_globals and uses request data globally. In the process of fixing/updating I spend a lot of time writing ...
11
votes
1answer
149 views

YAuB - Micro Benchmark Follow-on

Following some great advice here from Simon, I realized that I had over-engineered things, and that the Task builder methods were a horrible Java8 abstraxction. In Simon's words: "From a usability ...
7
votes
1answer
87 views

Nisse Server: Part 1 Helper Functions

Getting close to a release of generic server. So a couple of reviews will be coming this way over the next few weeks. Stating with the lowest levels and working up to the main server. The result is ...
5
votes
0answers
143 views

Scheduler built with observables v2 (follow-up)

It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one ...
5
votes
3answers
476 views

Readable code with many components (Swing)

Please help me to make more readable and simple code like this. What if I had 20 components? Is it right to organize code like this? ...
4
votes
2answers
104 views

Sign an EC2/S3 URL Version 3

From the previous 2 versions: Sign an EC2/S3 URL Version 2 I fixed the comments from the previous version. Most of the code remains the same (so I have split out the new code for review). The main ...
38
votes
3answers
10k views

Exporting doc types using queues and multithreading

For a while I have been interested in seeing if some tasks work well when split across multiple threads. On the one project I have been busy with I have been creating a lot of small utility apps, to ...
39
votes
4answers
19k views

Seed std::mt19937 from std::random_device

Many people seed their Mersenne Twister engines like this: std::mt19937 rng(std::random_device{}()); However, this only provides a single ...
22
votes
5answers
69k views

Conversion between enum and string in C++ class header

I have the following redundant-feeling design to convert between enums and strings regarding a class that stores enums. The ...
39
votes
2answers
35k views

Balanced parentheses

Given an expression string exp, write a program to examine whether the pairs and the orders of "{","}","(",")","[","]" are correct in exp. For example,...
31
votes
5answers
47k views

Brute Force Algorithm in C

This is a simple brute force algorithm that I have programmed in C. All the program does is print out every possible combination of the given alphabet for the ...
11
votes
4answers
64k views

Different way of writing multiple click functions

I have the following .click() functions: ...

15 30 50 per page