$30 off During Our Annual Pro Sale. View Details »

Double-Array Build

jojonki
November 20, 2019

Double-Array Build

jojonki

November 20, 2019
Tweet

More Decks by jojonki

Other Decks in Technology

Transcript

  1. 0 0 0 0 0 0 0 0 0 0

    0 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc ߏஙͯ͠ΈΑ͏ʂ 0 0 7
  2. 0 0 0 0 0 0 0 0 0 0

    0 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ base[1] >= 1ͷ৚݅Ͱɼ base[1]+code(a) == ະ࢖༻index Λ୳͢ base஋0͸ະ࢖༻Λද͢ͷͰ 1Ҏ্Ληοτ͢Δඞཁ͕͋Δ 0 0 7
  3. 1 0 0 0 0 0 0 0 0 0

    0 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ base[1] == 1ͷ࣌ɼbase[1]+code(a) == 2 index 2͸ະ࢖༻ͳͷͰOK! 0 0 7
  4. 1 0 0 0 0 0 0 0 0 0

    0 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ index 1͕ભҠݩͳͷͰɼcheck[2]=1Ληοτ 0 0 7
  5. 1 0 0 0 0 0 0 0 0 0

    0 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ aͷ࣍͸ऴ୺จࣈ#Λొ࿥͢Δ base[2] >= 1ͷ৚݅Ͱɼbase[2]+code(#) == ະ࢖༻index Λ୳͢ 0 0 7
  6. 1 0 0 0 0 3 0 0 0 0

    0 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ base[2] == 3ͷ࣌ɼbase[2]+code(#) == 3 index 3͸ະ࢖༻ͳͷͰOK! 0 0 7
  7. 1 0 0 0 0 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ Index 2͕ભҠݩͳͷͰɼcheck[3]=2Ληοτ 0 0 7
  8. 1 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “a#”Λొ࿥ʂ ऴ୺จࣈΛొ࿥ͨ͠ͷͰ base஋Λ-1ʹͯ͠ऴྃ base஋0͸ະ࢖༻index base஋Λ-1͸ऴ୺ϊʔυΛҙຯ͢Δ 0 0 7
  9. 1 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[1]͸طʹηοτࡁΈͳͷͰ Index (base[1]+code(b))͕ະ࢖༻or check͕ਖ਼͍͔͠νΣοΫ 0 0 7
  10. 1 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ check[3] != 1ͳͷͰବ໨ʂίϯϑϦΫτ͕ൃੜ… base[1]͸΍Γ௚͠ 0 0 7
  11. 1 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ index 1Λ਌ʹ࣋ͭϊʔυΛ͢΂ͯ୳͢ index 2͕֘౰ 0 0 7
  12. 1 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ 2 (index൪߸) - check[2] = 1 == code(a) ͭ·Γindex 2͸ɼindex 1͔ΒaΛొ࿥ͨ͠ભҠ 0 0 7
  13. 0 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ ΑͬͯɼaͱbΛindex 1͔Βొ࿥͢Δඞཁ͕͋Δ base[1]Λ·ͣ0Ϧηοτʂ aͷݩભҠઌ͸ޙͰ࢖͏ͷͰ͓֮͑ͯ͘ 0 0 7
  14. ? 0 0 0 -1 3 0 0 0 0

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[1] >= 1ͷ৚݅Ͱɼbase[1]+code(a) ͱbase[1]+code(b)͕ ͍ͣΕ΋ະ࢖༻ͳindexͱͳΔ஋Λ୳͢ 0 0
  15. 3 0 0 0 -1 3 0 1 0 1

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[1] = 3ͱ͢Δͱɼa, b͍ͣΕ΋ొ࿥Ͱ͖ͦ͏ͩ bͷભҠ aͷભҠ 0 0 7
  16. 3 0 0 3 -1 3 0 1 0 1

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ a͕෇͚มΘͬͨͷͰɼݩભҠઌ͔Βbase஋Λίϐʔ aͷݩભҠઌ aͷ৽ભҠઌ 0 0 7
  17. 3 0 0 3 -1 3 0 1 0 1

    2 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ aͷݩભҠઌΛ਌ʹ࣋ͭϊʔυΛ͢΂ͯ୳͢ index 3͕֘౰ aͷݩભҠઌ aͷ৽ભҠઌ 0 0 7
  18. 3 0 0 3 -1 3 0 1 0 1

    4 1 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ a͸index 4ʹҠͬͨͷͰɼ ਌ϊʔυͷ৔ॴʢcheck஋ʣΛ4ʹߋ৽ aͷݩભҠઌ aͷ৽ભҠઌ 0 0 7
  19. 3 0 0 3 -1 0 0 1 0 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ aͷݩભҠઌͷbaseͱcheck஋͸ ৽ભҠઌʹҠߦͰ͖ͨͷͰϦηοτ ͜ΕͰίϯϑϦΫτΛղফͰ͖ͨ aͷݩભҠઌ aͷ৽ભҠઌ 0 0 7
  20. 3 0 0 3 -1 0 0 1 0 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ ొ࿥࡞ۀʹ໭Δ b·Ͱొ࿥Ͱ͖͍ͯͨͷͰcΛొ࿥ bͷભҠઌ 0 0 7
  21. 3 0 0 3 -1 0 0 1 0 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[5] >= 1ͷ৚݅Ͱɼ base[5]+code(c) == ະ࢖༻index Λ୳͢ 0 0 7
  22. 3 3 0 3 -1 0 0 1 0 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[5] == 3ͷ࣌ɼbase[5]+code(c) == 6 index 6͸ະ࢖༻ͳͷͰOK! 0 0 7
  23. 3 3 0 3 -1 0 0 1 5 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ index 5͕ભҠݩͳͷͰɼcheck[6]=7Ληοτ 0 0 7
  24. 3 3 0 3 -1 0 0 1 5 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[6] >= 1ͷ৚݅Ͱɼ base[6]+code(#) == ະ࢖༻index Λ୳͢ 0 0 7
  25. 3 3 7 3 -1 0 0 1 5 1

    4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ base[6] == 7ͷ࣌ɼbase[6]+code(#) == 6 index 6͸ະ࢖༻ͳͷͰOK! 0 0 7
  26. 6 3 3 7 3 -1 0 0 1 5

    1 4 0 base check index 1 2 5 4 6 3 จࣈίʔυ஋ #: 0 a: 1 b: 2 c: 3 ޠኮࣙॻ a bc “bc#”Λొ࿥ʂ check[7]ʹભҠݩindex 6Ληοτ ऴ୺จࣈͳͷͰbase[7]ʹ-1Ληοτͯ͠ऴྃ -1 7