15
Help needed! (lemmy.zip)

Hi! I've recently started learning C and I've been getting stuck on the basic tasks cuz I keep overcomplicating them T-T Could anyone please help me with this specific task?

Problem Statement

You have a digit sequence S of length 4. You are wondering which of the following formats S is in:

  • YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order
  • MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order

If S is valid in only YYMM format, print YYMM; if S is valid in only MMYY format, print MMYY; if S is valid in both formats, print AMBIGUOUS; if S is valid in neither format, print NA.

Constraints
- S is a digit sequence of length 4.

Sample Input 1
1905

Sample Output 1
YYMM
May XX19 is a valid date, but 19 is not valid as a month. Thus, this string is only valid in YYMM format.

Sample Input 2
0112

Sample 2
AMBIGUOUS
Both December XX01 and January XX12 are valid dates. Thus, this string is valid in both formats.

Sample Input 3
1700

Sample Output 3
NA
Neither 0 nor 17 is valid as a month. Thus, this string is valid in neither format.

The code I wrote for this is:

#include <stdio.h>

int main(){
    int S;
    scanf("%d", &S);
    int p1 = S/100;
    int p2 = S%100;
    if (p1!=0 && p1<=12){
        if(p2!=0 && p2<=12){
            printf("AMBIGUOUS");
        }
        else if (p2>=13){
            printf("MMYY");
        }
        else{
            printf("NA");
        }
    }
    else if (p1>=13){
        
        if(p2!=0 && p2<=12){
            printf("YYMM");
        }
        else {
            printf("NA");
        }
    }
   return 0;
}

It passed the 7 checks in the system, but failed on the 8th and I have no idea what kind of values are on the 8th check... Thanks to anyone for reading this far!

[-] yris_latteyi@lemmy.zip 3 points 2 months ago

I use NewPipe on mobile and freetube on desktop, although you probably considered them since they're often recommended first when you just start looking into youtube alternatives

[-] yris_latteyi@lemmy.zip 3 points 3 months ago

Yeah, I'm friends with 2, we were in a poly relationship and I quit. My mentall health was awful which was affecting my relationships with them, so I distanced away for like 2 years. Now we speak regularly, share some news and stories, they even wanna invite me to their wedding, I'm so happy for them🥹

[-] yris_latteyi@lemmy.zip 2 points 3 months ago

Thanks! I'll check it out!

[-] yris_latteyi@lemmy.zip 8 points 3 months ago

What is this game called? 👀

[-] yris_latteyi@lemmy.zip 2 points 3 months ago

That's a valid thought, but I guess the starting point matters less if the characters becomes a yandere eventually. I noticed though, most tsundere characters don't devolve to become yanderes, it mostly happens to dandere types(which I might be mixing up, cuz I'm not sure) the ones that are interested and friendly towards MC from the start🤔

[-] yris_latteyi@lemmy.zip 2 points 3 months ago* (last edited 3 months ago)

Gorgeous! Really love the way you blended the sky and trees together, looks very lifelike. Admittedly, I first thought this was a traditional painting, so the fact that you can do this in digital really impresses me. Kudos for using Krita!

[-] yris_latteyi@lemmy.zip 3 points 3 months ago

Yeah, fits the definition, and generally that's a common development for yandere characters

[-] yris_latteyi@lemmy.zip 2 points 3 months ago

Really pretty, NGL kinda reminds me of the redbull advertisements with the style

[-] yris_latteyi@lemmy.zip 10 points 3 months ago

I love frieren for this, beautiful drawing!

[-] yris_latteyi@lemmy.zip 2 points 4 months ago

I love this image of Kim cuz he kinda looks like sans Undertale XD

[-] yris_latteyi@lemmy.zip 2 points 4 months ago

I don't think it's very surprising

[-] yris_latteyi@lemmy.zip 2 points 4 months ago

Yes, let's all be part of the homosexual underground, before the upperground burns to ashes

18
submitted 4 months ago* (last edited 4 months ago) by yris_latteyi@lemmy.zip to c/digitalart@lemmy.world
view more: next ›

yris_latteyi

0 post score
0 comment score
joined 4 months ago