Hi,
I'm trying to program a pyramid like score system for an ARG game and have come up with a problem. When users get into the game they start a new "pyramid" but if one start the game with a referer code from another player they become a child of this user and then kick points up the ladder.
The issue here is not the point calculation...
class TreeNode
{
public string Value { get; set;}
public Collection<TreeNode> Nodes { get; set;}
public TreeNode()
{
Nodes = new Collection<TreeNode>();
}
}
1) How would you write the recursive lambda expression to return the TreeNode with a particular value (or null if not found) assuming the values are u...
I'm trying to code a very rudimentary GTD app for myself, not only to get organized, but to get better at coding and get better at Python. I'm having a bit of trouble with the classes however.
Here are the classes I have so far:
class Project:
def __init__(self, name, actions=[]):
self.name = name
self.actions = ...
I'm building a list of hashes that represent root to node paths in a tree. My functions work but they are incredibly slow over large tree structures - is there a better way? I've tried building the list in one function but I get unique hashes where I don't want them.
public ArrayList<Integer> makePathList(AbstractTree<String> tree){
...
This is a continuation of one of my previous questions
Here are my classes.
#Project class
class Project:
def __init__(self, name, children=[]):
self.name = name
self.children = children
#add object
def add(self, object):
self.children.append(object)
#get list of all actions
def actions(...
I'm trying to build a list of "phrases" using an array of word lists. I have an array that looks something like this:
[ [ 'big', 'small', 'wild' ],
[ 'brown', 'black', 'spotted' ],
[ 'cat', 'dog' ] ]
The first array is the first word in the resulting "phrase", the second array is the second word, and so on. The number of word list...
I have an array that can contain any number of elements. Each element contains an ID and an array called "options" (also with any number of elements). Here is the structure:
$arr = array(
array('id' => 10, 'options' => array(3, 5)),
array('id' => 15, 'options' => array(2, 4, 8, 9)),
array('id' => 2...
Hello there,
i've been trying to write a java class to solve the n queens problem using some sort of stacking and recursion, the answers are stored in grids(two dimensionnal arrays), but i've hit a dead wall which is stack overflow for recursion at n=8 (max recursion depth reached 2298)
So i've been wondering if there is some way to bypa...
I've got a standard boss/subordinate employee table. I need to select a boss (specified by ID) and all his subordinates (and their subrodinates, etc). Unfortunately the real world data has some loops in it (for example, both company owners have each other set as their boss). The simple recursive query with a CTE chokes on this (maximum r...
I have a class called Profile that has some simple properties and then it can have a collection of ProfileItem that again has some simple properties and then it can have a collection of ProfileItem (RECURSION).
Now I am trying to generated a very simple save function using XML Literals that come with VB.NET (3.5).
The code I am using i...
Dear all: In advance, thank you for your time.
Lately, I have decided to learn Objective-C (I am a long time C-hacker) and after reading the beautiful text by Kochan and diving into the Apple documentation I am still confused as to the best way to implement a recursive class (ie. a class in which an ivar has the type of
the same class)...
I'm trying to write a lambda-expression that calls itself, but i can't seem to find any syntax for that, or even if it's possible.
Essentially what I wanted to transfer the following function into the following lambda expression: (I realize it's a silly application, it just adds, but I'm exploring what I can do with lambda-expressions i...
I have the following code:
class myClass
{
private delegate string myDelegate(Object bj);
protected void method()
{
myDelegate build = delegate(Object bj)
{
var letters= string.Empty;
if (someCondition)
return build(some_obj); //This line seems to cho...
I want to download only .htm or .html files from my server. I'm trying to use ncftpget and even wget but only with limited success.
with ncftpget I can download the whole tree structure no problem but can't seem to specify which files I want, it's either all or nothing.
If I specify the file type like this, it only looks in the top fo...
I have two functions that I'm using to add or remove slashes from a deeply nested object/array combo. The first "level" of the array is always an object, but some of its properties may be arrays or objects.
Here are my two functions:
function objSlash( &$obj, $add=true )
{
foreach ( $obj as $key=>$field )
{
if ( is_object( $field )...
What is the best method to loop through TreeView nodes and retrieve a node based on certain value?
...
I'm writing an application that makes use of a tree structure, so of course I have some recursive methods that will iterate down every node of the tree and do something. The problem is sometimes these take a while, and I'd rather show a progress bar of some sort to the user rather then the program stop responding for a period of time.
I...
Hi every one, I have this Table
CREATE TABLE IF NOT EXISTS `branch` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`studcount` int(11) DEFAULT NULL,
`username` varchar(64) NOT NULL,
`branch_fk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKADAF25A2A445F1AF` (`branch_fk`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=14...
I have some code which uses recursion in its implementation. The profiler which I'm using doesn't do well with recursive function calls, so I'd like to rewrite it to be non-recursive.
The current code is something like this:
void Parse(Foo foo)
{
A()
for (;;)
{
B();
if (C())
return;
if (D())
{
Run();
...
I am a Computer Science student, and as such I have no problem whatsoever understanding recursion. However, I can't seem to wrap my head around the recursive solution to the Tower of Hanoi problem. Here is the code from Wikipedia:
procedure Hanoi(n: integer; source, dest, by: char);
Begin
if (n=1) then
writeln('Move the pl...