#59 How long is the cable?


The goal is to calculate the length of a cable.


The cable will be symbolized with a combination of the following characters: -, _, =.


Each character has a different length: - is of length 1, _ of length 2 and = of length 3.


Sometimes the cable is making a loop. This will be symbolized with brackets.


When you have reached a closing bracket ), you have to go back to the corresponding opening bracket and count the length again -> this represents a loop.


For example:


Cable.calculateLength("----"); // => 4

Cable.calculateLength("_(-_)"); // => 8 --> _-_-_

Cable.calculateLength("_(-(_))="); // => 15 --> _(-__)= --> _-__-__=

If a cable is broken, meaning number of ( is not equal to number of ), you must throw a BracketException of type RuntimeException that you must implement yourself.


If the cable has a node, meaning a different character is detected on the input string, throw a NodeException of type RuntimeException (implement it as well)


If a cable is both broken and contains nodes then it should throw the exception that can be first detected and confirmed.


Good luck and keep an eye on the performance of your code - suboptimal solutions may time out in the Submit tests ;)



#23 Prime Streaming


Create an endless stream of prime numbers - a bit like IntStream.of(2,3,5,7,11,13,17), but infinite. The stream must be able to produce 50 million primes in a few seconds.


당당하게 도전하고 ,당당하게 망했다 3시간동안 고민해봤는데 못풀겠다.

현재 레벨보다 높은 단계라 솔루션도 못본다. 포기하고 다른문제 풀어서 올릴까하다가 

들인시간이 아까워서 주말에 다시 풀어보려고 올림



 #20 The Millionth Fibonacci Kata 


The year is 1214. One night, Pope Innocent III awakens to find the the archangel Gabriel floating before him. Gabriel thunders to the pope:


Gather all of the learned men in Pisa, especially Leonardo Fibonacci. In order for the crusades in the holy lands to be successful, these men must calculate the millionth number in Fibonacci's recurrence. Fail to do this, and your armies will never reclaim the holy land. It is His will.


The angel then vanishes in an explosion of white light.


Pope Innocent III sits in his bed in awe. How much is a million? he thinks to himself. He never was very good at math.


He tries writing the number down, but because everyone in Europe is still using Roman numerals at this moment in history, he cannot represent this number. If he only knew about the invention of zero, it might make this sort of thing easier.


He decides to go back to bed. He consoles himself, The Lord would never challenge me thus; this must have been some deceit by the devil. A pretty horrendous nightmare, to be sure.


Pope Innocent III's armies would go on to conquer Constantinople (now Istanbul), but they would never reclaim the holy land as he desired.


In this kata you will have to calculate fib(n) where:


fib(0) := 0

fib(1) := 1

fin(n + 2) := fib(n + 1) + fib(n)

Write an algorithm that can handle n where 1000000 ≤ n ≤ 1500000.


Your algorithm must output the exact integer answer, to full precision. Also, it must correctly handle negative numbers as input.


HINT I: Can you rearrange the equation fib(n + 2) = fib(n + 1) + fib(n) to find fib(n) if you already know fin(n + 1) and fib(n + 2)? Use this to reason what value fib has to have for negative values.


HINT II: See http://mitpress.mit.edu/sicp/chapter1/node15.html




얼마 전에 DB 호스팅을 알아보다가 

네이버 클라우드 플랫폼에서 30만 캐시 지급 이벤트 ( 바로가기 ) 를 진행하고 있길래


제일 싼 서버로 쓰면 꽤 오랫동안 쓰겠다 싶어서 서버를 생성하고 ( CentOS+DB 까지 한번에 깔아준다. )

알던대로 외부에서 접속 가능한 계정을 만들고 방화벽 깔고 3306 포트까지 열었는데

개인 PC 에서 접속이 안된다.


2일동안이나 애먼 서버 삭제했다 만들었다. 방화벽 깔았다 지웠다 쇼를 다했는데.......

네이버 클라우드 플랫홈에서는 ACG로 방화벽 규칙을 설정할 수 있었다.


ACG란? 찮으니 링크로 대체



요약


원인 : 네이버 클라우드 플랫폼엔 ACG를 통해 개별적으로 방화벽을 구축할 필요 없이 ACG에 서버 그룹별로 방화벽 규칙을 설정할 수 있다.

해결 : ACG 에 3306 포트를 허용한다. (가이드를 읽자)

+ Recent posts