Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unagi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vishal
unagi
Commits
e645f14b
Commit
e645f14b
authored
Aug 26, 2020
by
Keshav Agarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
week2 q4 and readme changes
parent
bd7faddc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
week2/Readme.txt
week2/Readme.txt
+10
-5
week2/q4/q4.sh
week2/q4/q4.sh
+4
-3
No files found.
week2/Readme.txt
View file @
e645f14b
Members:
Keshav - Q1
Aditya Aditya
Mahesh - Q2
Keshav Agarwal
Aditya - Q3
Mahesh
Vishal - Q4
Vishal Mishra
\ No newline at end of file
GIT: https://git.cse.iitb.ac.in/keshavagarwal/unagi/tree/master/week2
References:
https://www.tutorialspoint.com/unix/unix-special-variables.htm
https://stackoverflow.com/questions/1975849/how-to-split-a-line-into-words-separated-by-one-or-more-spaces-in-bash
\ No newline at end of file
week2/q4/q4.sh
View file @
e645f14b
...
@@ -2,18 +2,19 @@
...
@@ -2,18 +2,19 @@
sums
=
0
sums
=
0
counts
=
0
counts
=
0
arr
=()
arr
=()
sort
q4_in.txt
>
tem.txt
xargs
-n1
< q4_in.txt |
sort
-n
>
tem.txt
while
read
p
while
read
p
do
do
arr[counts]
=
$p
arr[counts]
=
$p
counts
=
`
expr
$counts
+ 1
`
counts
=
`
expr
$counts
+ 1
`
sums
=
`
expr
$sums
+
$p
`
sums
=
`
expr
$sums
+
$p
`
done
< tem.txt
done
< tem.txt
echo
`
e
xpr
$sums
/
$counts
`
echo
`
e
cho
"
$sums
/
$counts
"
| bc
-l
`
rem
=
$((
$counts
%
2
))
rem
=
$((
$counts
%
2
))
if
[
$rem
-eq
0
]
if
[
$rem
-eq
0
]
then
then
echo
"
$((
(
arr[
$((
$counts
/
2
))
]
+
arr[
$((
$counts
/
2
-
1
))
]
)
/
2
))
"
mid
=
$((
arr[
$((
$counts
/
2
))
]
+
arr[
$((
$counts
/
2
-
1
))
]
))
echo
`
echo
"
$mid
/ 2"
|bc
-l
`
else
else
echo
"
${
arr
[
$counts
/2]
}
"
echo
"
${
arr
[
$counts
/2]
}
"
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment