If you're just looking for the longest stretch of zeros you don't need to use a list at all. You just iterate through the binary representation until you find a stretch of zeros. If you hit a new high score, you can overwrite the old high score with the new one and keep moving forward, forgetting about the past.

This is called a "greedy algorithm."

    public static int FindGap(int number)
    {
        string binaryRep = Convert.ToString(number, 2);

        int maxGapSize = 0;
        int currGapSize = 0;

        foreach(char ch in binaryRep)
        {
            if (ch == '0')
            {
                currGapSize++;
            }
            else
            {
                maxGapSize = Math.Max(currGapSize, maxGapSize);
                currGapSize = 0;
            }
        }

        return maxGapSize;
    }

If you want to get really fancy, you don't even need to convert the number to a string. You can use bit shifts to "iterate" through the bits in the number. The number 9 is 1001 in binary. Shift the bits over one, and you've got 100. Shift it over again, and you've got 10. You can use modulus operations to see if the least significant digit is 0 or 1.

This is just a fancy way to repeatedly divide by 2. In fact, you could solve this problem by dividing by 2 instead but this way works as well. (There's also probably a more terse way to write this, but this is perfectly efficient.)

    public static int FindGap2(int number)
    {
        int maxGapSize = 0;
        int currGapSize = 0;

        if (number == 0)
            return 0;

        while (number % 2 == 0)
            number = number >> 1;

        while (number > 0)
        {
            if(number%2 == 0)
            {
                currGapSize++;
            }
            else
            {
                maxGapSize = Math.Max(currGapSize, maxGapSize);
                currGapSize = 0;
            }
            number = number >> 1;
        }

        return maxGapSize;
    }


Determine if a triangle is equilateral, isosceles, or scalene

A triangle has, by definition, three sides. I find it therefore weird to take a single sides argument, which could be of any size. This opens you up to obscure bugs, such as these ones, which are not covered in your tests:

>>> is_triangle([1,2,3,4])
True    # ?
>>> is_triangle([1, 1])
True    # ???
>>> is_triangle([float('nan')])
True    # WTF?

Instead, just explicitly take three arguments. The sides of a triangle are customarily called a, b, c.

def is_triangle(a, b, c):
    a, b, c = sorted([a, b, c])
    return a > 0 and a + b > c

This uses the fact that after the sorted, a is always the smallest side, as mentioned in the comments.

The only thing you need to change in your calling code is to call this with is_triangle(*sides), i.e. use tuple unpacking.

Your other functions can also be shortened a bit. Try to put multiple checks in one line to return right away (but don't push it if it gets too complicated).

def equilateral(a, b, c):
    return is_triangle(a, b, c) and a == b == c

Instead of manually checking all combinations of sides for equality, just use set to get rid of multiples:

def isosceles(a, b, c):
    return is_triangle(a, b, c) and len(set([a, b, c])) <= 2

def scalene(a, b, c):
    return is_triangle(a, b, c) and len(set([a, b, c])) == 3

Note that all functions need to use is_triangle. You could define a decorator that makes sure the input is a triangle:

from functools import wraps

def ensure_triangle(func):
    @wraps(func)
    def wrapper(a, b, c):
        return is_triangle(a, b, c) and func(a, b, c)
    return wrapper

@ensure_triangle
def equilateral(a, b, c):
    return a == b == c

@ensure_triangle
def scalene(a, b, c):
    return len(set([a, b, c])) == 3

@ensure_triangle
def isosceles(a, b, c):
    return len(set([a, b, c])) <= 2


Looks pretty good to me. The only glaring stylistic issue I see is that you inherit from std::set instead of having a member of that type. Inheriting from classes whose innards you don't personally control usually leads to issues with slicing and/or expecting-polymorphism-and-not-getting-it. However, since you're doing private inheritance, this is probably okay.

There are a couple of functional improvements you might want to make (but then again might not, because they're subtle).

(1) Your Object type has an operator< that does nothing but compare ids. That's unlikely to be useful in practice. But you need to have that "compare ids" operation so that you can make your sorted set. The solution is to pass a comparator to your set, like so:

class ObjectSet {
    static bool id_less(const Object& a, const Object& b) {
        return a.id() < b.id();
    }
    std::set<Object, decltype(&id_less)> items_;

  public:
    ObjectSet() : items_(id_less) {}

    // ...
};

This allows you to reclaim Object::operator< for some more appropriate semantics.

(2) Continuing with comparators... Every time I call removeObject, you construct a whole Object to pass to erase. This seems wasteful (assuming Object is a heavyweight type), and also counter-intuitive: what do you mean, removeObject calls the constructor of Object?! :)

The solution requires C++14 or better, because it depends on a particular overload of std::set<T>::find() that first showed up in C++14.

class ObjectSet
{
    static bool id_less(const Object& a, const Object& b) { return a.id() < b.id(); }
    static bool id_less(const Object& a, std::uint32_t b) { return a.id() < b; }
    static bool id_less(std::uint32_t a, const Object& b) { return a < b.id(); }

    struct Comparator {
        template<class T, class U>
        bool operator()(const T& a, const U& b) { return id_less(a, b); }
        using is_transparent = void;
    };

    std::set<Object, Comparator> items_;

    // ...

    void removeObject(std::uint32_t id)
    {
        items_.erase(items_.find(id));
    }
};

(Wandbox link.)


So there are a few improvements that I can see in your code, mainly in the create function.

When reading a file, use the with keyword. This will open the file and, once the program leaves that scope, the file will automatically be closed.

I would recommend changing how you read the file. From what I can tell, each line will be its own key in your dict. So instead of reading the entire file in one statement, I would recommend reading line-by-line.

By making the changes mentioned above, when we split the input by $, we get unnecessary values in the first and last index of the resulting list. To fix this, we can use list slicing. By using the notation list[start:end], where start specifies the first index you want included and stop specifies the first index you want excluded, we can remove the first and last indices.

Finally, when creating a dict you can assign a key-value pair simply by using the syntax:

dict[key] = value

Bringing all of these suggestions together, here is my version of your create function:

def create(self, location):
    # Once this block of code finishes, f will close.
    with open(location, 'r') as f:
        # Reads the file line-by-line
        for line in f:
            # Split the data and remove the first and last indices
            data = line.split('$')[1:-1]

            # Assign the key-value pair to the dict
            self.d[data[0]] = data[1:]

As a final aside, look over PEP8. PEP8 is the official Python style guide. Following those conventions (especially underscores in variable names, so table_string instead of tablestring) will help your code look and feel more Pythonic.


Optimizing Laravel Eloquent multiple joins

SQL formatting

Your SQL script in my opinion could use some indentation and a few more line breaks.

Variable names

Table & column aliases are useful. But it is a good practice to use a variable name that at least says something about what the table contains.

Consistency

SQL is not case sensitive, but still it is good practice to use one style and stick to it.

Here is the same script that reads much more easily

SELECT
    Bk.title,
    GROUP_CONCAT
        (
        DISTINCT (Gnr.name) ORDER BY Gnr.relevancy,
        Gnr.name ASC
        SEPARATOR ' '
        ) AS genre_list,
    GROUP_CONCAT
        (
        DISTINCT CAST(Gnr.relevancy AS CHAR) ORDER BY Gnr.relevancy ASC
        SEPARATOR ','
        ) AS genre_relevancy,
    BkGnr.book_id
FROM book_genres BkGnr
    INNER JOIN genre_book Gnr
        ON BkGnr.genre_id = Gnr.id
        AND Gnr.id IN (". (($genreIdList) ? $genreIdList : 0) . ")
    INNER JOIN book Bk
        ON BkGnr.book_id = Bk.id
    INNER JOIN licensors Lic
        ON Bk.licensor_id = Lic.id
WHERE Bk.status = 'active'
    AND Bk.premium = 'yes'
    AND Lic.status = 'active'
GROUP BY BkGnr.book_id

SQL functions

This doesn't seem to make sense:

DISTINCT (Gnr.name)

DISTINCT CAST(Gnr.relevancy AS CHAR)

Why would there be duplicate genre name records... wouldn't that defeat the purpose of normalizing into a Genre type of table?

Also I don't think casting as CHAR is a good idea. Use VARCHAR instead. If you know about what the maximum character lenght should be, specify it so RDBMS doesn't have to guess, e.g., VARCHAR(50).

This is a bad idea.

AND Gnr.id IN (". (($genreIdList) ? $genreIdList : 0) . ")

It is bad practice to concatenate PHP and SQL together. Instead, use prepared statements with PDO.

SQL procedure

  This is the PHP/Eloquent version:

This whole section looks messy. You would gain clarity, repeatability and performance by using a SQL stored procedure. I'm going to assume your RDBMS is MySQL as is most common with PHP. Here is what you would execute once in MySQL to create it:

DROP PROCEDURE sp_genreIdList IF EXISTS;
DELIMITER |
CREATE PROCEDURE sp_genreIdList (IN p_genreIdList VARCHAR) -- assuming you are passing a string type parameter to RDBMS
AS
BEGIN
SELECT
    Bk.title,
    GROUP_CONCAT
        (
        DISTINCT (Gnr.name) ORDER BY Gnr.relevancy,
        Gnr.name ASC
        SEPARATOR ' '
        ) AS genre_list,
    GROUP_CONCAT
        (
        DISTINCT CAST(Gnr.relevancy AS CHAR) ORDER BY Gnr.relevancy ASC
        SEPARATOR ','
        ) AS genre_relevancy,
    BkGnr.book_id
FROM book_genres BkGnr
    INNER JOIN genre_book Gnr
        ON BkGnr.genre_id = Gnr.id
        AND Gnr.id IN (". (($genreIdList) ? $genreIdList : 0) . ")
    INNER JOIN book Bk
        ON BkGnr.book_id = Bk.id
    INNER JOIN licensors Lic
        ON Bk.licensor_id = Lic.id
WHERE Bk.status = 'active'
    AND Bk.premium = 'yes'
    AND Lic.status = 'active'
GROUP BY BkGnr.book_id;
END|
DELIMITER ; --make sure you don't forget that line

Then from PHP you simply:

$sql = "CALL sp_genreIdList("$genreIdList");";

Or something similar. And you can do this from multiple scripts in multiple languages and you will still get consistent results from RDBMS.


Learning C, basic string reversal function

Your code has a number of issues, the main one being that it doesn't work.

If you want to reverse a string in place then I suggest you write a function just
for that, separate from main.   The function will need a temporary variable
and will, for example:

swap first and last characters
swap 2nd and 2nd-from-last characters
swap 3rd and 3rd-from-last characters
etc

To swap the characters pointed to by a and b, you would do

char temp = *a;
*a = *b;
*b = *temp;

or if you have a pointer and a length:

char temp = a[0];
a[0] = b[len];
b[len] = temp;

So your reversal function needs to contain one of these sequences in a loop
and the loop must arrange a and b to point to the correct places.  For
example, here is a reverse function:

static char* reverse(char *str)
{
    char *s = str;
    char *end = s + strlen(s) - 1;
    for (; s < end; ++s, --end) {
        char ch = *end;
        *end = *s;
        *s = ch;
    }
    return str;
}

Then in main all you do is call the reverse function with the desired
string:

printf("'%s'\n", reverse(argv[1]));

Of course it is best to check that argv[1] exists first (remember that argv[0] is the program name and argc is always greater than or equal to 1):

if (argc == 2) {
    printf("'%s' reversed is ", argv[1]);
    printf("'%s'\n", reverse(argv[1]));
}

Notes:

In your code, aLen and sWord are unnecessary. And reversed is
not initilaised but is then used in

reversed = reversed + sLen;  // See the EDIT below

In the line

int sLen = strlen(sWord);

strlen returns the length as a size_t, not int

EDIT

When you declare a variable local to a function, the compiler sets aside a
space on the stack.  It does not write anything there unless you declare
the initial value for the variable.  So in your code, reserved contains
whatever happens to be at that location on the stack and, as reserved is a
pointer, it therefore points to some unknown (unplanned) location in memory.
If you are unlucky that location will be writeable, your accesses 'work'
and you won't see the problem (or not immediately - in a larger program you
will probably encounter strange behaviour later on while the code is executing
because your accesses have overwritten something important); if you are
lucky and the location is unwritable you will see the problem the first
time you run the program.

The moral is always to initialise variables, just to be safe.  Zero (NULL) is
a good value for pointers.  With C99 you are not restricted to defining them at
the start of a function, so it is often best to define a variable only at the
point where you need it and have a useful value with which to initialise it.


JS Function warning before closing browser

If you don't need the confirmExit function anywhere else, you can just assign it to to window.beforeunload.

window.onbeforeunload = function() {
    if (formmodified == 1) {
        return "Are you sure you want to leave this page? This will abandon any progress on changes to document preferences";
    }
}

Make sure your indentation is consistent, it's confusing to read when brackets don't match up.

Last but not least, it might be helpful (saves you the trouble of writing the same thing multiple times) and more performant to use a class for elements that should have a click handler to reset the "modified" state of the form:

$("input.formreset").click(function() {
    formmodified = 0;
});


Validate parentheses "()" and "[]" are balanced

A short review;

checkBalancedBrackets("([)]") returns true, not sure that was the intention
b1 and b2 are not great names, what does the b stand for?
Using arrays is not needed, all the code does is counting numbers, you can just use numbers
The inconsistent use of curly braces in your if and else if clauses is not good


Count the number of ways to obtain a sum, with consecutivity restriction

This looks wrong:

memset(arr, -1, sizeof(arr));

This is setting sizeof(int*) bytes of arr to -1.  It doesn't set the entire contents of arr.

You should probably be doing this:

int arr_size = sizeof(int)*score;
arr = (int*)malloc(arr_size);
memset(arr, -1, arr_size);

Although as pointed out by @Andrea Biondo, this only works because most architectures and compilers are based around twos complement numbers.  There are some exceptions to this rule, which you're likely to know about if they effect you.


Flag variables suck, and should be avoided.  Moreover, variables should not be named in ALL_CAPS to look like constants.  All you need to get out of the loop is a break.

You've hard-coded the parts of the menu in three places:

the prices
the ASCII table
the loop

All of the menu information should be defined in one place.  You can programmatically generate the ASCII table using the astropy.io.ascii package, but I've put together a quick-and-dirty implementation below.

The if statements in the loop should be replaced by a dictionary lookup.  Furthermore, is is the wrong operator to use; string comparison should be done using ==.  In fact, entering "done" doesn't correctly end the loop, because of that.

You used + str(0) as a hack to get a price ending in "0" to display properly.  To represent fixed-point numbers, you should use a Decimal instead.

This program is long enough that it would be a good idea to make a main() function.

Statements should generally not be terminated with semicolons in Python.  Also, PEP 8, the official style guide, specifies that indentation should be four spaces.  This is an important convention in Python, where indentation matters a lot.

Suggested solution

from collections import OrderedDict, namedtuple
from decimal import Decimal
from string import ascii_uppercase

def tabular(table, widths):
    def sandwich(delim, contents):
        return delim + delim.join(contents) + delim
    def cell(value, width):
        return ' ' + str(value).ljust(width - 2)
    def cells(row):
        return sandwich('|', (cell(col, w) for col, w in zip(row, widths))) + '\n'
    horiz_rule = sandwich('+', ('-' * (w - 1) for w in widths)) + '\n'
    return sandwich(horiz_rule, (cells(row) for row in table))

# In Python 3.7, this should be a @dataclass instead:
class Item(namedtuple('Item', 'name price')):
    def __new__(cls, name, price):
        return super().__new__(cls, name, Decimal(price))

def main():
    menu_items = OrderedDict(zip(ascii_uppercase, [
        Item('The "Big Boy" Burger', '16.99'),
        Item('French Fries', '5.99'),
        Item('Currie sauce', '19.99'),
        Item('Napkins with Chokolates', '10.50'),
        Item('Juice Box', '89.01'),
        Item('Takeout', '18.99'),
    ]))

    print(
        tabular([['The Restaurant at the End of the Universe']], [36 + 9]) +
        tabular(
            (('{0} {1.name}'.format(*stuff), '${1.price}'.format(*stuff))
              for stuff in menu_items.items()),
            [36, 9]
        )
    )

    total = Decimal('0.00')
    while True:
        print('Total: ${0}'.format(total))
        selection = input("Select a letter or 'done': ")
        if selection == 'done':
            break
        total += menu_items[selection].price
    print('Final total: ${0}'.format(total))

if __name__ == '__main__':
    main()


Collect distances from 1 point to all others in a graph

Interesting question;
Naming

The names are on the whole terrible, it really blocks the reading flow, the only good 1 letter variable is i
Further evidence of the bad naming is that I only realized that n, w, and max are never used because of jshint.com
JavaScript follows lowerCamelCase so get_path -> getPath
In fact, even getPath would be a bad name, because you are not getting a path, getPaths could be better (you are getting more than 1 ), but getDistances or even getDistancesFromNode seems best

Declarations

You are mixing var and let in your code, I would stick to let and const

You are not declaring res at all (now it's a global) because this
var s_t = performance.now()
res = get_path(graph, 157)

should be
var s_t = performance.now(),
res = get_path(graph, 157)

Performance
This is already quite impressive, the only thing I noticed is that you process child nodes even if their child count is one (meaning really zero, since that 1 node must be the parent).
I assume the while loops are meant to be the fastest approach, however it seems that the fastest approach is now the most readable approach.
If you were allowed to just use/modify graph instead of cache it would be faster, of course the code reviewer would have told you that's not clean ;)
Comments
Comments should be meaningful, these comments are rather obvious.
All in all, if I had to maintain this, then I would rewrite with proper variable names but otherwise this is perfectly maintainable.

function getDistancesFromNode(graph, origin) {

  let cache, i, j, queue, node, links, root,
      link, nextNode, distance, nodeCount = graph.length;

  cache = Array(nodeCount);
  i = nodeCount;
  while (--i >= 0) {
      node = graph[i];
      cache[node.id] = {
          id: node.id,
          distance: Infinity,
          links: node.links,
          prev: null,
      };
  }
  root = cache[origin];
  root.distance = 0;
  queue = [root];

  i = 0;
  while (i < queue.length) {
      node = queue[i];
      links = node.links;
      j = links.length;
      while (--j >= 0) {
          link = links[j];
          nextNode = cache[link.id];
          distance = node.distance + nextNode.weight;
          if (distance < nextNode.distance && nextNode.links.length > 1) {
              nextNode.prev = node;
              nextNode.distance = d;
              queue.push(nextNode);
          }
      }
      i++;
  }
  return cache
};

var graph = [{"id":0,"links":[{"id":6,"weight":70.71067811865476},{"id":1,"weight":810}]},
{"id":1,"links":[{"id":0,"weight":810},{"id":2,"weight":70.71067811865476}]},
{"id":2,"links":[{"id":1,"weight":70.71067811865476},{"id":3,"weight":1592}]},
{"id":3,"links":[{"id":2,"weight":1592},{"id":5,"weight":70.71067811865476},{"id":153,"weight":205.87711451966396}]},
{"id":4,"links":[{"id":7,"weight":70.71067811865476},{"id":112,"weight":512.6115351930363},{"id":153,"weight":737.0774717197235}]},
{"id":5,"links":[{"id":3,"weight":70.71067811865476},{"id":153,"weight":135.6583919878893}]},
{"id":6,"links":[{"id":0,"weight":70.71067811865476},{"id":94,"weight":310.40008748620136}]},
{"id":7,"links":[{"id":4,"weight":70.71067811865476},{"id":94,"weight":1281.6150329914337}]},
{"id":8,"links":[{"id":9,"weight":55.43314410935759},{"id":27,"weight":394.91497146070554},{"id":89,"weight":249.25217498817833},{"id":17,"weight":37.97639596422426}]},
{"id":9,"links":[{"id":8,"weight":55.43314410935759},{"id":10,"weight":62.68381161480822},{"id":85,"weight":257.37611801643203},{"id":119,"weight":357.92609495024175}]},
{"id":10,"links":[{"id":9,"weight":62.68381161480822},{"id":11,"weight":22.00603386355706},{"id":43,"weight":325.893754212365},{"id":95,"weight":145.6349677143284},{"id":114,"weight":495.27154468751036},{"id":157,"weight":475.0410693030716},{"id":159,"weight":424.5428223515612},{"id":160,"weight":386.9207320551183},{"id":161,"weight":293.9650424785912}]},
{"id":11,"links":[{"id":10,"weight":22.00603386355706},{"id":12,"weight":40.754770931103174},{"id":66,"weight":338.44828019294425},{"id":154,"weight":277.7768610143829}]},
{"id":12,"links":[{"id":11,"weight":40.754770931103174},{"id":13,"weight":63.96396957495827},{"id":71,"weight":279.46200199816974},{"id":130,"weight":423.73430144247175},{"id":142,"weight":605.3109163530141}]},
{"id":13,"links":[{"id":12,"weight":63.96396957495827},{"id":14,"weight":42.685329113484585},{"id":22,"weight":267.044681207588},{"id":18,"weight":383.79570105328406},{"id":89,"weight":295.1151050396651},{"id":97,"weight":173.37684490280637},{"id":147,"weight":644.3394809974541}]},
{"id":14,"links":[{"id":13,"weight":42.685329113484585},{"id":15,"weight":45.39123913699872}]},
{"id":15,"links":[{"id":14,"weight":45.39123913699872},{"id":16,"weight":47.047036449194316},{"id":65,"weight":294.0887879580657},{"id":86,"weight":183.6721765115165},{"id":114,"weight":486.6941103104043},{"id":159,"weight":416.3689141062264},{"id":160,"weight":344.37793610826577}]},
{"id":16,"links":[{"id":15,"weight":47.047036449194316},{"id":17,"weight":25.7772200449739},{"id":43,"weight":298.08763602419685},{"id":39,"weight":354.1679638306291},{"id":70,"weight":371.37278825824006},{"id":74,"weight":670.2294043204714},{"id":132,"weight":378.87860482952715},{"id":157,"weight":434.2784913076533},{"id":161,"weight":262.12088923847034}]},
{"id":17,"links":[{"id":16,"weight":25.7772200449739},{"id":8,"weight":37.97639596422426},{"id":22,"weight":283.4489103653117},{"id":136,"weight":499.55002623505305},{"id":142,"weight":589.0762111107545}]},
{"id":18,"links":[{"id":13,"weight":383.79570105328406},{"id":19,"weight":68.56451044560333},{"id":27,"weight":31.90572098820839}]},
{"id":19,"links":[{"id":18,"weight":68.56451044560333},{"id":20,"weight":60.809531997686655},{"id":64,"weight":400.06011580087164},{"id":156,"weight":445.50275071828963}]},
{"id":20,"links":[{"id":19,"weight":60.809531997686655},{"id":21,"weight":41.7268040869492}]},
{"id":21,"links":[{"id":20,"weight":41.7268040869492},{"id":22,"weight":44.409786926805985},{"id":70,"weight":244.19177296204867},{"id":91,"weight":205.16309784978526},{"id":131,"weight":170.98157093493768}]},
{"id":22,"links":[{"id":13,"weight":267.044681207588},{"id":17,"weight":283.4489103653117},{"id":21,"weight":44.409786926805985},{"id":23,"weight":73.41351083187409},{"id":44,"weight":578.7057992684693},{"id":39,"weight":603.7781336207288},{"id":49,"weight":794.3115697606781},{"id":57,"weight":486.1389713865941},{"id":86,"weight":298.95911490661615},{"id":128,"weight":342.80891355908545},{"id":135,"weight":282.6431518625895},{"id":142,"weight":308.1360659862511},{"id":147,"weight":378.58967001309463},{"id":161,"weight":491.24332514971724}]},
{"id":23,"links":[{"id":22,"weight":73.41351083187409},{"id":24,"weight":47.156569853258866},{"id":63,"weight":299.1373917294431},{"id":156,"weight":424.0775352517563}]},
{"id":24,"links":[{"id":23,"weight":47.156569853258866},{"id":25,"weight":86.13825660873893},{"id":131,"weight":210.320160984807}]},
{"id":25,"links":[{"id":24,"weight":86.13825660873893},{"id":26,"weight":33.06353502569152}]},
{"id":26,"links":[{"id":25,"weight":33.06353502569152},{"id":27,"weight":67.91460112401641},{"id":57,"weight":540.3387174980588},{"id":92,"weight":228.93825991593803},{"id":120,"weight":412.75883815805963},{"id":128,"weight":418.9168740031914},{"id":142,"weight":333.7521131385038}]},
{"id":27,"links":[{"id":8,"weight":394.91497146070554},{"id":26,"weight":67.91460112401641},{"id":18,"weight":31.90572098820839},{"id":80,"weight":593.5258503155924},{"id":89,"weight":148.5928396302128},{"id":147,"weight":349.297544643658}]},
{"id":28,"links":[{"id":29,"weight":59.67018420401978},{"id":81,"weight":209.96278270854182},{"id":106,"weight":69.99034725665763},{"id":149,"weight":340.8623984131601},{"id":37,"weight":28.746317165572204}]},
{"id":29,"links":[{"id":28,"weight":59.67018420401978},{"id":30,"weight":23.113480906778186},{"id":60,"weight":155.8179847580466},{"id":77,"weight":297.5407757529884}]},
{"id":30,"links":[{"id":29,"weight":23.113480906778186},{"id":31,"weight":24.194433832360634},{"id":48,"weight":312.87236629082633}]},
{"id":31,"links":[{"id":30,"weight":24.194433832360634},{"id":32,"weight":95.03245812683691},{"id":52,"weight":306.82477443979093},{"id":107,"weight":78.85870804148841}]},
{"id":32,"links":[{"id":31,"weight":95.03245812683691},{"id":33,"weight":28.769841069179858},{"id":60,"weight":147.93878749367386}]},
{"id":33,"links":[{"id":32,"weight":28.769841069179858},{"id":34,"weight":26.884913041414087},{"id":149,"weight":324.73490720293273}]},
{"id":34,"links":[{"id":33,"weight":26.884913041414087},{"id":35,"weight":34.539644671799884},{"id":48,"weight":312.60280041119495},{"id":82,"weight":298.7966839326061}]},
{"id":35,"links":[{"id":34,"weight":34.539644671799884},{"id":36,"weight":47.88309910969351},{"id":52,"weight":298.6492567682363},{"id":78,"weight":270.88254329096384}]},
{"id":36,"links":[{"id":35,"weight":47.88309910969351},{"id":37,"weight":55.92799176338086},{"id":146,"weight":250.2794421195491}]},
{"id":37,"links":[{"id":36,"weight":55.92799176338086},{"id":28,"weight":28.746317165572204},{"id":101,"weight":174.53904785374436}]},
{"id":38,"links":[{"id":45,"weight":41.60346490016386},{"id":160,"weight":259.95392603739697}]},
{"id":39,"links":[{"id":16,"weight":354.1679638306291},{"id":22,"weight":603.7781336207288},{"id":40,"weight":28.56292626279466},{"id":136,"weight":827.1618749297187},{"id":142,"weight":911.9072364060776}]},
{"id":40,"links":[{"id":39,"weight":28.56292626279466},{"id":41,"weight":71.83348433366919},{"id":87,"weight":385.18415791555594}]},
{"id":41,"links":[{"id":40,"weight":71.83348433366919},{"id":42,"weight":25.66448755744104},{"id":84,"weight":301.86449922516306},{"id":119,"weight":304.09006218105435},{"id":160,"weight":191.66415098549578},{"id":161,"weight":42.17582986887332}]},
{"id":42,"links":[{"id":41,"weight":25.66448755744104},{"id":43,"weight":25.041564347271354},{"id":114,"weight":201.32515950767336},{"id":159,"weight":136.50001088374017}]},
{"id":43,"links":[{"id":10,"weight":325.893754212365},{"id":16,"weight":298.08763602419685},{"id":42,"weight":25.041564347271354},{"id":44,"weight":53.81505716045718},{"id":70,"weight":668.6142302142265},{"id":95,"weight":464.5912380083568},{"id":132,"weight":675.2576499747647},{"id":157,"weight":149.3858968154142},{"id":161,"weight":35.96703115932087}]},
{"id":44,"links":[{"id":22,"weight":578.7057992684693},{"id":43,"weight":53.81505716045718},{"id":45,"weight":41.40801209082323},{"id":57,"weight":1063.3996891527247},{"id":136,"weight":809.6193736796965}]},
{"id":45,"links":[{"id":44,"weight":41.40801209082323},{"id":38,"weight":41.60346490016386},{"id":86,"weight":326.14140573310647},{"id":83,"weight":413.3998108385815},{"id":118,"weight":301.0257064648056}]},
{"id":46,"links":[{"id":47,"weight":32.324323407861954},{"id":54,"weight":25.030634943141447}]},
{"id":47,"links":[{"id":46,"weight":32.324323407861954},{"id":48,"weight":74.97098636842881},{"id":150,"weight":482.148526864346}]},
{"id":48,"links":[{"id":30,"weight":312.87236629082633},{"id":34,"weight":312.60280041119495},{"id":47,"weight":74.97098636842881},{"id":49,"weight":51.584467579702824},{"id":61,"weight":244.27972531448285},{"id":106,"weight":336.640487491796}]},
{"id":49,"links":[{"id":22,"weight":794.3115697606781},{"id":48,"weight":51.584467579702824},{"id":57,"weight":308.50551001966323},{"id":128,"weight":451.6465055929891},{"id":135,"weight":511.844500792933}]},
{"id":50,"links":[{"id":51,"weight":49.512416392803104}]},
{"id":51,"links":[{"id":50,"weight":49.512416392803104},{"id":52,"weight":53.04787162699196}]},
{"id":52,"links":[{"id":31,"weight":306.82477443979093},{"id":35,"weight":298.6492567682363},{"id":51,"weight":53.04787162699196},{"id":53,"weight":76.43056418497244},{"id":82,"weight":547.120073731121},{"id":110,"weight":325.05226324305437},{"id":150,"weight":458.3924820628751}]},
{"id":53,"links":[{"id":52,"weight":76.43056418497244},{"id":54,"weight":20.039265191224455}]},
{"id":54,"links":[{"id":53,"weight":20.039265191224455},{"id":46,"weight":25.030634943141447},{"id":58,"weight":244.9260216552532},{"id":67,"weight":756.3463895463947},{"id":76,"weight":482.3227102069046},{"id":124,"weight":422.2533744531271}]},
{"id":55,"links":[{"id":56,"weight":58.460583239231624},{"id":102,"weight":115.82406310298205},{"id":125,"weight":152.5815324765102}]},
{"id":56,"links":[{"id":55,"weight":58.460583239231624},{"id":57,"weight":55.57519143003837}]},
{"id":57,"links":[{"id":22,"weight":486.1389713865941},{"id":26,"weight":540.3387174980588},{"id":44,"weight":1063.3996891527247},{"id":49,"weight":308.50551001966323},{"id":56,"weight":55.57519143003837},{"id":58,"weight":48.45767081071381},{"id":158,"weight":180.39992938539922},{"id":136,"weight":253.7803363149803},{"id":142,"weight":206.67779462996376}]},
{"id":58,"links":[{"id":54,"weight":244.9260216552532},{"id":57,"weight":48.45767081071381},{"id":59,"weight":24.092997373752972}]},
{"id":59,"links":[{"id":58,"weight":24.092997373752972},{"id":60,"weight":82.39211060953677},{"id":76,"weight":268.66979964854914},{"id":124,"weight":204.95995317424766}]},
{"id":60,"links":[{"id":29,"weight":155.8179847580466},{"id":32,"weight":147.93878749367386},{"id":59,"weight":82.39211060953677},{"id":61,"weight":56.8386682833888}]},
{"id":61,"links":[{"id":48,"weight":244.27972531448285},{"id":60,"weight":56.8386682833888},{"id":77,"weight":395.3342593777817},{"id":106,"weight":94.82870098367673}]},
{"id":62,"links":[{"id":63,"weight":50.239660941572126},{"id":138,"weight":456.67384076187767},{"id":71,"weight":38.53358308507445}]},
{"id":63,"links":[{"id":23,"weight":299.1373917294431},{"id":62,"weight":50.239660941572126},{"id":64,"weight":49.29188012559735}]},
{"id":64,"links":[{"id":19,"weight":400.06011580087164},{"id":63,"weight":49.29188012559735},{"id":65,"weight":34.9390920450358},{"id":91,"weight":484.70495246456426}]},
{"id":65,"links":[{"id":15,"weight":294.0887879580657},{"id":64,"weight":34.9390920450358},{"id":66,"weight":44.386933593419634},{"id":86,"weight":473.4945906187595},{"id":160,"weight":638.3194987663459}]},
{"id":66,"links":[{"id":11,"weight":338.44828019294425},{"id":65,"weight":44.386933593419634},{"id":67,"weight":46.35007638082747},{"id":97,"weight":354.99096425656126},{"id":155,"weight":98.46201480548129}]},
{"id":67,"links":[{"id":54,"weight":756.3463895463947},{"id":66,"weight":46.35007638082747},{"id":68,"weight":83.11118143775956},{"id":76,"weight":275.22916188389814},{"id":124,"weight":334.3275404295602}]},
{"id":68,"links":[{"id":67,"weight":83.11118143775956},{"id":69,"weight":61.82288775247714}]},
{"id":69,"links":[{"id":68,"weight":61.82288775247714},{"id":70,"weight":32.72720780632854}]},
{"id":70,"links":[{"id":16,"weight":371.37278825824006},{"id":21,"weight":244.19177296204867},{"id":43,"weight":668.6142302142265},{"id":69,"weight":32.72720780632854},{"id":71,"weight":82.01328044192185},{"id":74,"weight":299.3033974268629},{"id":86,"weight":467.8800531253375},{"id":114,"weight":795.7351820979673},{"id":131,"weight":74.14997079035552},{"id":157,"weight":798.2577975693512},{"id":159,"weight":728.6111329180097},{"id":161,"weight":632.6993752105095}]},
{"id":71,"links":[{"id":12,"weight":279.46200199816974},{"id":70,"weight":82.01328044192185},{"id":62,"weight":38.53358308507445},{"id":97,"weight":376.4367138297526},{"id":122,"weight":299.55665657848795},{"id":132,"weight":92.36209904758263},{"id":131,"weight":67.09223542194184},{"id":156,"weight":229.10251215735252}]},
{"id":72,"links":[{"id":73,"weight":22.44295867376786},{"id":124,"weight":96.7927637387651},{"id":76,"weight":30.383770443458943}]},
{"id":73,"links":[{"id":72,"weight":22.44295867376786}]},
{"id":74,"links":[{"id":16,"weight":670.2294043204714},{"id":70,"weight":299.3033974268629},{"id":75,"weight":41.39428112635902},{"id":121,"weight":140.7096972711017},{"id":132,"weight":291.38771611392053}]},
{"id":75,"links":[{"id":74,"weight":41.39428112635902},{"id":76,"weight":30.0627689482037}]},
{"id":76,"links":[{"id":54,"weight":482.3227102069046},{"id":59,"weight":268.66979964854914},{"id":67,"weight":275.22916188389814},{"id":75,"weight":30.0627689482037},{"id":72,"weight":30.383770443458943}]},
{"id":77,"links":[{"id":29,"weight":297.5407757529884},{"id":61,"weight":395.3342593777817},{"id":78,"weight":52.00968489404878},{"id":106,"weight":300.6735447670068},{"id":145,"weight":213.64883986492893}]},
{"id":78,"links":[{"id":35,"weight":270.88254329096384},{"id":77,"weight":52.00968489404878},{"id":79,"weight":44.23783407847146}]},
{"id":79,"links":[{"id":78,"weight":44.23783407847146},{"id":80,"weight":38.118361538425795}]},
{"id":80,"links":[{"id":27,"weight":593.5258503155924},{"id":79,"weight":38.118361538425795},{"id":81,"weight":88.22727131494065},{"id":92,"weight":748.610228678086},{"id":117,"weight":922.5836952812741},{"id":160,"weight":981.0925983047125}]},
{"id":81,"links":[{"id":28,"weight":209.96278270854182},{"id":80,"weight":88.22727131494065},{"id":82,"weight":65.51209274182104},{"id":101,"weight":323.12731048143235},{"id":147,"weight":350.10072558836436}]},
{"id":82,"links":[{"id":34,"weight":298.7966839326061},{"id":52,"weight":547.120073731121},{"id":81,"weight":65.51209274182104},{"id":111,"weight":269.9434631344396}]},
{"id":83,"links":[{"id":45,"weight":413.3998108385815},{"id":84,"weight":49.04899812555336},{"id":92,"weight":30.837464050468025}]},
{"id":84,"links":[{"id":41,"weight":301.86449922516306},{"id":83,"weight":49.04899812555336},{"id":85,"weight":63.71188304619065},{"id":161,"weight":262.445211274406}]},
{"id":85,"links":[{"id":9,"weight":257.37611801643203},{"id":84,"weight":63.71188304619065},{"id":86,"weight":49.09351203637654}]},
{"id":86,"links":[{"id":15,"weight":183.6721765115165},{"id":22,"weight":298.95911490661615},{"id":45,"weight":326.14140573310647},{"id":65,"weight":473.4945906187595},{"id":70,"weight":467.8800531253375},{"id":85,"weight":49.09351203637654},{"id":87,"weight":83.46480593410709},{"id":119,"weight":151.90228469087668},{"id":114,"weight":329.0079671927419},{"id":128,"weight":641.7308695509025},{"id":132,"weight":471.07620316344014},{"id":135,"weight":581.5450583764579},{"id":157,"weight":337.27659265236},{"id":159,"weight":264.5824947674739},{"id":160,"weight":170.91599639926625}]},
{"id":87,"links":[{"id":40,"weight":385.18415791555594},{"id":86,"weight":83.46480593410709},{"id":88,"weight":41.619088536378854},{"id":161,"weight":285.65519727136444}]},
{"id":88,"links":[{"id":87,"weight":41.619088536378854},{"id":89,"weight":19.022840656019405}]},
{"id":89,"links":[{"id":8,"weight":249.25217498817833},{"id":13,"weight":295.1151050396651},{"id":27,"weight":148.5928396302128},{"id":88,"weight":19.022840656019405},{"id":90,"weight":35.841603038774416}]},
{"id":90,"links":[{"id":89,"weight":35.841603038774416},{"id":91,"weight":32.398612793756314}]},
{"id":91,"links":[{"id":21,"weight":205.16309784978526},{"id":64,"weight":484.70495246456426},{"id":90,"weight":32.398612793756314},{"id":92,"weight":48.582975729764854}]},
{"id":92,"links":[{"id":26,"weight":228.93825991593803},{"id":80,"weight":748.610228678086},{"id":91,"weight":48.582975729764854},{"id":83,"weight":30.837464050468025},{"id":120,"weight":188.7591372909066},{"id":117,"weight":174.02812344524793},{"id":146,"weight":572.3906052533645},{"id":159,"weight":344.37896644057383},{"id":160,"weight":232.48237745520552}]},
{"id":93,"links":[{"id":97,"weight":102.0522575060609}]},
{"id":94,"links":[{"id":6,"weight":310.40008748620136},{"id":7,"weight":1281.6150329914337}]},
{"id":95,"links":[{"id":10,"weight":145.6349677143284},{"id":43,"weight":464.5912380083568},{"id":96,"weight":20.309465539051313},{"id":114,"weight":637.3889554757393},{"id":159,"weight":567.3380419121927},{"id":161,"weight":434.67294753052647}]},
{"id":96,"links":[{"id":95,"weight":20.309465539051313},{"id":97,"weight":63.213233743350074}]},
{"id":97,"links":[{"id":13,"weight":173.37684490280637},{"id":66,"weight":354.99096425656126},{"id":71,"weight":376.4367138297526},{"id":96,"weight":63.213233743350074},{"id":93,"weight":102.0522575060609},{"id":100,"weight":240.91712277511493},{"id":130,"weight":525.9007129529984},{"id":142,"weight":709.2888517760487},{"id":147,"weight":817.6275336689539},{"id":155,"weight":256.52958550596395}]},
{"id":98,"links":[{"id":99,"weight":38.26238414408713}]},
{"id":99,"links":[{"id":98,"weight":38.26238414408713},{"id":100,"weight":81.55030224358033}]},
{"id":100,"links":[{"id":97,"weight":240.91712277511493},{"id":99,"weight":81.55030224358033},{"id":130,"weight":766.6709881560315},{"id":142,"weight":949.697709689759}]},
{"id":101,"links":[{"id":37,"weight":174.53904785374436},{"id":81,"weight":323.12731048143235},{"id":102,"weight":47.30056869901373},{"id":143,"weight":92.85603330225935},{"id":109,"weight":48.22919045283958}]},
{"id":102,"links":[{"id":55,"weight":115.82406310298205},{"id":101,"weight":47.30056869901373},{"id":103,"weight":35.380667355785846},{"id":125,"weight":257.26089278078433},{"id":145,"weight":86.69660180432261}]},
{"id":103,"links":[{"id":102,"weight":35.380667355785846},{"id":104,"weight":43.58038875739012}]},
{"id":104,"links":[{"id":103,"weight":43.58038875739012}]},
{"id":105,"links":[{"id":106,"weight":49.00253118207074}]},
{"id":106,"links":[{"id":28,"weight":69.99034725665763},{"id":48,"weight":336.640487491796},{"id":61,"weight":94.82870098367673},{"id":77,"weight":300.6735447670068},{"id":105,"weight":49.00253118207074},{"id":107,"weight":27.405833077229865}]},
{"id":107,"links":[{"id":31,"weight":78.85870804148841},{"id":106,"weight":27.405833077229865},{"id":108,"weight":39.67467085048693},{"id":146,"weight":161.5285374896578}]},
{"id":108,"links":[{"id":107,"weight":39.67467085048693},{"id":109,"weight":28.034817769574357}]},
{"id":109,"links":[{"id":108,"weight":28.034817769574357},{"id":101,"weight":48.22919045283958}]},
{"id":110,"links":[{"id":52,"weight":325.05226324305437},{"id":111,"weight":25.375224080516592},{"id":150,"weight":133.5176916667986}]},
{"id":111,"links":[{"id":82,"weight":269.9434631344396},{"id":110,"weight":25.375224080516592}]},
{"id":112,"links":[{"id":4,"weight":512.6115351930363},{"id":113,"weight":83.28092580028589},{"id":153,"weight":239.32930481887956}]},
{"id":113,"links":[{"id":112,"weight":83.28092580028589}]},
{"id":114,"links":[{"id":10,"weight":495.27154468751036},{"id":15,"weight":486.6941103104043},{"id":42,"weight":201.32515950767336},{"id":70,"weight":795.7351820979673},{"id":86,"weight":329.0079671927419},{"id":95,"weight":637.3889554757393},{"id":115,"weight":101.77827438406392},{"id":132,"weight":799.5716987622106},{"id":159,"weight":71.39727162164735},{"id":161,"weight":202.98164149753293}]},
{"id":115,"links":[{"id":114,"weight":101.77827438406392},{"id":116,"weight":55.33658324913234},{"id":160,"weight":63.25551243883601}]},
{"id":116,"links":[{"id":115,"weight":55.33658324913234},{"id":117,"weight":64.34602362067791}]},
{"id":117,"links":[{"id":80,"weight":922.5836952812741},{"id":92,"weight":174.02812344524793},{"id":116,"weight":64.34602362067791},{"id":118,"weight":25.616725172113455},{"id":157,"weight":242.8128909397011},{"id":159,"weight":170.35193802012466},{"id":160,"weight":58.715883663506396}]},
{"id":118,"links":[{"id":45,"weight":301.0257064648056},{"id":117,"weight":25.616725172113455},{"id":119,"weight":49.34327971363866}]},
{"id":119,"links":[{"id":9,"weight":357.92609495024175},{"id":41,"weight":304.09006218105435},{"id":86,"weight":151.90228469087668},{"id":118,"weight":49.34327971363866},{"id":120,"weight":92.13543408276188},{"id":161,"weight":262.52409073917073}]},
{"id":120,"links":[{"id":26,"weight":412.75883815805963},{"id":92,"weight":188.7591372909066},{"id":119,"weight":92.13543408276188}]},
{"id":121,"links":[{"id":74,"weight":140.7096972711017},{"id":122,"weight":49.158380910815055}]},
{"id":122,"links":[{"id":71,"weight":299.55665657848795},{"id":121,"weight":49.158380910815055},{"id":123,"weight":22.072670207307805},{"id":132,"weight":207.55080569931508}]},
{"id":123,"links":[{"id":122,"weight":22.072670207307805},{"id":124,"weight":23.95147516157658}]},
{"id":124,"links":[{"id":54,"weight":422.2533744531271},{"id":59,"weight":204.95995317424766},{"id":67,"weight":334.3275404295602},{"id":72,"weight":96.7927637387651},{"id":123,"weight":23.95147516157658},{"id":125,"weight":37.10612238764236}]},
{"id":125,"links":[{"id":55,"weight":152.5815324765102},{"id":102,"weight":257.26089278078433},{"id":124,"weight":37.10612238764236},{"id":126,"weight":34.927378155183234},{"id":141,"weight":258.1518700205428}]},
{"id":126,"links":[{"id":125,"weight":34.927378155183234},{"id":127,"weight":32.98615477724716}]},
{"id":127,"links":[{"id":126,"weight":32.98615477724716},{"id":128,"weight":16.22742340952728}]},
{"id":128,"links":[{"id":22,"weight":342.80891355908545},{"id":26,"weight":418.9168740031914},{"id":49,"weight":451.6465055929891},{"id":86,"weight":641.7308695509025},{"id":127,"weight":16.22742340952728},{"id":158,"weight":35.94532649063341},{"id":135,"weight":60.199671727187834}]},
{"id":129,"links":[]},
{"id":130,"links":[{"id":12,"weight":423.73430144247175},{"id":97,"weight":525.9007129529984},{"id":100,"weight":766.6709881560315},{"id":131,"weight":89.63249969243708},{"id":137,"weight":44.67921793243463}]},
{"id":131,"links":[{"id":21,"weight":170.98157093493768},{"id":24,"weight":210.320160984807},{"id":70,"weight":74.14997079035552},{"id":71,"weight":67.09223542194184},{"id":130,"weight":89.63249969243708},{"id":132,"weight":70.44518620133896},{"id":142,"weight":273.78551731820147},{"id":138,"weight":351.5407196157602},{"id":156,"weight":296.14115910691856}]},
{"id":132,"links":[{"id":16,"weight":378.87860482952715},{"id":43,"weight":675.2576499747647},{"id":71,"weight":92.36209904758263},{"id":74,"weight":291.38771611392053},{"id":86,"weight":471.07620316344014},{"id":114,"weight":799.5716987622106},{"id":122,"weight":207.55080569931508},{"id":131,"weight":70.44518620133896},{"id":133,"weight":53.20257740632008},{"id":157,"weight":803.2044974295419},{"id":159,"weight":733.0042344492691},{"id":161,"weight":639.4014374495188}]},
{"id":133,"links":[{"id":132,"weight":53.20257740632008},{"id":134,"weight":50.32148162147291}]},
{"id":134,"links":[{"id":133,"weight":50.32148162147291}]},
{"id":135,"links":[{"id":22,"weight":282.6431518625895},{"id":49,"weight":511.844500792933},{"id":86,"weight":581.5450583764579},{"id":128,"weight":60.199671727187834},{"id":136,"weight":49.49620942581232}]},
{"id":136,"links":[{"id":17,"weight":499.55002623505305},{"id":39,"weight":827.1618749297187},{"id":44,"weight":809.6193736796965},{"id":57,"weight":253.7803363149803},{"id":135,"weight":49.49620942581232},{"id":137,"weight":31.43818529653531},{"id":161,"weight":721.2341683340406}]},
{"id":137,"links":[{"id":136,"weight":31.43818529653531},{"id":130,"weight":44.67921793243463}]},
{"id":138,"links":[{"id":62,"weight":456.67384076187767},{"id":131,"weight":351.5407196157602},{"id":139,"weight":23.777001819899976},{"id":156,"weight":645.5864796077194},{"id":147,"weight":60.21879922428856}]},
{"id":139,"links":[{"id":138,"weight":23.777001819899976},{"id":140,"weight":47.7270317027185}]},
{"id":140,"links":[{"id":139,"weight":47.7270317027185},{"id":141,"weight":23.039143895070726}]},
{"id":141,"links":[{"id":125,"weight":258.1518700205428},{"id":140,"weight":23.039143895070726},{"id":142,"weight":70.27931275561932}]},
{"id":142,"links":[{"id":12,"weight":605.3109163530141},{"id":17,"weight":589.0762111107545},{"id":22,"weight":308.1360659862511},{"id":26,"weight":333.7521131385038},{"id":39,"weight":911.9072364060776},{"id":57,"weight":206.67779462996376},{"id":97,"weight":709.2888517760487},{"id":100,"weight":949.697709689759},{"id":131,"weight":273.78551731820147},{"id":141,"weight":70.27931275561932},{"id":143,"weight":64.98383750211529}]},
{"id":143,"links":[{"id":101,"weight":92.85603330225935},{"id":142,"weight":64.98383750211529},{"id":144,"weight":30.097551026293797}]},
{"id":144,"links":[{"id":143,"weight":30.097551026293797},{"id":145,"weight":100.10632073495346}]},
{"id":145,"links":[{"id":77,"weight":213.64883986492893},{"id":102,"weight":86.69660180432261},{"id":144,"weight":100.10632073495346},{"id":146,"weight":43.76422694558446}]},
{"id":146,"links":[{"id":36,"weight":250.2794421195491},{"id":92,"weight":572.3906052533645},{"id":107,"weight":161.5285374896578},{"id":145,"weight":43.76422694558446},{"id":147,"weight":62.554721469410964}]},
{"id":147,"links":[{"id":13,"weight":644.3394809974541},{"id":22,"weight":378.58967001309463},{"id":27,"weight":349.297544643658},{"id":81,"weight":350.10072558836436},{"id":97,"weight":817.6275336689539},{"id":146,"weight":62.554721469410964},{"id":138,"weight":60.21879922428856}]},
{"id":148,"links":[{"id":153,"weight":83.09197814327331}]},
{"id":149,"links":[{"id":28,"weight":340.8623984131601},{"id":33,"weight":324.73490720293273},{"id":150,"weight":40.27917844217807}]},
{"id":150,"links":[{"id":47,"weight":482.148526864346},{"id":52,"weight":458.3924820628751},{"id":110,"weight":133.5176916667986},{"id":149,"weight":40.27917844217807}]},
{"id":151,"links":[{"id":152,"weight":16.05179269405632}]},
{"id":152,"links":[{"id":151,"weight":16.05179269405632},{"id":153,"weight":95.08995160516936}]},
{"id":153,"links":[{"id":3,"weight":205.87711451966396},{"id":4,"weight":737.0774717197235},{"id":5,"weight":135.6583919878893},{"id":112,"weight":239.32930481887956},{"id":152,"weight":95.08995160516936},{"id":148,"weight":83.09197814327331}]},
{"id":154,"links":[{"id":11,"weight":277.7768610143829},{"id":155,"weight":33.19341980748434}]},
{"id":155,"links":[{"id":66,"weight":98.46201480548129},{"id":97,"weight":256.52958550596395},{"id":154,"weight":33.19341980748434},{"id":156,"weight":58.397228717203404}]},
{"id":156,"links":[{"id":19,"weight":445.50275071828963},{"id":23,"weight":424.0775352517563},{"id":71,"weight":229.10251215735252},{"id":131,"weight":296.14115910691856},{"id":138,"weight":645.5864796077194},{"id":155,"weight":58.397228717203404}]},
{"id":157,"links":[{"id":10,"weight":475.0410693030716},{"id":16,"weight":434.2784913076533},{"id":43,"weight":149.3858968154142},{"id":70,"weight":798.2577975693512},{"id":86,"weight":337.27659265236},{"id":117,"weight":242.8128909397011},{"id":132,"weight":803.2044974295419}]},
{"id":158,"links":[{"id":57,"weight":180.39992938539922},{"id":128,"weight":35.94532649063341},{"id":160,"weight":44.1282092957909}]},
{"id":159,"links":[{"id":10,"weight":424.5428223515612},{"id":15,"weight":416.3689141062264},{"id":42,"weight":136.50001088374017},{"id":70,"weight":728.6111329180097},{"id":86,"weight":264.5824947674739},{"id":92,"weight":344.37896644057383},{"id":95,"weight":567.3380419121927},{"id":117,"weight":170.35193802012466},{"id":114,"weight":71.39727162164735},{"id":132,"weight":733.0042344492691},{"id":160,"weight":112.12052199347016},{"id":161,"weight":134.34656675925888}]},
{"id":160,"links":[{"id":10,"weight":386.9207320551183},{"id":15,"weight":344.37793610826577},{"id":38,"weight":259.95392603739697},{"id":41,"weight":191.66415098549578},{"id":65,"weight":638.3194987663459},{"id":80,"weight":981.0925983047125},{"id":86,"weight":170.91599639926625},{"id":92,"weight":232.48237745520552},{"id":117,"weight":58.715883663506396},{"id":115,"weight":63.25551243883601},{"id":158,"weight":44.1282092957909},{"id":159,"weight":112.12052199347016}]},
{"id":161,"links":[{"id":10,"weight":293.9650424785912},{"id":16,"weight":262.12088923847034},{"id":22,"weight":491.24332514971724},{"id":43,"weight":35.96703115932087},{"id":41,"weight":42.17582986887332},{"id":70,"weight":632.6993752105095},{"id":87,"weight":285.65519727136444},{"id":84,"weight":262.445211274406},{"id":95,"weight":434.67294753052647},{"id":119,"weight":262.52409073917073},{"id":114,"weight":202.98164149753293},{"id":132,"weight":639.4014374495188},{"id":136,"weight":721.2341683340406},{"id":159,"weight":134.34656675925888}]}]

var get_path = function(graph, a) {
// declaration
  let cache, i, v, queue, node, links, root,
      j, link, c, n, d, max, w, L = graph.length;

  // initialization
  cache = Array(L);
  i = L;
  while (--i >= 0) {
      v = graph[i];
      cache[v.id] = {
          id: v.id,
          distance: Infinity,
          links: v.links,
          prev: null,
      };
  }
  root = cache[a];
  root.distance = 0;
  queue = [root];

  // processing
  i = 0;
  while (i < queue.length) {
      node = queue[i];
      links = node.links;
      j = links.length;
      while (--j >= 0) {
          link = links[j];
          c = cache[link.id];
          d = node.distance + link.weight;
          if (d < c.distance) {
              c.prev = node;
              c.distance = d;
              queue.push(c);
          }
      }
      i++;
  }

  return cache
};

var times = [], newTimes = [];

for (let i=0; i < 1000; i++) {
  var s_t = performance.now();
  res = get_path(graph, 157);
  times.push(performance.now() - s_t);
}

for (let i=0; i < 1000; i++) {
  var s_t = performance.now();
  res = getDistancesFromNode(graph, 157);
  newTimes.push(performance.now() - s_t);
}

function average(nums) {
    return nums.reduce((a, b) => (a + b)) / nums.length;
}

console.log(average(times), 'ms')
console.log(average(newTimes), 'ms')


Simple PHP project to store inputs in MySQL and output them

Is the coding in my project acceptable?

More or less. There are no essential flaws but the structure is quite questionable.

Is it similar to how most PHP projects are built? (i.e. are most procedural or OOP)

Depends on the project's maturity. Your code is quite similar to what a usual first project looks like, and even above the average. Speaking of mature projects, they indeed are mostly written using OOP and essentially different from what you wrote here.

What should I learn as a beginner? (procedural or OOP?)

First of all, there is nothing wrong with procedural programming, it's perfectly OK to start from it. Eventually you will learn some OOP and may be even master it.
Besides, it looks like you are confusing OOP which is indeed opposite to procedural programming with PDO which is just a PHP extension to work with databases (though using OOP syntax).
PDO is better than mysqli which you are using at the moment, so to answer your questions about procedural/OOP/PDO:

Learn procedural PHP with occasional use of built-in objects
Better to use PDO for the database access instead of mysqli

Do you have any beginner advice?

Just write a code and post it here for the review.
Now to your code
db.php
this file is better to be rewritten (in case you are going to stick with mysqli) according to my article How to properly connect to Mysql database using mysqli.
index.php
is better to be split into two parts, the data gathering part and the output part. Such a separation will make both parts cleaner:
<?php
include 'db.php';
// Fetch data from db
$query = mysqli_query($con, 'SELECT *, t_firstNo * t_secondNo as result FROM data');
// the following function will give you an array
$data = mysqli_fetch_all($query);
?>
<?php foreeach ($data as $row) : ?>
    <li>
        <?= $row['t_name'] ?> entered
        <?= $row['t_firstNo'] ?> and
        <?= $row['t_secondNo'] ?>
        (result = <?= $row['result'] ?>)
    </li>
<?php endwhile ?>

as you can see, we calculated the result right in the query, which made our output code cleaner and focused on the output. Getting data into array before output is also a good practice, completely separating the database interaction from the output.
process.php
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if(empty($_POST['nickname']) || empty($_POST['firstNo']) || empty($_POST['secondNo'])) {
        echo 'Bad input - try again.';
    } else {
        include 'db.php';
        // insert into DB
        $sql = "INSERT INTO data (t_name, t_firstNo, t_secondNo) VALUES (?,?,?)";
        $stmt = mysqli_prepare($sql);
        $stmt->bind_param("sss", $_POST['nickname'], $_POST['firstNo'], $_POST['secondNo']);
        $stmt->execute();
        header("Location: index.php");
        exit();
    }
}
?>
<form>
Here goes your input form

some notes

it's better to use $_SERVER['REQUEST_METHOD'] if POST method is used.
empty() is essentially a shorthand of isset($var) || $var==''.
it's better to keep the form and its processing on the same page. it can let you to fill the entered values for the convenience.
it is much, much better to use a prepared statement as opposite to the manual escaping you were using, so you should stick with the former.
there is no need to check for the success, your application should be just configured to say "Error" in case of error automatically.


Functions for outputting the rows and columns of a matrix

I think the most performant solution here would be to create an iterator:

julia> immutable EachRow{T<:AbstractMatrix}
           A::T
       end
       Base.start(::EachRow) = 1
       Base.next(itr::EachRow, s) = (itr.A[s,:], s+1)
       Base.done(itr::EachRow, s) = s > size(itr.A,1)
done (generic function with 48 methods)

julia> AA = [1 2 3; 1 2 3]
       for ii in EachRow(AA)
         println(ii)
       end
[1 2 3]
[1 2 3]

EachCol would be coded similarly.

This is advantageous over your task-based iterator design because Julia is not able to infer the return types from anonymous tasks.  This means that within your loop, the iteration variable ii is typed as Any, so the compiler isn't able to emit efficient type-specific code. The custom iterator is type-stable, so that means that Julia knows that the iteration variable is always going to be an array, allowing it to compile specific and optimized instructions.

To answer a few of your questions: We could similarly make an EachDim iterator which also stored the dimension parameter, but this is a little trickier to write in a type-stable manner.  Since indexing into columns returns a 1-dimensional column vector and indexing rows returns a 2-dimensional row vector, simply using an integer argument 1 or 2 to specify which dimension would result in a type-instability.  We'd need to ensure that the dimension information is stored in the type-domain.  One way to do this would be to use a parametric type… but doing this nicely requires the call-overloading feature from the development 0.4 version.

Also note that Julia's JIT doesn't "vectorize" for loops in the way you're using the word.  It can be thought of more as a just-barely-ahead-of-time compiler that compiles specialized machine code for each function based upon the types of the arguments.  This is why type-stability is so important; when Julia can infer the types precisely the compiled code is typically very similar to what you'd get from equivalent C code.


Merging hashes, summing values that have the same key

One way might be to use #reduce (as you suggest) and Hash#merge with a block:

totals = codes_and_totals.reduce({}) do |sums, location|
  sums.merge(location) { |_, a, b| a + b }
end

The merge-block is only invoked if a key exists in both the hashes being merged, so we don't need to guard against nil or start with a zero value. If the block runs, it's because there are two number values that need to be merged (i.e. added, in this case).


std::string like compile-time const char* string

I would only ever mark polymorphic classes final. For them, there's a potential benefit to balance out the unnaturalness of not being able to inherit.
You should really indent the contents of the class by one step. Though that could possibly be an artifact of only partially adapting to SE's markup.
Consider verifying that prefix and suffix have sensible values, at least in debug-mode (assert()).
The first ctor has sensible defaults for its last two parameters. Why not take advantage of that?
Is there a reason you only accept std::string, instead of generally std::basic_string<char, std::char_traits<char>, AnyAllocator>?
You could use !_size instead of _size == 0. Well, de gustibus.
Your comparison is curious, but at least consistent.
I would suggest conforming to C++17 std::string_view as closely as possible so you can later remove your custom class, and to ease the burden for users.


Please use braces {} to wrap your code, even those one line if statements, makes it so much easier to read.

First off, you do know that JSON has an option to output an array right? json_decode( $json, TRUE ) returns an array. No need to create a function for it.

"there's no native PHP function for that" - If it uses the countable interface, which is any data object I've come across (XML, JSON, SQL, etc...) then you can just use count(). If you have an object that holds the comments I would just try using count() on that first before creating a new query just to get a count.

Make sure you are not calling the "same" object twice. I imagine you can just get the whole table into an array then perform array operations on it to get the desired results without having to query the server multiple times. This is probably the biggest reason your program runs so slow. Hope this helps!


Preprocessing text input to a machine-learning algorithm

Given that you are already using Python, I would highly recommend using Spacy (base text parsing & tagging) and Textacy (higher level text processing built on top of Spacy).  It can do everything you want to do, and more, with one function call:

http://textacy.readthedocs.io/en/latest/api_reference.html#textacy.preprocess.preprocess_text

For your further travels in text based machine learning, there are also a wealth of additional features, particularly with Spacy 2.0 and its universe.


Setting some element widths, disabling a button, and initializing some date fields

Since your code is all the same, you can dynamically create your selector:

...

$( '#0LevelId,#1LevelId,#3LevelId' ).change( function(){
    ...
    $( '#' + this.id.substr( 0, 1 ) + 'EffectiveDate' )...
} );


removeClass and addClass optimization in a scoring system

Both the removeClass and addClass methods will accept a space-separated list of class names to add/remove, and both can be chained.

You can cache the selector so you don't have to repeatedly search the DOM.

And since you remove the same three classes in each branch of execution, you can move that outside of the if/else if/else:

var bkf = $(".bkf").removeClass("label-success label-warning label-important");
if (bodyPercent >= successRatio) {
    bkf.addClass("label-success");
}
else if (bodyPercent >= warningRatio) {
    bkf.addClass("label-warning");
}
else {
    bkf.addClass("label-important");
}


I wanted to tackle the problem from a TDD standpoint

and

  I ended up with ~11 tests, although not all of them are probably required (some were me just trying to break things after the fact to prove to myself it was working).

You should look at other options for example QuickCheck (Haskell), but there apparently is a F# port [fscheck][1].
Basic idea is the quickcheck asserts some invariant of the output value of a function.

Or in the same vein but more simply, why not test the following cases:
For each array with a length between 1 and 5 and whose each element is one of {-2, -1, 0, 1, 2}.
It gives you tests in 10s of thousands tests, not several;
and exhaustively searches the most interesting, albeit small, portion of the problem domain.
You can generate and store the answers or can generate them on the fly.

This is the black box part.

For white box part you can check the internal invariants of the algorithm.
You can use Debug.Assert or whatever else your compiler gives you.

  if (bestSum < 0 && bestSum < value)
  {
    bestSum = value;
    currentSum = value;
  }

...........

bestSum = Math.Max(currentSum, bestSum);

snippets are repetitive

So is value > -1 * currentSum and value <= -1 * currentSum.

Moreover, (currentSum + value) > 0 is more readable than value > -1 * currentSum.
Similarly (currentSum + value) <= 0  is more readable than value <= -1 * currentSum.
Also note there is another currentSum + value hidden in currentSum += value.

Compare

if (value < 0 && value > -1 * currentSum)
     currentSum += value;

and

if (value < 0 && (currentSum + value) > 0)
     currentSum = currentSum + value;

currentSum is called currentSum but most of the time holds the previousSum.
This isn't semantic nitpicking. Correct naming is valuable in itself,
but this also prevents you from bestSum = Math.Max(currentSum, bestSum);
right at the end of the for loop. Which is an important loop invariant.
That is expressed succinctly in a single site.
As it is, this is provided by the two bestSum= assignments mentioned above.
But it requires the reader to reason (rightly or wrongly) third clause and the conspicuously missing 4th (else) clause in the conditional analysis of the code does not break the invariant (that is bestSum remains the maximal sub-array sum).

if (bestSum < 0 && means we only encountered negative numbers and this is a special case and should be handled lower than the main cases. Or better yet do not handle this case separately.

  Is there some extraneous logic in here that could be refactored away?

I think your algorithm is not fundamentally different Kadane's algorithm, unless there is a missed case in the confusing conditional.


You declare all your variables with let. You aren't using var, so that's good - but it's better to prefer const over let unless you have no choice but to reassign the variable later. (I recently did a check of one of my scripts and found 414 uses of const compared to 16 uses of let - that's the sort of proportion you want to be aiming towards.) Code is most readable when any reader can immediately understand that a variable is never going to be reassigned from its initial value.
This is a bit opinion-based, but I would prefer to avoid IDs in HTML when possible: they not only automatically create properties on the global object (which can result in strange bugs), but also, only one element with a particular ID can exist in the document at a given time. So, for example, if you were tasked to refactor the code so that multiple lists can be interacted with on a page, you would have to make changes.
(Actually, in new code, I get the feeling that the "industry standard" is to usually avoid vanilla DOM manipulation like this at all - usually, a framework like React is used instead, allowing for the functional composition of components. Eg, if you had a working TodoList, changing to a page with two of them would be as simple as
<TodoList />

<TodoList />
)
You do
<input onblur="this.placeholder = 'What do you want to do?'" onfocus="this.placeholder = ''" placeholder="What do you want to do?" type="text">

Never, ever use inline handlers. They have numerous problems (such as executing inside a few confusing with blocks) and have no place in modern code. To attach an event listener to an element, use addEventListener instead.
But here, you don't need Javascript at all: you can use CSS instead:
input:focus::placeholder {
  color: transparent;
}

You sometimes use functions, and you sometimes use arrow functions. Code is best when its style is consistent - I'd recommend picking one and sticking with it everywhere. (I'd prefer arrow functions, since they're always expressions rather than hoisted and reassignable declarations, and because they're usually more concise, and because they make it clear that this is not being captured in the new function.)
You use KeyboardEvent.keyCode, but it's deprecated. As MDN puts it:

This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

I'd prefer to use the key property instead, which is not only supported, but it's also a whole lot more intuitive when you can simply perform a comparison against a character as a string rather than have to refer to a table mapping keycode numbers to their characters. So, this:
if (e.keyCode === 13 && input.value !== '') {

can be replaced with:
if (e.key === 'Enter' && input.value !== '') {

The deleted function here:
let deleted = () => {
    let spans = document.querySelectorAll('span');
    for (let span of spans) {
        span.addEventListener('click', function() {
            this.parentNode.parentNode.removeChild(this.parentNode);
        });
    };
};

can be improved. First, its name isn't particularly informative - it's good for a function's name to represent what it does. What this function does is it adds an event listener to each  in the document, which deletes the span's ancestor when clicked. A better name would be deleteTodosOnTrashClick.
But, it selects all s in the document. So, if you had, say, a header with a  in addition to the todo list, if the header's span was clicked on, the header would be removed. It would be better to remove only the s which are children of the todo list:
const spans = ul.querySelectorAll('span');

But you're also adding an event listener to every span, every time a new todo is added. Since these spans are being created dynamically, it would be even better to add an event listener to just the created , at the moment that it's created:
const addTodo = () => {
    const listItem = document.createElement('li');
    listItem.innerHTML = ' ' + input.value;
    listItem.addEventListener("click", function() {
        this.classList.toggle("lineThrough");
    });
    ul.appendChild(listItem);
    listItem.querySelector('span').addEventListener('click', () => {
        listItem.remove();
    });
    input.value = '';
};

Note the use of .remove(). This is often preferable to removeChild because removeChild requires a reference to both the parent and the child, which can get a bit verbose, as you can see in your original code.
There's another issue in addTodo. You are creating the HTML string for the new todo by concatenating user input, which should be avoided without taking precautions; this allows the user to execute arbitrary scripts, and insert arbitrary elements, which is a security risk and can result in unpredictable behavior.
For example, imagine if this was hosted on a website for students learning, where the students have logged in, and one of them got a message saying:

Try pasting the following string into the todo list, you won't believe what happens next!

(except obfuscated). Then the student could have their login stolen by an attacker, because the site created the HTML by concatenating user input and did not sanitize it beforehand.
Either strip out all HTML tags from the input first, or assign to the textContent of the container for the text instead, or use insertAdjacentText:
listItem.innerHTML = ' ';
// ...
listItem.insertAdjacentText('beforeend', input.value);

It would also be a good idea (as always) to run the script in strict mode, and put it inside an IIFE so as to avoid global pollution. All together:

(() => {
  'use strict';
  const ul = document.querySelector('.list');
  const input = document.querySelector("input");
  const toggle = document.querySelector('.fa-plus');
  toggle.addEventListener('click', () => {
    toggle.classList.toggle('rotated');
    input.classList.toggle('hide');
  });

  input.addEventListener('keydown', (e) => {
    if (e.key === 'Enter' && input.value !== '') {
      addTodo();
    };
  });

  const addTodo = () => {
    const listItem = document.createElement('li');
    listItem.innerHTML = ' ';
    listItem.addEventListener("click", () => {
      listItem.classList.toggle("lineThrough");
    });
    ul.appendChild(listItem);
    listItem.querySelector('span').addEventListener('click', () => {
      listItem.remove();
    });
    listItem.insertAdjacentText('beforeend', input.value);
    input.value = '';
  };
})();
html {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  font-size: 16px;
}

*,
*:before,
*:after {
  -webkit-box-sizing: inherit;
  -moz-box-sizing: inherit;
  box-sizing: inherit;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ol,
ul {
  margin: 0;
  padding: 0;
  font-weight: normal;
}

ol,
ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* RESET FINISHED */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@500&display=swap');
body {
  font-family: 'Heebo', sans-serif;
  background: rgb(200, 230, 201);
  background: linear-gradient(90deg, #00b09b 0%, #96c93d 100%);
}

#container {
  width: 360px;
  margin: 100px auto;
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(42, 59, 56, 0.4);
}

h1 {
  font-size: 1.6em;
  font-weight: bold;
  padding: .8em .5em;
  background: #00b09b;
  color: #fff;
}

.fa-plus {
  float: right;
  transition: ease-in .2s;
}

.rotated {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transition: ease-in .2s;
}

.hide {
  display: none;
}

input {
  clear: left;
  font-size: 1em;
  padding: .8em .5em;
  width: 100%;
  outline: none;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid rgba(48, 87, 80, 0.4);
  background-color: rgb(236, 236, 236);
  transition: ease-in .2s;
}

input:focus {
  box-shadow: 0 5px 5px rgba(42, 59, 56, .4);
  border-bottom: none;
}
input:focus::placeholder {
  color: transparent;
}

.lineThrough {
  text-decoration: line-through;
  color: grey;
  transition: ease-in .2s;
}

li {
  width: 100%;
  line-height: 40px;
  transition: ease-in .2s;
}

li:nth-child(2n) {
  background-color: rgb(236, 236, 236);
}

span {
  background-color: #e74c3c;
  height: 40px;
  margin-right: 10px;
  text-align: center;
  color: #fff;
  width: 0;
  display: inline-block;
  transition: 0.2s linear;
  opacity: 0;
}

li:hover span {
  width: 40px;
  opacity: 1;
}

Javascript To-Do List

  <input placeholder="What do you want to do?" type="text">


Is my JavaScript test actually testing anything worthwhile here

I'm not quite sure what you mean by "abstracting out the call...", but given that the "production module" actually looks like that, then I'd say that you have a perfectly valid little test there.

It is good to hear that you really are interested in making sure that your test cases are testing the right things. Unit tests are too often something that programmers write simply because they are forced to do it, and they are therefore happy enough when the tests don't fail - not pausing to consider that it might have passed because the test was incorrect, tested the wrong criteria, or did not in fact test anything at all.

Using fake data is what you normally do at this level of functionality, so you are good there. You might generally want to consider using more than one set of test data, but in this case I would say that it is not necessary.


This is not how deleting objects work in Django.

The __del__ method is a Python mechanism and is called when an object is garbage collected. This would be a huge mess if database rows were dropped anytime an object goes out of scope. This is also why calling del object doesn't seem to have any side effect: Django still caches the value somewhere, you just got rid of your variable.

Instead, you should use the delete() method on a model instance or on a queryset. But in fact none of this code is required as the on_delete=models.CASCADE will take care of that for you: as soon as a User object is deleted, the other linked objects will be deleted as well.

The only thing missing is to automatically delete the User instance when a UserProfile instance is deleted. This is better implemented using signals as it will be called for both usages discussed earlier.

Alternatively, you can provide a method on your UserProfile model that will delete the underlying User and, thus, everything related to it:

def delete_user(self):
    self.User.delete()

But you won't be able to use it for bulk deletions.


Configuring an editor for various languages using Factory Method Pattern

I need to know if my code is a valid implementation of the factory method pattern.

No.

The reason is that the factory cannot be part of the objects to be created. I think you would be surprised to find a factory in the the hedge of your car, wouldn't you?

Generally spoken your approach fails the Separation of Concerns principle.

You have two responsibilities in your code that belong to a factory:

identifying the requested type.
creating the actual object.

Both should be in a separate factory class.

Also: your "factory" is producing the wrong type of objects because of your misconception of inheritance.

We employ inheritance when the child classes differ in behavior. But your Editor extensions only differ in configuration (as far as your code example is showing...).

So what your (yet to build) factory should do is creating the "language depended"  key word list and pass that into a new instance of the one and only Editor class.


Mixing Lens operations with "original" operations

I wouldn't say there's anything like a proscription against doing so, but as a non-user of lens I can't say it helps me understand what's going on. I'm also not sure that your data structure is complex enough to warrant using lens in this case, functions out of base tend to produce a pretty concise solution on their own when properly deployed.

I haven't tested this, but I think it's equivalent.

import Control.Monad.State
import Data.Map
import Safe (atMay) -- "safe".Safe.atMay :: [a] -> Int -> Maybe a

getUniqueIdent :: String -> State (Map String Int) (Maybe String)
getUniqueIdent typeName =
  do indices <- get
     modify $ adjust succ typeName
     return $ do identifiers <- Data.Map.lookup typeName typeNameMap
                 uniqueIndex <- Data.Map.lookup typeName indices
                 identifiers `atMay` uniqueIndex


Calling the number next to the ids "neighbours" is confusing, actually the ids are more like keys and the second parameter can be considered a value?

You have an AVL tree listing all the keys, and for each key, an AVL storing all the values.

You have 350000 ids with 50 values for each key. 50 is a small number, making it not completely necessary to use an AVL tree. A simple array or vector could work, it would remove a lot of the overhead of dynamically allocating nodes for each new value.

AVL trees are supposed to do every basic operation in \$O(log(n))\$, meaning insert, search, delete. Meaning, individual operations should still be very fast even after 350000 IDs are inserted (for reference, \$log_2(350000)\$ ~ 18).

The reason your program slows down should be the insert method in the AVL tree. It balances the tree after every insertion, starting from the root. Which in turn calculates the height difference and the height of both subtrees recursively:

int AVLTree::height(Node *node)
{
    if (node != NULL)
    {
        int leftHeight = height(node->left);
        int rightHeight = height(node->right);
        int maxHeight = max(leftHeight, rightHeight);
        return maxHeight + 1;
    }
    else
    {
        return 0;
    }
}

This function is actually \$O(n)\$ since it goes recursively through each child of node. Meaning, each time you get the height of a node when rebalancing the tree, it will be slow.

The solution is to keep track of the height of each node. It could look something like this for the insert function:

Node* AVLTree::insert(Node *node, int ID)
{
    if(!node) //if you want to use a comparison to null here, use nullptr instead of NULL
    {
        node = newNode(ID); //node->height should be 0 at init
        size++;
        return node;
    }

    if (node->ID == ID) {
        return node;
    }

    if(node->ID > ID)
    {
        node->left = insert(node->left, ID);
    }
    else if(node->ID < ID)
    {
        node->right = insert(node->right, ID);
    }

    updateHeight(node);
    balance(node);

    return node;
}

Then the updateHeight function could be like this:

void AVLTree::updateHeight(Node *node) {
    if (!node) {
        return;
    }

    node->height = max(height(node->left), height(node->right)) + 1;
}

And the height function would be simplified and non-recursive:

int AVLTree::height(Node *node)
{
    if (!node) {
        //since the value of a leaf is 0, the value of a non existing-node is -1
        //if you want 0 here the value for a new node should be 1
        return -1;
    }
    return node->height;
}

The node's height is only updated for nodes that are traversed during the insert function, so this operation only has a complexity of \$O(log(n))\$.

Of course you also have to update the height manually when rotating the nodes or deleting the nodes, by calling updateHeight() on the appropriate nodes. (Note that children have to have their heights updated before the parents).

There is also another area in the balance function that introduces complexity:

balance(node->left);
balance(node->right);

It will traverse the whole subtree and be applied to every node in the tree, causing a complexity of \$O(n)\$. In the insert function balance is already applied to all the ancestry of a node that gets a new child, so in the balance function you should only do recursive calls when necessary.

I'm not sure the calls to balance the children are necessary if the rotations are properly done (maybe they are) but at least they are not necessary when the current node is already balanced, so changing the beginning of the balance function to this will reduce its complexity to \$O(log(n))\$:

void AVLTree::balance(Node *&node)
{
    if (!node)
    {
        return;
    }
    int height_diff = heightDifference(node);
    if (abs(height_diff) <= 1)
    {
        return;
    }

    //...

As it will stop going down the subtree if it is balanced.

No comments on the rest of your code, it's very readable and I wouldn't sacrifice that over small optimizations when they are not needed.

PS: If you keep this:

balance(node->left);
balance(node->right);

At the end of the balance function, don't forget to call updateHeight(node) as the height of the children have potentially changed. But those two calls seem weird to me as balancing children can change their height and potentially unbalance the current node again.


Add the number of descendants for each li node

I think functional coding style is best suited here, because it will significantly reduce amount of code. Also, you will have clearly separated structure consisting of functions with single responsibility.

Suggested solution

function insertCounts(root) {
    forEachElement(root, (el) => el.innerHTML = countText(count(el)) + el.innerHTML, el => !isLeaf(el) && (el.tagName === 'LI'));
}

function countText(count) {
     return `[${count}]`;
}

function forEachElement(root, apply, predicate = () => true) {
    Array.from(root.children).forEach(el => { predicate(el) && apply(el); forEachElement(el, apply, predicate) });
}

function count(root) {
    return Array.from(root.children).reduce((acc, el) => isLeaf(el) ? acc + 1 : acc + count(el), 0);
}

function isLeaf(elem) {
    return (elem.firstElementChild === null);
}

try {
    if(document.body.firstElementChild !== null) {
        insertCounts(document.body.firstElementChild);
    }
}  catch (err) {
    console.log(err);
}


Subclassing Flask for Permissions with Google App Engine

The first thing that comes to mind is just to cache user permissions in memcache, but that might or might not be necessary. I'd try this way first and see if you run into issues.

A simpler approach would be to define each user's key to be their username, then use get_by_id(). That has the advantage of being automatically memcached by ndb and being faster (I think).


Implementation of unix utility tail in C

Avoid globals. lines_read is naturally suited to return lines_read.
tail leaks memory. You shall free the line pointed by buffer[....] before reassigning it.
sizeof(char) is guaranteed to be 1.

I don't remember at which point K&R offer this exercise. In any case,

The line-reading loop is better expressed as fgets.
malloc/strcpy combination is a long way to say strdup.


Well, you could just call the toArray method of your list to transform the list into an array. Or even better, you could make the table model use a List<Object[]> rather than an Object[][], which would avoid the unnecessary conversion.


Get length of the longest sequence of numbers with the same sign

A small portability bug: std::size_t is in the std namespace, assuming it's declared by including <cstddef> (recommended).

No unit tests are included, but I'd expect one that tests that the result is zero when the input collection is empty.  We need to initialize maxlen to zero for that test to pass.

When comparing consecutive elements of a collection, always consider using std::adjacent_find().  With a suitable predicate function, we can find changes from negative to non-negative and vice versa without needing to code our own loop or do any indexing.

(More advanced) Consider making your algorithm generic, templated on an iterator type, so that it can be applied to any collection (or even to an input stream directly).

Here's a version that applies all of these suggestions (and some from other answers that I've not repeated above):

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <iterator>

template<typename ForwardIt>
std::size_t getLongestSameSignSequenceLength(ForwardIt first, ForwardIt last)
{
    auto const signdiff =
        [](auto a, auto b){ return std::signbit(a) != std::signbit(b); };

    std::size_t maxlen = 0;

    while (first != last) {
        ForwardIt change = std::adjacent_find(first, last, signdiff);
        if (change != last) { ++change; }

        std::size_t len = std::distance(first, change);
        if (len > maxlen) { maxlen = len; }

        first = change;
    }

    return maxlen;
}

// tests:

#include <vector>

int main()
{
    struct testcase { std::size_t expected; std::vector<int> inputs; };
    std::vector<testcase> tests
        {
         {0, {}},
         {1, {1}},
         {1, {1, -2}},
         {1, {1, -2,  3}},
         {1, {-1, 2, -3}},
         {2, {1,  2}},
         {2, {1,  2, -3}},
         {2, {-1, -2, 3}},
         {2, {-1, 2,  3}},
         {2, {-1, 2,  3, -4}},
        };

    int failures = 0;
    for (auto const& [e, v]: tests) {
        failures += getLongestSameSignSequenceLength(v.begin(), v.end()) != e;
    }

    return failures;
}


"When to take medicine" CodeChef Challenge MEDIC

You don't check whether the input is invalid.
Try to extract useful well-named functions, like int days(int month, int year) and bool is_leap_year(int year).
You can extract the numbers directly from std::cin, the colon will be left behind.
And the colon can thereafter be extracted like any other single character.
As an aside, using scanf() would probably be easier than juggling streams.
break should be indented like any other Statement. It does not deserve more indentation (first occurrence), nor less (second occurrence).


Calculating the determinants of data entered

General comments:

Use one line per variable.

int x,y,z,;

Prefer to use smaller than than smaller than or equal. This is a bit nit-picky but when working with array bounds you can then use the same number in the test as in the size of the array, which makes it slightly easier to read.

int mReader[9];
for (x = 0 ; x <= 8 ; x++)

// try
int mReader[9];
for (x = 0 ; x < 9 ; x++) // easy to see correlation between x and mReader

The variables x/y/z are not used to pass information between different loops. So rather than declare them at the top declare them as close to the point of use as possible. Your loops should look more like this:

for(int x = 0; x<=2 ;x++)
 // ^^^ x is local to the loop

Do not fall in to the mental trap of thinking that you are saving space for re-use. The compiler is quite capable of doing that all by itself.

This test seems a bit redundant:

if ((x % 3) == 0 || x == 0)
     //          ^^^^^^^^^  Why? if x == 0 then (x % 3) == 0 thus the second part of the
     //                          test will never be evaluated.

Are you sure this is correct?

for(x = 9 ; x >= 1 ; x--)

Seems like x never reaches 0. As it turns out it is correct even if it looks wrong. But you need to read the rest of the code to make sure it is being used correctly. Writing code were you need to scan ahead to determine correctness is not a good idea. I would loop the same way as all the other loops (using a different variable name) then adjust the usage.

for(int reverseX = 0 ; reverseX < 9 ; ++reverseX)
{
 .....
     Determinant[y] =  Determinant[y] * My3DMatrix[z][mReader[9 - 1 - reverseX]];

Does this work?

cin.get();

Looks like you are trying to pause the application before termination. But to me it looks like it will try and swallow the '\n' from the last time you hit enter, and thus do nothing.


Expression evaluator with Shunting-Yard algorithm

This is a strong question with easy-to-read code.  I'm impressed with it.

I will pick on formatting some, because that's easier than the substantive, but I don't get the feeling that there's are many real issues with this code.

Vertical whitespace in methods

It is my opinion that vertical whitespace in code is of limited value, makes the boundaries between methods less visually apparent, and can usually be replaced with stronger mechanisms for revealing meaning.

  def symbolize input
    stripped = input.lstrip

    if stripped.size == 0 then
      []
    ...
  end

Here, the purpose of the vertical whitespace is not apparent to me, so I cannot comment on what might replace it.  Some alternatives:

Move the related lines into a method, or
Use a comment to indicate why the lines are special, or
Just get rid of the whitespace

Use parentheses when defining methods

Whether or not you use parentheses when calling methods, use them when defining methods.  Prefer:

  def shunt(symbol)

to:

  def shunt symbol

Reasons:

If I recall, there are some argument declarations that just won't work without parentheses anyhow.
The parentheses help clue the eye in that a method declaration is happening.
At least one standards guide recommends this.

Omit then on most ifs

With a multi-line if (most if expressions):

    (ShuntingYard.new.parse input).each do |symbol|
      result << (if @eval[symbol]
                  right = result.pop
                  left = result.pop
                  @eval[symbol].call left, right
                else
                  symbol
                end)

If the parentheses around the if...else...end were driven by the then, then the parentheses can (and should) now be removed.

Use #map

This iterative code builds a new array based on an enumeration:

    result = []

    (ShuntingYard.new.parse input).each do |symbol|
      result << (if @eval[symbol] then
                  right = result.pop
                  left = result.pop
                  @eval[symbol].call left, right
                else
                  symbol
                end)

This could use #map instead (note: untested):

    result = (ShuntingYard.new.parse input).map do |symbol|
      if @eval[symbol]
        right = result.pop
        eft = result.pop
        @eval[symbol].call left, right
      else
        symbol
      end
    end


Scrapy crawler to parse data recursively

The code is quite clean and easy to read, good job!

I would only focus on couple things:

remove extra spaces around = when it is used to define a keyword argument
CSS selectors are more appropriate and reliable when it comes to handling multi-valued class attribute than XPath expressions. Plus, they are more concise and generally faster
naming - for links in should actually be for link in
as for the target_page method, I don't think you need a loop - if I understand correctly, there should be a single "product" parsed at this point
you may use start_urls instead of start_requests()

All things taken into account:

import scrapy

class SephoraSpider(scrapy.Spider):
    name = "sephorasp"
    start_urls = ["https://www.sephora.ae/en/stores/"]

    def parse(self, response):
        for link in response.css('ul.nav-primary a.level0::attr(href)').extract():
            yield scrapy.Request(url=link, callback=self.parse_inner_pages)

    def parse_inner_pages(self, response):
        for link in response.css('li.amshopby-cat > a::attr(href)').extract():
            yield scrapy.Request(url=link, callback=self.target_page)

    def target_page(self, response):
        name = response.css('.product-name > a::text').extract_first()
        price = response.css('span.price::text').extract_first()
        yield {'name': name, 'price': price}

(not tested)


Leetcode - First Unique Character in a String

You don’t need Objects.isNull(...).  Simply using != null would suffice, and avoids an extra function call so should be faster (unless the compiler can optimize the call out).

Your loop at the end is using raw types.  You should use

for(Map.Entry<Character, Integer> e : map.entrySey()) {

instead, for type safety.  Your castings then are unnecessary.

There is no need to fetch the character c = e.getKey() unless value == 1 is true; you can more that inside the if for a minor performance gain.

Counting the character occurrences is slightly dangerous: you could overflow an Integer, or even a Long with a long enough string.  Simply flagging the character as “seen once” or “more than once” avoids the counting overflow bug.

The map.put(c, 1) call returns the previous value stored in the map, or null if no value was stored.  Instead of fetching the value, testing whether it was present or not, and then storing another value, why not store & fetch in one operation?  Then, if a value was already present, you can flag it as occurring twice (or more).

if( map.put(c, 1) != null )
    map.put(c, 2);

Since you are no longer counting, you don’t need a LinkedHashMap<Character, Integer>.  You just have 3 states: not seen, seen once, and seen more than once.  A Boolean can cover this.  Boolean.TRUE is seen once (unique), Boolean.FALSE is seen more than once, and not present (null) is never seen.

LinkedHashMap<Character, Boolean> unique = new LinkedHashMap<>();

for(char c: ...) {
    if (unique.put(c, Boolean.TRUE) != null)
        unique.put(c, Boolean.FALSE);
}

We’ve saved a tiny bit of space, since we only have two Boolean objects, instead of several (possibly interned) Integer objects.  Much more importantly, we’ve avoided auto boxing, so this should be much faster.

We are still wasting time storing both Boolean.TRUE and Boolean.FALSE successively on the third and subsequent occurrences of any character.

If we always store Boolean.FALSE, then on the first occurrence null will be returned.  We can detect that and overwrite it with Boolean.TRUE instead, so the exceptional first occurrence has 2 map put operations, but subsequent occurrences only use 1 map put operation, for better performance.

    if (unique.put(c, Boolean.FALSE) == null)
        unique.put(c, Boolean.TRUE);

To truly gain speed and reduce memory usage, avoid clunky HashSet<> memory structures, and store the data yourself.  You are told you can assume only lowercase letters are used, so you can use a new byte[26] array for “not seen”, “seen once”, and “seen multiple times” storage.  And use a new char[26] array to maintain encounter order of “first seen” characters.

You can use a bit more memory and store the index of the first seen characters in a new int[26], so you can avoid the linear s.indexOf(c) search at the end.  You could even use 0 for not seen, index+1 for seen once, and -1 for seen multiple times, and avoid the new byte[26] flag storage.


The final asynchronous VB function we use is WebClient.DownloadStringTaskAsync(). This is arbitrary, and is used for example purposes only.

This indicates to me that you should think about making this reusable, so that when you need to use the progress bar somewhere else, you don't need to copy & paste the code.

Dim progressTarget As Action(Of Integer) ' We have to create an event handler for the function we use to report progress
progressTarget = AddressOf ReportProgress ' We assign the handler to our specific function (see below)
myProgress = New Progress(Of Integer)(progressTarget) ' When we initialize our progress reporter, we pass our handler to it

This is way too verbose. What's wrong with just the following line?

myProgress = New Progress(Of Integer)(AddressOf ReportProgress)

You don't need to comment every single thing you do, that's obvious from the code.

You should disable the button that doesn't make sense at the moment. This is especially important for the StartButton, because right now, the user can start the download multiple times.

Dim myString As String = ""

' code that doesn't use myString

myString  = …

Return myString

There is no need to declare the variable early or to set it to "". Actually, there is no need to declare the variable at all, you can just return the expression directly.

Names like Label1 and myInt are very unhelpful. Use descriptive names like ProgressLabel (though that's not great either) and stepNumber.


Printing the bits of an integer using bitfields and union

Avoid global variables - there's no need for t and v to exist outside main().

Always check the return value of scanf() before using the written values.

Don't assume that CHAR_BIT is 8, or that sizeof (short) is 2.  Neither of those is portable.

Don't assume a particular ordering of bit fields within a struct - that's entirely compiler-dependent.

Portable code needs a loop to print the bits, like this:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    short x;
    if (scanf("%hi", &x) != 1) {
        fputs("Input error\n", stderr);
        return EXIT_FAILURE;
    }

    unsigned short v = (unsigned short)x;

    unsigned short mask = -1u;                /* 11111... */
    mask -= (unsigned short)(mask / 2);       /* 10000... */

    while (mask) {
        printf("%d ", (v & mask) != 0);
        mask >>= 1;
    }
    printf("\n");
}