All Questions
5,616
questions
80
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.
...
54
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 (...
100
votes
2answers
11k 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 ...
11
votes
1answer
3k 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 ...
48
votes
3answers
13k 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>. ...
81
votes
5answers
24k 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 ...
68
votes
6answers
3k 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 ...
56
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 ...
28
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?
...
35
votes
2answers
7k 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 ...
41
votes
4answers
10k 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 ...
70
votes
8answers
11k 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 ...
30
votes
5answers
14k 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 ...
13
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 ...
15
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 ...
79
votes
4answers
21k 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:
...
19
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 ...
16
votes
1answer
3k 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 ...
19
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 ...
99
votes
9answers
29k 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:
...
39
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 ...
26
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, ...
19
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 ...
11
votes
4answers
519 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.
...
20
votes
4answers
24k 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 ...
15
votes
3answers
752 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
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 ...
17
votes
3answers
3k 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 ...
7
votes
4answers
15k 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. ...
48
votes
4answers
25k 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 ...
41
votes
2answers
38k 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,...
28
votes
1answer
4k views
Extensible logging
Whenever I need logging functionality in .net, I use a logging framework, such as NLog. Obviously there's no logging framework for vba, at least none that I know of.
As much as I love using NLog, the ...
25
votes
1answer
49k 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
...
47
votes
4answers
5k 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 &...
12
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 ...
9
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 ...
44
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, ...
19
votes
3answers
5k 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#
...
14
votes
1answer
2k 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 ...
15
votes
1answer
7k views
A simple Thread Pool
A very simple Thread pool:
Any work added to the pool will be executed. The destructor will wait for all work to be finished before letting the threads stop. We then join all threads before letting ...
12
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 ...
7
votes
0answers
527 views
Sieve32FastV2 - A fast parallel Sieve of Eratosthenes
I’ve created a much cleaner, better designed version to my parallel sieve. I’ve implemented most of EBrown’s micro-optimizations but also revamped the code on my own (that is not in direct response ...
10
votes
1answer
4k 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.
...
6
votes
0answers
174 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
0answers
137 views
C++ string Formatter Again Part-4
Previously asked here.
The code is now available on GitHub.
Since the previous review I have added unit tests.
Since it is big it will come in a couple of parts.
Part 1 | Part 2 | Part 3 | Part 4
...
2
votes
1answer
194 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 ...
12
votes
1answer
156 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 ...
8
votes
1answer
106 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
3answers
505 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
116 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 ...