instruction stringlengths 71 71.9k |
|---|
The title pretty much explains everything. I'm try to check if a line in a file contains user.Handle and '-r'+any single digit number, AND that the aforementioned user.Handle does not contain '-r'. I'm sure there is an easier way to do this. And I'm sorry if this made your eyes bleed.
if (line.Contains(user.Handle) && ... |
I am an absolute beginner. This is the first thing I've ever coded in VBA. I don't know if I'm allowed to ask for just criticism in general without a question.
But just in case I can't, this file is going to get very large and I imagine I will have resource optimization problems - so what should I have done differentl... |
This function derives a 'stars' rating from a product score that is retrieved from local storage. What would be the best way to refactor these else if statements?
$scope.ratingStars = function(productID) {
var bottomLine = $filter('filter')($localStorage.bottomlinesObject.bottomlines, {domain_key:''+produ... |
I need to know if I am going in the right direction with my code so far. I am really trying hard to transition from procedural, page-based programming into OOP MVC. So far I have written a simple router, and MVC for updating users.
First, my index.php file acts as my bootstrapper.
index.php:
// start session
session_st... |
Here is my code for checking to see if two strings are anagrams. This seems a little short. Am I missing anything? Both time and space complexity seem to be \$O(1)\$.
//Determine if a string is an anagram
//Time complexity: O(1)
//Space complexity: O
#include <iostream>
#include <string>
using namespace std;
bool an... |
I have made a multi-platform Snake clone in C++ using OpenGL and GLUT. I am a beginner in graphic game development. I would like to add more features, but I have programmed the base game so far. I would love it if you could review my code and tell me how to make it better.
#include <ctime>
#include <deque>
#include <GL... |
I just wrote a cows and bulls implementation in Rust. It seems a little large. Are there any changes I could make while still keeping it easily readable?
extern crate rand;
use rand::Rng;
use std::{io,process,str};
fn input_check(s: &str, size: u32) -> bool{
//Check if number is positive valid number
let mut r... |
This is a problem from Project Euler and on Hackerrank (here)-
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible
(divisible with no remainder) by all of the numbers from 1 to N?
Input Format Fir... |
I would like to use C to implement the following formula:
$$\mathbf S(u,v)=\sum_{r=i-p}^{i}\sum_{s=j-q}^{j}N_{r,p}(u)N_{s,q}(v)\mathbf P_{r,s}$$
Namely,
$$
\left(N_{i-p,p}(u),\cdots,N_{i,p}(u)\right)_{1\times(p+1)}
\begin{pmatrix}
\mathbf{P}_{i-p,j-q} & \cdots & \mathbf{P}_{i-p,j}\\
\vdots& \cdots &\vdots\\
\mathbf{P}... |
Could this code be improved? Would you suggest more sophisticated way of doing client-side signup validation?
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var name = document.forms["registrationForm"]["username"].value;
if (name == null || name == "") {
... |
Part 1 here.
I improved my code from my previous question (linked above).
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Used to store data as bits. Acts as a queue - first data added is the first data removed.
/// Data should be read in the same order it is written. If rea... |
I'm a beginner and self learning programming students. While learning binary tree data types, for the sake of understanding graph theory and other interesting programming problems, I've writen the below implementation. Would you please suggest if there's anything wrong or either this can be improved.
It may seem rein... |
I've implemented an identity function (well, actually a functor struct) in C++. The goal is that every occurrence of an expression expr in the code can be substituted by identity(expr) without changing the semantics of the program at all.
I make it a struct with a templated operator() instead of simply a function templ... |
I tried to implement a queue using two stacks. I saw there are questions about this topic, but in my example, I used build-in stack from java. My question is, can someone give me some advice to make my code more efficient or better (in turn of class structure, for-loop, etc)?
This is for practising and understanding ho... |
Although my code works as expected, there are a few gotchas.
A single row is not filled at once; instead, I can see partially filled rows during the rendering process(Fixed in the updated code below.).
The application still feels slow; can it be optimized further?
And the biggest thing, how can I make the code more OO... |
I am currently using Python 3.5.2 to create a connect four basic game. My game should work for two players and tell you when you have won, be it horizontal vertical or diagonal. However I do not know how to make my code smaller or more efficient, is there a way to cut down, or is my method just not very efficient in it... |
This is my improvement of a minesweeper game I took from the internet, which I am quite proud of. Nevertheless I am willing to hear your opinions, suggestions, and comments.
/* Minesweeper V2.0
Written by:-Shivam Shekhar
Improved and understood by Eshel BM*/
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#in... |
I'm working on a node.js bindings for libcurl. As libcurl accepts many callback functions as options (like CURLOPT_READFUNCTION for example), I had to store their respective javascript callbacks somewhere when those options were set.
Initially I had the following class members (Easy.h:71):
Nan::Callback *cbChunkBgn;
Na... |
What are nonogram tables?
Nonograms, also known as Hanjie, Picross or Griddlers, are picture logic puzzles in which cells in a grid must be colored or left blank according to numbers at the side of the grid to reveal a hidden picture.
There are two kind of nonogram tables, ones with only one row and column, and kinds... |
I'm currently working on my first project and I have been programming in python for 4 days now. I currently have a dilemma where my code is running too slowly. I don't want you to make a full review, I am mostly interested in advice on how to optimise my code. Here is my code:
Note that the comments aren't perfect Engl... |
My code creates a "grid" of empty places, where 0 is used as the place holder, in a size specified by the user.
I was wondering if there were more efficient ways of doing this,or perhaps ways that make more aesthetically pleasing grids with less code.
My code is in working order and does as it says on the label, I also... |
I've gotten a lot of feedback about my tracking system already. So now I'm changing gears and looking at my email generation system. I have a class called Email which manages the sending of emails, validation of user email addresses, and validation of whether the user is a permissible "victim". To do this, I created a ... |
I'we created an interface that communicates with Postman collection and Jira api more precise the Xray addon for jira.
I would much appreciate if you could give me notes on how to improve this code.
Adding variables in constructor, too loosely maybe.
Function add_steps_to_test_case_v1 and add_steps_to_test_case_v2 cou... |
I am fairly new to C++ programming and I, so far, love it. I just have been trying to make sure what I am doing is fast, unique, readable, and efficient. Is there anyway I can improve this code, or is there ways I can improve my coding convention (in C++)? Here I wrote a program that generates a 20 random vectors of bi... |
Yesterday, I gave an interview after a long time, and I was asked a question which I couldn't solve on the spot.
I had to implement a sort function for a Array of strings in JavaScript, with the following requirements:
The Array will always contain Strings
For sorting, Upper Case has higher priority than Lowe Case Let... |
This function of my program is searching a file that is formatted as first_name last_name rate hours:
John Smith 25 80
Mary Johnson 15.5 60.0
...
With one space between each item.
The user enters the first name and last name of the employee and while the line is not equal to null it searchs for the employee. If its f... |
I have a seemingly simple issue. Consider this list:
a = [[12.0, 5.0, 63.0], [0.1, 2.0, 7.1, 3.0, 2.3, 5.0, 8.4]]
I want to find the mean (using numpy) of all the elements in its sublists combined. In this case the result should be:
10.79
obtained as:
np.mean([12.0, 5.0, 63.0, 0.1, 2.0, 7.1, 3.0, 2.3, 5.0, 8.4])
The... |
I have the following bash script that:
Finds all files with .cfc and .cfm extension and converts them to lowercase
Stores the relative file paths to those files (filenames.txt)
Chops those files to get only the name, excluding the extension (files.txt)
Loops through 1500 files checking for references to any of the oth... |
I have a simple Angular application that lists some object requests from a backend, allows the users to click once to edit the item, and then click again to update the object in the backend.
Here's a Codepen demonstration. I've replaced the backend service in this Codepen to return a $q promises, rather than making act... |
Task:
This function searches given null terminated string pStr by given subset of
regular expression pMatch.
Return value is matched string appeared in pStr.
If nothing has matched, return value is empty string.
The subset of regular expression grammar is defined as follows:
A string is set of 8-bit characters. Beware... |
Was fiddling with java-8; trying to write a program for getting all Armstrong Numbers between 1 and 10_000_000.
Following is my working solution:
public class ArmstrongNumbers {
public static void main(String[] args) {
IntStream.range(1, 10_000_000)
.filter((n) -> {
int ... |
Following code has some issues:
$args = func_get_args();
$paths = array();
foreach ($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
$paths = array_map(create_function('$p', 'return trim($p, DIRECTORY_SEPARATOR);'), $paths);
$paths = array_filter($paths);
return DIRECTORY_SEPARATOR . join(DIRECTORY_SE... |
This will be my last question for awhile. Thanks for your interest in my take on splicing enumerables together, object instantiation in constructors via illumination, and of course, my 100% accurate but considerably slow prime number computer.
For this last post, I ask that you consider the abstract notion of a tree. ... |
Triggered by an interview question (I didn't answer during the interview) I wrote a Java program to reverse a linked list. I went with a loop-based approach instead of recursion. I would like to know the following:
Is the reverse() method efficient as it is, or can it be improved?
Are the inline comments inside the re... |
I'm writing a package that is designed to provide a convenient way to inspect the schema for a database. The goal is that I can use it for generator code to suit the schema. The complete code can be found at https://github.com/courtney-miles/schnoop.
For example, I have classes for IntType, VarCharType, BlobType, etc... |
I'm developing a Java 8 + JSF application, where all the view classes extend from an abstract class called Navegable.
All the methods called from the view and intended to modify the DB in any way, have to add an information message if everything goes OK or an error message otherwise. This involves wrapping many of my ... |
Recently I started programming with python.
Today I was trying to make a stone, paper, scissor game. After so scratching my head long time, finally I got a working code.
from random import choice
def play_again():
print "Do you want to play again:- Choose 'yay' or 'nay'"
user_again = raw_input('->')
... |
In my ongoing effort in learning advanced JavaScript I tried to develop the traditional rock paper scissors game by using the famous revealing module pattern. I'm not comfortable yet with what has to be Private/Public. In my solution, I decided to have a single public function: Game. It uses a lot of private stuff and ... |
I have to read some data from xml file and then need to store the converted json in the database. The class DtoProcedureXml mapped with xml attributes.
public class ProcedureManager
{
#region Declaration
private DtoProcedureXml procedure;
private ProcedureDataManager procedureDataManager;
#endregion
... |
I made this class (MFC lib) to write a log files. Eventually I want to implement this code in a thread safe way.
Log.h
#pragma once
class CLog
{
public:
CLog();
~CLog();
int CLog::Log(CString log);
void CLog::TWriteAllToLog();
};
Log.cpp
#include "stdafx.h"
#include "Log.h"
#include <queue>
#include <m... |
Previous Question: Armstrong numbers in a given range using Java 8
Updated program for getting all Armstrong Numbers between 1 and 10_000_000 as per the suggestions in this answer.
public class ArmstrongNumbers {
public static void main(String[] args) {
IntStream.range(1, 10_000_000)
.filte... |
I'm trying to compare several files using md5 hash with powershell 2.0. The code works, the problem is that it's to slow. It takes longer in step 3. It's about 500 files to compare. Can you see a way to get it faster, like, don't do the step 3 every time?
write-host "1"
$COMP_ORI=$LOCAL_HOME+"\"+$PROG+"\"+$COMPARE
... |
I am attempting to put my new OOP skills to the test and am eventually going to build a simple OOP login/registration system.
However as I am making use of OOP I have decided to make my own simple MVC.
Here is my layout of my directory
root-directory/
.htaccess
app/
Config/
Controllers/
Models/
... |
I have function that processes text and returns it in altered state. Result of the processing is a property list with following properties of interest:
:success - t if processing finished correctly
:text - complete changed text
:changedLines: list of changed lines as 2 element vectors [number-of-line line-text] (numbe... |
It's not fair that 1% of the users hold 75% of the lolcode questions. #OccupyMatsMug
~ user2296177
I agree. Without further ado, here's the LOLCODE version of 99 bottles of beer on the wall:
OBTW
PRINT TEH LOLCODE VERSHUN OV N BOTTLEZ OV BER ON TEH WALL.
TLDR
HAI 1.3
HOW IZ I COUNTDOWN YR NUMAH
I HAS A NA... |
I have few models like this below for diferent tools i manage. I am trying to clean/improve the code... Could you help me?
All the informations comes inside columns B to N, and the column P concatenate it with ";". There are 6 sheets i do the same thing.
Any ideas to have a better performance and cleaner code?
Private ... |
I created an application using multiple threads defined in multiple class files which read and write into a "shared variable" (a dictionary).
To ensure thread-safety, I am using a Lock, and I pass it as argument to my Thread class next to my variable.
What bothers me is that two objects which are intrinsically linked h... |
Our solar system has 8 planets, including earth. Our calendar has some very confusing concepts such as leap years, which I still don't fully understand. In fact, since where I live, we use a different solar calendar that is different from the Gregorian reforms of the Julian Western calendar, I think I'm born in March b... |
@Pimgd gave some good feedback on the previous post. I've made the changes that I think best suit my application and am looking to see what people think of this implementation.
PhishingController
/**
* sendEmail
* Function mapped to Laravel route. Defines variable arrays and calls Email Class executeEmail.
*
* @pa... |
For an assignment (not school), I was supposed to make a "web browser" using Scapy.
While storing the response, I initially thought of
# got an array of packets using sniff() named responses
ans = ""
for pack in responses:
ans += pack[Raw].load
But that clearly doesn't work if one of the ACKs gets lost or with any... |
Please look at the above code
#include<stdio.h>
#include<stdlib.h>
void mergesort(int *,int ,int);
void merge1(int *,int ,int ,int);
int main()
{
int low=0,high,n,i,a[100];
printf("Enter the lenght of array\n");
scanf("%d",&n);
high =n-1;
printf("Enter the array that you want to sort\n");
for(i=low;i<=high... |
I have a function that receives a String like the following:
"-10.0 -10.0,10.0 10.0,0.0 0.0"
And needs to translate that into a Seq[Coordinate] that would look like this:
Seq(
Coordinate(-10.0, -10.0),
Coordinate( 10.0, 10.0),
Coordinate( 0.0, 0.0)
)
Here is the function that I wrote to achieve this:
... |
This class represents a single query on an Active Directory. It is given the type of query to run and the types of data to return, and performs the query and returns the data when it is commanded to do so.
The goals I had with this class were to ensure that the query is run async so it doesn't freeze (and crash) the UI... |
I implemented quicksort using iterators. I am will be grateful, if someone can review my piece of code. BTW, I am just selecting the last element as the pivot (which I plan to randomize later) I am mainly looking for the following:
1) Correctness of the Implementation
2) Correct usage of iterators
3) Basic coding styl... |
I recently completed a programming task in Java for a job that was javascript heavy but the hiring company wanted some Java knowledge. I've been using Java since the turn of the year. Other than learning on the job I've read Clean Code and thought I could have a go at this task. Clearly I failed because the recruitment... |
I am using codeigniter framework in PHP. In signup form I have:
Controller:
$info['csrf_token'] = array('signup'=>$this->csrf_token('signup'));
echo $this->load->view('/signup',$info,TRUE);
// generate token:
public function csrf_token($form_name){
if (function_exists('mcrypt_create_iv')) {
$t = bin2hex(mc... |
I wrote a function to find all the possible permutations of a list in Haskell. I know it can definitely be optimized, but I'm not sure how. I'm pretty sure foldl or foldl' can be used, but I'm not sure how. It gets kinda slow when the size of the argument for perms is more than 6 items, but I don't know if this is avoi... |
In my python code, date formats are stored as "strftime and strptime syntax". For instance %d/%m/%Y %H:%M.
On the client side, I use pickadate.js which format is rather dd/mm/yyyy HH:i.
So I have to translate %d/%m/%Y %H:%M to dd/mm/yyyy HH:i before sending a datetime format to the client.
I first thought str.translate... |
After reviewing this approach:
Rock-Paper-Scissors with the revealing module pattern
I decided to write an alternative where the Revealing Module Pattern is used for the UI, model, and controller.
I am open to all feedback from style to design.
// noprotect
var roshambo = (function() {
var UI = ( function contai... |
import math
import time
import sys
import random
import os
def isPrime(number):
if number % 2 != 0:
for i in range (3,math.floor(number**0.5)+1,2):
if number % i == 0:
return False
else:
if number != 2:
return False
return True
def makeListInts(lst):... |
I've implemented a C++14 for_each for tuple-like objects. It's similar to std::for_each in that it also returns the functor once it's done. Usage examples:
With a visitor functor:
// visitor functor
struct print {
void operator()(int x) const { std::cout << "int: " << x << '\n'; }
void operator()(double x) cons... |
I had a need for some inventory management in a recent project. I decided to create a custom struct for managing the concept of a number range. It allows for easy navigation of a collection.
It function similar to .NET's own Enumeration classes, with extension methods, wrapper classes and so forth allowing for dealing ... |
To learn Scala, coming from Java and Python, I'm attempting to program an implementation of Conway's Game of Life.
I've implemented two different approaches so far, with the first being so bad I'm not even going to ask for review.
The second is a bit cleaner, and produces the correct output, but since I'm new to Scala,... |
I am having a serial port communication application using 3 serial ports DMX (m_port,m_port1,m_port2) which will run 24 *7 , so i just need to ensure memory usage doesn't go above limit with using(), Idisposable and minimize use of global variables.
Start method to start sending hex data continuously till i stop it usi... |
The jQuery code is for html5 video event GA tracking and I want to make it a little bit more shorter and cleaner. The code works: I am getting all the events, but would like to make it more simple.
function videoEnd() {
console.log("Finished");
ga('send', 'event', 'Videos', 'Finished', 'omegavideo');
}
$(docume... |
Please look the code below
#include<stdio.h>
void quicksort(int *,int ,int);
int partition1(int *,int ,int);
void swap1(int *,int *);
int main()
{
int low = 0;
int length;
int i;
int a[100];
int high;
printf("Enter the length of array\n");
scanf("%d",&length);
high=length-1;
printf("Enter the array elememts\n"... |
I am working on a image slider for a website, the user can add up to 0 - 3 images to the slider. What kind of loop should I use to make this code more efficient and DRY? "data-slide-number" starts from 0 and changes based on the image. The images are not "required" so there won't always be 3 images.
<?php
// image url... |
The Country, State and City functions accepts the Integer as Parameter and returns the relevant error code if the validation fails in ValidateNotExist Class.
Therefore, I have enhanced the ValidateNotExist class with a slight different implementation (using switch) and named it as ValidateNotExistImproved.
But I think,... |
What I wanted to achieve is tableView with clickable cells, anytime somebody click a certain cell, another cell with picker, UITextField etc appears below, it's like a dropdown menu.
When browsing Stack Overflow, I saw many people suggest using tableView methods such insertRowsAtIndexPaths and deleteRowsAtIndexPaths.
T... |
The purpose of the OCaml code below is to decompose (or "parse")
a string into parenthesed (or possibly non-parenthesed) blocks.
(*
Decompose a string into parenthesed blocks.
Sample example at the end of this file
*)
type parenthesis_pair=PP of string*string;;
type data_for_decomposition={
mutable partial_resul... |
Is the code part in the finally block well handled or should I do it in another, more cleaner way.
private TestClass() throws Exception {
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
try {
// Codeblock
}
} finally {
try... |
I've been learning a lot about functional programming lately and I've recently started learning Haskell to which I'm very new.
I've written a simple number guessing game and I would like to have feedback on what is good or bad about my code and how it could be improved.
#!/usr/bin/env runhaskell
import Text.Printf (pr... |
I did an assessment task where I had to implement the game snap. The description:
Simulate a simplified game of snap between two computer players using N packs of cards (standard 52 card, 4 suit packs). A game of snap proceeds by shuffling N packs of cards and then drawing cards from the top of the shuffled pile. Each ... |
This interesting idea came up when I was designing the for_each for tuple-like objects in this post. The for_each in that post makes it possible to write code like:
auto t = std::make_tuple(42, 'c', 3.14);
for_each(t, [](auto x) { std::cout << x << '\n'; });
But unfortunately, this way we can only iterate over the ent... |
What do you think about this implementation of 2 floats comparison functor considering how tolerance is introduced?
class Less
{
private:
float m_tolerance;
public:
Less(const float tolerance)
: m_tolerance(tolerance)
{
}
bool operator()(const float f1, const float f2) const
{
... |
I wrote this question asking about how to implement my error handling while still maintaining functional code and based on 200_success's very interesting note on the spaces, I decided to trim() the String first, but I wanted to avoid using try/catch blocks and use more of Scala's specific features, so I thought of a so... |
Recently I started a blog project. It is my first time that I create something so advance. I use task runners, SEO optimization, preprocessors, I will code in full stack environment and all the other stuffs that needs a project.
After many days, structuring my page through UX and UI, think about HTML5 tags usage and k... |
I have programmed a Gaming Emulator in C# and I have a class to handle all the connection side of things for the player, here we continuously listen for packets (each packet has a ID like a number, from 1 - 300), I just wondered is there any way I could speed it up or make it better performance wise? It seems a bit mes... |
I have a long list of data pulled in from a csv file that has comments / descriptions scattered throughout the document. I'd like to collapse the descriptions into the last element of each row of data, and my current solution seems slow and overly complex. Rows with data have values in the first index and description r... |
I need a simple dispatcher implementation(invoke methods on one thread from many threads)
once you dispatch method curent thread should wait for results, so I'm thinking about something like this:
public class Dispatcher
{
private readonly BlockingCollection<Tuple<Delegate, object[]>> runQueue = new BlockingCollec... |
(See the previous and initial iteration.)
This time, I use tag dispatching in order to make sure that non-random access iterators are not put into a std::distance, which would take \$\Theta(n)\$ time to complete, but instead, computes the distance while making the only pass over the data. See what I have now:
coderodde... |
Seeking recommendations on how to improve this code, LL always seem to be a struggle.
A basic linked list that does include next and previous pointers. I used a struct inside of a class, which I'm not sure if that's frowned upon. The program includes 5 basic member functions, one to add to the head of the list, one to... |
I'm reading big csv files and mashing the lines into hierarchical objects for analysis and display. The csv might look like this:
YEAR,QUAD,SPEC,FIASP,COND,SZ2,SZ3,SZ4,SZ5,SZ6,SZ7,SZ8,SZ9
1984,4D1,1,129,1,1,0,1,1,0,1,3,0
1984,4D1,8,371,0,0,0,0,0,1,0,0,1
1984,4D1,9,375,1,0,0,0,0,0,0,1,0
1984,4D1,1,129,0,2,0,1,1,1,1,1,0... |
EDIT
The previous proxy code, after thorough testing, had issues with the stream_copy_to_stream() when sending from $client stream to $dest stream, and vice versa. I have rewritten the code to remedy that issue:
set_time_limit(0); // Run server indefinitely, or until SIGINT (CTRL+c)
$destination = '172.16.12.1:125'; /... |
Usually I don't start using pointers for a few microseconds here and there.
But with this implementation I started getting results of factor 2.
using System;
class BenchmarkPointers {
public static void Main() {
#if ALLOW_UNSAFE
Console.WriteLine("This is safe code");
#else
Console.WriteLine("This ... |
I'm writing a little C program that computes matrices (for learning purpose). The matrix is fed through arguments in the following form : "{{43,543.324,34},{43,432,87}}"
The user doesn't give the dimensions.
I have solved this problem two times in two different ways:
Short series of entangled if / else / mess
Kind of ... |
I want to build a small console program, that for given directory, will print (for now) all files inside that tree.
Here is an F# script that I came up with:
open System.IO
let getDirObjects (dir :DirectoryInfo) =
let dirs = dir.GetDirectories()
let files = dir.GetFiles()
dirs,files
let rec traverse allFi... |
A Rule of Divisibility by 13
When you divide the successive powers of 10 by 13 you get the following remainders of the integer divisions:
1, 10, 9, 12, 3, 4.
Then the whole pattern repeats.
Hence the following method: Multiply the right most digit of the number with the left most number in the sequence shown above, th... |
Edit: I have added the revised code in an answer to this question.
Currently, I handle the keyboard shortcuts of my applications in a single huge method that looks like this:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Next issue (validate the fix)
if (keyData == ... |
This is part 2 of the previous question asked which is at - QuickSort C++ Implementation using Iterators.
Based on Jerry Coffin's answer, I have made the changes except for using templates.
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
typedef std::vector<int>::ite... |
As suggested by @MikeBrant in the previous question, I've added in two configuration classes to simplify and more broadly organize the objects required to send my mail messages. This also removes the need to actively read and write with the .env file. I did not have time to write new PHPDocs for any of the changes toda... |
I've been working on refactoring a piece of my code that allows a user to add items to their cart. Each product can also be added with different attributes. Thus if somebody adds the same product, with matching attributes it shouldn't be added again. It should just increase the quantity by += X where X is the quantity ... |
While reviewing another Scala implementation of the Game of Life, I ended up drastically rewriting it. The board is represented as a Set[(Int, Int)] containing the coordinates of the live cells.
I'm not sure whether the case class is appropriate here, and not too happy about the long parameter list. I'm also dissatis... |
Here's the implementation of a common data structure I use at work, mainly for logging purposes.
I tried to make it C++11-compliant, but even if this standard has been around for a few years, it is still quite new to me since I play with it only in my spare time (locked on VS2010 at work, which has a poor implementatio... |
So I'd like to get a performance boost above and beyond standard Julia matrix-vector multiply, using my Intel HD Graphics 4000 1536 MB GPU, but I can't do better than an order of magnitude worse performance.
The kernel I'm using is based on this approach. I don't know how ArrayFire gets such fast speeds, they're clear... |
This is (yet another) integer to Roman numeral converter.
To give it a slightly interesting twist, I've implemented this as a num_put facet of a C++ locale, so by creating the right locale, and imbuing a stream to use that locale, all the numbers written to that stream will be written out in Roman numerals (yeah, I kno... |
For a theoretical modelling course for biology students, I am trying to decide which would be the best technical programming language for doing evolutionary simulations in terms of elegance and compactness, whilst still being performant (this is for simulations, for analytical stuff I am using Mathematica).
As a simple... |
I am trying to validate that when given two lists,
List<String> models;
List<String> titleOfVehicle;
that one of the models must be contained in each of the titleOfVehicle.
For example, given the following:
models = {Accord, Civic, Element}
titleOfVehicle1 = {2014 Honda Accord, 2011 Toyota Camry}
titleOfVehicle2 = {20... |
I have a working shell sort code. I had already written a code for insertion sort, which I have used as underlying algorithm for doing shell sort on sub lists. So if you pass value of gap as 1 to method insertionSortNew, it would become a normal insertion sort. Can this code be improved ?
Shell sort reference link
imp... |
I created this code and it works fine, but I think it's ugly. Could you show me a better way to create a list of three different random numbers from 1 to 9?
class Baseball_Engine(object):
def __init__(self):
self.count = 0
self.random_number_list = [0, 0, 0]
while self.count < 3:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.