Why Nostr? What is Njump?
2024-07-02 23:24:24

npub1ad…rplea on Nostr: commit df842883142c67f491dd62b84d0d773a88595112 Author: @RandyMcMillan ...

commit df842883142c67f491dd62b84d0d773a88595112
Author: @RandyMcMillan <[email protected]>
Date: Sat Nov 4 19:18:24 2023 -0400

template/gnostr-hexidrome:initial commit

diff --git a/template/gnostr-hexidrome b/template/gnostr-hexidrome
index de1cd591c..9258fffda 100755
--- a/template/gnostr-hexidrome
+++ b/template/gnostr-hexidrome
@@ -1,16 +1,8 @@
#!/usr/bin/env python3
import sys

-def get_arg(index):
- try:
- sys.argv[index]
- except IndexError:
- return ''
- else:
- return sys.argv[index]
-
# define a function to check if a number is a palindrome
-def gnostr_hexidrome(n):
+def is_palindrome(n):
# convert the number to a string
s = str(n)
# check if the string is the same forwards and backwards
@@ -28,7 +20,7 @@ def loop(lb, ub):
# loop through the range of numbers
for n in range(start, end+1):
# if the number is a palindrome, add it to the list
- if gnostr_hexidrome(n):
+ if is_palindrome(n):
palindromes.append(n)

# print the list of palindromes
@@ -48,48 +40,45 @@ def loop(lb, ub):
## print('[{}]'.format(''.join(str(x)[2:] for x in hexlist)))
print('{}'.format(''.join(str(x)[2:] for x in hexlist)))

-
-
-
-
-
if (args_count := len(sys.argv)) == 3:

- if int(get_arg(1)) > int(get_arg(2)):
- ## print("int(get_arg(1)) > int(get_arg(2))");
- lower_bound = int(get_arg(2));
- upper_bound = int(get_arg(1));
+ if int(sys.argv[1]) > int(sys.argv[2]):
+ ## print("int(sys.argv[1]) > int(sys.argv[2])");
+ lower_bound = int(sys.argv[2]);
+ upper_bound = int(sys.argv[1]);
loop(lower_bound, upper_bound)

- if int(get_arg(1)) < int(get_arg(2)) or int(get_arg(1)) == int(get_arg(2)):
- ## print("int(get_arg(1)) < int(get_arg(2))");
- lower_bound = int(get_arg(1));
- upper_bound = int(get_arg(2));
+ if int(sys.argv[1]) < int(sys.argv[2]) or int(sys.argv[1]) == int(sys.argv[2]):
+ ## print("int(sys.argv[1]) < int(sys.argv[2])");
+ lower_bound = int(sys.argv[1]);
+ upper_bound = int(sys.argv[2]);
loop(lower_bound, upper_bound)

-elif (args_count := len(sys.argv)) == 2:
+elif args_count == 2:

- if int(get_arg(1)) > int(get_arg(2)):
- print("int(get_arg(1)) > int(get_arg(2))");
+ if int(sys.argv[1]) > int(sys.argv[2]):
+ print("int(sys.argv[1]) > int(sys.argv[2])");
lower_bound = int(0);
- upper_bound = int(get_arg(2));
+ upper_bound = int(sys.argv[2]);
loop(lower_bound, upper_bound)

- if int(get_arg(1)) < int(get_arg(2)):
- print("int(get_arg(1)) < int(get_arg(2))");
+ if int(sys.argv[1]) < int(sys.argv[2]):
+ print("int(sys.argv[1]) < int(sys.argv[2])");
lower_bound = int(0);
- upper_bound = int(get_arg(1));
+ upper_bound = int(sys.argv[1]);
loop(lower_bound, upper_bound)

-elif (args_count := len(sys.argv)) > 2:
- print("Usage:")
- print("gnostr-hexidrome <int>")
- print("gnostr-hexidrome <int> <int>")
+
+elif args_count > 2:
+
+ print("Usage:\n")
+ print("is_palindrome <int>\n")
+ print("is_palindrome <int> <int>\n")
raise SystemExit(0)

-elif (args_count := len(sys.argv)) < 2:
+elif args_count < 2:

- print("Usage:")
- print("gnostr-hexidrome <int>")
- print("gnostr-hexidrome <int> <int>")
+ print("Usage:\n")
+ print("is_palindrome <int>\n")
+ print("is_palindrome <int> <int>\n")
raise SystemExit(0)
Author Public Key
npub1ad0j7y75mztna6ea2tnedv33znv53j5v7x89qtxps8sx2ea3589s8rplea