instruction stringlengths 71 71.9k |
|---|
I want to find total word count in string. I have two methods as mentioned below.
public static int Wordcount(string strName)
{
bool wordfound;
int ctr = 0;
for (int i = 0; i < strName.Length; )
{
wordfound = false;
while ((i < strName.Length) && (strName[i] == ' '))
i++;
... |
The array size is <= 16. The difference is defined as:
diff[i] = array[i+1] - array[i];
I need to find the number of permutations of the original array, which have a difference that is a permutation of the difference of the original array.
This is my code:
public class Main {
Scanner scan = new Scanner(System.in);... |
I have this currently working code, but it's extremely slow. I'm talking almost an hour to execute, if it executes at all (our server isn't all that great to start with). Is there a better way to write this?
Basically, I am wanting to return the Top 5 parts, that match a distinct pattern code within the same table. So,... |
I'd like comments on the following code, explanations, etc. are given in the javadoc:
package ocr.base;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import ja... |
I have a small animation with Raphael using a large amount of code. Is there any way to reduce it?
Demo
window.onload = function () {
var elements = document.querySelectorAll('.colbr');
for (i=0; i<elements.length; i++) {
var loadSpinner = spinner(elements[i], 7, 12, 10, 3, "#000");
}
};
function ... |
Please let me know what you think. Is the code well written? Am I using best practices (like when I chose === over ==)? Is my script too verbose?
Note: I'm only asking because the tutorial I'm using is a little old.
/* A login script to that checks two users and their
corresponding passwords and then greets one of th... |
I am making this program that is going to calculate distance from randomly generated dots (with x and y coordinates) to 5 bigger ones and then its going to put each smaller dot into the group with bigger one that is nearest to it. So, i am making this with classes and every dot is made as an object. I made 2 arrays of ... |
I wanted to avoid running the code HttpContext.Current.Server.MapPath every time file_path_includes is called.
Is the below an effective way of doing so?
private static string file_path_includes_;
public static string file_path_includes
{
get
{
if (file_path_includes_ == null)
file_path_incl... |
I have created a small crypto extension and I want a deep review of it, such as possible fixes (for hidden problems) and tweaks...
1- Crypto.cs
public static class Crypto
{
public static Salt Salt = new Salt();
public static string GetMd5Hash(this string input)
{
using (var md5Hash = new HMACMD5(S... |
Here is a code that guesses the number chosen by the user. I know that using goto is a bad practice, but it seems unavoidable here.
that's because using do while doesn't work, for example:
do{
scanf("%c",&variable);
}while(variable == 'a' || variable = 'b' || variable = 'c');
would accept all letters while I want... |
I am beyond stuck in a half way point between PHP structural and OOP, but I can never achieve proper SOLID patterns despite reading DI, IOC, and reading about the interfaces.
Rather than to read logical examples (i.e. a storage class that takes a book class and you typecast an interface etc...). I want to know how I c... |
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
Not all numbers produce palindromes so quickly. For example,
349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337
That is, 349 took three iterations to arrive at a palindrome.
Although no one has proved it yet, it is thought that some numbers,
... |
This code was already reviewed, but the reviewer missed many points of my code. Most of the following question is from the previous review.
I have written a system for handling the dispatch of events between objects. I need this functionality for a larger project I am working on. Objects should be able to dispatch even... |
I've been programming with Python 2.7 for about six months now and if possible, I'd like some critique to see what I might have done better or what I might be doing wrong.
My objective was to make a script scraper that finds variables and functions, outputting them to a text file along with their line number. It also o... |
This is about my first backbone.js application. It is a small directory that fetches data and presents it in a search-like UI.
Here is a working (minified) example.
Here is the file that handles everything
window.Directory = function() {
"use strict";
// Create the view and listen to main events
this.view... |
Is there a better way to pass variables into a class?
public class Truck
{
private int _wheels;
private string _color;
private bool _loaded;
public int wheels { get { return _wheels; } }
public string color { get { return _color; } }
public bool loaded { get { return _loaded; } }
public Tru... |
I have the following code which basically takes a list of sorted integer arrays and merges them together removing the duplicates.
I have tried to do the complexity analysis and came to a rough conclusion that it may be O(n2) order. Could you please see if my understanding is correct here.
Also, if you could sugge... |
I'm writing a simple remote PC app (mouse-keyboard). Android is the client and is connected with WiFi to Java PC Server. I'm using TCP but I see a bit of latency compared to other remote apps. I'm sending a String to Server like these: "a","B","2".
Why am I getting latency sometimes? When I press any key, sometimes som... |
This is just some test code I'm doing to learn C++11. It compiles and runs consistently. But is anything wrong that will eventually (or under slightly different circumstances) fail?
Besides additional refactoring for sheer cleverness, are there any notable improvements that can be made to remove lines (like unnecessa... |
Project Euler problem 3 asks for the largest prime factor of 600851475143.
I have gone from 96 lines to 17 lines taking hits at this one. This is what I am left with after all of that effort:
public class IntegerFactoriseFive {
public static void main(String[] args)
{
long n = 600851475143L;
f... |
Someone asked if their singleton is good for OOP:
Using a singleton class to get and set program wide settings.
However, the answer just provides tweaks to his existing code - but the question wasn't entirely answered. What is the best practice to use for configuration files so that it doesn't become spaghetti code?
Al... |
This draws blocks on the screen from a grid to make a background for my game. I am wondering if anyone has any suggestions on optimizing it for speed.
int blockwidth=blocksize-2;
//Draw coloured blocks
for (int x=0;x<sizex;x++){
int screenx=-(int)camerax+(x*blocksize);
if (screenx>-blocksize && screenx<gamewid... |
For practicing reasons I would like to write a method which inserts a character into a string.
I would like to know:
What is the best practice concerning placement of a comment within methods? For example, is the way that I commented about what raises an exception fine, or are there better practices? Would I need mo... |
I'm creating a location-based reminder application in Android using proximity alerts, geocoder, Google Maps API and their Places API.
Currently there is a default ListView using a Cardlibs library and a button for a new reminder, which then asks for the 'subject' and 'location'. There is a button for a map to allow the... |
I have a method that reverse each word in a string. I want to know how I can increase it's performance and memory efficiency. Ideas I had in mind were simply using char[] instead of strings being that strings are immutable and each time I concatenate the Strings, I am creating a new String object which is not efficient... |
Could you please see if they are no bugs in this implementation? I am especially interested in knowing if there could be here any multithreading problems (such as race conditions).
It is written in C# for .NET 3.5.
public interface IAsyncOperation
{
OperationToken Token { get; }
bool IsCompleted { get; }
E... |
I've been programming for about 4 months now, just trying to learn by myself. I've tried my way with coding the Game of Life here, would like some general feedback as well as some pointers on how I can speed it up because right now it seems to run incredibly slowly. Keep in mind I'm a newbie so I would like some easy ... |
To learn tree traversal i implemented os.walk, tail-recursive and stack-based. Unfortunately Python doesn't support tail call optimization. How do i rewrite my function so that it is maximally functional paradigm compliant? I want to keep side-effects to minimum yet not dive into deep recursions.
def walk_rec(path):
... |
I have a navigation controller set up with a user code and password and a log in button. When the user clicks on the Log In button or the return key on the keyboard on the password text box - the program checks if the user code and / or password is blank. It then goes off and calls a Web API running on a server to see ... |
I've created a program to calculate Pascal's triangle:
#include <stdio.h>
#include <stdlib.h>
void pascal(int limit)
{
int *begin;
begin=(int*)malloc(2*sizeof(int));
*begin=1;
*(begin+1)=1;
int* p,q,s,t;
int row=2,n=3,x;
p=begin;
q=begin+1;
for(n=3;n<=limit+1;n++)
{
if(n=... |
Just a slug generator. I'm wondering if this can be simplified any further.
Many thanks.
<?php
function slug($string) {
// Replace all non letters, numbers, spaces or hypens
$string = preg_replace('/[^\-\sa-zA-Z0-9]+/', '', mb_strtolower($string));
// Replace spaces and duplicate hyphens with a single hyp... |
I have a list of months in which users are required to update some data. I want to determine at what date they should have updated their data. They must update in March, May and August. If today is March, I want to get back the 1st of March. If today is February, I want to get back last year's August. In reality the li... |
var root = this;
root.node = function(path, type) {
root.type = type;
this.type = type;
this.parents = [];
this.children = [];
var components = path.split('/');
this.parents = parseParents(components);
this.name = components[components.length - 1];
this.addChild = function(path, type){
... |
I'm extremely new to Python, and the Twitter API, but I found an example online that walked me through the process. Now that I've been playing around with it for awhile, I've begun to push the limits of what my laptop can handle in terms of processing power with my current code. I was hoping someone here could check ov... |
I have recently forked/rewritten a SEDE query (here) that aims at figuring out where a site stands in terms of avid users and distribution of reputation scores, compared to a specific target (number of avid users in each major rep cluster).
declare @target_20k float
declare @target_10k float
declare @target_3k float
de... |
We have two C-strings and for their concatenation we need to know the size of resulting string. And we want to calculate it at compilation stage. How can I improve this solution?
char s1[] = "string1";
char s2[] = "string2";
constexpr auto SIZE =
sizeof(s1) / sizeof(*s1) + sizeof(s2) / sizeof(*s2) + 2; // + for space... |
I have written a method that checks if n number of true booleans are present in a boolean[] array. Then I improved it to var args format which is as follows:
public static boolean checkNTrue(int n, boolean... args) {
assert args.length > 0;
int count = 0;
for( boolean b : args ) {
if(b) count++;
... |
Bit of background info first - I've been struggling with a problem for a while now. How could you have one single event handler to handle every control (or all of a particular type of control) on a form? I've never been able to find a complete solution online either. The two 'easy' methods have glaring issues. For sake... |
The following code is for mapping a dataRecord to a class. I don't like this solution since it requires to duplicate the logic of mapping for each field in every method which access to the same table.
What do you think about? What about using automapper?
public IEnumerable<Model.Accounts.User> GetUsers(int IDUser)
{
... |
I'm working on Google Book API to post a book's basic information. I notice that some of the books will always miss a value or two under volumeInfo, like this book (Fiddle) that has no publisher value. Do I need to repeat if [object] undefined statement several times for the missing values (e.g Publisher,Average Rating... |
Is there any way to simplify the following C# helper class to numerate a string for Json.Net?
internal static string CreateContact(string title)
{
var createContact = new {Title = title};
string output = JsonConvert.SerializeObject(createContact);
return output;
}
[JsonProperty(PropertyName = "9")]
public ... |
I'm currently developing a method which performs an update of some data; much like the following simplified logic:
boolean updateRequired = (currentValue == null && newValue != null);
boolean deleteRequired = (currentValue != null && newValue == null);
if(updateRequired || deleteRequired) {
// ...
}
Which proba... |
I picked the first test (Tape Equilibrium) from Codility here.
Question:
A non-empty zero-indexed array A consisting of N integers is given.
Array A represents numbers on a tape. Any integer P, such that 0 < P < N,
splits this tape into two non−empty parts:
A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[... |
I am currently using this code (and more) to deal with 2D matrices. I am not very proficient in C, so I am not quite sure, if this is a good way of doing it.
I've seen other people in similar situations using pointers to a struct, but I didn't want to complicate things...
typedef struct CMatrix {
double *m;
... |
I've found myself wanting an easy way to implement chat into various apps, so I developed a set of classes for the firebase.com backend that make it easy for me to quickly set up the nuts and bolts of a chat system. To implement this, I have three classes:
FSPresenceManager
Current Connection / Other User's Connection... |
This code review is inspired by the this StackOverflow question and written in Java 8.
The code is supposed to:
Order all files, with syntax jobXXX.script, where XXX is a number, by the number.
Write the contents of the files in that ordering to one file.
I am asking for a general code review and there are two things... |
For the implementation of the Playfair encryption I needed a custom struct called Cell. This is because I not only need an array of characters I also want to get Elements in a matrix based on their "cartesian" position.
public struct Cell
{
public char character;
public int X;
public int Y;... |
I created a class to prevent the default delay which happens when holding down the key on Windows Forms. It seems like the class is working correctly but I don't know if I'm using the best practice.
KeyboardController class;
class KeyboardController
{
public event EventHandler kbEvent;
private DispatcherTimer t... |
As a first little Python exercise, I wrote an analyzer/summarizer for my nginx accesslogs. The code works fine but I'm not sure if I used the different types of sequences properly or made some other stupid things which could lead to bugs etc.
Steps:
read in access.log and heavily poke around to fetch the wanted data ... |
I've coded branch and bound to solve the knapsack problem, and use a greedy linear relaxation to find an upper bound on a node I'm currently exploring. What I mean by this is that I first sort the items by their respective value density (computed value/weight, for each item) and then fill the bag according to a greedy ... |
Our version of getword does not properly handle underscores, string constants, comments, or preprocessor control lines. Write a better version.
This is the exercise 6-1 and can be foud on K&R 2 at page 150.
http://net.pku.edu.cn/~course/cs101/2008/resource/The_C_Programming_Language.pdf
My solution:
static int isVal... |
Based on feedback on an earlier question, I decided to implement the addition of two big ints by putting multiple digits in a node of a linked list. Can somebody take a look at my code and let me know if I am on the right track.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node{
int d... |
I need to find linear conflicts of 8 puzzle state, state is represented by int[9], goal state is {1,2,3,4,5,6,7,8,0}. A linear conflict would be if in a line two tiles that are supposed to be in that line are reversed.
For example, in goal state, the first row is 1,2,3 if in the state the first row is 2,1,3 then that i... |
The purpose of this class is to read an IIS log (or multiple ones). One thing to note is that the columns can differ based on settings in IIS.
A couple of concerns that I have:
Is The ILogReader Interface neccessary?
Is the IFileReader the right way to allow me to stub out the File.ReadAllLines method?
Any other refac... |
Is there any way of counting how many shifts would it take to count shifts while doing insertion sort? This is a Hackerrank problem. Here's my solution, but it takes more than 16 seconds.
counts = []
for _ in range(int(input())):
size = int(input())
ar = list(map(int, input().split()))
count = 0
for i ... |
I consider these two options exactly the same. I prefer the first one but I'm not sure if it's better than the second option in terms of cyclomatic complexity or readability.
Assuming that this is not pure Ruby and I can call to the try method.
existing_transaction = database.find_transaction_by_id(transaction.id)
data... |
I have written a C# file reader that reads a file converts the bytes of the file to hex and writes it out to another file. It works fine but it takes 7.2GB of memory when converting a 300MB file.
What can I do to this code to make it take less memory?
using System;
using System.Collections.Generic;
using System.Linq;
u... |
Sometimes I run across the problem of having two member function overloads that only differ in the constness of this (and the return type, but that is less important):
int& operator[](int);
const int& operator[](int)const;
Most of the time these are one-liners, but even then, I hate the code duplication.
That's why I ... |
I am trying to create an AngularJS directive that will give information to the user about the text they are inputting such as the number of characters they must or may enter and so on and so forth.
To cut a long story short, I would be very grateful if someone could help me improve the javascript code for my directives... |
This is my first Haskell application, so any non-name-calling tips will be taken extremely well! It is just a beta reducer:
data Term = Var Int | Lam Term | App Term Term | Num Int | Add Term Term
deriving (Show)
subs :: Int -> Term -> Term -> Term
subs depth value (Lam body) = Lam (subs (depth + 1) value ... |
I'm looking for code review, optimizations, best practices.
/**
* Huffman encoding obeys the huffman algorithm.
* It compresses the input sentence and serializes the "huffman code"
* and the "tree" used to generate the huffman code
* Both the serialized files are intended to be sent to client.
*
*/
public final... |
I spent the past hour trying to optimize a block of code I wrote that renders a simple coloured line directly to a backbuffer.
I've compared it with one of the DrawLine method implementations of the WriteableBitmapEx project, and found that my algorithm isn't quite as fast (unless I use Parallel).
public static unsafe ... |
Given an array start from the first element and reach the last by jumping. The jump length can be at most the value at the current position in the array. Optimum result is when u reach the goal in minimum number of jumps.
For example:
Given array A = {2,3,1,1,4}
possible ways to reach the end (index list)
i) ... |
I'm primarily looking for ways to increase the performance of my code.
It is used to transform mesh data from blender into a format I can use and then save it to a file.
First it collects the colors of each vertex with an index to reference them, then for each of the vertices it writes its coordinates followed by its... |
This question is a follow up to these questions:
RPSLS Game in C#
Ensuring user input is an integer in a range
RPSLS is less messy now, but is it clean?
Right now I have a couple of ideas in the think tank about how I want to code what I like to call "killMessage" the whole process seems a little intimidating at the ... |
I have this conditional statement with use of regex:
do_stuff if (@string.match(/<(?:ingr?)>/i) &&
@string.match(/<(?:prod:alchemy?)>/i)) ||
@string.match(/<(?:key?)>/i)
It's a 1-line conditional statement, but due to it's length, it taking 3 lines instead. I'm wondering if there's a way to tr... |
My main concern is code style. Could you review this?
#pragma once
#include <time.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <functional>
#include <math.h>
#include <exception>
#include "InfInt.h"
#include "Array2d... |
I have a WCF service which should authenticate user against any bruteforce attack.
Below is the code to avoid any bruteforce attack. I have used MemoryCache to keep track of invalid attempts by a user.
Could you please review the code and let me know if there are any issues?
Following defined in config file:
<InvalidLo... |
I have a program that accesses a certain I/O controller using memory-mapped I/O. I currently store the base address of this controller in a const variable.
This leads to a code structure something like this:
gpio.h:
int gpioFunc (unsigned int pin, unsigned int func);
int setGpio (unsigned int pin, unsigned int val);
... |
I want to teach about "encapsulation" and chose Date with Year, Month and Day as an example -- because it demonstrates type-safety w.r.t. preventing accidental swapping of parameters. I want to demonstrate encapusulation to the extreme, meaning I want to hide the int-values of the Year, Month and Day completely and ins... |
I am the half-robot side of syb0rg that will be posting the recent answers of Code Review to the CR Answers chatroom. Here is the list of review suggestions I would like, in order of preference:
Efficiency (with API requests, speed of login and posting answers, etc.)
Security issues
Best practices
For feature reques... |
Is there any way to make this more efficient?
.386 ; assembler use 80386 instructions
.MODEL FLAT ; use modern standard memory model
INCLUDE io.h ; header file for input/output
cr EQU 0dh ; carriage return
Lf EQU 0ah ; line feed
maxArr EQU 5 ; constant for array... |
I just wrote this gem order_query to find next or previous records relative to the record assuming a (possibly complex) ORDER BY over the records. For example, this is needed to show a link to the next result from the current search result page.
The gem is used like so:
class Issue < ActiveRecord::Base
include Order... |
I've written some python code to solve the map coloring problem. In my code, I represent the problem using Territory and MapColor objects:
class Territory:
def __init__(self, name, neighbors, color = None):
self.name = name
self.neighbors = neighbors
self.color = color
def __... |
I'm new to Python and want to make sure I'm not developing bad habits. If you could please review this code below and give me any tips, practice ideas or critiques you might have. Any ideas on which aspects of the language I should focus on early would also be appreciated.
#!usr/env/python
#Modeling a soccer team with ... |
A friend of mine dabbles in lua, and he recently sent me a code which applies an equation we were discussing. I personally am very mediocre with lua, but my Python senses are tingling - I feel as though this code could almost certainly be shortened. Any thoughts?
print("Choose what you want to find:")
print("Health")
p... |
I'm setting up a Django development environment using Vagrant to run an Ubuntu virtual machine on VirtualBox. As this is a student project run mostly by very amateur coders and I want everyone to be able to contribute, I want the environment to be as convenient as possible.
What I'm trying to achieve:
LESS-files would... |
This is loosely based on one of W3_School samples:
<!DOCTYPE html>
<html>
<body>
<p>Hello World!</p>
<p>The DOM is very useful!</p>
<p>This example demonstrates forEach() function</p>
<script>
var x=Array.prototype.slice.call(document.getElementsByTagName("p"));
x.forEach(function(value, index)
{
document.write(... |
I am still working on A Z80 CPU emulator and I have decided to prototype it in javascript and then translate it into a faster language, It might be ported to C but more likely is Java - this means I cannot use pointers or jump-tables. It both compiles assembly and interprets it however both are giant nested switch-case... |
I am writing a python script that will call mandrills export activity api for every blog on a worpress mu install except for the main site. The script is designed to be called from a cron job on a regular schedule. The code I have is here.
__author__ = 'Taylor'
import datetime
import mandrill
import phpserialize
impor... |
I built a simple Node app, and the code "works", with no failures, no syntax errors, and does not break, but one component doesn't work right. I showed a snippet on Stack Overflow, in this question, but viewers found no issue. So, I think the infrastructure, the method, in which I put this app together must be problema... |
I recently gave an interview and was asked the following question. I posted this here
Finding path in Maze also, and someone suggested I should try Code Review. So here it goes.
A maze is a group of linked Places. Each Place has a North, South, East, and West Place adjacent to it. There are two special pre-defined Pla... |
Excel column letters to actual numbers, if you recall, Excel names its columns with letters from A to Z, and then the sequence goes AA, AB, AC... AZ, BA, BB, etc.
You have to write a function that accepts a string as a parameter (like "AABCCE") and returns the actual column number. And then do the exact reverse, giv... |
I've been messing with metaprogramming and variadic templates in C++, and I came up with this very primitive implementation of a tuple:
constexpr bool GreaterThanZero(int N)
{
return N > 0;
}
template <int, typename...>
struct Helper;
template <int N, typename Head, typename... Tail>
struct Helper<N, Head, Tail..... |
I am writing a new web service that will be performing a lot of large data load operations. To do so I am moving the data to a temporary table then merging the data in to the live data via a stored procedure.
That part I have down and working and am very confident in. What I am doing now is trying to optimize the loadi... |
I find sometimes it is useful to capture the notion of invertible functions.
The idea is that if two functions f :: a -> b and g :: b -> a are the inverse function of each other, and if there is another function h :: b -> b, then h can also work on values of type a.
Moreover, if there f' and g' are another pair of func... |
Here is my Code. But I feel that my code isn't really that much object oriented.
There is a small piece of "styling" in it as well, the "message error" thing at the end.
Should that be in my class or should it go somewhere else?
<?php
require 'contact.class.php';
?>
<form action="" method="post">
<?php
if (isset($_P... |
I needed to write a small program to convert floats from any base to any other base. The thing is, it got big. I know there are other ways to implement the conversions (such as doing subtractions instead of divisions), but isn't there a more simple way to do the whole process? I feel like I'm missing something. Any opt... |
This question I asked previously mentions a function named BuildControlCollection, which I didn't go into the details of since it wasn't relevant. However, because the implementation contains some funky code I'm not 100% on (it completely works, I'm just unsure if it's the best way to do it), I decided to put this up f... |
I have to create some APIs for a online game and I decided to learn to use namespaces correctly.
I used the factory pattern, then the loadModule method checks if in the Modules folder there is a class named $module and then it return the object.
The folders are synchronized with the namespaces.
The main class Metin2.cl... |
I am trying to create a function that I want to use in my real data. Is there any way to optimize the following function? This is a function I created to filter the data.
filter <- function(x, m, delt) {
series <- x
series_filtered <- rep(0,length(series))
delta_t <- delt # time step between data points (hours)
... |
I've created this router for my framework and wanted to get some feedback on if it's the most efficient way to search the routes.
The main router
public static function route($modules = true){
$route = (isset($_GET['route']) && $_GET['route'] != '') ? trim($_GET['route'], '/') : '/';
$parts = explode('/', $rou... |
The program counts attributes of various (geo-)objects and prints them to different files.
One of the options compares two different datasets with each other.
parser.add_option("-c", "--compare datasets", dest="compare",
help="If you want to campare two datasets (from different years for example) se... |
Rock Paper Lizard Spock Monkey Banana
My original post
Based off of Malachi's post
I've changed the way rules work in this version to allow ties to result in double loss or double win. While statistically picking monkey wins against the computer, my intention is to make this a multi-player game which would require more... |
So I noticed Chrome has quirky behaviour when it encounters script tags whose src is a base64 value. I decided to write a quick jQuery method that is supposed to work around it:
jQuery.extend({
/**
* Takes a script decodes the base64 src, puts it into the body of the script tag,
* then puts it in whateve... |
Part of my program is a variable-sized set of Star Systems randomly linked by Warp Points. I have an A* algorithm working rather well in the grid, but the random warp point links mean that even though the systems have X,Y coordinates for where they're located on a galactic map, a system at 2,3 isn't always linked direc... |
Following along another code review (Printing out JSON data from Twitter as a CSV) I would like to submit a slightly adapted code for review.
This code imports JSON data obtained from Twitter and prints out just the tweet author and if there are any users the author mentions in the tweet. User_mentions is a field tha... |
I was writing some geometry-related code again and had a closer look at my function supposed to compute the Euclidean distance between two points (N-dimensional points by the way, hence the N template parameter). Here is a simplified version:
template<std::size_t N, typename T>
auto distance(const Point<N, T>& lhs, con... |
I've taken a look at the SPL Listener/Observer model but found that it doesn't work when using static methods. So I wrote my own but it's very simply. Can anyone suggest ways to make it more like the Model standards and if there is anything obvious that I've missed?
<?php
namespace modular\core;
class Listeners{
... |
I'm implementing an algorithm that traverses a graph of nodes (after a given input) and outputs 3 things:
Number of Strongly connected components
Size of the largest strongly connected component
(And here I think is the step that slows down my algorithm) The number of SCC's that are ONLY connected between them.
This ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.