instruction stringlengths 71 71.9k |
|---|
The following Julia code implements Terry Feagin's 10th order explicit Runge-Kutta method (a more accurate cousin of RK4). Though the structure of the code is quite simple (i.e. no cyclomatic complexity), it involves many high-precision coefficients and lengthy arithmetic expressions which bring its length to over 150 ... |
I am designing a COM wrapper for a C++ library using ATL. Currently I am a little bit confused about enumerators that are based on ATL collections. I already wrote several enumerators based on STL collections, but since there is no ICollectionOnATL-interface (such as the ICollectionOnSTL-interface), I am a little bit c... |
Consider the following function:
func Listen(username string) (net.Listener, error) {
path := filepath.Join(socketsDir, username)
oldUmask := syscall.Umask(^0600)
defer syscall.Umask(oldUmask)
listener, err := net.Listen("unixpacket", path)
if err != nil {
return nil, err
}
passwd... |
I am a newbie to native JavaScript and am pretty much coming to grips with the operators, etc. At the moment I am currently constructing a slide.
"use strict";
var intSeconds = 3;
function loadSlider(){
flickrImgsShown = 0;
sliderImages = new Array(slides + 10);
sliderImages[0] = document.querySelector(".img");
... |
I'm currently trying to improve my C understanding. Would you mind telling me if there are good/bad things that I did here? (I implemented a function to reverse a string in place).
For example things I feel uncomfortable with:
I forwarded pointers to a buffer so that I could loosen the coupling of different parts of t... |
I wrote this code to delete an item from a linked list. I checked it and it works, but I want to know if the logic could be written simpler or clearer.
typedef struct linked_list{
int value;
struct linked_list * next;
}linked;
int deleteSpecificItem(linked ** head, int val)
{
if(!head || !(*head)) return -1;
lin... |
I have written a program that calculates the "cost" of transforming one string into another. I would like you to review it.
public class EditDistance {
public static void main(String[] args) {
// TODO Auto-generated method stub
String source="COTI",destination ="CAT";
System.out.println(get... |
I have tried to tackle this question as follows:
The program Calculates the next Working day, taking into account:
- weekends (Saturdays and Sundays)
- holidays happening in the middle of the week
param name="OrderDate" the date on which the order is placed
param name="workingDays" the number of workingday... |
As far as I can tell, there is no network access happening at this stage in the code. I am accessing Reddit's API via the PRAW module. However, it is crawling, and I think it should be faster, considering I am hardly doing any work (unless Python heavily penalizes object access?).
This is the entire short script:
impor... |
This is a follow-up on my previous question about a VBA macro for randomizing a draw from a table. It can be found here:
Randomizing Civilization 5 team choice
The code has been improved with the help I got earlier and I now seek even further improvements.
Public Enum CivilizationTableColumns
CivilizationName =... |
Print all the ways of arranging eight queens on an 8x8 board. Rules:
Queens should not share the same row, column, of any diagonal.
Any comment on my solution?
I didn't write unit tests but I checked visually the solutions.
public class solution {
public static void printMatrix(char[][] board) {
// 8x8 board... |
This code is intended to process commands in a CQRS+Messaging system. It will parallelize the message processing to the degree you specify by the msgToIdFn parameter. The function's intention is to extract the target ID from the command message. This will be used to correlate all messages with that ID to the same agent... |
I was wondering if I could get some feedback on the library I created to persist data online.
JitterPushDemo.java
public class JitterPushDemo {
public static void main(String[] args) {
Jitter jitter = new Jitter("scores");
// create hash map to map scores to players
HashMap<String, Stri... |
I'd like to get the indices of elements of an array with particular element. Is it okay or, or how can I make it even better?
//string Input = "Net Sales,COGS";
int[] numbers = { 0, 1, 2, 3, 4, 5 };
string[] Values = { "Net Sales", "COGS", "COGS%", "Gross Profit", "GP%", "Quantity" };
string[] selectedValues = Input.... |
I've built a wrapper for a LocalReport and I would like to hear your suggestions about it:
public class ReportWrapper : IDisposable
{
private string _reportResource;
private LocalReport _report = new LocalReport();
private int m_currentPageIndex;
private IList<Stream> m_streams;
public Dictionary<... |
I have the following script, which filters duplicates and returns only unique values for an array.
When passing false or nothing the "original" array is overwritten, when passing true a new array is created with unique values and returned instead.
The script should work only with numbers and strings.
I would like to kn... |
My Google Maps Script v1
Using the Google Maps JavaScript API v3.
Does my script have any room for improvement (naming, readability, oop, etc.)?
I'm going to pair it with some live time functionality, so that whenever the map its location changes the time would be updated accordingly.
I've added this script to my HTML... |
We just finished working on a Database project in Java Netbeans. We added the feature Import which will import the database record of one user to a text file.
String IMPORT_QUERY =
"SELECT pe.entry_id ID, pe.entry_account ACCOUNT, pe.entry_username USERNAME, pe.entry_password PASSWORD, pe.entry_category CATEGORY F... |
I'm a newbie at programming, just one month into C. Working with Stephen Kochan's programming in C. There is a question in chapter 6 to write a printing calculator where 's' tells the program to set the accumulator, 'e' tells that the execution must end. And the operators tell the operations to be performed on the accu... |
My task is to compute average half spread in percentages on a stream of market. This is part of the coding assignment that I have received.
namespace CodingAssignment
{
public interface IMarketDataFeed
{
string StockName { get; }
event Action<MarketDataUpdate> Update;
}
public interface... |
I've never did a real Project Euler in my life, so I figured it was about to do one.
And what better Project Euler to start with than Problem 42?
Project description from Project Euler:
By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word val... |
I have the following code in PHP that appends a file path with a timestamp of when it was last modified:
function AssetTimestamp($filename)
{
if (file_exists($filename)) {
return $filename . '?' . @filemtime($filename);
} else {
return $filename;
}
}
I have written the equivalent in C#
publ... |
I decided to write a small script to make writing HTML interactive stories less tedious:
import doctest
import re
import sys
import tkinter
import tkinter.filedialog
HTML_START = """<!DOCTYPE html>
<html lang="en">
<div align="center">
<head>
<title>{}</title>
<h1>{}</h1>
</head>
<body>
"""
HTML... |
I have the following code:
if (isMandatory)
{
x.MandatoryServices.ForEach(y =>
{
if (!y.IsSelectedByUser)
{
containsRemovedSrvcs = true;
return;
}
});
}
else
{
x.OptionalServices.ForEach(y =>
{
if (!y.IsSelectedByUse... |
First let me address why I'm not using the built-in string interning. My code is used in a utility that needs to free all of its memory once it's closed. Strings that are interned are not likely to be freed until the CLR is restarted. I can't create that situation since my utility is used on servers that primarily run ... |
I have written a function which generates combinations of string by replacing 1 or more characters by the symbol "*".
The code is as follows:
/**
this following code is responsible to generate all possible combiantions of letters from a
word with *
for eg. word = "fin",
wordSet --> {fi... |
I've just "finished" my second attempt a core game loop, which is a heavily refactored version of my first attempt.
My perceived benefits are:
Using functors means that the actual loops themselves are independent from the actual systems them manage. You can wrap states up elsewhere, and the only assumption they need t... |
I developed a program that collects probe requests from WiFi devices. It already works but I think that a programmer can improve it.
#!/usr/bin/env python
import platform
import threading
import signal
import sys
import time
import subprocess
import re
import os
import os.path
import argparse
import distutils.spawn
... |
I have the following code in a validation module. It works the way I want it to, but it has an obvious select n+1 problem. I would like to refactor this code to make a single call to the db to perform this validation.
Is there a way I can do it using linq or do I need to perform more major surgery? I am trying to avoid... |
I recently did a coding problem for an interview that I unfortunately did not receive the position. So I figured I'd get the code reviewed by other professionals because after asking about the problems with the code I got stonewalled by the organization.
The problem is just serving from an API endpoint using Angular an... |
I have an implementation of a factory like so:
public class CommandActionFactory : IFactory<ICommandAction, XElement>
{
private readonly IDictionary<string, IFactory<ICommandAction, XElement>> commandActionFactories;
public IDictionary<string, IFactory<ICommandAction, XElement>> CommandActionFactories
{
... |
To learn more about OOP, @nhgrif challenged me to implement a Shape abstract class (more details in code remarks below. Here is how I did it. Any and all advice appreciated!
Shape.java
/* nhgrif says:
* Phrancis ready for inheritance/polymorphism?
* Given the following abstract class:
*
* public abstract class Sha... |
My application compiles and seems to work correctly, but this is my first C project so I welcome any criticism. I developed this in Pelles C with no standard lib. Efficiency and optimizations are more important to me than readability or conformity. The parts that I'm particularly concerned about are marked with comment... |
I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language.
You can find the specification for the Hack Machine Language and the Hack Assembly Language here.
I have a working implementation here already. That one took me about 2 - 3 hours. Then ... |
I use NHibernate to search for data in the table Register. It contains monetary registers, incomes and outcomes. Some registers are repetitive, so I have managed to implement a few properties that my C# will check if a determined register is repetitive and loop through its repetition in order to add more registers to t... |
I have the following functions that for the most part are utilizing much of the same code (except for the actual message). What are the possibilities, if there are any, for combining / reducing these functions so that there isn't so much redundancy?
// ACCOUNT DISABLED FUNCTION
function accountDisabled() {
... |
I have a big project called 'PyDOS', written in Python 3.4, and it's going very well. Post your answers of anything that could make it look cleaner.
import time
import os
import sys
import random
import operator
def textviewer():
os.system('cls' if os.name == 'nt' else 'clear')
print ("Text Viewer.")
file_nam... |
This code mimics the "likes" tooltip from Facebook.
Given an array with the list of users that liked the content, it shows the first n users and displays a final item with the count of the users not shown.
It works as expected, but I'm sure it could be better written.
<? if ($count = $this->likes->count()) {
... |
I've implemented both as follows. Could someone be kind enough to just play around with various inputs and let me know if there are any bugs?
#include <iostream>
using namespace std;
/***************************************************************************/
class AStack {
public:
AStack(int);
... |
I was hoping to get some feedback on the implementation of this class for programmatically converting an access file into a PostgreSQL schema (works by obtaining schema data from the cursor object).
import os
import json
import pyodbc
import psycopg2
import time
import sys
# Refer to https://code.google.com/p/pyodbc/w... |
I created a New Event Emailer.
this takes some fun events from a nice SQL query and creates a little HTML message and sends it to all the subscribers of events, when new event types are added we need to be able to tell them that they need to add the events to their subscription if they want to be notified of them.
On... |
I wrote a non-vectorized, non-parallel wrapper function for computing the pairwise distance covariances (Wikipedia) (original paper) in a data frame:
library(energy)
pairwise_dcor <- function (DF, progress = FALSE, parallel = FALSE) {
stopifnot(is.data.frame(DF))
v <- names(DF)
n <- length(v)
corr <- matrix(1,... |
I have been working on this Rational Operations calculator where you can input two rational numbers and can add, subtract, multiply and divide and the final output is the reduced answer.
For example:
\$\dfrac{3}{4} \times \dfrac{8}{15}\$ and the output would be \$\dfrac{2}{5}\$.
I have all but the reducing done i hav... |
I'm trying to make a kind of Dungeon Keeper clone. I got the code up and running and even supporting touch events. But I don't think it's as well optimized as it could be, so I am looking for help and best practices on helping improve my map.
You can test it out and play with it here or for full screen here.
It runs pe... |
I'm completely new to C and my first project is to create a simple cURL-like HTTP request client... but first, I need to create a function that can parse a URL. I've created this function, and it seems to work quite well, but since I'm so new to the complexities of C, can someone check for any errors or to see if I can... |
I've made a little mechanism for creating 2-D vectors in Lua. Vectors have two components i and j, and support addition, dot product, magnitude, and conversion to strings.
Vector = {
new = function (i, j)
return setmetatable({i = i, j = j}, {
__index = Vector,
__add = function (self, v)
return... |
I have several methods that wrap the $.ajax() method and return its jqXHR, but I need to force fail before even calling the original $.ajax() and still allow to use success/error methods of the result.
//just a very simple example, actuall code is more complicated
$.rpc = function(method, args) {
if (!method || 's... |
Codepen Link
I've tried to Google, but there's no library that has an API to toggle table columns when clicked elsewhere on the page, so I've decided to do this:
function deleteColumnOnClick() {
$('.hide div').click(function() {
var index = $(this).index();
$('table thead th').eq(index).toggleClass... |
I used this answer to make a table with datatables.net and dc.js. However, I detected a performance issue in this loop:
function RefreshTable() {
dc.events.trigger(function () {
datatable.api()
.clear()
.rows.add( YearDimension.top(Infinity) )
.draw() ;
});
}
count = dc.chartRe... |
On our main symfony2 application at work I have had to manipulate some outputted grid fields by wrapping them in a hyperlink tag. This happens in quite a few different controllers, so I made a method to do this to prevent code repetition.
I decided to do this using DOMDocument and construct the new hyperlink with that... |
We have a base module consuming the company API. In each app I've written almost always a service per controller. Because most controllers are specific to a entity (a single user, a single post, list of posts written by a user), when I initialize them to query the data I have to request for that Id. So the service requ... |
I have four radio buttons and I want to display relevant contents for each of them if they are clicked. I am using knockout.js for data binding.
Is there a better way to write the if statement block?
<li class="row">
<div class="col-3">
<label>
<input type="radio" data-bind="checked: print_size_radio" na... |
My Google Maps Script v2
I re-factored my code to be more OO.
Does it have any more room for improvement (naming, readability, oop, etc.)?
I'm importing Gmap.js in the head tags and the main.js just before the closing body tag of the HTML document.
Gmap.js
'use strict';
function Gmap(element, options) {
if (!(typ... |
This code works, in the same way that a cardboard bicycle works until you cycle through a puddle. It powers a box that plays a sound file in sync with some lights on movement detected by a PIR sensor. Once the sound file has finished it concatenates some text and two random strings from an array and prints it. Once it'... |
I have an assignment for writing a Sudoku solver and have achieved the functionality required but a lot of the code is "ugly" and I'm wanting to simplify it but unsure how to.
def hiddenSingleCol(snapshot, cell):
j = cell.getCol() # Get column number for cell
colCells = snapshot.cellsB... |
I wonder if the following 301 redirect is the best way for my situation. I used this post on SO to give me the following 301 redirect:
RewriteRule locations\.php$ compare-biomass.php [R=301]
What we've done is changed a filename from locations.php to compare-biomass.php.
The new URL should be:
www.mydomain.com/compar... |
I was asked to write PHP code that can be used to parse a config file on the same server (same directory as well) and output all configuration parameters, and have them all be cast to the correct type. I wasn't allowed to use any of the existing functions made specifically to parse files, all string manipulation.
Class... |
I'm trying to implement a function to determine if a substring is indeed a substring of a string s.
This is what I came up with but I feel that there must be elegant way.
#include <iostream>
bool isSubstr(std::string s, std::string sub) {
if (s.size() < sub.size()) { return false; }
for (int i = 0; i <= s.size... |
Find the kth to last element of a singly linked list
Any comments?
import org.junit.Test;
public class Solution {
// Find kth to last element of a singly linked list
// Solution proposed: Use a runner that is k steps ahead
// when runner hits end of linked list, slow on kth to end element
public Node n3 = n... |
I have implemented a BST from scratch. My aim is to draft better code and understand some pitfalls which I may have overlooked.
It includes the following functionalities:
Insert a new item.
Find the Depth of a node, given the level of root is 0
Find the number of nodes in the subtree of a given node.
While removing t... |
On my educational trek through the capabilities of JavaFX, I thought it would be a valuable challenge to create Tic Tac Toe. It took me far longer than expected to get this far, but despite likely being even further from completion, I'd like a review on the current state of things and on anything my 'blind coding' unwi... |
I'm coding a school project that involves MVC and threading.
This is my Main class. From there I launch the actual client.
public class Main {
public static void main(String[] args) {
Controller myController = new Controller();
ScreenModel screenModel = new ScreenModel();
ChessBoardModel... |
Aim: Read in the userID, check if the userID has 10-digits and check if it not exists in database, when both right, the program will leave the loop.
This code works on my project, but I think its not the most elegant solution. Have someone any improvements?
InputReader.java
public class InputReader {
private Strin... |
Based on dropdown value and search text I need to filter a list and return.
Method 1
if (selectedValue == 1 && searchTerm.Length == 0)
return users;
if (selectedValue == 1 && searchTerm.Length > 0)
return users.Where(user=>user.Name == searchTerm).ToList();
if (selectedValue == 2 && searchTerm.Length > 0)
return user... |
I have created a library which consumes the Imgur API.
This is the main file.
var request = require('request-promise'),
fs = require('fs'),
path = require('path');
var Imgur = function(options) {
this.options = {};
if (typeof options.clientId === 'undefined' || !options.clientId) {
throw new ... |
I have a class Vector3d with 3 double components and want to store several of them in a Field. For reasons of efficiency when sending a Field over a network via MPI, I would like to allocate contiguous memory in the Field class and let the Vector3ds store their components in that chunk of memory. In addition, Vector3ds... |
I have a search form in my application. When I search, it takes too much time to retrieve and display data, so I need to optimize this code.
public void search_thread()
{
Stopwatch sw = new Stopwatch();
sw.Start();
string sqlcmd = "select en.eventname,q.Q,q.QLevel,q.QUsed,q.QType,q.QAlt,q.QStatus,q.QTag... |
Project Euler problem 48
The series, \$1^1 + 2^2 + 3^3 + ... + 10^{10} = 10405071317\$.
Find the last ten digits of the series, \$1^1 + 2^2 + 3^3 + ... + 1000^{1000}\$.
I made two different implementations of this problem, and added a benchmark, using rolfl's UBench library.
The code:
public class ProjEuler48 {
... |
I've created a function that makes a query of a database table and managed to use the results in another page where the function is called.
Is this approach good?
function cart_list($db, $user){
$stmt = $db->prepare("
SELECT
o.username,
o.quantity,
p.description,
p.product_name,
FROM
orders as... |
From the README.md
Introduction:
The purpose of data-in is to read all the lines from a text file and return the file's contents as a Clojure value in a standardized manner.
Specification:
Takes:
Filename
Assumes:
a space delimited text file
Returns:
Vector [L1,L2,...Ln] where Li:
represents a line in Filename
is... |
I am working on a fairly complex (at least it feels complex to me at the moment) search program and am looking to possibly increase the performance. Everything works exactly how I want it to, but I'm just wondering if there are any slight performance increases I could benefit from. In this code, even minor performance ... |
I have just completed problem 29 from the Project Euler website:
Consider all integer combinations of \$a^b\$ for \$2 \le a \le 5\$ and \$2 \le b \le 5\$:
\$2^2=4\$, \$2^3=8\$, \$2^4=16\$, \$2^5=32\$
\$3^2=9\$, \$3^3=27\$, \$3^4=81\$, \$3^5=243\$
\$4^2=16\$, \$4^3=64\$, \$4^4=256\$, \$4^5=1024\$
\$5^2=25\$, \$5^3=125\... |
The following example is an accordion script in JavaScript that does not use jQuery. When I started looking for a simple solution to this requirement I did not accept the idea of having to use a powerful and robust library for a simple implementation. I didn't like the idea of use a machine gun when what I really need ... |
I was tasked with re-writing a login VBScript we use on about 50 machines. The original script was hacked together by someone who clearly had no idea what they were doing (multiple lines that literally did nothing, including creating persistent shares, deleting them, then recreating them 4+ times in a ForEach loop)
I d... |
Assume you have an array of random integers and a sum value. Find all
pairs of numbers from the array that sum up to the given sum in O(n)
time. Find all distinct pairs. (1,2) and (2,1) are not distinct.
import java.util.HashSet;
public class PairsSummingToElement {
public static void main(String[] args) {
... |
The function below converts a time code into seconds, while maintaining the decimal value (fractions of seconds). The time code fed to this function will always contain microseconds. This currently works, but I'd be interested to see how it could be improved/simplified.
def Second_Conversion(x): #Takes a string such ... |
I will post both of the modules, some of the code in them may be "irrelevant" for the main concern here, which is Security.prototype.authenticate(). Nevertheless, comments are welcome about all of the code.
Security.prototype.authenticate() is a controller for a /login API-endpoint.
security.js
'use strict';
var crypt... |
To brush up on my C++ chops, I've implemented a toy version of "SICP Streams", which behave like lists with one twist: the first element of the list is always available, the rest of the list is stored as a "promise" to produce the rest of the list. Calling rest() forces its evaluation.
Following is my implementation o... |
I set about doing it as a challenge (and it's still far from finished) but I hit lots of problems. The main one that caused most of them was it can't deal with even numbers (it can be (1,1),(1,-1),(-1,1),(-1,-1), but nothing with a 0), so I had to multiply everything by 2 and add 1, which caused such a headache later o... |
Question:
Write a function that accepts integer values for day, month and year and returns them in a valid format. If the day is above 30, then convert it to 30. If the month is above 12 then convert it to 12. Similarly, if day or month is below 1, then it converts them to 1. Finally it ensures that the years are betw... |
Consider the following segment of code:
# Fetch my orders
orders = repo.get_orders_for(self._customer[0])
if len(orders) > 0:
current_order_no = -1
for (order_number, quantity, pid) in orders:
# Print new heading if needed
if order_number is not current_order_no:
print("Order #{}".... |
I need to make a library in which I will have synchronous and asynchronous methods in it. And then if there are any exception like TimeoutException or any other exception, I need to log an error into our company's storage system with the logging I have both from synchronous and asynchronous method.
Core Logic of my Lib... |
I like this solution but maybe there is another way. My goal with this is to limit user editing to the amount of credits they have. What do you think?
Here is what it does:
Credits are stored as user meta _credits (int).
Users can only edit pages, posts, custom post types if they have credits left.
Show a proper mess... |
In this code snippet, I want to be able to return the Amount as it is, unless the CashFlowTypeID is 12, 13, 14 or 15, in which case I want to return Amount, but negated.
How can this code snippet be improved? (Would you consider bitwise operations?)
public decimal GetAmount(decimal Amount, int CashFlowTypeID)
{
if ... |
This function will run every x seconds.
PAN: The name we are calling our fixed width file we are transmitting.
Private Sub Start()
' Get the data from the API so we can get ready to make the PAN File
Dim Baker As New PAN.Maker
Baker.SetIngredients(GetAPIData)
' Make the PAN file
Baker.Make()
... |
I need to convert a string value to its primitive type in JavaScript. Other values that are not of type String should just be returned.
Example:
String '34' should be converted to 34
String '34px' should be kept as '34px'
true should return true
'true' should return true
Here is a working example (please look at cons... |
I am trying a trial multiplication for factorization. This is a general example, but each sequence can be specified to pairs of sequences \${p,q}\$ for a given \$n\$. For example, if \$n\$ ended in 3, then {\$p,q\$} would be: {1,3},{3,1},{7,9} and {9,7} with sequence steps of -10 and 10 respectively.
The essence of the... |
This is a follow up to Log probe requests of WiFi devices focussing on a specific element of the code.
How can I indent this code to make it look great and be well formatted?
parser = argparse.ArgumentParser(description='Collect WiFi probe requests')
parser.add_argument('-i', '--interface',
default... |
I've got a function which updates an existing record or inserts a new one, but it looks very clunky to me.
using (SQLiteConnection db = new SQLiteConnection(AppSettings.DbPath))
{
db.RunInTransaction(() =>
{
var y = db.Table<MyClass>().Where(x => x.GUID == this.GUID && x.VersionNumber == this.VersionNu... |
This is a follow up to Log probe requests of WiFi devices focussing on a specific element of the code.
I have this line of code:
airport_path = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
It seems to be too long for Python style standard. Can I shorten it or make it mul... |
This is a follow-up to Log probe requests of WiFi devices, focusing on a specific element of the code.
Can I simplify this code and make it more readable?
if not os.path.isfile(args.tshark_path):
print "tshark not found at path {0}".format(args.tshark_path)
sys.exit(1)
if not os.path.isfile(args.ifconfig_path):... |
I have the following method of some class, which also defines the method isAllowed:
auto filter(const auto& in)
{
auto ret = decltype(in) {};
for(auto x : in)
if(isAllowed(x))
ret.insert(x);
return ret;
}
This is a clear case where copy_if could be used instead. I see two alternative versions... |
I wrote 2 classes in order to implement some basic cryptography algorithm. I tried to use some object-oriented concepts of C++. I'm a beginner, so any comment or suggestion is welcome.
First class: Message
The header:
#ifndef MESSAGE_H
#define MESSAGE_H
#include <iostream>
#include <fstream>
#include <string>
#includ... |
I have recently completed problem 25 from the project Euler site.
The Fibonacci sequence is defined by the recurrence relation:
\$\qquad F_n = F_{n−1} + F_{n−2}\$, where \$F_1 = 1\$ and \$F_2 = 1\$.
Hence the first 12 terms will be:
\$\qquad F_1 = 1\$
\$\qquad F_2 = 1\$
\$\qquad F_3 = 2\$
\$\qquad F_4 = 3\$
\$\qquad F... |
I wrote a simple to use C++ INI file parser. The only thing it requires is the STD libs (of course that come with most major C++ compilers) So far it works very well, and the only thing that needs work is the string parser to handle special characters in the key's value. I.E \", \ \n \r.
You can view the code here:
awe... |
I have this function to remove nodes that matches a certain criteria in the list. Initially when I wrote it, head node was not deleted if head->value was >= delete_value, but other nodes in the list were deleted, so I decided to write the last if statement to only delete and amend the list if head->value was >= delete_... |
I am developing a C# program, which performs various tasks in parallel threads. I created a Base task and let all tasks derived from this class execute. I just want to know if this a viable approach which won't cause unforeseen consequences if various tasks run in conjunction.
public abstract class BaseTask
{
priv... |
Use Case
The third party library that I am working with implements its data model in this fashion.
Interface
- Implementation (24 different implementations)
- Interface
- Implementation (variable number of implementations)
- etc...
Unfortunately, none of the interfaces have definitions fo... |
I am writing a conditional that checks two values, for several different scenarios.
What I am modifying is a series of objects, some of these objects are in arrays, and some are just arrays. I need to check these values and then check a file, and then check my values (the series of objects, array objects, and arrays) a... |
I wrote some code which simply retrieves the HTTP status code of the passed in URL. There are multiple potential causes of the same error. I am hoping to get some all around feedback on this code, but my primary concern is that I have low readability in an attempt to provide good feedback in the event of an error.
pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.