LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
49
SOLUTION MEGATHREAD-🎄- 2019 Day 4 Solutions -🎄-(self.adventofcode)
submitted 6 years, 1 month ago* (edited 7 minutes after) by daggerdragon to /r/adventofcode (134.8k)
741 commentsredditother-discussionssubreddit-indexmessage modsop-focus

--- Day 4: Secure Container ---


Post your solution using /u/topaz2078's [paste](https://top...

... view full text

since 6 years, 1 month ago
4 of 4

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–]chunes4 points6 years, 1 month ago* (edited 10 hours, 31 minutes after)

Factor

273025 767253 [a,b]                                          ! input range
[ 1 digit-groups reverse ] [ [ <= ] monotonic? ] map-filter  ! get a sequence of sequences of monotonically increasing digits
[ 2 clump [ first2 = ] any? ] filter dup length .            ! part 1
[ [ = ] monotonic-split [ length 2 = ] any? ] count .        ! part2

Edit: I made a version that's 80 times faster (10 ms vs. 800 ms). Because I generate monotonically increasing numbers directly, rather than filtering them from the natural numbers.

: d ( m -- n n ) 9 [a,b] amb-lazy dup ;

[ 1 d d d d d d drop 6 narray ] bag-of                           ! generate all 6-digit monotonically increasing sequences
[ reverse [ 10^ * ] map-index sum ]                              ! constrain to
[ 273025 767253 between? ] map-filter                            ! input range
[ number>string ] map [ [ 2 clump [ first2 = ] any? ] count . ]  ! part 1
[ [ [ = ] monotonic-split [ length 2 = ] any? ] count . ] bi     ! part 2
permalinkhide replies (1)author-focusas-ofpreserve
[–][deleted]3 points6 years, 1 month ago

I mean, how can people not love how this looks, I don't know, I might be just strange, but this is a beauty.

I'm thinking of maybe going through some of the easier ones in factor when this calendar is finished, I think being familiar with what kinds of words actualy exists :)

permalinkparentcontexthide replies (1)as-of
[–]chunes2 points6 years, 1 month ago* (edited 22 minutes after)

Heh, thanks.

One of my favorite things about Factor is due to the fact that everything is just words, even [, the way you write programs is unambiguous. What's the syntax? Whitespace between words. Done.

(The same applies to Forth, of course, but it's a little too imperative for my tastes until you extend it, at which time it becomes hard to share your code in a setting like this because you've essentially created a dialect.)

I like not having to fuss with whether I should write a=21 or a = 21 or (2 - (1 + 1) ) or (2-(1+1)) or [first2 =] or [ first2 = ].

The same sort of thing applies to evaluation order. No order of operations, no using syntax to change the way things are evaluated (unless you really want to).

It's hard for me to use anything else after experiencing this kind of simplicity.

I'd love to see any Factor programs you write! You did pretty well with it last year from what I remember.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]1 point6 years, 1 month ago

Yeah, I've been playing around with some different forths and the simplicity is for sure something that I like a lot about it as well.

Also the help system for factor is really good, it's usually possible to find things within the help window without having to rely on external sources which is nice :)

The only thing that usually breaks down for me is when I have to construct something larger, because I'm not yet used to how to put together something larger with the blocks that I have accessible to me. But it's something that I'm looking forward to learning.

Yeah, I'll try to be posting them over here again when I do, maybe some older years, I'm not sure yet. It just will take some time to get into remembering the vocabulary again :)

permalinkparentcontextas-of
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com