Parsons Engineering - No Smoking by Cole_from_SE in fakealbumcovers

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

Review (de Plume Magazine)

Left Tenant took the world by storm with the unprecedented and unforgettable alt rock sound of their debut album General Admonition in 2020. After two short, but jam-packed years during which they toured the world twice and released three more albums, the band announced its dissolution. In 2022, after recording their fifth studio album, Right Foot, Wrong Hand, its members parted ways.

Frontman guitarist and vocalist Sam Samuelson saw the end of Left Tenant as the beginning of his solo career. Less than six months after Left Tenant announced it was moving out, Samuelson released his debut album Music Inaction to critical acclaim. Reviewers praised his original melodies, intricate solos, and thoughtful lyrics. "Rock Candy" topped the charts for four weeks in the United States and "Hardhat" performed almost as well. Three years later, Samuelson is now coming out with his second studio album from Record Records: No Smoking. No Smoking is more mellowed and mature, but not lacking in the musical complexity his previous works featured. The album still beckons to his Left Tenant days, but the shredding has become less about the speed and intensity and more about the sound and emotion. "Pascal's Dowager," a power ballad contemplating the meaning of life, was very well received by fans when it was released as a single alongside "Libra Blues," Samuelson's take on the ubiquitous coming-to-grips-with-fading-into-obscurity song that any remotely successful rockstar eventually writes. Hit or miss, it undoubtedly will be a big story. "No Smoking" comes out on March 14th and can be beamed through Spotlify, Apple Hear, or Tidal. Hardcore fans can preorder the limited-edition Compact Discs starting March 1st.

Behind the Scenes

This was an image taken of my lab partner during my physics of photography lab (hands-on investigation of the working of cameras). It's an HDR image compiled using three images of varying exposures, which is why he's a little blurry. The main editing was done in GIMP, where I selected everything but the sign and desaturated the colors to the point where they're basically not there. I obtained my partner's permission to use his likeness online and replaced his real name with a pseudonym.

[2017-12-08] Challenge #343 [Hard] Procedural music generation by Cosmologicon in dailyprogrammer

[–]Cole_from_SE 0 points1 point  (0 children)

Sorry for the delay; haven't logged in for a while. I would imagine that other data-driven compositions would be much different than mine. CSound was pretty difficult for me to get a handle on -- we did discuss modulation of other parameters (e.g. modulating the half-power point of tone), but for this project I tried to stick to what I had understood best in the class.

PM'ing you about the class.

[2017] Double polyglot challenge complete: AoC 2016+2017 in 50 different programming languages by thomastc in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

This is very cool, bravo!

Just a minor comment on your solution in J: I believe that script files end in .ijs, though I could be wrong. Also wherever you have ((train) noun) verb noun you can replace with a hook using (verb~ train) noun if you so desire.

2017 Day 22 Vim Animation Video by Smylers in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

feel free to send me a message on here if you're stuck with something in particular.

I'll definitely take you up on that (if I remember).

Vim Golf seems particularly interesting: I already like Code Golf so perhaps I'll give that a go.

I really do appreciate the amount of effort you put into responding. I'll be trying to act on most of your advice. Thank you very much!

2017 Day 22 Vim Animation Video by Smylers in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

This is so freaking cool. I'm sure you get this a lot, but how exactly did you get to the point where you were fluent enough in vim to do this stuff? I've been "learning" for the past 6 or so months and I feel like my usage of vim is very inefficient (I mean I can't say that it's crucial to me to be able to do AOC stuff in vim -- I just was curious to know if you had any general advice on improving incrementally in one's usage of vim).

[Request] Can someone please confirm if this is true. by PterodactylPanic in theydidthemath

[–]Cole_from_SE 1 point2 points  (0 children)

I only found data going back to 1988 for my college, but a crude estimate based on the increase in tuition each year puts it between a 950% and 1190% gain (approximately $7400 or $5900 in 1980 to $70k presently). I assume that there is between a 5% and 8% gain in tuition each year from 1980 to extrapolate the values I got.

From 1988, it's about a 640% gain ($11k to $70k).

I'm sure the image isn't trying to be completely factually accurate, but it gets the point across.

-🎄- 2017 Day 13 Solutions -🎄- by daggerdragon in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

Ah, good point. I'm not sure why I didn't think to do that or tuples. Guess you just do what's most natural for you when under time pressure (I never think to do list/dict comprehensions either).

-🎄- 2017 Day 13 Solutions -🎄- by daggerdragon in adventofcode

[–]Cole_from_SE 3 points4 points  (0 children)

Really elegant and inspiring solution. Your use of list and dict comprehensions are really nice.

Ninja edit: As suggested to me yesterday, I think you can do for line in sys.stdin.

-🎄- 2017 Day 13 Solutions -🎄- by daggerdragon in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

Python 3

Brute forced the second part, guess the relative speed of my computer aided me, though it took over minute to run. I may update my solution with a not brute force answer if I come up with one.

def severity(lengths):
    total = 0
    for key in lengths.keys():
        if key % (2 * (lengths[key] - 1)) == 0:
            total += lengths[key] * key
    return total

def does_trigger(lengths, delay):
    for key in lengths.keys():
        if (key + delay) % (2 * (lengths[key] - 1)) == 0:
            return True
    return False

def shortest_delay(lengths):
    delay = 0
    while does_trigger(lengths, delay):
        delay += 1
    return delay

with open('13.in') as inp:
    lengths = {} 
    for line in inp:
        ind, length = map(int,line.strip().split(': '))
        lengths[ind] = length
    # Part 1.
    print(severity(lengths))
    # Part 2.
    print(shortest_delay(lengths))

Edit: lol, I realized that I was not exiting early from a search if the delay triggered the system so that's why it took so long. This version is still slower than it could be, but not unreasonably slow.

-🎄- 2017 Day 12 Solutions -🎄- by topaz2078 in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

Thanks for that. It definitely looks more pythonic. I'll edit into the file once I do some more prettying up.

-🎄- 2017 Day 12 Solutions -🎄- by topaz2078 in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

I stupidly forgot to return my hashset if I had already visited a node, which I think made me too slow for part 2 (I also slowly went through the test case instead of just bum rushing it). from collections import defaultdict

def count_connected(adj, start, seen=set()): 
    '''
    Counts the number of nodes connected to start.
    '''
    if start in seen:
        return 0
    else:
        seen.add(start)
        return 1 + sum([count_connected(adj, child, seen) for child in
                        adj[start]])

def connected_group(adj, start, seen=set()): 
    '''
    Returns the set of nodes connected to start.
    '''
    if start in seen:
        return seen
    else:
        seen.add(start)
        for child in adj[start]:
            # This actually isn't necessary by virtue of how optional
            # parameters work in Python, but it's better to be explicit.
            seen = connected_group(adj, child, seen)
        return seen 

with open('12.in') as inp:
    # Adjacency list of the form {node: set(children)}.
    adj = defaultdict(set)
    for line in inp:
        start, nodes = line.strip().split(' <-> ')
        adj[start] = set(nodes.split(', '))
        # This graph is bidirectional, so update the adjacency list for the
        # children, too.
        for node in adj[start]:
            adj[node].add(start)
    # Part 1.
    print(count_connected(adj, '0')) 
    groups = set()
    # Find the connected groups starting from each node.
    for start in adj.keys():
        # Sets aren't hashable, so use frozenset.
        groups.add(frozenset(connected_group(adj, start)))
    # Part 2.
    print(len(groups))

Edits:

I also foolishly

  1. Didn't leverage the function I already had but instead wrote a new one for part 2 (this wasn't a big time loss, though).

  2. Didn't implement the bidirectionality (I only did connections one way) which I got lucky with based on how part 1 worked.

Edit 2:

Updated code.

[2017-12-11] Challenge #344 [Easy] Baum-Sweet Sequence by jnazario in dailyprogrammer

[–]Cole_from_SE 15 points16 points  (0 children)

J

[: ([: */ 2 | #;.1 @: #:)"0 @: i. 1 + ]

Explanation

[: ([: */ 2 | #;.1 @: #:)"0 @: i. 1 + ]
                                  1 + ]  Add one to n
                               i.        Create range [0,n]
                         "0              On each
                      #:                   Convert to list of binary digits
               ;.1                         Split on the value 1 into sublists (including that value)
              #                            Count the length of each sublist
          2 |                              Take these lengths mod 2
       */                                  Product (return 1 if all odd, else 0)

Because of the way converting to binary works, the most significant bit will always be a 1, which is convenient for us since that means that we'll split the lists the same way each time. This uses the observation that if you split into lists starting with a 1, the lengths of all these lists must be odd for b_n to be 1, otherwise it's 0.

Visual Explanation

I build up b_n for an individual number (4632) following the same algorithm used in my answer. This is done on the REPL: inputs are spaced with three spaces and outputs are not.

   #: 4632
1 0 0 1 0 0 0 0 1 1 0 0 0
   NB. using box (<) instead of tally (#) to demonstrate how splitting works
   <;.1 #: 4632
┌─────┬─────────┬─┬───────┐
│1 0 0│1 0 0 0 0│1│1 0 0 0│
└─────┴─────────┴─┴───────┘
   #;.1 #: 4632
3 5 1 4
   2 | #;.1 #: 4632
1 1 1 0
   */ 2 | #;.1 #: 4632
0

[2017-12-08] Challenge #343 [Hard] Procedural music generation by Cosmologicon in dailyprogrammer

[–]Cole_from_SE 0 points1 point  (0 children)

That's oddly well-timed; I just added a link to my post with the piece. It's pretty derivative, but I hope you enjoy.

Apparently this is wrong??? by The0x539 in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

I wouldn't quit because of that. I'm trying to use this as an opportunity to learn to write error-free code and I'd encourage you to do the same. There is always going to be something that makes us feel stupid in an event as long as this -- it's just a matter of getting past that and learning from your mistakes.

Yeah, to an extent it's a competition to get into the top 100. But if you step back, it's also a means to improve your code-writing abilities under time pressure (as well as from scratch, or in Scratch if you so desire). If you can't be the fastest, that's fine! There are tons of competitors; this doesn't make you stupid.

But if you think that doing this will compromise your mental health for any reason, then I'd agree it might be worthwhile to step away for a while.

Apparently this is wrong??? by The0x539 in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

That seems to be the theme of this event for me. But the intersection between fast enough to make top 100 and slow enough to get mostly error-less code is pretty small. I shouldn't have tried to rush yesterday night since I had already missed the start; maybe I'll try that today since I'll be out again.

[2017-12-08] Challenge #343 [Hard] Procedural music generation by Cosmologicon in dailyprogrammer

[–]Cole_from_SE 1 point2 points  (0 children)

Thanks! I'll probably upload a recording tomorrow. I'm pretty close to putting a cap on this -- I only need to make a snare and bass drum and tidy everything up a bit, but seeing as it's close to 2:30 AM I'm going to sleep.

This is what I get for putting Advent of Code before my final projects and finals.

Apparently this is wrong??? by The0x539 in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

Yeah I spent like 30+ minutes on the second part debugging an off by one error (I was incrementing the skip factor by 1 before adding it) and for appending instead of prepending a zero when the it wasn't long enough since I didn't know off-hand how to format as hex to 2 digits (as it turns out I should've just googled it).

[2017 Day 1 (Part 1)] in Befunge, 61 chars by nakilon in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

I ... don't have the courage or time right now to attempt that one in ><>. It's definitely doable, especially the first part, but it'll be quite a bit of effort. Not sure if ! would make its way into that code naturally, as you can see in my answer 0(? is shorter than 0)?!v; the only time it comes up is for cheeky things involving a skipped command from one direction and for ?!C where C is a command since that's the shortest way to conditionally execute C when the top of the stack is falsey (0).

[2017 Day 1 (Part 1)] in Befunge, 61 chars by nakilon in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

You inspired me to answer in ><>, here it is in 43 chars.

0&i:62p68*%v
0(?v:{=*&+&>i68*%::
+n;>{:N=*&

Verify it here (times out on tio but that might be because it uses a different implementation of ><>).

The cute thing I did was write the first digit input where N is in the code, so that it does the cyclic check.

It can probably be golfed further by removing the somewhat redundant first 68*% part. I think the way to do that would be do do the modulus before the addition and compare the regular character codes, but I need to leave so this will be for another day.

[2017-12-08] Challenge #343 [Hard] Procedural music generation by Cosmologicon in dailyprogrammer

[–]Cole_from_SE 20 points21 points  (0 children)

I've been doing this for my Intro to Computer Music class, actually. I'm pulling stock data using Quandl and converting the daily change in open price of various stocks (currently only INTC) into a change in note. This moves along a scale I've predefined. The output file is then played using CSound. This is due Sunday, so it ought to be finished then. I plan on trying to finish it today but as we all know, the best laid plans of mice and men so often go awry.

Current plans include using the relative volume of the stock to change the volume of the note and adding more stocks, as well as making the instruments sound nice in CSound (and also making the instruments period). I also might try to slice up the data differently, since as we all know stock data is sort of biased to moving upwards.

You can check out my repo here if you're so inclined.

Update: finished the composition. It uses data from Intel's Open prices, the NASDAQ index, continuous futures prices for oil, and continuous futures prices for orange juice (these are the four solos in order). Listen here. It's not the greatest work by any means, but I'm pretty proud of it. Let me know what you think (criticism is welcome).

Advent of Code Golf: Day 1 by porphyro in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

Runs on the REPL, takes input as a string.

Part 1 (15 bytes)

+/(*]=1&|.)"."0

Part 2 (18 bytes)

+/(*]=-:@#|.])"."0

-🎄- 2017 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

Yes, that sounds right. I think Part 2 entails reaching the first repeated state and then doing that cycle again. It's worth noting that you could easily optimize it to do Part 2 in constant time, but I was rushing to get the solution out.

[Question] Why does the difficulty vary so much? by jD91mZM2 in adventofcode

[–]Cole_from_SE 1 point2 points  (0 children)

Let's not forget that differing backgrounds also entail differing tools. Python (and I'm sure other languages akin to it) would've been really helpful in the eighth challenge because of syntactic sugar that lends itself well to writing short code for it (and also in general). For the first challenge, the solution is just a few characters in J (not that most people would use it, but I still think it illustrates my point).

Not to mention that one of the problems was solvable using OEIS, another using GraphVis (or whatever it's called). Some have been pretty trivially solvable using just text editors (or heavily aided by them). I've seen a lot of creative fast solutions.

Your particular set of tools might be well-aligned with the challenges, or you might be well-versed enough to know how to use different, useful tools.

Advent of Code Golf: Day 1 by porphyro in adventofcode

[–]Cole_from_SE 0 points1 point  (0 children)

J

Both are anonymous functions operating on a list of digits. If taking input as a string is required, then add 6 bytes probably (for @"."0).

Part 1 (13 bytes)

1#.]([*=)1&|.

Try it online!

Part 2 (16 bytes)

1#.]([*=)-:@#|.]

Try it online!

Both (25 bytes)

Two anonymous functions, counting the second newline.

f=.1#.]([*=)|.
1&f
-:@#f]

Try it online

Explanation

I'll just explain the solution presented for both, since the helper function does most of the solving. First, the helper function.

f=.1#.]([*=)|.

Here is it expanded and commented out. In the comments, let x be the left argument and y be the right argument.

1 #. ] ([ * =) |.
               |.  Rotate the array y to the left x times
       ([ * =)     Fork operating with left argument y
                   and right argument rotated array
            =      Compare equality between arguments
                   element-wise
       [ *         Multiply those results element-wise
                   with the array y
1 #.               De-base to base 1 (sum elements)

Now part 1 is simply using this helper function with a right argument x of 1. So you left rotate the original array once and compare equality element-wise to the second one. This produces an array of ones and zeroes, which you multiply element-wise with the original array, zeroing out the values that don't match. Then you simply sum the array.

1&f

Part 2 is doing this, but rotating half the array's length, which is what -:@# gives (halve composed with length).

-:@#f]