This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> var str = '안녕하세요\ud83d\ude03하이'; | |
undefined | |
> str | |
'안녕하세요😃하이' | |
> str.length | |
9 | |
> encodeURI(str.slice(0,6)) | |
URIError: URI malformed | |
at encodeURI (native) | |
at repl:1:15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Send memory usage metrics to Amazon CloudWatch | |
This is intended to run on an Amazon EC2 instance and requires an IAM | |
role allowing to write CloudWatch metrics. Alternatively, you can create | |
a boto credentials file and rely on it instead. | |
Original idea based on https://github.com/colinbjohnson/aws-missing-tools | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1부터 n까지의 자연수를 차례로 더하여 구해진 값을 삼각수라고 합니다. | |
예를 들어 7번째 삼각수는 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28이 됩니다. | |
이런 식으로 삼각수를 구해 나가면 다음과 같습니다. | |
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... | |
이 삼각수들의 약수를 구해봅시다. | |
1: 1 | |
3: 1, 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
다음은 연속된 1000자리 숫자입니다 (읽기 좋게 50자리씩 잘라놓음). | |
73167176531330624919225119674426574742355349194934 | |
96983520312774506326239578318016984801869478851843 | |
85861560789112949495459501737958331952853208805511 | |
12540698747158523863050715693290963295227443043557 | |
66896648950445244523161731856403098711121722383113 | |
62229893423380308135336276614282806444486645238749 | |
30358907296290491560440772390713810515859307960866 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
소수를 크기 순으로 나열하면 2, 3, 5, 7, 11, 13, ... 과 같이 됩니다. | |
이 때 10,001번째의 소수를 구하세요. | |
*/ | |
object Ex07 extends App { | |
var n = 0 | |
var count = 0 | |
while(count != 10001) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1부터 10까지 자연수를 각각 제곱해 더하면 다음과 같습니다 (제곱의 합). | |
12 + 22 + ... + 102 = 385 | |
1부터 10을 먼저 더한 다음에 그 결과를 제곱하면 다음과 같습니다 (합의 제곱). | |
(1 + 2 + ... + 10)2 = 552 = 3025 | |
따라서 1부터 10까지 자연수에 대해 "합의 제곱"과 "제곱의 합" 의 차이는 3025 - 385 = 2640 이 됩니다. | |
그러면 1부터 100까지 자연수에 대해 "합의 제곱"과 "제곱의 합"의 차이는 얼마입니까? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1 ~ 10 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 2520입니다. | |
그러면 1 ~ 20 사이의 어떤 수로도 나누어 떨어지는 가장 작은 수는 얼마입니까? | |
*/ | |
object Ex05 extends App { | |
var allLcm = BigInt(1) | |
for(i <- (1 to 20)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
앞에서부터 읽을 때나 뒤에서부터 읽을 때나 모양이 같은 수를 대칭수(palindrome)라>고 부릅니다. | |
두 자리 수를 곱해 만들 수 있는 대칭수 중 가장 큰 수는 9009 (= 91 × 99) 입니다. | |
세 자리 수를 곱해 만들 수 있는 가장 큰 대칭수는 얼마입니까? | |
*/ | |
object Ex04 extends App { | |
var i = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
어떤 수를 소수의 곱으로만 나타내는 것을 소인수분해라 하고, 이 소수들을 그 수의 >소인수라고 합니다. | |
예를 들면 13195의 소인수는 5, 7, 13, 29 입니다. | |
600851475143의 소인수 중에서 가장 큰 수를 구하세요. | |
*/ | |
object Ex03 extends App { | |
println(run(13195)) | |
println(run(600851475143L)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'capybara-webkit' | |
require 'headless' | |
Headless.ly do | |
driver = Capybara::Driver::Webkit.new 'web_capture' | |
driver.visit 'http://www.google.co.kr' | |
driver.render 'out.png' | |
end |