From a3b53b180cc855955e19b8f5cc8b578473ce9a55 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sun, 28 Jul 2024 06:43:01 -0400 Subject: [PATCH] style: modify the output of scripts Instead of separating output primes by newline, the scripts now separate by spaces. --- bash/nixpkgs/soe | 4 +++- fish/nixpkgs/soe | 4 +++- python/nixpkgs/soe/main.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bash/nixpkgs/soe b/bash/nixpkgs/soe index 3aefb63..e861d8f 100755 --- a/bash/nixpkgs/soe +++ b/bash/nixpkgs/soe @@ -13,10 +13,12 @@ unset nums[-1] while [ -n "$nums" ]; do prime=${nums[0]} - echo $prime + echo -n "$prime " nums_=() for elem in "${nums[@]}"; do [ $(( $elem % $prime )) -eq 0 ] || nums_+=($elem) done nums=(${nums_[@]}) done + +echo diff --git a/fish/nixpkgs/soe b/fish/nixpkgs/soe index ae66188..5cc2b5a 100755 --- a/fish/nixpkgs/soe +++ b/fish/nixpkgs/soe @@ -7,7 +7,7 @@ set nums (seq 2 $num)[..-2] while test -n "$nums" set prime $nums[1] - echo $prime + echo -n "$prime " set -e nums_ for elem in $nums @@ -15,3 +15,5 @@ while test -n "$nums" end set nums $nums_ end + +echo diff --git a/python/nixpkgs/soe/main.py b/python/nixpkgs/soe/main.py index ba258ad..f6a1425 100644 --- a/python/nixpkgs/soe/main.py +++ b/python/nixpkgs/soe/main.py @@ -1,5 +1,4 @@ - def sieve_of_eratosthenes(n): nums = list(range(2, n)) while nums: @@ -11,7 +10,8 @@ def main(): num = int(input("Primes up to: ")) print() for i in sieve_of_eratosthenes(num): - print(i) + print(i, end=" ") + print() if __name__ == "__main__":