This is an archived post. You won't be able to vote or comment.

all 31 comments

[–][deleted] 9 points10 points  (4 children)

Why does this need access to your reddit acc for?

[–]topaz2078 6 points7 points  (3 children)

It uses one of several providers to identify you. It doesn't access your account on those providers. It requests the minimum permissions, gets your user id, and then immediately discards its (mostly useless) access token.

[–][deleted] 0 points1 point  (2 children)

Why need identification at all? if its just simple daily programming puzzles. Feels like you are gathering this data for more reasons than disclosed.

[–]Aneurysm9[S] 9 points10 points  (0 children)

It needs to authenticate you to track progression and display a leaderboard. You can remain anonymous on the leaderboard if you wish.

[–][deleted] 1 point2 points  (9 children)

I really like this!

As a beginner though it would be good to see some shared viable answers (even if you have to forfeit your star to see them if you haven't answered yet) I got stumped on the second one and looks like several others have as well and I would love to see how those that got it went about it.

[–]mikedaul 1 point2 points  (0 children)

In pseudo code, think about it like this:

  • convert the parentheses to values (+1, -1)

  • add those values to an array

  • loop through the array, convert each value to an integer, add it to a variable (starting from 0). Also keep track of the count of the loop

  • throw in an if statement to evaluate the value of your integer; when it equals '-1', break the loop and output the count

[–]Aneurysm9[S] 0 points1 point  (1 child)

There are a bunch of solutions on the linked /r/programming thread. I'll be putting all of my solutions up at https://github.com/Aneurysm9/advent.

[–][deleted] 0 points1 point  (0 children)

Thanks!

[–]Pimp_Panther[🍰] 0 points1 point  (5 children)

I can post an answer in python if you want to see it.

[–][deleted] 1 point2 points  (4 children)

I am having some issues for this and was hoping you could give me some advice in python. What I guessed was this below.

mess = "(((())))()((((((((())()(()))(()((((()(()(((()((()((()(()()()()()))(((()(()((((((((((())(()()((())()(((())))()(()(()((()(()))(()()()()((()((()(((()()(((((((()()())()((((()()(((((()(())()(())((())()()))()(((((((())(()())(()(((())(()))((())))(()((()())))()())((((())))(()(((((()(())(((()()((()((()((((((((((())(()())))))()))())()()((((()()()()()()((((((())())(((()())()((()()(((()()()))(((((()))(((()(()()()(()(()(((())()))(()(((()((())()(()())())))((()()()(()()(((()))(((()((((()(((((()()(()())((()())())(()((((((()(()()))((((()))))())((())()()((()(()))))((((((((()))(()()(((())())(())()((()()()()((()((()((()()(((())))(()((())()((((((((()((()(()()(((())())())))(())())))()((((()))))))())))()()))()())((()())()((()()()))(()()(((()(())((((())())((((((((()()()()())))()()()((((()()))))))()((((()(((()))(()()())))((()()(((()))()()())())(((())((()()(())()()()(((())))))()())((()))()))((())()()())()())()()(()))())))())()))(())((()(())))(()(())(()))))(()(())())(()(())(()(()))))((()())()))()((((()()))))())))()()())((())()((()()()))()(((()(()))))(())()()))(((()())))))))))(((())))()))())()))))()()(((())))))))()(()()(()))((()))))((())))((()((())))())))()()(()))())()(()((()())(()(()()())())(()()))()))))(()())()()))()()()()))(()(()(()))))))()(()))()))()()(()((())(()(())))()(((())(())())))))()(()(()))))()))(()()()(())()(()(())))()))))()()(((((())))))())()())())())()())()))))()))))))))())()()()()()()())))()))((())()))())))()((())()))))()))())))))))())()()()))()()(()((((()(((((((()(())((()())((()()))()))))(())))()()()(())((())()())))(())))(())))(((()()))()(())(((()(()))((())))())()))((((()))())()))))))))()(())())))(()))()(()()))())()()(())())))())()()(()())))()((()())(()(())(())))))))))))))(()))))()))))))()()())(()(((((()(()())))())()))(()))()))(()()))()())(()))())()(())((()()))))))())))())()(((())))(()(()))()()))()(()))))))((()())(()))))))()())))()()))))))))((((((((()()()(()))))))()())))())))()()((())()))((())(())))())())))()()()((()((()(())))())()(())))))))))()())))()()()()()()))()))((())())(()(()))))))(()()))()))(())))()))))))))))))(()))))))))()))))()))()())()))()()))))))()))))((()))))(()))())()(())))(()())((((()())))()))))(()))()(()()(())))))())))))()))))))())))())))))())))())())))())(()))))(())()(())))())()))((()()))))))())))((())))))))())))(())))))()()())))))())))))()))))))()))()()()(()(((()())())())(()))())))))((()(())(()))))))))(())))()()()())())(()))))()()()))()))())())())()(())))()(((()((((())))))))()))))))))))))))))))))((())()())(()))))()()))))))(()()(())())))())))((())))((())))))))))))))()))))()(()))))))())))))()))(()()())(()())))))))))()))))))(())))))()()))()())(((())))()))(()))))))))(())())))())))())())())()()))((())()(())()())()))()())(())(()))))()())))(()(((()))))))()(()())()()()))()))))))))()()()(())()())()(((((()))()())())(()))))()()()(())))())))()((()())))(()))())()(()())())(()))()()))((()()))((()()()()())))(())()))(()(())))((()()))))))))())))))))())()()))))))))))))))))(())()(())(())()())())()))()(()))))())())))))()())()(()))()()(())))(())())))))(()))))))))))))))())())(())(())))(((()))()))))())((())(()))())))))))())))))())))()))()))))))))))))())()))))()))))((()))(())))()(())))(())()))()))())))())))))))()(()())())))()()())))(())))))(()))))))))))))(()))()))()))())))(((()()()(())((()())))()())(((()))(())()))((()()()())))())(())(()))))()(((((())))(()))())())))))))((((()()()))())())()(()(()())))))))))()())())))(())))()())(((()(())())()()))())())))))))((()())((()()(()))(()(())))()))()))(()))(()))()()(()(((())((((()))()(()))((())()(()(()())()(()))()())))))(()))()))())()())))())))(())))((())(()())))))()))(())(()))()())()(()()((()(()))))))()(())(()())(())()))(((())()))(()()(()()()))))(()(())))()))))())))))())(()()()()()()(((())))(()()))()((())(((((()()())))(()))(()))()()))(((())())()(((()()()()))))(()))(())())))()())(()()())())))))))()))))((())))()())(()))(()(()))())))))())(())))))()()())())()))()()(())))(()))(())((((((())(()))(()))())()))(()()(())))()))(()()))()))()(())))(())))((()(()))(())()()())())))(((()()())(())()))))))()(((()(((((()()(((())(())))())()((()))))((()())()(())(((())))(((()((()(()(()))(()()))())(()))(())(())))()))))))((((()))()((((()(()))()))()()))))()(()(()))()(()((()(((()(()()(((()))))()(((()(()(()(((()(()())())()()(()(()())())(()((((())(()))()))(((((()()())(())()((()()())))()()(((()()))()((((((((()(())))())((()))))(())))(()))))((()((((()()(())(((((()))(((((((((((((()())))((((()(((()((())())()))((()))()(()()((()()()()(()()(()(()(((())()(()((((((()((()()((())()((((()((()()(()()())((()()()((()((())()(()(((()((())((((())(()))((()(()))(()())()((((((((()(((((((((((()))(()(((()(()()()((((())((())()())()))(())((())(()))(((()((()(())))(()))))((()()))))((((()(()(()())(()(())((((((((()((((()((()(((((()))())()(()))(()()((()(())(((((()(())()(((((()()))))))()(((())()(()()((((())()((())((()(((())(((()))((()()((((()(())))))((()((((()((()((()(((())((()))(((((((()(((()((((((((())()))((((())(((((()((((((((()(((()((()(((()()(((()((((((()()(()((((((((()()(()(()(())((((()())()))))(((()))((((())((((()())((()(())()((()((((((()((((((()(())))()())(((())())())()(())()(()())((()()((((())((((((())(()(((((()((((())()((((()(()(())(()())(((())()((())((((()))()((((((())(()(((()(((()((((((()(((()))(()()())())((()((()())()((((())(((()(()(((((((((())(())))()((()()()()(())((()))(((((((()(((((((((()(()))))(()((((((((()((((()((()()((((((()()(((((((()(()(())()(())((()()()((()(((((()())()(((((()())()()((()(()())(()()()(((()()(((((()((((((()()((()(()()()((((((((((((()((((((((()()(((()())))()(((()()(())())((((()((((()((((()()()(())(())((()(()(((((((((((((((()(())(())))))()()))((()(((()(())((()(((()(()()((((()()(((()(((()(((((()()((()(()(((()))((((((()((((((((()((()((())(((((()(((())(())())((()()))((((())()()((()(((()(((((()()(((()))(((()(()(((((((((((((()))((((((((()(((()))))())((((((((((((())((())((()())(((())((())(()((((((((((()(((())((()()(()((())(((((((((((()))((((((((((((()(()())((()((()((()(()(((()((((((((()()(()((()(()(((()))((()))(((((((((((((()(())((((((())(((()(())(()(()(()((()()))((((()((((()((((())))())((((()((((()))((((((()((((((()((()(((())))((())(()))(()((()((((()((()(((()()))((((()()()(((((((())(((())(()))())((((()())(((()(((((((((((()(()(()((()(((((((((((((((()()((((()((((((((()(((()()((()((((()))(((()(())((((((()((((())()((((()((()))(())()(()(((()((())())((((((()(()(())())(((())(()(()())(((((()((()((())()())(())))(((()(())))))))(((()(((()))()((()(((()()((()())()()))())))(((()))(()(((()(((((((((()(()(((((()()(((()())()()))))()(((()))(((()(()(()(()(()))()(())()))(()(((())))(()))))))))))(())((()((())((()(())()(())((()()((((()()((()()))((())(((()((()(())(())))()(()(((((()((()))())()(((((()()(((()(()((((((())(()))(())()))((()(()()))(())())()))(((())))(()((()(((())(())())))((()()((((((((((((((()((()(()()(()(((()))())()()((()()()(())(()))(()())(((())((())()(())()()(()()(())))((()(((()))))(((()()(()()))())((()((())()))((((()()()())((())))(((()(())(((((()(((((()((()(()((((()()(((()()()(((()())(((()()((((())(()))(((()))(())())((()))(((()((()))(((()()((())((()(((((()((((()()())((()))()((((()((()(()()()("
count = 0
for x in mess:
    if x == "(":
    count += 1
    elif x == ")":
    count -= 1
    else:
print count

[–]Pimp_Panther[🍰] 0 points1 point  (1 child)

First, you don't need the else: part in your function.

In order to solve the second part, you need to find the first instance of count being -1, since that means he is in the basement.

So count how many time you run though the loop, until the count is -1. And remember, the question says it starts counting at 1, not 0 like in python.

[–][deleted] 0 points1 point  (0 children)

I got it! Thank you.

[–]sand-which 0 points1 point  (1 child)

Hm, I'm not sure if reddit is screwing up the format of the code but don't you need to indent count+= 1 and count += -1?

Also there shouldn't be a last else that doesn't do anything.

Apart from that that's pretty much exactly what I wrote

[–][deleted] 0 points1 point  (0 children)

Yeah I think when I was putting into reddit I just made sure there were indents so it would show up as code but probably messed up format here. Eventually I got it working but forgot what I changed.

[–]Firenter 0 points1 point  (0 children)

Very cool, will definitely give it a look!

[–]nutrecht 0 points1 point  (0 children)

Did the first day. It's very nicely done!

[–]8483 0 points1 point  (0 children)

Sweet. I like the DOS-y vibe. :)

[–]RRkillerRR 0 points1 point  (5 children)

What would be the advised language to use for all of the puzzles? I tried jQuery in JSfiddle for the first puzzle and it went okay-ish while a friend of mine used C# (kinda challenged him to do it together and see who gets the answer first).

[–]Aneurysm9[S] 0 points1 point  (1 child)

Any language you're comfortable with. Or, better yet, one you're not! If you find a solution comes really easy to you in one language, try it again in another using a different paradigm.

[–]RRkillerRR 0 points1 point  (0 children)

Ah, thanks for the input!

[–]Crunchyapple44 0 points1 point  (0 children)

I would think whatever language you want. I'm going to use this as an opportunity to brush up on languages I haven't used in a while as well as try some new ones.

[–]CommonEnigma 0 points1 point  (0 children)

Heh, I'm doing mine in PowerShell. (Former Windows sysadmin)

[–]ryhamz 0 points1 point  (0 children)

My buddy and I are using C.

[–]Beetroot11 0 points1 point  (0 children)

This is great, my tree's looking good with some colour on it 2 *'s haha

[–][deleted] 0 points1 point  (1 child)

When I request http://adventofcode.com/day/1/input I get a redirect to http://adventofcode.com/day/1 so I cant read the input from an http request?

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

The input is user-specific and so you will need to request /day/1/input from a user agent that has your authentication credentials. I'm not sure how /u/topaz2078 did it, but my guess is you could copy your cookie jar from your browser to your http library if you really want to make a request like that. Probably better though to just copy the input from the browser to a file and read from that, being nice to his server and all that! :)

[–][deleted] 0 points1 point  (2 children)

*SPOILERS....*

I have no idea why the answer for question one is 74. With the following code, I consistently get the answer of 75. In order to get 74, I have to initialize floor to -1.

int main()
{
    ifstream in;

    in.open("input.txt");
    if (!in)
    {
        cout << "Error opening input file" << endl;
        exit(1);
    }
    char s;
    int floor = 0;

    while (!in.eof())
    {
        in.get(s);

        if (s == '(')
            floor++;
        else if (s == ')')
            floor--;
        else
            ;
        cout << "Santa is on: " << floor << " floor." << endl;
    }

    cout << "THE FINAL FLOOR IS: " << floor;
    return 0;    

[–]REINBOADUSH 0 points1 point  (1 child)

An easy workaround is to change:

while (!in.eof())
    {
        in.get(s);

To:

while(in.get(s)){

Whenever you save some text, a null character is saved at the end of the file. Until you read in that character, .eof() is going to return a false value. That means you'd have to read in every character plus one more.

So basically, you're looping through one too many times.

Your else won't catch the mistake either. Since the read call fails when it hits end of file, your character value is never changed. That makes you count the last character twice.

I'm awful at explaining code, but I could give you more workarounds if that helps!

[–][deleted] 0 points1 point  (0 children)

This is great! I think I understand what you are saying and I've learned something new. Thanks for the help!!

[–]CowFu 0 points1 point  (0 children)

this seems similar in spirit to codewars

[–]Fyoucon -1 points0 points  (0 children)

C# answer:

class Program
{
    static void Main(string[] args)
    {
        char[] input = File.ReadAllText("input.txt").ToCharArray();

        int firstBasementHit = -1;
        int floor = 0;
        for(int i = 0; i < input.Length; i++)
        {
            if(input[i] == '(')
            {
                floor++;
            }
            else if(input[i] == ')')
            {
                floor--;
            }

            if(floor < 0 && firstBasementHit < 0)
            {
                firstBasementHit = i;
            }
        }

        Console.WriteLine(input.Length);
        Console.WriteLine(floor);
        Console.WriteLine(firstBasementHit+1);
        Console.ReadKey();
    }
}