一百八 to 一百八十 一亿一千三百万 to 一亿 一千万 三百万
(integer_symbols, system)
| 639 | ] |
| 640 | |
| 641 | def correct_symbols(integer_symbols, system): |
| 642 | """ |
| 643 | 一百八 to 一百八十 |
| 644 | 一亿一千三百万 to 一亿 一千万 三百万 |
| 645 | """ |
| 646 | |
| 647 | if integer_symbols and isinstance(integer_symbols[0], CNU): |
| 648 | if integer_symbols[0].power == 1: |
| 649 | integer_symbols = [system.digits[1]] + integer_symbols |
| 650 | |
| 651 | if len(integer_symbols) > 1: |
| 652 | if isinstance(integer_symbols[-1], CND) and isinstance( |
| 653 | integer_symbols[-2], CNU |
| 654 | ): |
| 655 | integer_symbols.append( |
| 656 | CNU(integer_symbols[-2].power - 1, None, None, None, None) |
| 657 | ) |
| 658 | |
| 659 | result = [] |
| 660 | unit_count = 0 |
| 661 | for s in integer_symbols: |
| 662 | if isinstance(s, CND): |
| 663 | result.append(s) |
| 664 | unit_count = 0 |
| 665 | elif isinstance(s, CNU): |
| 666 | current_unit = CNU(s.power, None, None, None, None) |
| 667 | unit_count += 1 |
| 668 | |
| 669 | if unit_count == 1: |
| 670 | result.append(current_unit) |
| 671 | elif unit_count > 1: |
| 672 | for i in range(len(result)): |
| 673 | if ( |
| 674 | isinstance(result[-i - 1], CNU) |
| 675 | and result[-i - 1].power < current_unit.power |
| 676 | ): |
| 677 | result[-i - 1] = CNU( |
| 678 | result[-i - 1].power + current_unit.power, |
| 679 | None, |
| 680 | None, |
| 681 | None, |
| 682 | None, |
| 683 | ) |
| 684 | return result |
| 685 | |
| 686 | def compute_value(integer_symbols): |
| 687 | """ |