0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

計算気といえば、そろばん。
そろばんの状態遷移を考えたっていいじゃないか。

一桁そろばん

+1 -1

plantuml
@startuml
skinparam shadowing false

state0: 00000
state1: 01000
state2: 01100
state3: 01110
state4: 01111
state5: 10000
state6: 11000
state7: 11100
state8: 11110
state9: 11111

state0 --> underflow : -1
state0 --> state1 : +1
state1 --> state0 : -1
state1 --> state2 : +1
state2 --> state1 : -1
state2 --> state3 : +1
state3 --> state2 : -1
state3 --> state4 : +1
state4 --> state3 : -1
state4 --> state5 : +1
state5 --> state4 : -1
state5 --> state6 : +1
state6 --> state5 : -1
state6 --> state7 : +1
state7 --> state6 : -1
state7 --> state8 : +1
state8 --> state7 : -1
state8 --> state9 : +1
state9 --> state8 : -1
state9 --> overflow : +1
@enduml

状態遷移表

state 00000 01000 01100 01110 01111 10000 11000 11100 11110 11111
00000 - +1 +2 +3 +4 +5 +6 +7 +8 +9
01000 -1 - +1 +2 +3 +4 +5 +6 +7 +8
01100 -2 -1 - +1 +2 +3 +4 +5 +6 +7
01110 -3 ^2 -1 - +1 +2 +3 +4 +5 +6
01111 -4 -3 -2 -1 - +1 +2 +3 +4 +5
10000 -5 -4 -3 -2 -1 - +1 +2 +3 +4
11000 -6 -5 -4 -3 -2 -1 - +1 +2 +3
11100 -7 -6 -5 -4 -3 -2 -1 - +1 +2
11110 -8 -7 -6 -5 -4 -3 -2 -1 - +1
11111 -9 -8 -7 -6 -5 -4 -3 -2 -1 -
|state|00000|01000|01100|01110|01111|10000|11000|11100|11110|11111|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|00000|-|+1|+2|+3|+4|<font color="OrangeRed">+5</font>|<font color="OrangeRed">+6</font>|<font color="OrangeRed">+7</font>|<font color="OrangeRed">+8</font>|<font color="OrangeRed">+9</font>|
|01000|-1|-|+1|+2|+3|+4|<font color="OrangeRed">+5</font>|<font color="OrangeRed">+6</font>|<font color="OrangeRed">+7</font>|<font color="OrangeRed">+8</font>|
|01100|-2|-1|-|+1|+2|+3|+4|<font color="OrangeRed">+5</font>|<font color="OrangeRed">+6</font>|<font color="OrangeRed">+7</font>|
|01110|-3|^2|-1|-|+1|+2|+3|+4|<font color="OrangeRed">+5</font>|<font color="OrangeRed">+6</font>|
|01111|-4|-3|-2|-1|-|+1|+2|+3|+4|<font color="OrangeRed">+5</font>|
|10000|<font color="OrangeRed">-5</font>|-4|-3|-2|-1|-|+1|+2|+3|+4|
|11000|<font color="OrangeRed">-6</font>|<font color="OrangeRed">-5</font>|-4|-3|-2|-1|-|+1|+2|+3|
|11100|<font color="OrangeRed">-7</font>|<font color="OrangeRed">-6</font>|<font color="OrangeRed">-5</font>|-4|-3|-2|-1|-|+1|+2|
|11110|<font color="OrangeRed">-8</font>|<font color="OrangeRed">-7</font>|<font color="OrangeRed">-6</font>|<font color="OrangeRed">-5</font>|-4|-3|-2|-1|-|+1|
|11111|<font color="OrangeRed">-9</font>|<font color="OrangeRed">-8</font>|<font color="OrangeRed">-7</font>|<font color="OrangeRed">-6</font>|<font color="OrangeRed">-5</font>|-4|-3|-2|-1|-|
state underflow 00000 01000 01100 01110 01111 10000 11000 11100 11110 11111 overflow
00000 -1,-2,-3,-4 - +1 +2 +3 +4 +5 +6 +7 +8 +9 +9
01000 -2,-3, -4 -1 +1 +2 +3 +4 +5 +6 +7 +8 +9
01100 -3 -2 -1 - +1 +2 +3 +4 +5 +6 +7
01110 -3 ^2 -1 - +1 +2 +3 +4 +5 +6
01111 -4 -3 -2 -1 - +1 +2 +3 +4 +5
10000 -5 -4 -3 -2 -1 - +1 +2 +3 +4
11000 -6 -5 -4 -3 -2 -1 - +1 +2 +3
11100 -7 -6 -5 -4 -3 -2 -1 - +1 +2
11110 -8 -7 -6 -5 -4 -3 -2 -1 - +1
11111 -9 -8 -7 -6 -5 -4 -3 -2 -1 -

+1 +2 -1 -2

plantuml
@startuml
skinparam shadowing false

state0: 00000
state1: 01000
state2: 01100
state3: 01110
state4: 01111
state5: 10000
state6: 11000
state7: 11100
state8: 11110
state9: 11111

state0 --> underflow : -1
state0 --> state1 : +1
state1 --> state0 : -1
state1 --> state2 : +1
state2 --> state1 : -1
state2 --> state3 : +1
state3 --> state2 : -1
state3 --> state4 : +1
state4 --> state3 : -1
state4 --> state5 : +1
state5 --> state4 : -1
state5 --> state6 : +1
state6 --> state5 : -1
state6 --> state7 : +1
state7 --> state6 : -1
state7 --> state8 : +1
state8 --> state7 : -1
state8 --> state9 : +1
state9 --> state8 : -1
state9 --> overflow : +1
state0 --> underflow : -2
state1 --> underflow : -2
state0 --> state2 : +2
state1 --> state3 : +2
state2 --> state0 : -2
state2 --> state4 : +2
state3 --> state1 : -2
state3 --> state5 : +2
state4 --> state2 : -2
state4 --> state6 : +2
state5 --> state3 : -2
state5 --> state7 : +2
state6 --> state4 : -2
state6 --> state8 : +2
state7 --> state5 : -2
state7 --> state9 : +2
state8 --> state6 : -2
state9 --> state7 : -2
state9 --> overflow : +2
state8 --> overflow : +2
@enduml

+1 +2 +3 -1 -2 -3

plantuml
@startuml
skinparam shadowing false

state0: 00000
state1: 01000
state2: 01100
state3: 01110
state4: 01111
state5: 10000
state6: 11000
state7: 11100
state8: 11110
state9: 11111

state0 --> underflow : -1
state0 --> state1 : +1
state1 --> state0 : -1
state1 --> state2 : +1
state2 --> state1 : -1
state2 --> state3 : +1
state3 --> state2 : -1
state3 --> state4 : +1
state4 --> state3 : -1
state4 --> state5 : +1
state5 --> state4 : -1
state5 --> state6 : +1
state6 --> state5 : -1
state6 --> state7 : +1
state7 --> state6 : -1
state7 --> state8 : +1
state8 --> state7 : -1
state8 --> state9 : +1
state9 --> state8 : -1
state9 --> overflow : +1

state0 --> underflow : -2
state1 --> underflow : -2
state0 --> state2 : +2
state1 --> state3 : +2
state2 --> state0 : -2
state2 --> state4 : +2
state3 --> state1 : -2
state3 --> state5 : +2
state4 --> state2 : -2
state4 --> state6 : +2
state5 --> state3 : -2
state5 --> state7 : +2
state6 --> state4 : -2
state6 --> state8 : +2
state7 --> state5 : -2
state7 --> state9 : +2
state8 --> state6 : -2
state9 --> state7 : -2
state9 --> overflow : +2
state8 --> overflow : +2


state0 --> underflow : -3
state1 --> underflow : -3
state0 --> state3 : +3
state1 --> state4 : +3
state2 --> underflow : -3
state2 --> state5 : +3
state3 --> state0 : -3
state3 --> state6 : +3
state4 --> state1 : -3
state4 --> state7 : +3
state5 --> state2 : -3
state5 --> state8 : +3
state6 --> state3 : -3
state6 --> state9 : +3
state7 --> state4 : -3
state7 --> overflow : +3
state8 --> state5 : -3
state9 --> state6 : -3
state9 --> overflow : +3
state8 --> overflow : +3

@enduml

+1 +2 +3 +4 -1 -2 -3 -4

plantuml
@startuml
skinparam shadowing false

state0: 00000
state1: 01000
state2: 01100
state3: 01110
state4: 01111
state5: 10000
state6: 11000
state7: 11100
state8: 11110
state9: 11111

state0 --> underflow : -1
state0 --> state1 : +1
state1 --> state0 : -1
state1 --> state2 : +1
state2 --> state1 : -1
state2 --> state3 : +1
state3 --> state2 : -1
state3 --> state4 : +1
state4 --> state3 : -1
state4 --> state5 : +1
state5 --> state4 : -1
state5 --> state6 : +1
state6 --> state5 : -1
state6 --> state7 : +1
state7 --> state6 : -1
state7 --> state8 : +1
state8 --> state7 : -1
state8 --> state9 : +1
state9 --> state8 : -1
state9 --> overflow : +1

state0 --> underflow : -2
state1 --> underflow : -2
state0 --> state2 : +2
state1 --> state3 : +2
state2 --> state0 : -2
state2 --> state4 : +2
state3 --> state1 : -2
state3 --> state5 : +2
state4 --> state2 : -2
state4 --> state6 : +2
state5 --> state3 : -2
state5 --> state7 : +2
state6 --> state4 : -2
state6 --> state8 : +2
state7 --> state5 : -2
state7 --> state9 : +2
state8 --> state6 : -2
state9 --> state7 : -2
state9 --> overflow : +2
state8 --> overflow : +2


state0 --> underflow : -3
state1 --> underflow : -3
state0 --> state3 : +3
state1 --> state4 : +3
state2 --> underflow : -3
state2 --> state5 : +3
state3 --> state0 : -3
state3 --> state6 : +3
state4 --> state1 : -3
state4 --> state7 : +3
state5 --> state2 : -3
state5 --> state8 : +3
state6 --> state3 : -3
state6 --> state9 : +3
state7 --> state4 : -3
state7 --> overflow : +3
state8 --> state5 : -3
state9 --> state6 : -3
state9 --> overflow : +3
state8 --> overflow : +3

state0 --> underflow : -4
state1 --> underflow : -4
state0 --> state4 : +4
state1 --> state5 : +4
state2 --> underflow : -4
state2 --> state6 : +4
state3 --> underflow : -4
state3 --> state7 : +4
state4 --> state0 : -4
state4 --> state8 : +4
state5 --> state1 : -4
state5 --> state9 : +4
state6 --> state2 : -4
state6 --> overflow : +4
state7 --> state3 : -4
state7 --> overflow : +4
state8 --> state4 : -4
state9 --> state5 : -4
state9 --> overflow : +4
state8 --> overflow : +4
@enduml

今後の課題

状態遷移表の自動生成
Cソースコードの自動生成
桁あがり、桁下がり
5の玉を別の状態管理にするか。

色の付け方

'@twipg Qiitaのマークダウンで色をつける方法[140色]
https://qiita.com/twipg/items/d8043cd4681a2780c160

Qiitaのマークダウンで色をつける方法[140色]
https://pa-tu.work/blog/qiita-cheatsheets-collection/25842

1月6日は色(19)いろの日(1)参考資料
https://qiita.com/kaizen_nagoya/items/fcfe3901a0d7468d1528

Markdownの表でセルのバックグラウンドにカラーを
https://qiita.com/pooshikin/items/8850fd0ca53805449ffb

Markdown記法 チートシート
https://qiita.com/Qiita/items/c686397e4a0f4f11683d

Markdown記法/書き方(見出し・表・リンク・画像・文字色など)
https://notepm.jp/help/how-to-markdown

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?