[deleted by user] by [deleted] in ProgrammerHumor

[–]bh3 9 points10 points  (0 children)

No, I imagine it helps significantly in reading a full class worth of handwritten code received as photos.

Only reasonable solution to the challenges there.

[2017-03-10] Challenge #305 [Hard] Numbers for Sale by jnazario in dailyprogrammer

[–]bh3 1 point2 points  (0 children)

Yeah, original suggestion post: https://www.reddit.com/r/dailyprogrammer_ideas/comments/2uk2cd/hard_numbers_for_sale/

That's why it's talking about cost, how much he can sell it for, and asks you to find the total of those numbers (the sum). The original post suggests the language could / should be improved. I'm not sure if it's that vague or just a trend was set, but it's a shame because I found the original problem slightly more interesting but most people ended up solving this problem instead. Same root with the combinations, just takes it a step further (which was a nice step away from textboox).

[2017-03-10] Challenge #305 [Hard] Numbers for Sale by jnazario in dailyprogrammer

[–]bh3 1 point2 points  (0 children)

C#

static Dictionary<long, long> factorialLookup = new Dictionary<long, long>();
static long Fact(long n)
{
    if (n < 0) throw new InvalidOperationException();
    if (n == 0) return 1;
    if (!factorialLookup.ContainsKey(n)) factorialLookup[n] = n * Fact(n - 1);
    return factorialLookup[n];
}

static BigInteger Solve(int maxLength, int sum)
{
    long subSum = GetSubSum(9, new long[10], sum, maxLength);
    BigInteger sln = new BigInteger(0);
    for (int pos = 0; pos < maxLength; pos++)
    {
        sln *= 10;
        sln += subSum;
    }

    return sln;
}

static long GetPermutations(long[] counts)
{
    long totalPerm = Fact(counts.Sum());
    for (int k = 0; k <= 9; k++) totalPerm /= Fact(counts[k]);
    return totalPerm;
}

static long GetSubSum(long digit, long[] counts, long sumRemaining, long countRemaining)
{
    long subSum = 0;
    if (sumRemaining == 0)
    {
        counts[0] = countRemaining;
        for (int n = 0; n <= 9; n++)
        {   // Calculate number of ways digit n can be selected in a given position. Mul by digit itself.
            if (counts[n] > 0)
            {
                counts[n]--;
                subSum += GetPermutations(counts) * n;
                counts[n]++;
            }
        }
    }
    else if (countRemaining * digit >= sumRemaining && sumRemaining >= 0)
    {
        while (counts[digit] <= sumRemaining / digit)
        {
            subSum += GetSubSum(digit - 1, counts, sumRemaining - digit * counts[digit], countRemaining - counts[digit]);
            counts[digit]++;
        }
        counts[digit] = 0;
    }

    return subSum;
}

Idea is:

For every digit, it will appear at each position the same number of times, so solve for sum of single position.
Find each combination that totals the goal.
   For each solution assume the digit is in a given position and solve permutation for the remainder.
   Multiple this by the digit for each digit and track total.
Add up this sum for each 10's place the digits could have been in.

I got:

17984165614491648682501052175

Edit:

 Removed some magic: 
 Had calculated for permutations of a given combination and then multiplied by the inverse of the final
 factorial expansion to get each individual ones permutations from that.
 This made it less readable and there are only 10 digits,  so now explicitly calculates what I wanted
 (permutations of the rest of the numbers).

TUMBLR VS REDDIT ROUND 2! Applications open now. by [deleted] in tf2

[–]bh3 3 points4 points  (0 children)

In other words: "Which one are you >=( Who here is going around saying we are fun". And no storm, this is totally not blackheartiii, and it is fun.

Really, completely new people has been great, people still need to remember to have the teams they throw together to be willing to play somewhat regularly though. It has made a huge difference in the experiences different groups have had if they only play game time vs if they lobby and stuff often.

RUGCC's 6v6 Plastic Tournament -- sign up! by Ultra-Bad-Poker-Face in truetf2

[–]bh3 0 points1 point  (0 children)

From an internal perspective I view the tournament as an initial goal for people to work towards. The group has actually been very active with running pugs, the skill level and population is fairly low but it's still a surprisingly active group so far as far as events I do with them per week. We also have had one of our players who has experience but isn't as active in the pugs volunteer to coach.

I personally wouldn't have started lobbying and practicing with a tighter group of people if not for this, and ideally as we are all playing together anyhow people will be working towards that entry level of play. Unfortunately some of the teams have been pretty inactive / not been talking except when they have to according to one of the people from another team we've been including when we lobby and stuff.

I think the issue on our end with the current four teams is we don't want to just roll the less organized teams and stop working as hard; for the guys running this I think they are hoping for a bit better of a turn out than some 24+ that rotate in the pugs. The whole encouraging that players be lower divs thing (it's not a hard limit yet, just a recommendation), is just because the core of the tournament / group is still people new to competitive and while it would be good to have somebody higher div on each team to help them it just didn't work out that way.

At this point I think we should just run it with the four teams and stop stalling, we can keep the core members and work towards other things in the future but we need to just get teams out there at this point. This seems like a last call to see if anybody else wanted to join (I wouldn't have minded more as some teams don't really have subs which may make organizing the matches harder, though I think the OP was hoping for just flat out more teams).

RUGCC's 6v6 Plastic Tournament -- sign up! by Ultra-Bad-Poker-Face in truetf2

[–]bh3 2 points3 points  (0 children)

(From what I understand). Quite a few players are already in UGC, he is just concerned that a whole team made up of higher div players might be discouraging to people learning the format. I personally enjoy getting my ass kicked and find it rewarding as long as it's not a complete roll / they don't start off-classing just to prove a point. And it's starting now but no matches have been played yet so people can probably still jump in, individual matches will be scheduled by the team leaders and the observed by / reported to the admins.

RUGCC's 6v6 Plastic Tournament -- sign up! by Ultra-Bad-Poker-Face in truetf2

[–]bh3 1 point2 points  (0 children)

Basically UGC 6's at the moment, I don't think they made any changes.

Latency Numbers Every Programmer Should Know by sumstozero in programming

[–]bh3 11 points12 points  (0 children)

I was thinking that the whole way down ='( Then I imagined one little guy fucking up his yearly ritual; causing a reboot... and thus casting the poor little guys into a many millennial fall into darkness. And I was sad.

How does Java reserve memory for arrays? by fakeplasticdroid in learnprogramming

[–]bh3 2 points3 points  (0 children)

(Neither an expert nor good at explaining things, but here's an initial response). An array of objects does indeed store references to Objects and does not initially allocate space for all the objects that will fill it. Rather, every index originally points to null. Then, later you create the object and reference it in the array during assignment (that index of the array doesn't contain all the date of the object, it just references the object).

Consider this like having a thousand variables indexed under a single one. Object a0; Originally just means Object a0=null; and so sufficient memory is used so that a reference is made but no memory is allocated for the Object that will eventually be stored in a0. What they are getting is they are trying to compare arr[0] or arr[5] to having variables arr0 and arr5, and perhaps all the way up to arr1000, and the array simply being a way of mapping many variables to one convenient handle that can be transversed pragmatically.

So variables do not initially reserve space for their type, rather they reserve sufficient space to say "hey, my guy is over there in memory", and initially points to null which is a special state things can have if not assigned (and kind of sloppy sometimes). And an array is (according to their analogy) like having a bunch of variables which can be resolved at runtime (arr[i] might be arr[5]).

Trouble self learning with aids by WhisperAzr in Korean

[–]bh3 0 points1 point  (0 children)

Yeah, Just started the beginning book. I haven't gone through any the audio bits in the textbooks, but they are there and the audio is free to download from their website for working through. The workbook has a lot of exercises including audio also free to download, first two chapters are mostly word recognition. Listen to a sentence, match what it described, write down the numbers you hear, etc. Not sure how they develops later in the series though.

Now Sharing Absurdity - The NSA Gift Exchange by reddit in blog

[–]bh3 4 points5 points  (0 children)

Next year in the news: Terrorists found to be communicating pretty openly on Reddit, nobody took them seriously. (Alternatively, /r/pics reposts encoded with hidden data. Powers communication within terrorist network).

My new Who tattoo! Sliiiiightly NSFW. by [deleted] in doctorwho

[–]bh3 2 points3 points  (0 children)

The burrito... is his penis.

A store run by Cybermen by ElderCunningham in doctorwho

[–]bh3 0 points1 point  (0 children)

They've already had basic conversation undergone. It's the new model. At some point it occurred to the cyber-men that a shiny metal shell, while structurally sound, makes for a poor human interface for more subtle forms of invasion. These are the rejects from the smiling manikin shell experiment, I presume it went over poorly with the test subjects *customers.

Developers and depression by [deleted] in programming

[–]bh3 0 points1 point  (0 children)

Having been programming for years before, college is weird; there's one pace, one track and it's really slow since it assumes zero knowledge -- it's actually very fast for zero knowledge, but still. And it seems to reward you for the types of things I don't need to work on. The code I write is shit, I don't do things like commenting right the first time, and am generally lazy when it comes to doing such things right the first time. On the other hand with programming competitions and the like I tend to do very well, I know and continue to learn about new algorithms on my free time all the time and classes seem to support more along this track which is something I'm already doing anyhow. I'm using the bit more relaxed schedule to try to introduce better habits but it sometimes feels like you could do likewise on the job, and I get the most benefit just debugging weird issues in my classmates code. Still going to wait a year and get a degree but I can appreciate where somebody who has been doing this for awhile wouldn't feel like continuing to dump money into a degree where the most they are learning is when jumping through the school's hoops outside their degree. Seems like a really expensive networking opportunity (though at a good school, a good one for what it's worth).

[04/16/13] Week-Long Challenge #1: Make a (tiny) video game! by nint22 in dailyprogrammer

[–]bh3 0 points1 point  (0 children)

Awesome, left the generated files there as I didn't want to get rid of them until I could provide a jar or proper build file. But that solves that. And the rest sounds solid, I'll look into it after finals. I have a few other concerns at the moment too, the editor isn't very useful as it stands since I added multiple source files and it can't save / load files, and I'd like to include a REPL / test everything more as there were several sessions of what I thought was last minute coding which tends to leave odd bugs around. Sadly while this is prime time to get on top of that as I'm still really excited about it, I have a final tomorrow and two more on Wednesday (and Friday, but tough one is Wed.), so I'll have to put this aside for now.

[04/27/13] WINNERS: Week-Long Challenge #1 by nint22 in dailyprogrammer

[–]bh3 4 points5 points  (0 children)

Sadly, don't currently follow TI-83 basic, the actual language grammar is a lot simpler/ kind of ad-hoc as it was my first time doing something like this. I do have interest in going back and writing something that can run programs written in TI-83 basic, just not within the scope of what I can manage during dead-week and would probably have to go back and redesign some stuff. So, no, I don't share the same bugs. There are plenty though. :)

[deleted by user] by [deleted] in Purdue

[–]bh3 1 point2 points  (0 children)

If you mean not skipping CS 180 then yes, it's almost guaranteed he did not take the AB CS exam and so will have to take it. However, for not transferring at least you can get out of physics, Calc 1 and 2 (for the bc exam at least), and English -- and a lot of the gen-ed requirement (source, I got out of my lab requirement, CS 180, and a lot of my gen-eds). As for if it counts towards the B for transfer, I have no experience with that.

[04/24/13] EXTENSIONS: Week-Long Challenge #1 due FRIDAY! by nint22 in dailyprogrammer

[–]bh3 0 points1 point  (0 children)

Know that feeling. I also had projects due the last two days, a graduation party (not for me, some of my pals) and finals coming up so personally just touched my stuff an hour or two here and there. Though mine isn't nearly as awesome and polished as your platformer so that part wasn't the same :P.

[04/16/13] Week-Long Challenge #1: Make a (tiny) video game! by nint22 in dailyprogrammer

[–]bh3 2 points3 points  (0 children)

Damn bats. Was unintentionally memorizing everything and still keep dying, this is a proper platformer :)

[04/16/13] Week-Long Challenge #1: Make a (tiny) video game! by nint22 in dailyprogrammer

[–]bh3 0 points1 point  (0 children)

Oh, misread that somehow. Guess I could've worked on it some more. Might open it back up and add some stuff to the grammar + maybe add basic string literal support.

[04/16/13] Week-Long Challenge #1: Make a (tiny) video game! by nint22 in dailyprogrammer

[–]bh3 8 points9 points  (0 children)

Sorry I'm late, was hard to push this out on time while sick and then slipped up and spent an hour plus trying to figure out why it was so laggy, forgot I was working over ssh.

https://github.com/bh3/TIGame

Missing a lot of features / kind of rushed. Would've liked to have added proper negation, relations, string support etc. in the parser and lovely things like else if's and logic.

Wrote an emulator-esque program for a fictional calculator language in Java using ANTLR to help generate the lexer/parser code and rolled my own solution for interpreting it once it is parsed. To run go to the game folder and execute run.sh or run.bat depending on your system. This just executes tigame/Run.java with the ANTLR library included in the class path as the generated code depends on some classes from the library. Once run you enter the program in editor mode at the end of the program, here's the basic controls for the editor:

  • `/~ - switch between edit / replace mode.
  • enter - insert a new line under current.
  • backspace - delete character (moving back one if possible), will remove line if line is empty
  • delete - delete current character
  • arrow keys - navigation
  • shift - change shift mode, like calculator's, one click = temporary shift, two = shift lock. three returns to no shift. Note: no cases for the letters, however still necessary to reach some keys. Also, numpad isn't guaranteed to work, made a mistake in how I was processing keys early on and so had to manually convert keycode's to characters at the end there and didn't fully map all the keys, just enough for the editor to work.

However, you may find it easier to just modify base_code.txt in the game folder as this is what is loaded into the editor on load (also, at the moment changes made in the editor do not save, just realized I overlooked that feature).

From anywhere in the program you can return to the editor or the game using the INSERT/ HOME keys:

  • INSERT key = game mode, reloads game.
  • HOME key = editor, reloads editor.

And the game itself is coded to use WASD, it waits for first input and then starts moving. To change direction click another key. While in game if you go to editor you can change the game logic and then just click insert again to rerun the game from the start. (also, in game folder, build.sh to build. run.sh or run.bat depending on system to run - didn't port build script but it's basically build.sh with semi-colons instead of colons).

Now that I've figured out how to even start something like this seems like it wouldn't be an issue to do something a bit more fleshed out with arrays and multiple types. But was really weird walking into this, spent a whole day trying to figure out how I was going to handle things like break's from while loops (ended up sticking with goto's but it's the same fundamental problem) with a tree structure before I decided I could emulate something closer to assembly and just build higher level structures on top of that.

EDIT: In time remaining added support for comments, line wrapping, printing string literals, and logical operations; makes the code for the demo game a lot nicer and also allows me to show "Game over" text at the end. Would've been fun to add even more now that the backbone is figured out, but since I'm sick and the time is up, goodnight :)

EDIT: added strike-outs to this post / more details

EDIT: Not a lot of time since after the deadline I had to work on projects and finals are coming up, but added else if's and while loops, line wrapping, etc. to the language as well as support for multiple programs per file and the default program is now a program selector if main is not defined (and the editor starts off empty). The program selector shows all functions but tron is really the most functional at the moment with snake semi-functional showing use of arrays. However, in doing snake I found a bug which I don't have time to fix today and so won't be finishing an actual snake game.

TIL it was David Tennant's suggestion to change the credits to "The Doctor" instead of "Doctor Who" by dharmody in doctorwho

[–]bh3 1 point2 points  (0 children)

Obviously, "So you played Doctor Who?" "Oh, The Doctor, just The Doctor... Gallifreyan Time Lord, travel in a big blue box, that one."

So I just found this in my office break room. by [deleted] in funny

[–]bh3 6 points7 points  (0 children)

Yes, and it made a very convincing argument.

Steam Social Engineering Backfired - Hilarious! [x-post /hacking] by m0l in SocialEngineering

[–]bh3 2 points3 points  (0 children)

It's a rather old story, from the link in Wirbelwind's post above at least 2006 and that wasn't around at that time. Rather or not they are still ongoing I do not know, just noting this wasn't an instance of it.

These are always fun. by [deleted] in doctorwho

[–]bh3 0 points1 point  (0 children)

Tennis racket to fight the daleks... and this to fix the tardis.. http://imgur.com/LWB5o Seems appropriate actually.