tangled
alpha
login
or
join now
digi.rip
/
dollcode
4
fork
atom
my version of @dis.sociat.ing's dollcode algorithm in python
4
fork
atom
overview
issues
pulls
pipelines
added probably over-engineered check for input
digi.rip
1 month ago
ddf41dfb
faae9087
+9
-1
1 changed file
expand all
collapse all
unified
split
main.py
+9
-1
main.py
reviewed
···
1
1
import argparse
2
2
3
3
+
4
4
+
def positive_int(val: str):
5
5
+
ival = int(val)
6
6
+
if ival < 0:
7
7
+
raise argparse.ArgumentTypeError("Number must be non-negative")
8
8
+
return ival
9
9
+
10
10
+
3
11
parser = argparse.ArgumentParser(description="converts base-10 number into dollcode")
4
4
-
parser.add_argument("number", type=int, help="number to convert")
12
12
+
parser.add_argument("number", type=positive_int, help="number to convert")
5
13
args = parser.parse_args()
6
14
7
15
DOLLCODE_CHARS = ("▌", "▖", "▘")