istr-python 1.1.39__tar.gz → 1.1.39.post0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: istr-python
3
- Version: 1.1.39
3
+ Version: 1.1.39.post0
4
4
  Summary: istr - strings you can count on
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/istr
@@ -868,10 +868,9 @@ class istr(str):
868
868
 
869
869
  lines = []
870
870
  if len(number)%2==1:
871
- pairs=list(istr.batched('x'|number,2,join=True))
872
- pairs[0]=pairs[0][1]
871
+ pairs=istr.chain(number[0],istr.batched(number[1:],2,join=True))
873
872
  else:
874
- pairs=list(istr.batched(number,2,join=True))
873
+ pairs=istr.batched(number,2,join=True)
875
874
 
876
875
  root = istr(0)
877
876
  remainder = 0
@@ -897,7 +896,7 @@ class istr(str):
897
896
  lines = [root] + [number] + lines[1:]
898
897
  if as_str:
899
898
  result = []
900
- extra = len(pairs[0])==2
899
+ extra = len(number)%2==0
901
900
  result.append(f" {extra*' '}{' '.join(lines[0])}")
902
901
  result.append(f" {len(lines[1])*'-'}")
903
902
  result.append(f"\/{lines[1]}")
@@ -920,6 +919,30 @@ class istr(str):
920
919
  return "\n".join(result)
921
920
  else:
922
921
  return lines
922
+
923
+ def long_multiplication(self, number,as_str=False):
924
+ number0 = istr(istr.interpret_as_str(self))
925
+ number1=istr(number)
926
+ lines=[number0,number1]
927
+ for i in number1.reversed():
928
+ lines.append(number0*i)
929
+ lines.append(number0*number1)
930
+ if as_str:
931
+ result=[]
932
+ n=len(lines[-1])
933
+ result.append(f'{lines[0]:>{n}}')
934
+ result.append(f'{lines[1]:>{n}}')
935
+ result.append(f"{n*'-'} x")
936
+ for i,line in enumerate(lines[2:-1]):
937
+ result.append(f"{line:>{n-i}}")
938
+ result.append(f"{n*'-'}")
939
+ result.append(lines[-1])
940
+ return '\n'.join(result)
941
+ else:
942
+ return lines
943
+
944
+
945
+
923
946
 
924
947
  def this_base(self):
925
948
  return self._this_base
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: istr-python
3
- Version: 1.1.39
3
+ Version: 1.1.39.post0
4
4
  Summary: istr - strings you can count on
5
5
  Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/salabim/istr
@@ -10,7 +10,7 @@ authors = [
10
10
  { name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com" },
11
11
  ]
12
12
  description = "istr - strings you can count on"
13
- version = "1.1.39"
13
+ version = "1.1.39.post0"
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.10"
16
16
  dependencies = []