|
786 | 786 | }, |
787 | 787 | { |
788 | 788 | "cell_type": "code", |
789 | | - "execution_count": 31, |
| 789 | + "execution_count": 56, |
790 | 790 | "id": "e7368cf0", |
791 | 791 | "metadata": {}, |
792 | 792 | "outputs": [], |
|
796 | 796 | }, |
797 | 797 | { |
798 | 798 | "cell_type": "code", |
799 | | - "execution_count": 32, |
| 799 | + "execution_count": 57, |
800 | 800 | "id": "91426fd9-654b-48e7-a77d-0c78ff248c9e", |
801 | 801 | "metadata": {}, |
802 | 802 | "outputs": [ |
803 | 803 | { |
804 | 804 | "data": { |
805 | 805 | "text/plain": [ |
806 | | - "[0, 0, 1, 0, 0, 1, 1, 0, 1, 1]" |
| 806 | + "[1, 0, 1, 0, 1, 0, 1, 0, 1, 1]" |
807 | 807 | ] |
808 | 808 | }, |
809 | | - "execution_count": 32, |
| 809 | + "execution_count": 57, |
810 | 810 | "metadata": {}, |
811 | 811 | "output_type": "execute_result" |
812 | 812 | } |
|
817 | 817 | }, |
818 | 818 | { |
819 | 819 | "cell_type": "code", |
820 | | - "execution_count": 33, |
| 820 | + "execution_count": 58, |
821 | 821 | "id": "acd88973-5f07-4565-a4fd-ca4fc732b425", |
822 | 822 | "metadata": {}, |
823 | 823 | "outputs": [], |
|
827 | 827 | }, |
828 | 828 | { |
829 | 829 | "cell_type": "code", |
830 | | - "execution_count": 34, |
| 830 | + "execution_count": 59, |
831 | 831 | "id": "8be1959e-e0fb-4daa-8ccc-0ab5d083e8a3", |
832 | 832 | "metadata": {}, |
833 | 833 | "outputs": [], |
|
837 | 837 | }, |
838 | 838 | { |
839 | 839 | "cell_type": "code", |
840 | | - "execution_count": 35, |
| 840 | + "execution_count": 60, |
841 | 841 | "id": "3d62e21f-e93c-4870-9c56-6610cfaeb5b9", |
842 | 842 | "metadata": {}, |
843 | 843 | "outputs": [], |
|
847 | 847 | }, |
848 | 848 | { |
849 | 849 | "cell_type": "code", |
850 | | - "execution_count": 36, |
| 850 | + "execution_count": 61, |
851 | 851 | "id": "128a85b0-2626-431a-adde-137f3738eb8f", |
852 | 852 | "metadata": {}, |
853 | 853 | "outputs": [ |
|
857 | 857 | "(1, 10)" |
858 | 858 | ] |
859 | 859 | }, |
860 | | - "execution_count": 36, |
| 860 | + "execution_count": 61, |
861 | 861 | "metadata": {}, |
862 | 862 | "output_type": "execute_result" |
863 | 863 | } |
|
868 | 868 | }, |
869 | 869 | { |
870 | 870 | "cell_type": "code", |
871 | | - "execution_count": 37, |
| 871 | + "execution_count": 62, |
872 | 872 | "id": "92d7262c-88b3-46c9-87b9-813144df30da", |
873 | 873 | "metadata": {}, |
874 | 874 | "outputs": [ |
875 | 875 | { |
876 | 876 | "data": { |
877 | 877 | "text/plain": [ |
878 | | - "[[0, 0, 1, 0, 0, 1, 1, 0, 1, 1],\n", |
879 | | - " [0, 1, 1, 0, 1, 1, 0, 1, 1, 0],\n", |
880 | | - " [1, 1, 0, 1, 1, 0, 1, 1, 0, 0],\n", |
881 | | - " [1, 0, 1, 1, 0, 1, 1, 0, 0, 1],\n", |
882 | | - " [0, 1, 1, 0, 1, 1, 0, 0, 1, 1],\n", |
883 | | - " [1, 1, 0, 1, 1, 0, 0, 1, 1, 0],\n", |
884 | | - " [1, 0, 1, 1, 0, 0, 1, 1, 0, 1],\n", |
885 | | - " [0, 1, 1, 0, 0, 1, 1, 0, 1, 1],\n", |
886 | | - " [1, 1, 0, 0, 1, 1, 0, 1, 1, 0],\n", |
887 | | - " [1, 0, 0, 1, 1, 0, 1, 1, 0, 1],\n", |
888 | | - " [0, 0, 1, 1, 0, 1, 1, 0, 1, 1],\n", |
889 | | - " [0, 1, 1, 0, 1, 1, 0, 1, 1, 0]]" |
| 878 | + "[[1, 0, 1, 0, 1, 0, 1, 0, 1, 1],\n", |
| 879 | + " [0, 1, 1, 1, 1, 1, 1, 1, 1, 0],\n", |
| 880 | + " [1, 1, 0, 0, 0, 0, 0, 0, 0, 0],\n", |
| 881 | + " [1, 0, 0, 1, 1, 1, 1, 1, 1, 1],\n", |
| 882 | + " [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],\n", |
| 883 | + " [1, 1, 1, 0, 0, 1, 1, 1, 1, 1],\n", |
| 884 | + " [0, 0, 0, 0, 1, 1, 0, 0, 0, 0],\n", |
| 885 | + " [1, 1, 1, 1, 1, 0, 0, 1, 1, 1],\n", |
| 886 | + " [0, 0, 0, 0, 0, 0, 1, 1, 0, 0],\n", |
| 887 | + " [1, 1, 1, 1, 1, 1, 1, 0, 0, 1],\n", |
| 888 | + " [0, 0, 0, 0, 0, 0, 0, 0, 1, 1],\n", |
| 889 | + " [0, 1, 1, 1, 1, 1, 1, 1, 1, 0]]" |
890 | 890 | ] |
891 | 891 | }, |
892 | | - "execution_count": 37, |
| 892 | + "execution_count": 62, |
893 | 893 | "metadata": {}, |
894 | 894 | "output_type": "execute_result" |
895 | 895 | } |
|
903 | 903 | "id": "3da8dbca-2170-47c6-8de1-aadf6ad6a857", |
904 | 904 | "metadata": {}, |
905 | 905 | "source": [ |
906 | | - "Just to make sure we define a function that verifies the result. The generations prior to the start index should not occur in the history, the one at the start index should be equal to the last generation in the history." |
| 906 | + "Just to make sure we define a function that verifies the result. The generations prior to the start index should not occur in the history, the one at the start index should be equal to the last generation in the history. Finally, none of the other generations should occur more than once." |
907 | 907 | ] |
908 | 908 | }, |
909 | 909 | { |
910 | 910 | "cell_type": "code", |
911 | | - "execution_count": 38, |
| 911 | + "execution_count": 65, |
912 | 912 | "id": "7a60eae7-3ee5-4c2f-a334-a7629fd5b5dd", |
913 | 913 | "metadata": {}, |
914 | 914 | "outputs": [], |
915 | 915 | "source": [ |
916 | 916 | "def verify_cycle_strategy(strategy, result):\n", |
917 | 917 | " start_idx, cycle_length = result\n", |
918 | | - " for idx in range(start_idx):\n", |
919 | | - " assert strategy._history[idx] not in strategy._history[start_idx:]\n", |
920 | | - " assert strategy._history[start_idx] == strategy._history[-1]" |
| 918 | + " for idx, automaton in enumerate(strategy._history[:-1]):\n", |
| 919 | + " if idx == start_idx:\n", |
| 920 | + " assert automaton == strategy._history[-1]\n", |
| 921 | + " else:\n", |
| 922 | + " assert automaton not in strategy._history[idx + 1:] " |
921 | 923 | ] |
922 | 924 | }, |
923 | 925 | { |
924 | 926 | "cell_type": "code", |
925 | | - "execution_count": 39, |
| 927 | + "execution_count": 66, |
926 | 928 | "id": "72297084-e9a7-494e-81c7-3b936b60471b", |
927 | 929 | "metadata": {}, |
928 | 930 | "outputs": [], |
|
940 | 942 | }, |
941 | 943 | { |
942 | 944 | "cell_type": "code", |
943 | | - "execution_count": 40, |
| 945 | + "execution_count": 67, |
944 | 946 | "id": "f46f2070-1a3a-40b9-a718-22ee084cff44", |
945 | 947 | "metadata": {}, |
946 | 948 | "outputs": [ |
947 | 949 | { |
948 | 950 | "data": { |
949 | 951 | "text/plain": [ |
950 | | - "[<matplotlib.lines.Line2D at 0x7f6fd6a90400>]" |
| 952 | + "[<matplotlib.lines.Line2D at 0x7f6fe42ee800>]" |
951 | 953 | ] |
952 | 954 | }, |
953 | | - "execution_count": 40, |
| 955 | + "execution_count": 67, |
954 | 956 | "metadata": {}, |
955 | 957 | "output_type": "execute_result" |
956 | 958 | }, |
|
0 commit comments