Esempio n. 1
0
 public function testCanSetAndGetSignal()
 {
     $wire = new Wire('a');
     $wire->setSignal(123);
     $this->assertEquals(123, $wire->getSignal());
 }
Esempio n. 2
0
                break;
            case 'LSHIFT':
                $wire1 = $circuit->getWire($cmd['wires'][0]);
                if ($wire1 === false) {
                    break;
                }
                $result = $wire1->getSignal() << (int) $cmd['value'];
                break;
            case 'RSHIFT':
                $wire1 = $circuit->getWire($cmd['wires'][0]);
                if ($wire1 === false) {
                    break;
                }
                $result = $wire1->getSignal() >> (int) $cmd['value'];
                break;
            case 'NOT':
                $wire1 = $circuit->getWire($cmd['wires'][0]);
                if ($wire1 === false) {
                    break;
                }
                $result = ~$wire1->getSignal();
                break;
        }
        if ($result !== false) {
            $assignee->setSignal($result);
            $circuit->addWire($assignee);
            $processedIndexes[] = $key;
        }
    }
} while (count($lines) > count($processedIndexes) && ++$loopCount < 1000);
echo 'Answer: A: ' . $circuit->getWire('a')->getSignal() . PHP_EOL;