---
# System prepended metadata

title: CommonEdge Interview with Tiago

---

# CommonEdge Interview with Tiago

### If you could program in any language, what would it be?

C++ - it's behind everything

### Why doesn't 0.4 + 0.8 == 1.2? (in javascript, Java, PHP, C, etc.)

### Fix the bugs in this function to count reachable nodes in a directed graph.

```php
class Node {
    public $value; // assuming unique values
    public $children;
    
    // count how many nodes are reachable from this node including this node
    public countNodes($seen=[]) {
        $n = 0; 
        if(!$seen[$this->value]){
           $seen[$this->value] = $this; 
           $n = 1;
        }
        foreach($this->children as $child) 

{
            if(!$seen[$child->value])
                $n += $child->countNodes(&$seen);
        }
        return $n;
    }
}
```

### Given an array of numbers, return the second greatest number without using sort.
  
```php 
max = 0
second = 0
foreach ($numbers as $k => $v){
    if(v >= max) 
       second = max
       max = v 
    else if (v > second) 
       second = v

}
```

### What is this function?

```typescript=
const somemysteryfunction = <A,B>(f: (x: A) => B, xs: A[]): B[] => // ...

const blah = (x: Opening): Surface => // ...
const foo = (x: Surface): Panels[] => // ...
const bar = (x: Opening): Panels[] => foo(bar(s));
{
    const s: Surface = blah(x);
    const ps: Panels[] = foo(s);
    return ps;
}

const compose = <A,B,C>(f: (x: B) => C, g: (y: A) => B) => (y: A): C => f(g(y));
bar = compose(foo, blah);
```


