less than 1 minute read


1.

2.

  1. 키보드 입력 keydown 이벤트

    window.addEventListener("keydown", (e) => {
      const key = document.getElementById(e.key);
      if (key) key.classList.add("pressed");
    });
    
    • e.key로 누른 key값을 알아낼수 있다.
  2. svg html 에서 그리는법

      <svg height="250" width="200" class="figure-container">
              <!-- Rod -->
              <line x1="60" x2="140" y1="20" y2="20" />
              <line x1="140" x2="140" y1="20" y2="60" />
              <line x1="60" x2="60" y1="20" y2="230" />
              <line x1="20" x2="100" y1="230" y2="230" />
    
              <!-- Head -->
              <circle cx="140" cy="80" r="20" />
    
              <!-- Body -->
              <line x1="140" x2="140" y1="100" y2="160" />
    
              <!-- Arms -->
              <line x1="140" x2="120" y1="110" y2="130" />
              <line x1="140" x2="160" y1="110" y2="130" />
    
              <!-- Legs -->
              <line x1="140" x2="120" y1="160" y2="180" />
              <line x1="140" x2="160" y1="160" y2="180" />
            </svg>
    
  3. arr.prototype.find()

    • 주어진 판별함수를 마족하는 첫번쨰 요수의 값을 반환

    • 그런 요소가 없다면 undefined를 반환합니다.

    • const found = array1.find((element) => element > 10);
      
    • arr.find(callback[, thisArg])
      

solution

import sys
from functools import reduce
from collections import Counter
n = int(input())
arr = list();
for _ in range(n):
    t = int(sys.stdin.readline().strip("\n"))
    arr.append(t);
sum = reduce(lambda x,y:x+y ,arr)
print(round(sum/n))
arr.sort()
print(arr[n//2])
r3 = Counter(arr).most_common();

if len(r3) >1 and r3[0][1] == r3[1][1]:
    print(r3[1][0])
else:
    print(r3[0][0])
print(max(arr)-min(arr))

Tags:

Categories:

Updated: