![[TIL] JS Programmers Problems, Highest Paid Developer Workshop](https://cdn.hashnode.com/res/hashnode/image/upload/v1681171694925/94f5276a-2e2c-4db1-ac07-60811dc22ef0.png)
TIL
Issues encountered
What I tried
Handling numbers 2, 5, 8, and 0 in the middle
Initially, I compared the absolute values of the differences between each number received and the numbers subtracted as is, but I couldn't handle cases where they are vertically aligned.
I created an array pre-calculating the distances between 2, 5, 8, and 0, but it failed due to many exception cases
I created a new array that contains the distances between all numbers and the numbers 2, 5, 8, and 0.
I didn't handle
*and#before, and it resulted in failures in test cases 8 and 15. I updated them to be treated as index 10 and 11, respectively.ChatGPT recommended that it will be more clear to understand if we draw the keypad on the code and find the distance through that.
function getDistance(pos1, pos2) { return Math.abs(pos1[0] - pos2[0]) + Math.abs(pos1[1] - pos2[1]); } function solution(numbers, hand) { // 2 demensional array storing the location of each key const keypad = [[1, 2, 3], [4, 5, 6], [7, 8, 9], ['*', 0, '#']]; // initialize the initial position of each hand let leftPos = [3, 0]; let rightPos = [3, 2];
I was not able to come up with how to split the given string. I tried to iterate through the string and store the number before any NaN value is assigned. But, I was not able to deal with the score of 10 and the options
*and#.My pair programming partner suggested converting the string into an array and all we need to consider is
score,bonus, andoptionso just useshiftto store those values. At the same time, consider the exception cases by usingunshiftChatGPT recommended that it will be more clear if we utilize the index of the array instead of using
shift()three times (which led to O(3N) but this case will result in O(1))const bonusMap = { S: 1, D: 2, T: 3 }; for (let i = 0; i < 3; i++) { const score = Number(dartResult[i * 2]); const bonus = bonusMap[dartResult[i * 2 + 1]]; const option = dartResult[i * 2 + 2]; ... }
How I resolved the issues
let middleDistArr = [ // 2 5 8 0 [3, 2, 1, 0], // 0 [1, 2, 3, 4], // 1 [0, 1, 2, 3], // 2 [1, 2, 3, 4], // 3 [2, 1, 2, 3], // 4 [1, 0, 1, 2], // 5 [2, 1, 2, 3], // 6 [3, 2, 1, 2], // 7 [2, 1, 0, 1], // 8 [3, 2, 1, 2], // 9 [4, 3, 2, 1], // * [4, 3, 2, 1], // # ]; let middle = [2, 5, 8, 0]; let leftPos = 10; // * = 10 let rightPos = 11; // # = 11function solution(dartResult) { let dartResultArr = dartResult.split("") let answer = 0 let scoresArr = [] for(let i = 0; i < 3; i++) { let score = dartResultArr.shift() let bonus = dartResultArr.shift() if(bonus == 0) { // when the score is 10 score = 10; bonus = dartResultArr.shift() } let option = dartResultArr.shift() if(!isNaN(option)) { // when no options dartResultArr.unshift(option) option = undefined } if(bonus == 'S') score = score ** 1 if(bonus == 'D') score = score ** 2 if(bonus == 'T') score = score ** 3 scoresArr.push(score) if(option == '*') { scoresArr[i-1] *= 2 scoresArr[i] *= 2 } if(option == '#') scoresArr[i] = -score // save minus value } answer = scoresArr.reduce((acc, curr) => acc + curr); return answer }
What I newly learned
We can use the pre-determined array for some cases.
If there is a fixed number of performances (like Dartgame -> we only consider S, D, and T three cases), try to leverage that fixed number.
On VSCode Debugging mode, I tested what value of outputs or variables are assigned for each case inside the loop.
What to learn next
Review JS grammar (retake JS lecture parts 3 and 4)
Execution Context
Callback & Hoisting
This binding
Highest Paid Developer Workshop
How to Adapt?
It is important to actively ask questions and approach tasks with a mindset of finding the appropriateness of the questions.
As years of experience accumulate, it becomes harder to ask questions, and as a newcomer, it would be great to boldly ask questions knowing that it's natural to not know everything.
Meta-cognition is important again.
Actively asking questions with humility.
Fearlessness in making mistakes.
Cultivating a habit of recording/writing to avoid asking the same questions repeatedly.
How to Develop Meta-cognition for "ME"
Defining the key questions of my work.
Researching the background of the tasks I am assigned to and understanding the underlying causes that led to that background.
Practicing categorizing the stakeholders of the tasks in a tree structure

How to Work as a Developer?
As a professional developer = the process of developing expertise in my job within a company
- As a developer in a professional setting, the process of cultivating expertise involves learning and gaining practical experience in the company and becoming a valuable asset that is not easily replaceable. To achieve this, it is important to always have a learning mindset.
A sincere developer is someone who develops not just features, but services
- Features are like trees, whereas services are like forests.
Humility is crucial
Rapid project progress (MVP - Minimum Viable Product: Products that are deployed with minimal features, similar to experimental features, can lead to very fast development speed & get user feedback and comment, Agile)
Mini startup team (Squads - small team from each department for a few months)
Frequent communication (Scrum - daily, Sprints - monthly)
All three require communication skills that are not directly related to development expertise.
Communication skills are influenced by logical reasoning and humility.
Let's write living code (because writing good code is a default)
Communicate intention through code.
Follow team-consistent code style - apply and understand code conventions.
Focus on a single responsibility (SOLID principles).
Make parameters explicit.
Write predictable code.
Eliminate side effects (single functionality in one function).
Don't ignore important inputs (null checks).
Write test code.
Continuously assess and improve my expertise in the job market
- Regularly check job postings in my industry to identify relevant skills and continuously hone my skills as a developer.
![[코테] 그리디 문제 - 무지의 먹방 라이브](https://cdn.hashnode.com/res/hashnode/image/upload/v1712215455263/1ac1f35a-8862-4e42-8d0c-e2bea01e04c0.png)
![[코테] Bfs 토마토](https://cdn.hashnode.com/res/hashnode/image/upload/v1709032619170/70056896-c857-444b-9c99-45bfcb466806.png)
![[코테] Dfs 문제 유형 - 그래프 내에서 구분하여 카운트 하기](https://cdn.hashnode.com/res/hashnode/image/upload/v1709019361383/b0585d72-c808-4169-83a9-2724f312e927.png)
![[코테] DFS vs BFS](https://cdn.hashnode.com/res/hashnode/image/upload/v1708971211123/71f9386c-6a62-43b2-a602-4d084c24d6cf.png)
![[코테] 여행경로](https://cdn.hashnode.com/res/hashnode/image/upload/v1708971251412/27ce72ed-8ee7-4d13-a02f-ff4bbe50c4be.png)