Day_1
https://app.codesignal.com/arcade
Intro.
Q1. add
Write a function that returns the sum of two numbers.
1 | def add(param1, param2): |
Q2. centuryFromYear
Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
1 | def centuryFromYear(year): |
Q3. checkPalindrome
Given the string, check if it is a palindrome.
palindrome: 앞으로 읽어도, 뒤로 읽어도 같은 문자열
1
2
3
4
5
6def checkPalindrome(inputString):
return (inputString == inputString[::-1])
# string을 뒤집는 방법
# s = 'abc'
# s[::-1] = 'cba'
Q4. adjacentElementsProduct
Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.
1 | def adjacentElementsProduct(inputArray): |
Q5. shapeArea
Below we will define an n
-interesting polygon. Your task is to find the area of a polygon for a given n
.
A 1
-interesting polygon is just a square with a side of length 1
. An n
-interesting polygon is obtained by taking the n - 1
-interesting polygon and appending 1
-interesting polygons to its rim, side by side. You can see the 1
-, 2
-, 3
- and 4
-interesting polygons in the picture below.
1 | def shapeArea(n): |