Skip to content

Commit 2b9fcf0

Browse files
committed
n-mod-m
1 parent c4615e2 commit 2b9fcf0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Bash/n-mod-m.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# Source: https://www.codeeval.com/open_challenges/62/
3+
4+
file="$1"
5+
FS_OLD=$IFS
6+
IFS="\n"
7+
while read line || [[ -n "$line" ]]
8+
do
9+
IFS=",\n"
10+
read -a ar <<< "$line"
11+
echo $((ar[0] % ar[1]))
12+
IFS="\n"
13+
done < "$file"
14+
IFS=$IFS_OLD

0 commit comments

Comments
 (0)