This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Fibonacci | |
| { | |
| public int[] GenerateFibonacciSequenceWithLength(int length) | |
| { | |
| int[] sequence = new int[length]; | |
| for (int i = 0; i < sequence.Length; i++) | |
| { | |
| sequence[i] = i < 2 ? i : sequence[i - 1] + sequence[i - 2]; | |
| } | |
| return sequence; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def tick(cell, number_of_neighbors) | |
| if number_of_neighbors < 2 || number_of_neighbors > 3 | |
| cell.setAlive false | |
| end | |
| if number_of_neighbors == 3 | |
| cell.setAlive true | |
| end | |
| end |