r/GetCodingHelp • • Sep 12 '25

Beginner Help Struggling to code what you understand? You’re not alone.

6 Upvotes

I've been seeing a lot of posts by students that they are able to follow the tutorials but are not able to write code on their own. They understand the problem, the algorithm, and the pseudocode but when it comes to actually writing code, their mind just gets blank.

This happens when you’re focusing on concepts but not giving your brain enough muscle memory with code. If you're also struggling with it, don't worry. There's a way to get unstuck from this. Here's how:

  • Write code daily, even if it’s small snippets.

  • Don’t be afraid to peek at the solution at first — then rewrite it without looking.

  • Focus on syntax + debugging, that’s where the real learning happens.

  • Build small projects that force you to “apply” the concept.

If you’re stuck here, it doesn’t mean you’re bad at coding. It just means you’re in the normal transition phase from “understanding” to “implementing.” Gradually, you'll see yourself writing code without even needing a tutorial!


r/GetCodingHelp • • Mar 12 '26

Amazon, my SDE onsite interview Experience

2 Upvotes

Amazon SDE Onsite Interview Experience (5 Months Experience) – Need Advice on Bar Raiser Round

Got a mail for the onsite interview, and a form was shared to choose the location (Bangalore/Hyderabad). After filling out the form, I got a call from HR asking if I was available on the following date.

Round 1 (Onsite) – 1 hour

Two DSA questions.

Question 1: Similar to Rotting Oranges

Solved it using BFS.

Follow-up: Can we optimize it?
Basically, the interviewer didn’t want me to use a visited array.

Question 2: Solve two string DP/hash problems

Started with the brute force approach, then optimized it.

At the end, there were 2 Leadership Principle (LP) questions.

Interviewer seemed satisfied.

Round 2 (Onsite) – 1 hour

DSA Question: Something similar to Two Sum but in a Binary Tree.

Solved it using brute force, and in the follow-up optimized it using a map.

Second question (follow-up):
If the tree is a BST and we are not allowed to use a map, how would you solve it?

Solved it after receiving a hint. The interviewer seemed satisfied.

Then there were 2 LP questions.

Round 3 (Virtual) – 1 hour

DSA Question: Reverse the edges of a directed graph.
(I had to write the entire code from scratch — from taking input to printing the output — in an online compiler.)

Solved it.

LLD Question: Asked me to design 2 features from my past experience.

Got some follow-up questions. I completed the first feature, but there was no time left for the second one, so the interviewer asked me to leave it.

Ended with 2 LP questions.

Round 4 – Bar Raiser (Virtual) – 45 minutes

The interviewer mentioned at the beginning that this would be a pure behavioral round (Leadership Principles only).

It didn’t go as well as I expected.

He asked me to describe a complex problem I solved in my past experience. I had prepared stories in advance, but at the end of my answer he smiled and said:

“It doesn’t sound very complex to me.”

I dont know what he was expecting. At that point, I felt like I might already be rejected.

After that, he asked 3 more LP questions with follow-ups.

Verdict: Pending

Experience: 5 months
College: NIT (Tier 2)

Question:
If the Bar Raiser round doesn’t go very well, what are the chances of still getting selected? Would appreciate any insights from people who have gone through a similar experience.


r/GetCodingHelp • • Mar 04 '26

My Uber SDE-2 Interview Experience (Not Selected, but Worth Sharing)

2 Upvotes

I recently interviewed with Uber for a Backend SDE-2 role. I didn’t make it through the entire process, but the experience itself was incredibly insightful — and honestly, a great reality check.

Since Uber is a dream company for many engineers, I wanted to write this post to help anyone preparing for similar roles. Hopefully, my experience saves you some surprises and helps you prepare better than I did.

Round 1: Screening (DSA)

The screening round focused purely on data structures and algorithms.

I was asked a graph problem, which turned out to be a variation of Number of Islands II. The trick was to dynamically add nodes and track connected components efficiently.

I optimized the solution using DSU (Disjoint Set Union / Union-Find).

If you’re curious, this is the exact problem:

Key takeaway:
Uber expects not just a working solution, but an optimized one. Knowing DSU, path compression, and union by rank really helped here.

Round 2: Backend Problem Solving

This was hands down the hardest round for me.

Problem Summary

You’re given:

  • A list of distinct words

  • A corresponding list of positive costs

You must construct a Binary Search Tree (BST) such that:

  • Inorder traversal gives words in lexicographical order

  • The total cost of the tree is minimized

Cost Formula

If a word is placed at level L:

Contribution = (L + 1) × cost(word)

The goal is to minimize the total weighted cost.

Example (Simplified)

Input

One Optimal Tree:

Words: ["apple", "banana", "cherry"]
Costs: [3, 2, 4]

banana (0)
       /       \
  apple (1)   cherry (1)

TotalCost:

  • banana → (1 × 2) = 2

  • apple → (2 × 3) = 6

  • cherry → (2 × 4) = 8 Total = 16

What This Problem Really Was

This wasn’t a simple BST question.

It was a classic Optimal Binary Search Tree (OBST) / Dynamic Programming problem in disguise.

You needed to:

  • Realize that not all BSTs are equal

  • Use DP to decide which word should be the root to minimize weighted depth

  • Think in terms of subproblems over sorted ranges

Key takeaway:
Uber tests your ability to:

  • Identify known problem patterns

  • Translate problem statements into DP formulations

  • Reason about cost trade-offs, not just code

Round 3: API + Data Structure Design (Where I Slipped)

This round hurt the most — because I knew I could do better.

Problem

Given employees and managers, design APIs:

  1. get(employee) → return manager

  2. changeManager(employee, oldManager, newManager)

  3. addEmployee(manager, employee)

Constraint:
👉 At least 2 operations must run in O(1) time

What Went Wrong

Instead of focusing on data structure choice, I:

  • Spent too much time writing LLD-style code

  • Over-engineered classes and interfaces

  • Lost sight of the time complexity requirement

The problem was really about:

  • HashMaps

  • Reverse mappings

  • Constant-time lookups

But under pressure, I optimized for clean code instead of correct constraints.

Key takeaway:
In interviews, clarity > beauty.
Solve the problem first. Refactor later (if time permits).

Round 4: High-Level Design (In-Memory Cache)

The final round was an HLD problem:

Topics discussed:

  • Key-value storage

  • Eviction strategies (LRU, TTL)

  • Concurrency

  • Read/write optimization

  • Write Ahead Log

However, this round is also where I made a conceptual mistake that I want to call out explicitly.

Despite the interviewer clearly mentioning that the cache was a single-node, non-distributed system, I kept bringing the discussion back to the CAP theorem — talking about consistency, availability, and partition tolerance.

In hindsight, this was unnecessary and slightly off-track.

CAP theorem becomes relevant when:

  • The system is distributed

  • Network partitions are possible

  • Trade-offs between consistency and availability must be made

In a single-machine, in-memory cache, partition tolerance is simply not a concern. The focus should have stayed on:

  • Data structures

  • Locking strategies

  • Read-write contention

  • Eviction mechanics

  • Memory efficiency

Resource: PracHub

Final Thoughts

I didn’t get selected — but I don’t consider this a failure.

This interview:

  • Exposed gaps in my DP depth

  • Taught me to prioritize constraints over code aesthetics

  • Reinforced how strong Uber’s backend bar really is

If you’re preparing for Uber:

If this post helps even one person feel more prepared, it’s worth sharing.

Good luck — and see you on the other sid


r/GetCodingHelp • • Sep 16 '25

Programming Languages What’s the hardest coding concept you’ve faced so far?

3 Upvotes

Hey guys!

When I was a beginner, I struggled a lot with DSA. I kept memorizing examples without really “getting it”, until one day I tried drawing it out on paper step by step, and it finally clicked.

Want to get you know better. Curious to know what concept tripped you up the most while learning to code, and how did you eventually overcome it (or are still struggling with)?


r/GetCodingHelp • • Jan 17 '26

Discussion How do you actually find your niche in Computer Science?

21 Upvotes

A lot of students stress about picking a niche early. Be it web, AI, data, or systems…without realizing most people only figure it out after trying and failing at a few things. From talking to students, a pattern keeps showing up, your niche isn’t what you enjoy watching tutorials on, it’s what you’re willing to struggle with for weeks without quitting. Did you figure out your direction through projects, internships, assignments, or pure trial and error? Or are you still exploring?


r/GetCodingHelp • • Oct 03 '25

AI & Tools What’s Your Favorite "Hidden Gem" Tool for Coding?

2 Upvotes

Every developer has that one tool or website that saves them hours of frustration but isn’t widely known. Could be a debugger, snippet manager, code formatter, or even a productivity app.

Let’s share them so more people can benefit!! Drop your favorite coding tools below 👇


r/GetCodingHelp • • Nov 10 '25

Insights I am creating a absurd Design site

6 Upvotes

I am creating a website project that collects some of my creative coding projects. I would love to get some feedback on this. I just started this and need an opinion. https://overgrootoma.github.io/Accidental-Graphics/index.html Thank you in advance :)


r/GetCodingHelp • • Mar 04 '26

Python Code doesn't work in Minecraft education

Thumbnail
gallery
4 Upvotes

the agent needs to move till the end of the redstone line. In both pictures the code is wrong. I don't know what's wrong.


r/GetCodingHelp • • Sep 23 '25

Discussion Why Do We Even Need Data Structures? 🤔

6 Upvotes

Most of us learn arrays, linked lists, stacks, and queues as separate topics when starting out. But here’s the catch: in real-world coding, you almost never use a raw linked list. So why are we still taught them?

Is it because they build problem-solving foundations, or do they feel outdated to you?

Would love to hear what’s the first data structure you found genuinely useful in a project?


r/GetCodingHelp • • Apr 28 '26

Find the potential moves of a bishop in chess

4 Upvotes

Hello, I am trying to find the potential moves for a bishop in C#.net. My chess board is stored as a 2d array of strings, each string being a - for black or a + for white, followed by B for bishop. Here is the default for example:

string[][] pieces = [["-C","-N","-B","-Q","-K","-B","-N","-C"],

["-P","-P","-P","-P","-P","-P","-P","-P"],

[" "," "," "," "," "," "," "," "],

[" "," "," "," "," "," "," "," "],

[" "," "," "," "," "," "," "," "],

[" "," "," "," "," "," "," "," "],

["+P","+P","+P","+P","+P","+P","+P","+P"],

["+C","+N","+B","+Q","+K","+B","+N","+C"]];

If I have the coordinates of the piece that I want to move, how would I find all the potential moves if it is a bishop?


r/GetCodingHelp • • Jan 03 '26

Discussion What do you want to improve in coding this year?

10 Upvotes

Now that the new year has started, a lot of us are probably resetting our goals or recovering from last year’s unfinished ones. If you’re a beginner, what’s the one coding thing you want to focus on first this year? It could be anything…learning a language, building a small project, understanding DSA, or just being more consistent? Share your plan, even if it’s simple. Sometimes writing it out is the first step to actually sticking to it.


r/GetCodingHelp • • Feb 01 '26

Need help with Learning

Thumbnail reddit.com
3 Upvotes

r/GetCodingHelp • • Apr 24 '26

Project Guidance What Features do I Cut in My Game in Unreal Engine?

3 Upvotes

Hi, I'm a student coding a small 3D horror game set in an abandoned storage facility where the player avoids a ghost while collecting items and clues. For a first project, how do you decide which features to cut so the game is actually finishable in a 1 month time frame?


r/GetCodingHelp • • Sep 13 '25

Should you focus on DSA or projects? Here’s how to balance both.

2 Upvotes

Every student faces this choice. While it is important to have a solid resume showcasing your skills and quality projects, it is also necessary to focus on tackling problems during your interviews and coding assessments.

So, which one should you focus on? The answer is: both. How?

💡 The trick is balance:

  • Spend 1 hour/day on DSA to build problem-solving skills.

  • Use weekends for longer project sessions.

  • Pick projects that actually showcase your skills (APIs, CRUD apps, small games). Your portfolio + DSA prep together make you stand out in interviews.

Remember to stay consistent and reward yourself for small achievements as well. This will keep you motivated to hustle.


r/GetCodingHelp • • Sep 14 '25

Coding deadlines stressing you out? Try this hack!

2 Upvotes

Many students often say to me that their assignments “jump” from easy to hard overnight. Here’s what I tell them:

✅ Break down the problem into smaller tasks.
✅ Write pseudocode first, then translate it step by step.
✅ Don’t chase perfection on the first try — get a working version first, refine later.

Consistency > cramming. Even short daily coding practice beats last-minute stress.


r/GetCodingHelp • • Jun 16 '26

Beginner Help Not able to figure out the problem with compiler

Post image
4 Upvotes

r/GetCodingHelp • • Sep 25 '25

Insights Optional Parameters in Java & How Do You Handle Them?

2 Upvotes

Unlike Python or JavaScript, Java doesn’t directly support optional parameters in methods. But there are multiple ways developers handle this:

  1. Method Overloading: Define multiple versions of the same method with different parameter lists.

void greet(String name) {

System.out.println("Hello " + name);

}

void greet() {

System.out.println("Hello Guest");

}

2. Using Default Values with Objects: You can pass null or a special value and handle it inside the method.

3. Varargs: Useful if you want flexibility with the number of arguments.

void printNumbers(int... nums) {

for (int n : nums) System.out.print(n + " ");

}

4. Builder Pattern: Often used in real-world projects when you need readability and flexibility.

Each approach has its pros and cons. Overloading works fine for small cases, but for bigger projects, Builder Pattern makes code cleaner.

📖 Full breakdown with examples here:
👉 Optional Parameters in Java

What’s your go-to way of handling optional parameters in Java?


r/GetCodingHelp • • Mar 05 '26

Beginner Help Don’t skip DBMS while learning to code

5 Upvotes

A lot of students focus heavily on programming languages and frameworks, but quietly ignore DBMS. Then the moment they try to build a real project, they get stuck, not because of coding, but because they don’t know how to design the data.

I remember one student who reached out to us saying they had learned SQL queries but couldn’t figure out what database project to build or how to structure the tables. The issue wasn’t lack of effort, it was that they never practiced thinking in terms of data models. We helped them start by picking a simple real-world system, like a gym or e-commerce store, and breaking it down into entities, relationships, and constraints. Once that clicked, the project suddenly became much easier to build.

That conversation actually inspired us to compile a list of practical database project ideas students can use to apply DBMS concepts properly:
https://codingzap.com/top-database-project-ideas-for-students-to-work-on/

If you’re learning to code right now, don’t treat DBMS as just another subject in your curriculum. It’s the backbone of almost every real application.


r/GetCodingHelp • • Dec 22 '25

advice on a fun project

1 Upvotes

Hey everyone, I’m new to coding and I’ve been working on a project to track the prices of pets in Adopt Me. My goal is to scrape data about pet values from websites that track market changes (like winadopt.me), and then send notifications via Discord whenever a pet's price changes by a certain percentage (either going up or down). I’ve been using Python with libraries like Selenium and BeautifulSoup to scrape the data, but I’m still learning and running into some challenges.

At this point, I’m trying to figure out how to reliably pull the right data, especially when it comes to detecting changes in value over different timeframes (like the past week or month). I’ve also been looking into APIs and trying to figure out the best way to get the data I need. I’m just looking for general advice, best practices, or any tips that could help me improve my code and understanding.

If anyone has experience with web scraping, using APIs, or Discord bots, I’d really appreciate any guidance or suggestions! I’m excited to learn more and appreciate the help.


r/GetCodingHelp • • Nov 02 '25

Career & Roadmap How do I ensure I’m learning the right way without a senior dev to guide me?

2 Upvotes

Hi all, I need some advice.

I have been working part-time at a local cybersecurity startup while continuing studies at university. I am a self-taught programmer, and our team does not have any senior developers; others are either at my level or less experienced. The CEO is knowledgeable in cybersecurity but not much in backend or system design.

When I joined, the codebase was really messy, just like a toy project someone had built while he was learning. No message queues, heavy tasks blocking the main thread, random initialization, poor structure, and zero error handling. So, I refactored a lot of things, moving the CPU-heavy tasks into workers, adding message queues, Dockerizing the system, cleaning up the architecture.

Here's where I'm stuck: I learn everything through research, AI tools, and reading blogs. I don't just copy code; I ask questions, try to understand the architecture, evaluate pros/cons, and debug deeply. But often, I fear that not having a senior developer reviewing my work will cause me to develop bad habits or skip important nuances.

I've tried applying for other jobs, but most are looking for someone more experienced. For now, I will be staying here and do my best to learn and improve in my post.

Now, how can I be sure that I am moving in the right direction without a senior to guide me? Any tips or strategies from those who have been in a situation similar to mine are very welcome.


r/GetCodingHelp • • Oct 24 '25

Discussion How do you stay consistent when coding feels overwhelming?

3 Upvotes

We all hit that phase where coding starts feeling like too much. There are too many bugs to be fixed, too many topics to learn, and too little time. When you reach that point, what keeps you going? Do you take a break, switch projects, or push through it anyway?


r/GetCodingHelp • • Oct 02 '25

Resources & Recommendations 10 Online Tools to Simplify C++ Homework & Assignments

3 Upvotes

When I was in college, I wished I had tools to format, compile, and debug C++ faster. Today, there are so many online tools that make life easier:

  • C++ compilers you can run in the browser

  • Debuggers with step-by-step execution

  • Code formatters for clean submissions.

I’ve listed some of the best free ones here 👇

👉 Best Online Tools for C++ Homework


r/GetCodingHelp • • Jun 08 '26

need help for a class project!

Thumbnail
reddit.com
2 Upvotes

r/GetCodingHelp • • Nov 22 '25

Beginner Help script.js not working - first time making a website and i ran into a problem

6 Upvotes

edit: thank you to everyone who helped me 😚 i am so so grateful for your assistance and i cant thank you enough 💗 its two days before his birthday and now ill be able to paste the very long letter i have drafted for him. this is very personal to me since he loves coding and now i can give him a very special gift for such a special year. thank you so much 🥹

hi everyone ! im very VERY new to like coding and stuff so i had asked one of my friends to help me make a website for my boyfriend but it doesnt seem to be working. they had asked me to use github for this. the website should have sort of questions with buttons and (one has) a dropdown feature which, if the answer is correct, unlock 6 different letters and consequently a birthday message. ive just pasted in the code for files index.html, style.css, and script.js as my friend had told me to (its a simple website, not much to it) but the buttons and the dropdown dont seem to work. is there a quick fix for this ? or should i paste the code here for you guys to pick at and find the issue ?

his birthday is on the 26th nov im quite late and im panicking aahh please help if you can 😓

thank you so much everyone 💗

edit: this is the .html (first) and .js (second) so sorry for not pasting it earlier

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Birthday Unlock — FOSSIL</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="card" role="main">
  <div class="left">
    <h1>Secret Birthday Unlock</h1>
    <p class="lead">answer the 6 questions correctly to reveal each letter of a surprise word. 2 questions use buttons (yes/no). date input (q6) supports dropdown or many text formats like <em>20/31/2030</em> or <em>12/31/2030</em>.</p>

    <!-- Q1 -->
    <div class="question" id="q1">
      <div class="q-title">1) WHAT IS YOUR NAME</div>
      <div class="q-hint">accepts uppercase and lowercase YAY</div>
      <input id="nameInput" type="text" placeholder="type the birthday boy’s name" autocomplete="off">
      <div style="display:flex;gap:8px;margin-top:10px;">
        <button class="btn" onclick="checkQ1()">check answer</button>
        <button class="btn" onclick="clearField('nameInput')">clear text</button>
      </div>
      <div class="small" id="q1-msg"></div>
    </div>

    <!-- Q2 -->
    <div class="question" id="q2">
      <div class="q-title">2) is it your birthday (yes/no)</div>
      <div class="q-hint">press <strong>yeahhhh</strong> or <strong>no..</strong>.</div>
      <div class="btn-row" style="margin-top:8px;">
        <button class="btn btn-yes" onclick="checkQ2('yes')">yeahhfebibfbdffb</button>
        <button class="btn btn-no" onclick="checkQ2('no')">no…………</button>
      </div>
      <div class="small" id="q2-msg"></div>
    </div>

    <!-- Q3 -->
    <div class="question" id="q3">
      <div class="q-title">3) how old are u turning</div>
      <div class="q-hint">type the number in uh numbers ??</div>
      <input id="ageInput" type="number" placeholder="18" min="1">
      <div style="display:flex;gap:8px;margin-top:10px;">
        <button class="btn" onclick="checkQ3()">check answer</button>
        <button class="btn" onclick="clearField('ageInput')">clear text</button>
      </div>
      <div class="small" id="q3-msg"></div>
    </div>

    <!-- Q4 -->
    <div class="question" id="q4">
      <div class="q-title">4) who sent you this</div>
      <div class="q-hint">my name basically - caps or no idm</div>
      <input id="senderInput" type="text" placeholder="whats my nameeee">
      <div style="display:flex;gap:8px;margin-top:10px;">
        <button class="btn" onclick="checkQ4()">check answer yay</button>
        <button class="btn" onclick="clearField('senderInput')">clear text</button>
      </div>
      <div class="small" id="q4-msg"></div>
    </div>

    <!-- Q5 -->
    <div class="question" id="q5">
      <div class="q-title">5) can you accept youre literally ancient</div>
      <div class="q-hint">press <strong>yes</strong> or <strong>no</strong>.</div>
      <div class="btn-row" style="margin-top:8px;">
        <button class="btn btn-yes" onclick="checkQ5('yes')">yes hahahaha</button>
        <button class="btn btn-no" onclick="checkQ5('no')">No</button>
      </div>
      <div class="small" id="q5-msg"></div>
    </div>

    <!-- Q6 -->
    <div class="question" id="q6">
      <div class="q-title">6) what is the date today..</div>
      <div class="q-hint">again date input supports dropdown or many text formats like 20/31/2030 or 12/31/2030.</div>
      <div style="display:flex;gap:8px;margin-bottom:8px;">
        <select id="daySel"></select>
        <select id="monthSel"></select>
        <select id="yearSel"></select>
      </div>
      <div style="margin-bottom:8px;">
        <input id="dateText" type="text" placeholder="or type by hand e.g. 26/11/2025">
      </div>
      <div style="display:flex;gap:8px;margin-top:6px;">
        <button class="btn" onclick="checkQ6()">check answer</button>
        <button class="btn" onclick="clearField('dateText')">clear text/date</button>
      </div>
      <div class="small" id="q6-msg"></div>
    </div>

  </div>

  <div class="right">
    <div class="progress">Letters unlocked:</div>
    <div class="letters" aria-live="polite">
      <div class="letter" id="l1">F</div>
      <div class="letter" id="l2">O</div>
      <div class="letter" id="l3">S</div>
      <div class="letter" id="l4">S</div>
      <div class="letter" id="l5">I</div>
      <div class="letter" id="l6">L</div>
    </div>

    <div class="final-card">
      <div class="small">Progress: <span id="progressCount">0</span>/6</div>
      <div class="final-message" id="finalMessage">
        <div class="typewriter" id="typewriter">🎉 HAPPY BIRTHDAY! 🎉 — message arriving soon.</div>
      </div>
    </div>

    <footer class="small">Dark blue theme — replace images by dropping them into the code where indicated.</footer>
  </div>
</div>

<canvas id="confetti-canvas" style="position:fixed;left:0;top:0;pointer-events:none;z-index:9999;"></canvas>

<script src="script.js"></script>
</body>
</html>

this is as a file named script.js if that may be wrong

const ACCEPTED = {
  names: ['arsen','toji'],
  birthdayAnswer: 'yes',
  age: '18',
  senders: ['chloe','taiga'],
  fossilAnswer: 'yes',
  dateTarget: { day:26, month:11, year:2025 }
};

function showMsg(id, txt, ok){
  const el = document.getElementById(id);
  el.textContent = txt;
  el.style.color = ok ? '#bff7ff' : '#ffadb0';
}
function clearField(id){document.getElementById(id).value='';}

let progress = [false,false,false,false,false,false];
function revealLetter(index){
  if(progress[index]) return;
  progress[index]=true;
  const el=document.getElementById('l'+(index+1));
  el.classList.add('revealed');
  const count=progress.filter(Boolean).length;
  document.getElementById('progressCount').textContent=count;
  el.animate([{transform:'translateY(6px) scale(.98)'},{transform:'translateY(-6px) scale(1.06)'}], {duration:320, easing:'cubic-bezier(.2,.9,.3,1)'});
  if(count===6){
    document.getElementById('finalMessage').style.display='block';
    typeWriter(document.getElementById('typewriter'), 20);
    launchConfetti();
  }
}

function checkQ1(){
  const val=(document.getElementById('nameInput').value||'').trim().toLowerCase();
  if(!val){showMsg('q1-msg','WHAT IS YOUR NAME'); return;}
  if(ACCEPTED.names.includes(val)){showMsg('q1-msg','correct now move on',true);revealLetter(0);}
  else{showMsg('q1-msg','nuh uh',false);}
}

function checkQ2(answer){
  const a=String(answer||'').trim().toLowerCase();
  if(a===ACCEPTED.birthdayAnswer){showMsg('q2-msg','correctt',true);revealLetter(1);}
  else{showMsg('q2-msg','no loser',false);}
}

function checkQ3(){
  const val=parseInt(document.getElementById('ageInput').value,10);
  if(isNaN(val)){showMsg('q3-msg','how old is u turning');return;}
  if(val===parseInt(ACCEPTED.age,10)){showMsg('q3-msg','i mean the answer should be 7.9 trillion but okay ig..',true);revealLetter(2);document.getElementById('ageInput').disabled=true;}
  else{showMsg('q3-msg','are you okay.. answer again',false);}
}

function checkQ4(){
  const val=(document.getElementById('senderInput').value||'').trim().toLowerCase();
  if(!val){showMsg('q4-msg','who send u this (hint: amazingly amazing person who is amazing heheh)'); return;}
  if(ACCEPTED.senders.includes(val)){showMsg('q4-msg','correct correct i am amazing yes',true);revealLetter(3);}
  else{showMsg('q4-msg','theres no way',false);}
}

function checkQ5(answer){
  const a=String(answer||'').trim().toLowerCase();
  if(a===ACCEPTED.fossilAnswer){showMsg('q5-msg','so you know just how old you are hahaha',true);revealLetter(4);}
  else{showMsg('q5-msg','do you have memory issues or smth..',false);}
}

function checkQ6(){
  const text=(document.getElementById('dateText').value||'').trim();
  const daySel=document.getElementById('daySel').value;
  const monthSel=document.getElementById('monthSel').value;
  const yearSel=document.getElementById('yearSel').value;
  let parsed=null;
  if(text){parsed=tryParseDate(text);}
  else if(daySel && monthSel && yearSel){parsed={day:parseInt(daySel,10),month:parseInt(monthSel,10),year:parseInt(yearSel,10)};}
  if(!parsed){showMsg('q6-msg','try another format.. its not working',false);return;}
  const t=ACCEPTED.dateTarget;
  if(parsed.day===t.day && parsed.month===t.month && (parsed.year===t.year || parsed.year===(t.year%100))){showMsg('q6-msg','right right so basically like this is like when you like okay so idk how to explain it like its when you kinda like sigh okay so basically',true);revealLetter(5);}
  else{showMsg('q6-msg','how can you not know your own birthday..',false);}
}

function tryParseDate(text){
  text=text.trim();
  const sepText=text.replace(/\s+/g,' ').replace(/[,]/g,'').trim();
  const partsSlash=sepText.split(/[\/\-\.\s]+/);
  if(partsSlash.length===3){
    const a=parseInt(partsSlash[0],10);
    const b=parseInt(partsSlash[1],10);
    const c=parseInt(partsSlash[2],10);
    if(!isNaN(a)&&!isNaN(b)&&!isNaN(c)){
      if(a>12){return {day:a,month:b,year:normalizeYear(c)};}
      else if(b>12){return {day:b,month:a,year:normalizeYear(c)};}
      else{return {day:a,month:b,year:normalizeYear(c)};}
    }
  }
  const iso=sepText.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);
  if(iso){return {day:parseInt(iso[3],10),month:parseInt(iso[2],10),year:parseInt(iso[1],10)};}
  const monthNames={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12};
  const tokens=sepText.split(' ');
 const monthNames = {
    january:1,february:2,march:3,april:4,may:5,june:6,
    july:7,august:8,september:9,october:10,november:11,december:12
  };

  const tokens = sepText.split(' ');

  if(tokens.length >= 2){
    for(let i=0; i<tokens.length; i++){
      const tkn = tokens[i].toLowerCase();
      if(monthNames[tkn]){
        const month = monthNames[tkn];
        // try formats like: "26 November 2025" or "November 26 25"
        const nums = tokens.filter(x => !isNaN(parseInt(x,10))).map(x => parseInt(x,10));
        if(nums.length >= 1){
          const day = nums[0];
          const year = nums[1] ? normalizeYear(nums[1]) : (new Date()).getFullYear();
          return {day, month, year};
        }
      }
    }
  }
  return null;
}

function normalizeYear(y){
  if(y < 100){
    return 2000 + y; // e.g. 25 → 2025
  }
  return y;
}

/* ---------- Dropdown population ---------- */
window.addEventListener('DOMContentLoaded', () => {
  const daySel = document.getElementById('daySel');
  const monthSel = document.getElementById('monthSel');
  const yearSel = document.getElementById('yearSel');

  for(let d=1; d<=31; d++){
    const opt=document.createElement('option');
    opt.value=d; opt.textContent=d;
    daySel.appendChild(opt);
  }
  for(let m=1; m<=12; m++){
    const opt=document.createElement('option');
    opt.value=m; opt.textContent=m;
    monthSel.appendChild(opt);
  }
  for(let y=2020; y<=2035; y++){
    const opt=document.createElement('option');
    opt.value=y; opt.textContent=y;
    yearSel.appendChild(opt);
  }
});

/* ---------- OPTIONAL: typewriter & confetti placeholders ---------- */
function typeWriter(el, speed){
  const txt = el.textContent;
  el.textContent = "";
  let i = 0;
  const tick = () => {
    if(i < txt.length){
      el.textContent += txt.charAt(i);
      i++;
      setTimeout(tick, speed);
    }
  };
  tick();
}

function launchConfetti(){
  // empty function for now so page doesn’t error
}