# All Questions

61,483 questions
Filter by
Sorted by
Tagged with
3k views

### Regularity in the “Rusty Towel of Mutual understanding”

I have the following Java class: ...
4k views

### Rock-Paper-Scissors-Lizard-Spock Challenge

"Scissors cuts paper, paper covers rock, rock crushes lizard, lizard poisons Spock, Spock smashes scissors, scissors decapitate lizard, lizard eats paper, paper ...
52k views

### Delete folder if it exists in PowerShell

In my PowerShell script I'm trying to delete a folder, but only if it exists: if (Test-Path $folder) { Remove-Item$folder -Recurse; } I find myself repeating ...
22k views

### Determining if two words are anagrams

I was given a this problem at a technical interview and failed miserably in the time given. Afterwards, I sat down and worked out what I think is a good solution. The task was actually to build an ...
227k views

### Converting DataTable to List of class

I am using ExcelDataReader to import an Excel file to a dataset. Example Excel table: ...
3k views

### The right way to hang a man

Problem: I have seen a few questions around hangman. Usually this is done in a very hackish way, which usually can not be generalized any further. My thought or question is about the creation of the ...
2k views

### Finding minimum scalar product using ST Monad

Inspired by a Stack Overflow question, I decided to practice my Haskell by taking a crack at the Google Code Jam's Minimum Scalar Product problem: Given two vectors \\$\mathbf{v_1}=(x_1,x_2,\ldots,...
804 views

### Swiftly turning wheels – The May 2017 Community Challenge

This is my attempt at the May 2017 Community Challenge in Swift, with a chain consisting of rigid links. I took this as an opportunity to learn SpriteKit, Apple's framework for 2D games. At least ...
17k views

### Deck of cards as an interview exercise

I was asked to write a test code for an exercise for a job I applied for. I was rejected, and I didn't know why. And I want to ask your opinions about my code. The exercise is like that: Write a ...
3k views

### SHOUTY_SNAKE_CASED NUMBERS

WE_ALL_LOVE_SHOUTY_SNAKE_CASE_SO_I_WROTE_A_PROGRAM_FOR_IT!!1! Alright, enough of this. This is a rags-to-riches from this question. The pattern is pretty simple, it takes a ...
3k views

### Is my code a 'safe' singleton?

I was wondering if my code will produce a true singleton. I am creating an Android app, and all activities should access my API through one instance of the SyncApi ...
4k views

### Hello, Brainfuck

It has been bugging me for a while that while I understand how the basics of Brainfuck works, I can't get a firm grasp on the advanced features of the language. So I started to re-evaluate what I know ...
70k views

### Finding the closest point to a list of points

I'm trying to find the closest point (Euclidean distance) from a user-inputted point to a list of 50,000 points that I have. Note that the list of points changes all the time. and the closest distance ...
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 ...
4k views

### Easier user input in C++

A more proper version of this utility can be found at the following link here: Giveth me thy easier user input in C++ - follow up. I've always been a little bothered by the fact, that in order to get ...
24k views

### Designing a coffee machine

I was recently rejected from what looked like a really promising string of interviews. I did very well in a questionnaire style review, and then they handed me this assignment (more or less): ...
17k views

### Rendering a person's time clock record in HTML, with many color-coded conditions

I have coded this mess of JavaScript and a bit of jQuery. Everything here works perfect as intended, however it is a real mess. What would be the best way to clean this up with best practices and ...
9k views

### Database connection in constructor and destructor

I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This ...
5k views

### Parallel sieve of Eratosthenes

For the first time, I tried to use threads by myself in order to implement a parallel sieve of Eratosthenes. The trick is that each time a prime is found, a thread is spawned to eliminate all the ...
11k views

### Logging without Code Bloat

I was wondering if any of you know any best practices or design patterns so that I can have good logging in my programs without them looking messy or bloated. I am currently using C# and NLog, ...
5k views

### Everyone loves Fibonacci

I was bored and burnt out on more serious projects.... until I saw this Computerphile video on YouTube. Now I'm inspired again. Now I feel like spending some time implementing that recursive algorithm ...
8k views

### Why is my C program for calculating Euler's constant of poor quality?

I was trying to post this code to a Wikipedia article, but it was soon removed. I then asked about the code in the page's talk section, and some other contributors said that is was "very poor" and ...
31k views

### Incrementing Integers in Map

I have a HashMap<Token, Integer>, which counts occurrences of Token. Each time Token ...
392k views

### Snake game in C++

This is my version of the Snake game, written in C++. How could it be improved, and what general advice would be useful for future projects? ...
6k views

### Ultimate Tic-Tac-Toe in C

Here is my attempt at the UTTT code-challenge (in response to the the Weekend-Challenge Reboot). Here is what I would like critiqued: I tested the code a few times for bugs, but I may have missed ...
34k 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,...
448 views

### Beta-Blue B. Gone

I've written a Code Review design using Userscripts and CSS. It works by fetching the CSS from my GitHub repo, and using the built in gm_addStyle function to add ...
971 views

### Brainfuck to x86 Assembly Compiler

After my Brainfuck Interpreter written in x86 Assembly I decided that it was time to get to the next step, writing a Brainfuck Compiler in Java that generates x86 Assembly and compiles that to an ...
5k views

### Beheading of knights, who survives?

We have a round table of n knights, where n is some positive integer. These have failed to satisfy the expectations of the mad ...
7k views

### Which FizzBuzz is better, and why?

I was in an interview and the guy asked me to do the typical FizzBuzz question of printing numbers 1-100, but for each factor of 3 print Fizz, each factor of 5 print Buzz, and each factor of both ...
2k views

### First Time HTML5/CSS Site

I am working on my first HTML5/CSS web site and, like all of my first-time projects, they end up cumbersome, crude, and hard to work with when changes need to be made later in the life cycle. I am ...
7k views

### “How are you spending your time on the computer?”

I've made a Windows Forms application to track all of the processes running on my machine and it also saves the time an application is "active", an active application is the one that is on focus ...
4k views

### Someone thinks poorly of my server log parser

I have just been informed that the following code written by me is extremely poor. I have absolutely no idea why. It is memory efficient, and looks clean to me. But still the feedback is very poor. I ...
3k views

### Running Lights - Embedded “Hello World”

I'm getting my feet wet in embedded development, and like all those before me, my first task was to make an LED blink. I went a bit further than that and made a "runner" that lights up each led from 0 ...
8k views

### The FizzBuzz challenge in Java 8 written in a short, readable and interesting way

I decided to take on the FizzBuzz challenge with as twist that I would use Java 8 concepts to make it a bit modular, yet still let it be a short, readable and understandable program. This in contrary ...
30k views

### Swift 1.2 Singleton Implementation

I am pretty new to Swift, as a solo developer I was wondering if somebody could pass comments on the singleton implementation below. The code does work, but being new to Swift and knowing that there ...
7k views

### Calculation of prime numbers making use of Parallel.ForEach

In my spare time I decided to write a program that would systematically identify prime numbers from 2 to 18,446,744,073,709,551,615. This is for fun and learning, as I know it will take too long to ...
4k views

### Displaying courses in an HTML calendar

I'm struggling for a while now with the readability of my code, I after I tried to get as much insight as possible (for my standards). On my level, I think I understand and use it all right for my ...
6k views

### Python package for handwriting recognition

I am currently writing my bachelor's thesis about on-line handwriting recognition. This is not OCR, because I have the information how a symbol is written as a list of pen trajectory coordinates (x, y)...
3k views

### KISS my… unit of work

I've seen many, many UoW+Repository implementations. Whenever one was built on top of Entity Framework, I'd cringe at the added complexity. Sure the complexity buys you (sometimes) full decoupling ...
3k views

### Recursive shared_mutex implementation

I found myself in need of a Readers-Writer mutex. With C++17 TR2 support not yet available in our compiler, I set out to implement std::shared_mutex so that we have ...
1k views

### Utility that decodes and logs UDP packets

I have written the following utility, as my first non-tutorial program in Go. The purpose of the utility is to connect to a torque/force sensor (aka load-cell) via UDP; to send an initialization ...
1k views

### JSON formatter in your least favorite language

Just joking guys, Brainfuck is an awesome, challenging language. I've tested the following code with bf-x86 compiler and rather big JSON file. I believe code is fully functional on a valid (!) JSON ...
13k views

randip.py I know there are probably better, easier ways to do this. It was just a bit of a learning exercise for the sake of familiarising myself with Python. It takes a single argument (positional ...
142k views

### String.IsNullOrEmpty in JavaScript

I am aware of it being frowned upon to do something like write C# in JavaScript. (see this if you don't know what I'm talking about) But as a judgement call, I think we could stand to have a ...
3k views

How can I clean this up? ...
27k views

### Perform instruction in loop every time except the last time?

The specific issue is this: I am writing to a file and want to output a new line after each line written. If I use a normal loop without any further checks, this will create a blank line at the very ...
5k views

### Quicksort implementation seems too slow with large data

I've written a program to compare different sorting algorithms with the array size being 10, 1,000, 100,000, 1,000,000 and 10,000,000. I, of course, expect Insertion to win out on 10 and merge heap ...