Walking a graph without recursion

I’m working on a class that receives a relational EDM/data model (e.g. a SQL DB or OData API manifest) and performs a couple tasks on them (not necessarily at the same time, could be two separate runs). The class/alg doesn’t know anything when it starts, finds everything from the schema data, but the schema doc is static so could be re-processed. What I call “sets” are tables, REST API endpoints, etc., i.e. publicly/user-accessible entry points to the data. One of the things I output is a “path” to each type (e.g. A is a set, so just “A”; B is not a set but is a child of A, so “A→B”). Another is whether anything changes between two models (true/false equality of the model pair).

Unfortunately, the input isn’t necessarily “correct”–some related child types are not available on their own (only through parents), some are missing relations (no ID fields) so I infer based on existence of the property, some have relation loops (A → B → C → A). Some have child collections (1:N) with no mapping type, so I infer that based on the relation prop and invent a mapping type.

Anywho, my current solution uses depth-first and recursion and keeps track of the types it has seen to prevent overflow and false negatives. We’ve found some wacky corner cases (in addition to the above; such as a type set existing, but the type definition itself isn’t in the schema). What I have written works, for what we’ve tested/seen so far, but I am curious if there are other methods by which this sort of traversal or processing might be done, hopefully that could be implemented more simply than what I have now, which gets increasingly ugly and seems more fragile as more weird cases come up.

Generally, what I do now, single-threaded, is: get the list of sets, find outliers that don’t exist in the opposing model, then for each set common between the two models get the type of that set, call CompareType(t1, t2). This will compare properties on those types between the two models and then descend into each related type. If a child has been seen before or is itself a set, I assume it’s OK (skip/return true) because it gets checked on its own.

This is in C# though I’m not sure that is very important as far as the general design of the algorithm. I was curious if there is a better way to do it, e.g. some sort of token walking like I’ve seen in JSON parsers, or a FSM-like solution, or something like that.

Manually walking through the signature generation of a certificate

Based on this very enlightening question and answer, I’m interested in how to generate the signature of an x509 certificate manually, assuming I do have the private key.

Let’s create a self-signed certificate named scrt with matching private key skey as an exercise. I’d expect this to work:

#!/bin/bash  # extract TBS certificate openssl asn1parse -in scrt -strparse 4 -noout -out tbs # create signature of TBS certificate cat tbs | openssl sha256 -sign skey -out sig # create hash of TBS certificate cat tbs | openssl sha256 -binary -out hash # check if the signature of the hash is valid openssl pkeyutl -verify -in hash -sigfile sig -inkey scrt -certin 

However, it tells me: “Signature Verification Failure”

What am I doing wrong?

Is there a functional difference between having a listed climb speed and being able to climb at full walking speed?

The normal rules for climbing state that:

Each foot of movement costs 1 extra foot (2 extra feet in difficult terrain) when you’re climbing, swimming, or crawling. You ignore this extra cost if you have a climbing speed and use it to climb, or a swimming speed and use it to swim. At the DM’s option, climbing a slippery vertical surface or one with few handholds requires a successful Strength (Athletics) check. Similarly, gaining any distance in rough water might require a successful Strength (Athletics) check.

(noting that the basic rules version of the same neglects to clarify that you actually have to be using your climbing speed to benefit, and accidentally suggests that your listed climbing speed is irrelevant if your walking speed is faster)

The Thief rogue archetype has the ability Second-Story Work which provides the following benefit:

When you choose this archetype at 3rd level, you gain the ability to climb faster than normal; climbing no longer costs you extra movement.

The Athlete feat, as one of its benefits, offers the same effect:

Climbing doesn’t cost you extra movement.

As far as I can tell, a 3rd level Thief or an Athlete functionally has a climbing speed equal to their normal walking speed, but they definitely don’t actually have a climbing speed. Unlike in previous editions, having a climbing speed doesn’t seem to offer any side benefits, such as a bonus to skill/ability checks made to climb in difficult circumstances.

Is there any mechanical difference between having an actual climbing speed equal to walking speed or having the ability to climb with your walking speed without penalty? Are there any other abilities or effects a character might be subject to where the distinction is meaningful?

maximal number of time slots until a successful transmission in adaptive tree walking protocol

i have a problem understanding some vital points in adaptive tree walking protocol:

for simplicity sake, only two stations want to broadcast in the given network: A and C.

what is the maximal number of time slots until and including a successful transmission occurs?

what i think: in bit slots, first both stations want to broadcast, so there’s a collision at 1. same occurs when traversing to 2. now we traverse to 2, and A is transmitted, afterwards C is transmitted.

if the probability of a successful transmission is p, then let’s mark that a successful broadcast in station A occurs at probability p and a successful broadcast in station C occurs at probability 1-p. if they both want to transmit all the time and there are constant collisions, then the aforementioned traversal will occur and 5 bit slots will be used. but i don’t understand how can i use it to calculate the maximal amount of time slots until a successful transmission.

would really appreciate your assistance with it

Walking: counting steps when walking back and forth in a circle

I am aware of the fact that Android devices can count the number of steps taken by a person as they walk. However, I am uncertain as to how they do this. Do they rely solely on GPS? If so, if someone keeps on walking in a circle so that their position does not change much and stays within a few meters, then is the device successful at reporting number of steps walked? If not, what other data do they use and how do they carry out the computation at the device level and how does the computation work?

Do the Forced March rules apply to walking around in a dungeon?

Do the Forced March rules (PHB, p. 181) apply to walking around in a dungeon, in Omu, in cities, etc. – i.e. to all movement? Or does it only apply to “far travel”?

Do RAI and RAW differ? It says “travel”.

We’ve been playing it as “adventuring 8 hours, chilling at the camp 8 hours, sleeping 8 hours”. (We like a very rules driven, time-tracked-in-detail, encumbrance, etc. all in a detailed “simulationist” style rather than a more story-focused style.)

Coding across the room while walking, possibly using AIDE, TeamViewer, Chromecast, or other mechanism

Why is it that only certain apps can Chromecast to a TV with a Chromecast device? I would like to open AIDE and cast my code onto the television so that I can code on my smartphone as I walk around the room and look at the code on the television. Is it possible to do this? Alternatively, I would like to cast my AIDE code to a laptop or tablet on my desk and let in the keys on my Android smartphone, using it as a keyboard, so that I can type as I walk.

Note, as I code I might only need to view the current line of code on my smartphone and look at the rest of the code on the TV, PC, or tablet, across the room, maybe even sitting down at my desk occasionally.

This way the smartphone is used mainly add an input keyboard for my other devices.

Is there a way to do this?


Is how to Walking is one of best exercisess Worth it?

Walking is one of best exercises

Is how to Walking is one of best exercisess Worth it? We think that how to Walking is one of best exercisess is worth it since it does its work without harming any organ of the body or having any side effects on the body. The supplement is great for people who want to burn off extra calories from their body. In today’s time, there are many people who are suffering at the hands of obesity and this supplement is a blessing for them all.

Walking over a N branching tree

The aim of this code, written in Python3.6, was to write a function that will non-recursively walk over a N-branching tree structure.

It works by using a list of indices that keep track of visited nodes and by retracing prior steps when a tree branch ends. The function non_recurs visits nodes top down left to right (as far as I can tell).

non-recurs allows the caller to provide a function to the func argument which will be applied to to each node. The end_only argument will determine if the supplied function will be applied to all nodes (end_only=False) or only nodes at the end of branches (end_only=True).

1st I would like to know if this attempt is actually capable of walking over N-branching trees and 2nd I would like to know what you think about my implementation.

NOTE: There are two sections to my code below. The first is to generate N-branching trees and is not the focus of this code review. But is required to generate my demonstrated output


  1. I added IndexError to the except of the try block

tree generation code

from itertools import product  # CODE to create test tree's for walking def assign(tree, idx, value):     new_idx = idx[:]     assignment_idx = new_idx.pop()     ref = tree     for i in new_idx:         ref = ref[i]     ref[assignment_idx] = value     return tree  def n_branch_tree(height, branches):     idx = ([i] for i in range(branches))     tree = list(range(branches))     count = 0     node = 0     while count < height:         for i in idx:             # mutates tree             assign(tree, list(i), list(range(node, node+branches)))             node += branches         count += 1         idx = product(range(branches), repeat=count)     return tree 

tree walk code

# Code to walk over tree  def walk(tree, idx):     """Return tree node at provided index      args:         tree: tree to index         idx: index of desired node      returns: node     """     for i in idx:         tree = tree[i]     return tree  def non_recurs(tree, func=print, branches=2, end_only=True, ):     """Non-recursively walk n-branching tree      args:         tree: n-branching tree         func: function that takes tree node as first argument         branches: The number of branches each node has         end_only: Default is True. When  True will only apply func to                 end nodes. When False will apply func to all Nodes      """     branches = branches - 1  # Because index's start at 0     idx = [0]     node = None     while True:         # print(idx)         try:             node = walk(tree, idx)         except (TypeError, IndexError):             # Could not find node at index             try:                 # If walk back up tree until a node has not                 # been fully explored                 while idx[-1] == branches:                     idx.pop()             except IndexError:                 # Means all nodes in index have been fully explored                 break              # Increase index if current index is under node branch limit             if idx[-1] < branches:                 idx[-1] += 1              # Apply func to end node             if end_only and node:                 func(node)                 node = None         else:             idx.append(0)              # Apply func to all nodes             if not end_only:                 func(node)  if __name__ == '__main__':          tree = n_branch_tree(height=3, branches=3)          print(tree)          value_store = []          non_recurs(tree, func=value_store.append, branches=3, end_only=True)          print(value_store) 


[[[18, 19, 20], [21, 22, 23], [24, 25, 26]], [[27, 28, 29], [30, 31, 32], [33, 34, 35]], [[36, 37, 38], [39, 40, 41], [42, 43, 44]]] [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]