instruction
stringlengths
71
71.9k
First, I'm adding words entered into a search field to an array. Then, I'm getting results from a stored procedure on SQL Server using Database First approach with Entity Framework. Finally, for each word in the array, I'm filtering the results using this query: products = products.Where(item => (item.basedescription....
Before I begin using this code in vital systems, I wanted to quadruple-check that it was soundproof. I plan to implement this as part of a larger program, obviously not by itself. Are there any clear flaws (output is incorrect) or optimization issues in this code? #include <iostream> using namespace std; int main() {...
I developed a program that creates and displays a Newton fractal based on a complex polynomial. For example, the complex polynomial: $$z^{3}-1$$ which is what is given as input in the code, will produce an image similar to this one: Basically what happens is that the program finds the function's derivative, uses it to...
This is my first time making an Office 365 Addin and wanted advice on my current form structure. I'm particularly looking for advice on best partices for constructing directives and how to properly separate logic into app controllers. I feel that my single controller below and various redundancies could cause issues in...
I asked this on Stack Overflow and got some good ideas, but was advised to post here instead. There are obviously several ways to code this, each with a drawback and a benefit. A person works a number of hours and can bill for the work in one of three ways: Hourly: the number of hours worked * hourly rate Dual: (for s...
I've been working on Project Euler, here was my solution for Problem #1. It gave me the proper answer, but it's egregiously slow. How can I implement this more efficiently? My math skills aren't top-notch, sorry. package main import ( "fmt" ) // Problem1: find the sum of all the multiples of 3 or 5 below 1000. //...
I'm going through a beginners exercise for writing a small program in Java. My task is to print out (i.e. find an algorithm) the following output: XOOOOOOOOO XXOOOOOOOO XXXOOOOOOO XXXXOOOOOO XXXXXOOOOO XXXXXXOOOO XXXXXXXOOO XXXXXXXXOO XXXXXXXXXO XXXXXXXXXX I have figured out how to do it but the code I wrote seems r...
How is this designed so far? #ifndef LINKEDLIST_H #define LINKEDLIST_H #include <memory> #include <iostream> template <typename T> using ptr = std::shared_ptr<T>; template <typename V> class LinkedList { private: class Node { private: V data; ptr<Node> next; public: Node() : n...
I have created this method to do all my WebRequests. Generally my question is, if this could be improved in any way. As a side question, I would like to know if it be better to create methods for each type (PUT, POST, GET, UPDATE, DELETE) of a request separately? /// <summary> /// Test-Method /// </summary>...
There has been talk recently of how we should be handling the lifetime of the System.Net.Http.HttpClient. This article http://byterot.blogspot.co.uk/2016/07/singleton-httpclient-dns.html says that we should use it as a singleton, but we need to be careful about ensuring the connections are properly closed otherwise DNS...
I wrote a program to copy directories in Windows 10. I have tested copying a directory (696MB) in 3 different ways: xcopy: time taken - 52 seconds ctrl+c: time taken - 78 seconds My program: time taken - 193 seconds What can I do to improve the performance of my program to be as fast as xcopy? #include <stdio.h> #inc...
Find the fractions for, all positive numbers, all negative numbers and zeros in a given set of integer array. I wrote the below program. If you see any improvements required, please feel free to point them out. Sample input: 6 -4 3 -9 0 4 1 Sample output: 0.500000 0.333333 0.166667 Here is my program :) public class...
Let's say we've two parallel galaxies with same amount of stars. What I want to do is to find the nearest neighbour of GalaxyA in GalaxyB. But if that particular neighbour is shared by other star(closer to another GalaxyA star) then look another nearest neighbour. This way we will get unique nearest neighbour for each ...
Vogel612 and I decided to take a shot at the StackSTV challenge in Haskell. This is part of the CRitter Collaboration challenge. Except I don't know any Haskell. So let's try a FizzBuzz first! I'm quite pleased with the readability of the following code. Let me take a shot at trying to explain how it works. main = mapM...
I inherited this code that saves data to a sharepoint list. This method saves the data to the list. In other parts of the application a list is presented and can be paged through. You then select an item and it loads all the columns and you can modify them and save them. It's taking roughly 25 seconds to save data. Any...
I have the following java class which has many private variables and methods: package gui; import java.awt.Color; import java.io.File; import java.util.*; import java.util.stream.Stream; import javax.swing.*; import messages.Message; import net.miginfocom.swing.MigLayout; import utils.*; public class FileCopyManager ex...
A book1 that I'm reading states Goldbach's conjecture as follows: Every even integer > 2 could be represented as a sum of two prime numbers. Every integer > 17 could be represented as a sum of three unique prime numbers. Every integer could be represented as a sum consisted of maximally six prime numbers. Every odd i...
I put together a little tool for finding where people have suppressed warnings, and to see if they have commented why. Its in Haskell for fun and some practice. Its split into two files, the thinking here was to keep all of the IO functions in one place and the pure parser code in another. My immediate concerns are: ...
By default, QSlider move his thumbtrack by a value belonging to the singleStep() prop on mouse click. To make thumbtrack jump directly at the mouse click point, we need to create a new class inherited by QSlider. Header file (.h): #include <QWidget> #include <QAbstractSlider> #include <QSlider> #include <QMouseEvent> #...
I designed a Python3 webservice which gets a file name, looks for this file in a local folder, converts it using an external software, then sends the converted file to the user. For this example, the input and output file types are respectively PNG and JPEG, but they're actually proprietary formats. Here is my code: #!...
I'd like to know if this piece of code is thread-safe. I'm learning something about threads, queues and synchronization, and I'd like to make sure this is correct, before moving forward to next step. The code is very simple. It just runs two threads (producer and consumer). Producer reads data from stdin (until "0" is...
public static DataSet execute_query(string query) { DataSet ds = new DataSet(); SqlConnection con = new SqlConnection(); con.ConnectionString = DataAccessLayer.Properties.Settings.Default.cn; try { con.Open(); SqlDataAdapter da = new SqlDataAdapter(query, con); da.Fill(ds); ...
I am currently in the process of completely rewriting an older Chess project and have written the main recurring function in the AI: //Finds and applies the best move for the ai. function aiTurn() { //Recursive function. recurBoard is the board array passed to the function. //Colour is either -1 or 1, -1 means it's cal...
I created a simple little script for the people I work with, what it does is copy information to the users clipboard for escalation approvals. It's pretty simple and not very exciting but I want to know if there are ways to do this better: from Tkinter import Tk import getpass import os import time class ClipBoard(ob...
I have a function that will take an image and then return that image in 8-bit color. Almost all of the code was taken from MSDN. The code is quite short compared to all of the other methods I've seen for converting an image to 8-bit color. I'm just curious as to if this is the most efficient method? private static Imag...
This is a follow-up to the previous question: Implementation of the linked list data structure in C++ I've tried to improve the design of the previous code by fixing some indexes that could go out of range and cause the dereferencing of a nullptr, and minor changes for compactness and elegance. However, I'm not sure ab...
I am running a simple OCaml program which opens a CSV file with a pseudo dict-reader and hashes "key" + "value" (where key and values are strings). Then some counts are evaluated on the hashes (but it is not really relevant for what follows). After a quick look at the default OCaml profiler (gprof), I noticed that my p...
I have a table that looks like this Directory nvarchar(max) Extension nvarchar(10) Length bigint I also have another table that provides the type of file (lookup table) extension nvarchar(10) FileType nvarchar(50) That being said I have a correlated subquery I wanted to migrate to a sproc that takes in the levels from ...
I am making a snake game and I'm almost done but I want to make my code more organized so people can understand so how to do it. # -*- coding: utf-8 -*- import pygame import random import time import thread ##########################Functions############################################################################...
I created this regex in Javascript that returns a boolean for Domain validation that meets the criteria to allow IP addresses and ascii domain name. The assumption is that the TLD should be atleast two letters. /^((([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z0-9]+(([\-]?[a-zA-Z0-9]+)*\.)+)*[a-zA-Z]{2,}))$/ I used the follow...
I am working on a Simon game using python and tkinter, just now it is incomplete, but I don't know if I am doing it right because it looks messy, and I would like to have a check on my code for corrections and suggestions on how to improve it. This is the first game I'm making, and I don't have to much experience in pr...
In a very specific application I have, I needed the ability to easily convert between different data sizes. I.e. when I give an input of 1,048,576KiB, I needed it to say 1GiB, etc. So, I built a struct for it. It's pretty robust, includes operations for subtraction, addition, multiplication and division, == and !=, IsS...
In https://stackoverflow.com/a/39299060, I wrote the following program. #include <fstream> #include <iostream> #include <string> static std::string str_xor(const std::string &data, const std::string &key) { std::string result(data.size(), '\0'); for (std::size_t i = 0, i < data.size(); i++) { result[i] = data...
Can someone please evaluate my code and let me know how I can improve it? public class ArrayListImplementation { static class ListNode<T> { private T value; public ListNode(T val) { this.value = val; } public T getValue() { return this.value; } public String toString() { ...
A few days ago I wanted to build a tools to cut a long text into one hundred-letters strings with the number of the tweets and which part of the tweets the tweet belongs to. I tried to have a tweet with one-hundred characters long but I could not find anything relevant to [1/x] This is my tool: import tweepy n = 100...
So I made a class for playing a sound in JavaFX when a button is pressed, a window pops up... I don't know about the quality of the code though. I don't know if I used the best way to play the sound. It's meant to be used to play small mp3 or wav files (not longer than 5 seconds) I made it so you can adjust the volume ...
Given a vector of seller orders (asks) of a certain product (each order having a price) and buyer orders (bids) of the same product, I'm creating a function that resolves the auction by matching the best sellers (lowest asked price) with the best buyers (higher offered price) and then clears the market by selecting a p...
I'm learning Scala, and I wrote a program to estimate the value of Pi. When I'm using multiple threads, it takes 5-6 times longer to calculate the same iterations. I wrote a similar program in Java, with plain old threads, and with ExecutorService , and the results are the same. Why is this the case? (I have 4 cores in...
I'm very new to C and have extensive experience with C# and very little with C++, but basically none with C. I wrote a small program that declares a singly-linked list struct, a few methods operating on the list, and then uses it from the main method. Even though I've read about it a lot, this is only my second/third p...
The LinkedList nodes can be 1-->2-->3-->4, where --> indicates next. For their random pointers: 1--> 2, 2--> 4 3-->2 4--1. There can be duplicate data values of the nodes. I'm looking to see if the solution can be improved upon. class Node { int data;//Node data Node next, random;//Next and random reference //Node con...
Is there a faster way of getting the key of 1 or 2 by using the accs value for my getID function? Unfortunately I cannot use an inverse dict due to the fact I'm using a list for the value which causes a unhasable list error. Mainly I'm worried more when the db gets larger in size the getID function will take longer to ...
A simple reworking of the Bash date command to my own personal liking. Possibly a rather trivial task; I just wanted the date and time to be in the form of: Fri Sep 2 2016 11:37 P.M. I think this accomplishes that: #!/bin/bash today() { now="$(date | awk '{ OFS=" "; print $1,$2,$3,$6 }')" h="$(date "+%H")" ...
I've made a JavaScript library that retrieves a Google Spreadsheet. It's something like Sheetrock.js, while mine is just a less powerful prototype. I've uploaded the source code and example in GitHub. But you can just see the implementation and demo in JSFiddle. A sample spreadsheet is here. Since I am not not a JavaSc...
Given that I have a set of vectors(or called vector-group), like \$\{\mathbf U_1,\mathbf U_2,\cdots,\mathbf U_n\}\$. Below is a simple instance U1, U2, U3 U1 = {0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 0.8}; U2 = {0.21, 0.25, 0.3, 0.6, 0.7, 0.8}; U3 = {0.25, 0.3, 0.7, 0.8}; Now I would like to calculate their common vector ,...
Here is the classic K-means clustering algorithm implemented in Python 3. My main concern is time/memory efficiency and if there are version specific idioms that I could use to address issues of the former. import numpy as np class kmeans(): ''' Implementation of classical k-means clustering algorithm para...
I am taking a beginning programming class and have been given the assignment to create a calendar as described in the title. Per the assignment the user entering offset of 0 will begin the calendar on a monday and 6 will start on sunday. There are to be 4 spaces per column and the request for input should prompt the ...
This header implements a very simple set of C (only) functions for logging. This is part of a larger collection of utility functions aimed to be used during the development process, meaning that they are intended to provide quick, easy to use solutions that could be replaced in the production code if needed. To ease wi...
I have coded a free .psd layout for the first time. I did not make it responive because I would like to know if the code is correct. The layout's appearance in Firefox and Chrome seems to be ok (though in Firefox there's a bit of white space), but I know sometimes your code can be incorrect even if it looks good. I don...
I was posed with a challenge when trying to load XML files from Stack Exchange into a SQL Server database; some of these XML files are extremely large (largest one being a whopping 67 GB in a single XML file), so much so that the database just cannot handle them without throwing a System.OutOfMemoryException. After som...
The "Rope Intranet" problem from Google Codejam 2010 asks us to count the number of intersections (black circles) in a planar straight-line graph like this: That is, with each line segment having one endpoint with \$x=x_0\$ and the other with \$x=x_1\$. Input The first line of the input gives the number of test cas...
I am trying to build a multiple file uploader with jQuery and Ajax. I would like to know how this code could be improved. I feel the client side validation of file types in my code are presently not good enough. app.js $(document).ready(function() { $('#upload').click(function () { $('input[type=file]').cli...
I'm developing, just for fun and learning, a TypeScript Class that creates an Array<Array<string>> that represents a pyramid. So, for length = 5 the array would look like : [ ['X', 'X', '0', 'X', 'X'], ['X', '0', '0', '0', 'X'], ['0', '0', '0', '0', '0'] ] The class constructor can take a few arguments: The fin...
This question is continuation of: Sending email using libcurl I developed a class to send email. Does this code have any problems? Is it thread-safe? #include <ctime> #include <cstring> #include <curl/curl.h> class Email { public: Email (const std::string &to, const std::string &from, ...
I am given pasted data from a table, so I have spaces as delimiters and in some of the fields I don't care about. I want the first field and the last three fields, and got them using this code: testdata = """8/5/15 stuffidontneed custid locid 55.00 8/9/15 stuff i really dont need with extra spaces custid otherlocid 79....
I'm writing a basic wrapper around a restful service that returns a list of Stores. I'm using RestSharp which I'm injecting into the class. Naturally, I want to make it completely testable (that's a major requirement!). I'm also thinking that it could be more generic i.e. GetStores but I'm struggling how to do as I nee...
Task aim: Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum. I've been trying to make my implemented function below run faster (less than 7000ms) and taking into account records upwards of 10,000,000 items. Wh...
I don't have a lot of experience in C++; I'm more of a C# guy. I'm trying to convert some Matlab image processing code to C++. I would appreciate any feedback about C++ coding conventions, which data structures to use, what kills performance, and anything which is considered to be good or bad coding style for C++. I'm ...
I have a select box with some options in it and a input box. I have to filter the values of select box on the basis of the keyword entered in the text box. JavaScript function filter() { var keyword = document.getElementById("search").value; var select = document.getElementById("select"); for (var i = 0; i ...
Please review my implementation. I know there is already an implementation in Java, but I just wanted to come up with my implementation. Let me know if I can improve this. import java.util.NoSuchElementException; public class LinkedListImplementation<T> { private int size; private ListNode<T> head; static...
The requirement is to iterate over a list of Foos, and when 2 Foos have the same id merge their list of inputs together and obtain a new object. I have achieved this with 2 streams and a private method to do this: import java.util.HashSet; import java.util.Set; class Foo { private String id; private Set<String...
update: So, this is weird, I just reinstalled Adobe Animate, and now, when I do ctrl+enter (test movie), it pulls up an AIR window, and plays my app, and it works smooth as butter! (now I'm just not able to install a published package because I screwed up something with my certificate...) I have just posted 1 out of 4 ...
Please review my Stack implementation and let me know if you have any suggestions. public class StackImplementation<T> { private StackNode<T> top; private StackNode<T> head; private int size; static class StackNode<T> { private T value; private StackNode<T> next; public StackNode(T val) { this.val...
I am attempting to validate a set of business rules in order for a user to successfully add to cart. The rules vary from requiting to add/decline a requested add-on to not having more then 60 items in your shopping cart. For my end goal, I need to be able to have several dozen rule sets and if any return false then exe...
For a Laravel project I needed to show latest three blog posts on the homepage. The blog was made with Wordpress and after some research I found a cool plugin called REST API that allows to get a json object of posts. I made a Laravel Controller that uses curl to get the posts and send the response to jquery in the hom...
I am a college student and started my first week of C++ and we were given an assignment to convert a Java program that calculate the interest on a series of loans given the amount of the principal, the annual interest rate, and the number of days in a sentinel loop into C++. Here is what we were given: import java.uti...
This finds the prime factors of a number given in a variable. Is it efficient or in need of improvement? public class PrimeFactorFinder { public static void main(String args[]){ long n = 18; long md = 2; while(n!=java.lang.Math.sqrt(n)){ if(n%md==0){ System.out.p...
From a React course I'm taking: I could implement most of the demands. A life-demo can be seen here: http://n-or.de/news/#/ You have to click the "News" and "Photos" links on the right side for getting to the subpages. Here's the code of the relevant components: main.jsx var React = require('react'); var ReactDO...
This is a very simple text-based "game" I made in Java. The whole idea is to repeatedly type "eat/sip _____" until you eat all the food and win. (Pertaining to skill level) I have been programming in Java for a little over two years, in high school. I feel I can be considered a beginner, but not quite enough to warrant...
I have been using Scala as a means to learn Functional Programming and writing better code. However, I have some questions regarding some exercises or if there's a better way to approach them. In the exercises below, I have already defined the functions foldLeft, foldRight,append, sum, product, head and tail. HARD - ...
I'm currently reviewing some different ways to have reusable components enforcing both most of the style & logic. The use case is a generic MainList with children components (eg. MainListToolbar, MainListContent, etc.) that can all be used together to create multiple mostly agnostic lists for business objects (eg. User...
I am using Tablayout for an Activity in my app but for some reason icons for each tab using tabLayout.getTabAt(position).setIcon(icon) are getting small. Additionally the text is always in uppercase. So I decided to implement custom views for each tab to get the desired result. It did work but the code is not up to the...
I have written a program to compare two 3D raw data equal or different. But I think the time consuming would be reduced if I use the STL. How to improve the program? The complete and varifiable code is showed as follows: #include <cstdio> #include <string> #include <iostream> #include <assert.h> #include <cstdlib> usi...
I have made my first app in Elm, a lookup of Github users. You type the name of the user into the search bar and the user's username and profile image - which has an anchor linked to their profile - appears below. Here is my code: module Main exposing (..) import Html exposing (..) import Html.App as App import Html.A...
This is basically my attempt to the German Tank Problem in which we are given a few serial numbers and expected to return an estimation of the total production count. Such as, if 4 tanks are captured with serial numbers 19, 37, 42 and 60, return the total number of German tanks there. For a given number of serial numbe...
I've written a simple multiple-sender multiple-receiver channel, but I'm unsure if my approach is the best way to do this. I'm not using multi-threaded primitives but instead wrapping around std's builtin sync::mpsc. Performance is fine so far for my use case, but I'm unsure how well this will scale given the fact that...
Trying to create something really lightweight. Sources are on GitHub. To create a proxy we need to define an interface first, e.g.: // Fake Online REST API for Testing and Prototyping [Site("https://jsonplaceholder.typicode.com")] public interface ITypicode { [Get("posts")] Task<BlogPost[]> GetAsync(); ...
So during my thesis I used xppaut quite extensively. In the end there were some minor problems and I decided to have a look at the code, which was just released at github. So after 30 years of on and off development by Bard Ermentrout, it kind of showed some rough edges github link to xppaut, which I tried to smooth gi...
Challenge Swap the numbers surrounding the words in sentences. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a sentence. Each sentence begins and ends with a number. Print out the sentence obtained by swapping the numbers surrounding ea...
Here is my solution for an exercise, which requires translation of strings to key presses on a phone keypad (for example, to get 'b' the digit '2' needs to be pressed twice). It's taken from the book Haskell from first principles, and originally appeared in 1HaskellADay. I'd love to get feedback. module Phone where imp...
The code reads 512 bytes at a time and stores them in a buffer. When the code sees a .jpeg signature it will proceed by writing to a .jpeg file until another signature is found, thereafter the process repeats. #include <stdio.h> #include <stdlib.h> #include <cs50.h> #define infile "card.raw" #define BLOCK 512 /** * ...
I'm a beginner with rails working on a rails 4 project to use with my students. Users enroll in lessons; on enrollment, four activities are created for each user (expositions, scrambled, dictations, and spellings). Each of these activities has a number of words which are set to false in the db upon creation, and change...
This class is part of the Construct library. Container is a dict that: turns attribute access into key access so con.a -> con["a"] preserves the order of keys I know, this is similar to collections.OrderedDict but it isn't available in Python 2.6. For anyone preferring more interactive code, you can pull the trunk an...
I had the need in one of my activies to handle displaying a message to the user when the network disconnected, and then reload the data for a RecyclerView adapter when the network reconnected to ensure it was up to date. After getting that working for my use case, I wanted to make the implementation more abstract for r...
I've struggled with this for quite some time. Today I finally wrote the following code. The ViewModel contains an int property which later tells the view how many pages the data has been split into. The controller splits the data by taking a specified amount of rows and, in the event of paging, splits by pageNumber * r...
Please review my Queue implementation and let me know if you have any suggestions. I am not returning an exception for any of the methods defined here. As we know the exception is thrown only for add and remove functions and not for poll or offer functions. public class QueueImplementation<T> { private QueueNod...
I recently answered a question that had an interesting problem statement (I've slightly modified the wording): I have an abstract class A which is base for the other classes, let's say B and C. Classes B and C should have a handle_input() method, but argument number and types may vary from B to C. I also have a fu...
As I was creating a CLI program, I realized having a ton of switch/if-then statements was a messy way to process user input. So, I set up a way to dynamically create commands as I added modules (Classes that extend the Module class) and methods. When a user enters a command like "sys::get bios" it gets passed to the lo...
Please review my Deque implementation in Java and suggest ways of improving this. public class DequeImplementation<T> { private QueueNode<T> first; private QueueNode<T> last; private int size; private static class QueueNode<T> { private T val; private QueueNode<T> next; priv...
This is a simple bash script (hopefully with a little style as well) for converting temperatures from Fahrenheit to Celsius and vice versa. #!/bin/bash re='^-*[0-9]+([.][0-9]+)?$' while true do printf "\n\e[1;39mWhat is the temperature you wish to convert?\e[0m\n\n\t" read -p "Enter a numeric value " n w...
I'm trying to create my own service, $hR. This service uses XMLHTTPrequest to get data from a URL with promise. ;(function(global){ var http = function(){ var self = {} self.get = function (url){ var ajax = new XMLHttpRequest(); ajax.open('GET',url,true) ajax...
I'm writing the HTML for this website: And this is the HTML I made: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Gustoso</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflar...
Given I have a linked list, and I want to move a given node to the end of the list, is there a more elegant way of doing this, than what I've done here? #include <stdio.h> #include <stdlib.h> typedef struct node { int val; struct node *next; } node_t; void insert(node_t **head, int val) { node_t *new_node = mal...
Challenge Given a list of numbers and a positive integer k, reverse the elements of the list, k items at a time. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a comma separated list of numbers and the number k, separated by a semicolon....
I currently have this monstrosity: next_period = (((current_month + tax_period_months)-1) % 12) + 1 I want to get the month that is tax_period_months after the current month. E.g. if tax_period_months=3, and current_month=09 then next_period=12 This works, but has that horrible -1 +1 to stop month 12 becoming 0 Any a...
As the title states. I need a different type of icon for the different nodes types. at the moment I have this hacky way of achieving that. for (var x = 0; x <= nodeList.Count - 1; x++) { if (xNode.Attributes["TYPE"].Value == "server.point.AV") { var tNode2 = new TreeNode(xNode.Attributes["NAME"].Val...
My only concern with the following class is the line hierarchy.trimToSize() in determineHierarchy, because it is not necessary for determining the class hierarchy. However, putting it in the constructor clutters the code more than my current solution. Any recommendations or should I just live with it? Since this class ...
I am learning about reinforcement learning and came across the first and simplest form of reinforcement learning system called multi-armed reinforcement learning (also called as n-armed bandit). I have read Sutton's book and an outlace.com tutorial regarding this learning. Outlace.com has written a nice Python implemen...
I needed to parse some command line switches from a string and I tried to do it the easy way so I just wrote this: static class CommandLineParser { public static IEnumerable<string> ParseCommandLine(this string text) { if (Regex.Matches(text, "\"").Count % 2 != 0) { throw new Argume...
I have to read from a file and store the data inside an std::vector container. The procedure of opening the file, reading and writing onto the container are enclosed in a routine: readData. Reading and writing include the use of several std functions that may fail. Instead of putting a try catch for each of those std f...
Problem Introduction You are given a primitive calculator that can perform the following three operations with the current number x: multiply x by 2, multiply x by 3, or add 1 to x. Your goal is given a positive integer n, find the minimum number of operations needed to obtain the number n starting from the nu...