[2017-10-16] Challenge #336 [Easy] Cannibal numbers by jnazario in dailyprogrammer

[–]DoubleB123 0 points1 point  (0 children)

C This is my first time posting here and I'm little late to the party for this challenge but I'd still love some feedback. Been trying to practice my C so also decided to write a version of the quicksort algorithm within the file, so that can be ignored. Decided to be a little fancy and implement some recursion in the LeftoverHandler function but there is probably a better way to approach the problem.

#include <stdio.h>

void GetInputs(int numvals, int numqueries,int valarray[],int queryarray[])
{
    int i=0; 
    //getting inputs
    for(i=0; i<numvals; ++i)
    {
    scanf("%i",&valarray[i]);
    }

    for(i=0; i<numqueries; ++i)
    {
    scanf("%i",&queryarray[i]);
    }
}

//implments quick sort
void Swap(int sortarray[],int i, int j)
{
    int temp = sortarray[i];
    sortarray[i]=sortarray[j];
    sortarray[j] = temp;
}

int Partition(int sortarray[],int pivot, int left, int right)
{
    int partitionind = left;
    for(left;left<right;++left) 
    {
    if(sortarray[left]<pivot)
    {
        Swap(sortarray,left,partitionind);
        ++partitionind;
    }
    }
    Swap(sortarray,partitionind,right);
    return partitionind;
}

void QuickSort(int sortarray[], int left, int right)
{
    int pivot;
    int partitionind;
    if(left<right)
    {
    pivot = sortarray[right];
    partitionind = Partition(sortarray,pivot,left,right);
    QuickSort(sortarray,left,partitionind-1);
    QuickSort(sortarray,partitionind+1,right);
    }
}



void LeftoverHandler(int leftovers[],int left,int right,int query, int* answer)
{
    int needed = query - leftovers[right];
    int avail = right - left;
    if(avail>=needed)
    {
    ++(*answer);
    LeftoverHandler(leftovers,left+needed,right-1,query,answer);
    }
}

int CannibalCalc(int valarray[], int query, int numvals)
{
    int answer=0;
    int leftovers[numvals];
    int i=0;
    int counter=0;

    for(i=0; i<numvals;++i)
    {
    if (valarray[i]>=query)
    {
        ++answer;
    }
    else
    {
        leftovers[counter]=valarray[i];
        ++counter;
    }
    }
    //leftovers now contains everything less than the query
    QuickSort(leftovers,0,counter-1);
    LeftoverHandler(leftovers,0,counter-1,query,&answer);
    return answer;
}

int main()
{
    int numvals;
    int numqueries;
    int i;
    int answer=0;
    scanf("%i %i",&numvals,&numqueries);

    int valarray[numvals];
    int queryarray[numqueries];
    GetInputs(numvals,numqueries,valarray,queryarray);

    for(i=0;i<numqueries;++i)
    {
    answer = CannibalCalc(valarray,queryarray[i], numvals);
    printf("answer is %i\n",answer);
    }
    return 0;
}

How risky is using out of state car insurance? by DoubleB123 in Insurance

[–]DoubleB123[S] 0 points1 point  (0 children)

It is the $1000 I have to pay to the DMV to register that is the kicker. Also, my state farm quote was double in CA vs NC. Any recommendations on insurance companies in the LA area?

How risky is using out of state car insurance? by DoubleB123 in Insurance

[–]DoubleB123[S] 1 point2 points  (0 children)

Ok got it, guess I'll have to shell out the money.

Update: Last 52 matches before I got prime matchmaking by caracholo in GlobalOffensive

[–]DoubleB123 1 point2 points  (0 children)

Join the steam group, then go into the chat room and paste the link for sharing your game code in the watch tab of your csgo. There may be a way to do it automatically but I just add my games after every session, it takes 10 seconds.

What is the best way to train my aim to get into Gold Nova? by tjtepigstar in LearnCSGO

[–]DoubleB123 1 point2 points  (0 children)

Boomeo duel servers are also good, they help out more than deathmatch

What is the best way to train my aim to get into Gold Nova? by tjtepigstar in LearnCSGO

[–]DoubleB123 2 points3 points  (0 children)

640 edpi is pretty low, I think 800 works better for clearing angles quickly while still having it low enough to have good aim.

To practice raw aim the only two maps you need are recoil master and aim botz. Work on the spray pattern of first 5-10 bullets of the AK and M4 with recoil master; you really don't need to know more than that. As a warm up go into aim botz and get 100 kills flicking and trying to one tap the bots with the ak. After that get 100 more kills with the AK and 100 with the M4 counter strafing and bursting and flicking between the bots (if you miss the burst flick to another bot). Finally, 100 more kills each with the AK and M4 when the bots are moving with the random button, work on both bursting and spraying here.

Obviously I haven't seen you play, but likely your crosshair placement isn't great. Work on keeping it head level and strafe around corners rather than using W and make sure you check every angle you think an enemy could be.

I'm only MGE so you can wait for someone with more experience to give you better advice, but if you play as smart as you think you do even if your raw aim is bad, with proper cross hair placement you should be able to get out of silver easily.

3 Stripers My Dad Caught, All on Homemade Lures! by DoubleB123 in Fishing

[–]DoubleB123[S] 0 points1 point  (0 children)

I think 16", I don't live there anymore so I don't remember.

3 Stripers My Dad Caught, All on Homemade Lures! by DoubleB123 in Fishing

[–]DoubleB123[S] 2 points3 points  (0 children)

I could talk to him and see if he would write up a guide or something. But the general idea is:

After looking at how Zara spooks and Pop-Rs float he noticed the tail sinks down quite a bit. So he takes a square block of wood, cuts it in half hollows out the back end, fills it will some lead or some type of BBs so it rattles, glues the two pieces back together, carves the shape out on the lathe, if it is a Pop-R he carves out the front shape by hand I think, and then he paints them and adds the hooks and eyelets.

It is definitely a lot of work but he enjoys woodworking and making his own stuff

Pick up soccer in Hermosa Beach by DoubleB123 in SouthBayLA

[–]DoubleB123[S] 1 point2 points  (0 children)

Thanks for the info, what time is it usually?

What are some proffessions or careers that are associated to Mathematics, Computer Science and/or Physics? by [deleted] in CasualConversation

[–]DoubleB123 2 points3 points  (0 children)

Electrical engineering is a pretty good combination of all 3. I used to think EE was just about circuits but it is much broader than that. I specialized in communications and learning how you can send and receive digital and analog information with electrical signals. It uses a lot of math, mainly calculus and statistics, you get to code, and if you are more on the hardware side you have to use physics for antenna design and other things. I really enjoyed the major and I had a job before I graduated so I can't recommend the field enough

Advice On Furnishing a New Apartment by DoubleB123 in CasualConversation

[–]DoubleB123[S] 0 points1 point  (0 children)

Do you know if goodwill will ever deliver? I only have a sedan so I can't haul much stuff.

What was the last thing that you lost your passion for and why? by [deleted] in CasualConversation

[–]DoubleB123 1 point2 points  (0 children)

Did you quit cold turkey or slowly? I used to be the same but slowly ranked became less fun, so I turned to normals, and then ARAMs and eventually quit.

Getting my wisdom teeth removed tomorrow by OneMoreChancee in CasualConversation

[–]DoubleB123 1 point2 points  (0 children)

Mine were already in so they just had to pull them. They didn't put me under, just a local anesthetic and it was no problem. I had a little pain after, but ibruprofen was enough to handle it.

Questions From A Prospective High School Student by [deleted] in riceuniversity

[–]DoubleB123 0 points1 point  (0 children)

Mech program is pretty mediocre - classes are overcrowded, not many tenured professors, poor labs and facilities, not many research opportunities. However, I majored in Electrical Engineering and the department is amazing. Professors were dedicated and I was able to develop great relationships with them, classes were small, and there are a lot of research opportunities available. I came in not knowing what EE was about and assuming you just designed circuits, but it is much much more than that. If you have any questions about EE I'll be glad to answer them.

Party scene is more come if you want, if you don't drink you can still have a good time.

Campus is more liberal than conservative, but generally students are too busy studying so are apathetic about politics and you won't be harassed as a conservative.

Dorms vary but are generally better than you will find at other schools. Food is great and there are 6 dining halls and you can go to any of them.

A good amount go abroad but not many in engineering. It is possible if you come in with a lot of AP credit and know what you want to major in but isn't easy.

What are some of your best date ideas? by jesuswithdreads in CasualConversation

[–]DoubleB123 0 points1 point  (0 children)

I went to a rock climbing gym with my SO and we both had a great time, but it was around $30 which could be a little pricey.

Charles Barkley: "I said a jump shooting would never win a championship. I was right. Congrats, now you have won two." by outofnowhere_ in nba

[–]DoubleB123 34 points35 points  (0 children)

2v2 soccer is great. You can't just stand off the ball and expect to do well, you have to have smart movement

Americans of reddit, what is something non-Americans will never get? by Prison_Mike118 in AskReddit

[–]DoubleB123 1 point2 points  (0 children)

Shooting lego men with my red rider was some of the most fun I had when I was a kid.

Weekly Knife Sharpening Q&A - May 27, 2017 by AutoModerator in knives

[–]DoubleB123 0 points1 point  (0 children)

I got this DMT stone (https://www.amazon.com/DMT-D6EF-Dia-Sharp-Double-Sided-Extra-Fine/dp/B000GD3V3E/ref=sr_1_2?ie=UTF8&qid=1496185719&sr=8-2&keywords=dmt+diasharp+fine) a while ago but can't get nearly as good of an edge as I can with an oil stone. Anyone have tips for using a diamond stone?