From b9715913fe4ca2330541300b77c7e830adb0a032 Mon Sep 17 00:00:00 2001 From: rl544 <111494264+rl544@users.noreply.github.com> Date: Sat, 10 Dec 2022 07:44:08 +0900 Subject: [PATCH] =?UTF-8?q?uploaded=20at=202022.=2012.=2010.=20=EC=98=A4?= =?UTF-8?q?=EC=A0=84=207:44:07?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- programmers/옹알이 (2)/solution.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 programmers/옹알이 (2)/solution.java diff --git a/programmers/옹알이 (2)/solution.java b/programmers/옹알이 (2)/solution.java new file mode 100644 index 0000000..9d19d49 --- /dev/null +++ b/programmers/옹알이 (2)/solution.java @@ -0,0 +1,17 @@ +// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/133499 + +class Solution { + public int solution(String[] babbling) { + int answer = 0; + String[] available = {"aya", "ye", "woo", "ma"}; + for (String i : babbling){ + int index = 1; + for(String ava : available){ + i = i.replaceAll(ava,String.valueOf(index++)); + } + if(!(i.matches(".*[^1-4].*") || i.matches(".*1{2}.*") + || i.matches(".*2{2}.*") || i.matches(".*3{2}.*") || i.matches(".*4{2}.*"))) answer += 1; + } + return answer; + } +} \ No newline at end of file