일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 빅데이터
- 누가 진정한 리더인가
- K-MOOC
- 자료구조
- 코테
- 당신이 몰랐던 진화론
- 백준
- 위대한 수업
- EBS
- Progate
- 데이터분석전문가가이드
- 공부정리
- Joseph Samuel Nye Jr.
- ADP
- 조지프 나이
- Udemy
- 맛집
- 알고리즘
- Baekjoon
- KMOOC
- python
- ADsP
- CNN10
- 데이터분석전문가
- MySQL
- 미분적분학
- 후기
- Great Minds
- Hacker Rank
- 정치학
- Today
- Total
ㅇ
[Hacker Rank_Linux Shell]문제 풀이#Bash_1 본문
Linux Shell > Bash > Looping and Skipping
Looping and Skipping | HackerRank
Let's play with for loops, a little more. Let's skip numbers!
www.hackerrank.com
for i in {1..99..2}
do
echo $i
done
read name
echo "Welcome $name"
Linux Shell > Bash > Looping with Numbers
Looping with Numbers | HackerRank
Let's experiment with 'For' loops
www.hackerrank.com
for i in {1..50}
do
echo $i
done
Linux Shell > Bash > The World of Numbers
The World of Numbers | HackerRank
Let's move on to playing with numbers in Bash.
www.hackerrank.com
read X
read Y
echo $((X + Y))
echo $((X - Y))
echo $((X * Y))
echo $((X / Y))
Linux Shell > Bash > Comparing Numbers
Comparing Numbers | HackerRank
Simple comparisons between numbers: Greater than, less than, equal to.
www.hackerrank.com
read X
read Y
if ((X < Y)); then
echo X is less than Y;
elif ((X > Y)); then
echo X is greater than Y;
else
echo X is equal to Y;
fi
Linux Shell > Bash > Getting started with conditionals
Getting started with conditionals | HackerRank
-
www.hackerrank.com
read char
if [[ $char == "Y" || $char == "y" ]]; then
echo "YES";
else
echo "NO";
fi
Linux Shell > Bash > More on Conditionals
More on Conditionals | HackerRank
Three sides of a triangle are provided to you. Is the Triangle Scalene, Equilateral or Isosceles?
www.hackerrank.com
read X
read Y
read Z
if [[ $X == $Y && $Z == $Y ]]
then
echo "EQUILATERAL";
elif [[ $X != $Y && $Z != $Y && $X != $Z ]]
then
echo "SCALENE";
else
echo "ISOSCELES";
fi
Linux Shell > Bash > Arithmetic Operations
Arithmetic Operations | HackerRank
Math in shell scripts.
www.hackerrank.com
# echo "scale = 3; $result" | bc -l 을 사용했을 때
# round가 적용되지 않아 다른 코드를 참고한 결과
# 아래와 같이 printf를 함께 사용한다
# scale 디폴트가 0이므로 우선 4로 지정한 후
# %.3f를 이용해 3자리로 맞춘다
read result
printf "%.3f" $(echo "scale = 4; $result" | bc -l)
'IT > 코테문제' 카테고리의 다른 글
[Codeup] Python 기초 100제_내용 정리 (0) | 2023.10.16 |
---|---|
[Python] 문제 풀 때 요령_231012 (0) | 2023.10.15 |
[Hacker Rank_MySQL]문제 풀이#Contest Leaderboard (0) | 2022.03.02 |
[Hacker Rank_MySQL]문제 풀이#Symmetric Pairs (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#New Companies (0) | 2022.03.01 |