Upgrade to Pro — share decks privately, control downloads, hide ads and more …

42Tokyo-push_swap

love42
February 28, 2023

 42Tokyo-push_swap

love42

February 28, 2023
Tweet

More Decks by love42

Other Decks in Programming

Transcript

  1. 2

  2. 6 1 2 3 -> x ( ) 1 3

    2 -> 2 1 3 ( rra ) -> 1 2 3 ( sa ) 2 1 3 -> 1 2 3 ( sa ) 2 3 1 -> 1 2 3 ( rra ) 3 1 2 -> 1 2 3 ( ra ) 3 2 1 -> 2 1 3 ( ra ) -> 1 2 3 ( sa )
  3. 6

  4. ( )

  5. 2

  6. ( )

  7. B → A B → A A → B YES

    NO YES NO A → B ( )
  8. B B

  9. A B 10 16 17 14 13 12 15 18

    11 5 3 6 2 9 7 4 1 8 8 10 16 1 17 4 7 14 9 13 2 12 6 15 18 11 3 5 A B A B pb ra ra pb ra pb rb rb pa rb pa pa
  10. A B A B 8 7 9 6 10 |

    18 5 3 2 4 1 4 5 8 7 9 6 10 | 18 1 3 2 A B 4 5 8 7 9 6 10 | 18 1 2 3 A B 4 5 8 7 9 6 10 | 18 1 2 3 pa rb rb pa rra sa pa ra pa ra pa ra
  11. A B A B 8 7 9 6 10 |

    18 1-3 5 4 8 7 9 6 10 | 18 1-3 4 5 A B 8 7 9 6 10 | 18 1-3 4 5
  12. A B A B A B 10 | 18 1

    | 5 6 9 7 8 8 9 10 | 18 1 | 5 6 7 8 9 10 | 18 1 | 5 6 7
  13. A B A B 10-18 10 | 18 1 |

    7 9 8 10 | 18 1 | 7 8 9 A B 10 | 18 1 | 7 8 9
  14. A B 10 - 18 8 - 9 6 -

    7 4 - 5 1 - 3 A B 8 - 9 6 - 7 10 - 18 4 - 5 1 - 3 A B 4 - 5 8 - 9 6 - 7 10 - 18 1 - 3 A B 4 - 5 8 - 9 6 - 7 10 - 18 1 - 3 A B 8 - 9 5 - 7 10 - 18 4 - 5 A B 8 - 9 6 - 7 10 - 18 1 - 3 4 - 5 A B 10 - 18 1 - 5 8 - 9 6 - 7 A B 8 - 9 10 - 18 1 - 5 6 - 7 A B 8 - 9 10 - 18 1 - 5 6 - 7 A B 10 - 18 1 - 7 8 - 9 A B 10 - 18 1 - 7 8 - 9 A B 1 - 9 10 - 18 B 4 →A B → A A B → A A B 2 →A B →A 1 → B A → B 2 4 → B 1 2 → B B 2 →A B →A B →A B →A
  15. 16 → 8 → 4 → 2 2 → 4

    → 8 → 16 4 8 16
  16. int func(int N) { int A; if (N == 1)

    return (1); A = func(N - 1) * N; // printf("%d\n", N); return (A); }
  17. printf func ( 5 ) = func ( 4 )

    x 5 func ( 4 ) = func ( 3 ) x 4 func ( 3 ) = func ( 2 ) x 3 func ( 2 ) = func ( 1 ) x 2 func ( 1 ) = 1 1 2 6 24 120 printf 2 3 4 5
  18. A B 10 - 18 8 - 9 6 -

    7 4 - 5 1 - 3 A B 8 - 9 6 - 7 10 - 18 4 - 5 1 - 3 A B 4 - 5 8 - 9 6 - 7 10 - 18 1 - 3 A B 4 - 5 8 - 9 6 - 7 10 - 18 1 - 3 A B 8 - 9 5 - 7 10 - 18 4 - 5 A B 8 - 9 6 - 7 10 - 18 1 - 3 4 - 5 A B 10 - 18 1 - 5 8 - 9 6 - 7 A B 8 - 9 10 - 18 1 - 5 6 - 7 A B 8 - 9 10 - 18 1 - 5 6 - 7 A B 10 - 18 1 - 7 8 - 9 A B 10 - 18 1 - 7 8 - 9 A B 1 - 9 10 - 18 B 4 →A B → A A B → A A B 2 →A B →A 1 → B A → B 2 4 → B 1 2 → B B 2 →A B →A B →A B →A
  19. A = 4 B → A A → B A

    = 2 B → A A → B A = 2 B → A A → B B → A B → A B → A B → A A A push B B B = 5 B = 3 B = 2 B = 4 B = 2 B = 2 B = 9
  20. ...