2021.12.03 20:08 Due_rr Tips for Advent of Code day 3 part 1
To practice my F# skills I want to complete Advent of Code this year. The first two days went OK, but already on day three I'm struggling. Almost wanted to switch back to my trusted Python. My solution for part one can be seen below and the explanation of the assignment can be found here.
There were two main difficulties for me: 1. There is no build-in way to do element wise operations, so I had to write these myself. 2. I had to convert often between
Any tips to improve this code? Did I maybe make it unnecessary difficult?
```fsharp open System.IO open System
let read fname = File.ReadLines fname
let input = read "input.txt" |> Seq.toList
let elementWiseAdd (list1: int list) (list2: int list) = List.zip list1 list2 |> List.map (fun (x, y) -> x + y)
let elementWiseSum (lst: seq
>) = let head = lst |> Seq.head
let charArrayToInts = List.map (fun x -> int (x) - 48)
lst |> Seq.fold (fun acc lst -> elementWiseAdd acc lst) [ for _ in 1 .. head.Length -> 0 ]
let stringToInts = Seq.map Seq.toList >> Seq.map charArrayToInts
let mostCommonDigit (lst: string list) = lst |> stringToInts |> elementWiseSum |> Seq.map (fun x -> x > lst.Length / 2)
let leastCommonDigit = mostCommonDigit >> Seq.map (fun x -> not x)
let boolsToDecimal (boolNumber: seq
let mostCommonDigitsAsInt = mostCommonDigit >> boolsToDecimal
let leastCommonDigitsAsInt = mostCommonDigit >> Seq.map (fun x -> not x) >> boolsToDecimal ```
submitted by Due_rr to fsharp [link] [comments]
2021.12.03 20:08 swagNextTuber CNN reporter: Is 'Die Hard' really a Christmas movie?
|submitted by swagNextTuber to TrendingQuickTVnews [link] [comments]|
2021.12.03 20:08 noviaccou Brim Financial Referral Code 73573 - $10 Sign up Bonus
|submitted by noviaccou to CanadianReferralCodes [link] [comments]|
2021.12.03 20:08 Salt-Shop Got crypto? Here are 3 software wallets for storage, staking and swapping
|submitted by Salt-Shop to SatoshiStreetBets [link] [comments]|
2021.12.03 20:08 exitmass Cinnamon stick Redeye with 1,000HP?
|submitted by exitmass to Challenger [link] [comments]|
2021.12.03 20:08 southpawFA Christian adoption agency sues Biden admin to keep kids out of loving gay homes. A Tennessee children's home says its religious freedom is more important than the best interests of the child.
|submitted by southpawFA to LAMPNet [link] [comments]|
2021.12.03 20:08 Wishbones_007 Reddit be like
|submitted by Wishbones_007 to mildlyinfuriating [link] [comments]|
2021.12.03 20:08 Maxi_27 I need help for some trade backs to evolve rhydon, dusclops. Will give all iv foreign ditto for helping me complete my pokedex. Thanks
2021.12.03 20:08 endauver The boys chilling
|submitted by endauver to BorderCollie [link] [comments]|
2021.12.03 20:08 98dpb What’s this?
2021.12.03 20:08 tangerinesubmerine Question about smoking
So im 23 and smoked weed for about 4 years. Im trying to stop but I have such bad anxiety, and I'm not in a location where I can make edibles, but I digress. Given that im only 23, if I'm able to stop smoking, can my voice heal a bit? I'm a male soprano, not sure what my range is precisely, but it hasnt lowered my voice that I've noticed. I can still hit all the high notes. But I've noticed i have to clear my throat more than usual for instance, and I don't like the path this is going down.
submitted by tangerinesubmerine to singing [link] [comments]
2021.12.03 20:08 Azazeel_- The normies will be a pain in the ass
|submitted by Azazeel_- to ShitPostCrusaders [link] [comments]|
2021.12.03 20:08 birb_dude001 does anyone have any music suggestions?
my playlist is kinda getting bland and im looking for basically anything to keep it spicy, ill leave a link to it so yall know what to suggest
submitted by birb_dude001 to Music [link] [comments]
2021.12.03 20:08 walden_gal If I liked the Mandela Catalog, what music should I listen to?
It's a bit of cross-pollination, but I loved the audio in the Mandela Catalog, the lo-fi crackling, the manipulated audio of songs and voices. Does anyone know any music that's similar to this, or just the Mandela Catalog in general? Cheers
submitted by walden_gal to ifyoulikeblank [link] [comments]
2021.12.03 20:08 tonimont876 Private reservist pay
2021.12.03 20:08 LilyKitty98 [XB1] [PC] [PSN] PVE/PVP Clan recruiting for members
Heatstroke is still recruiting for more guardians! We are an end game content clan (e.g. raids, dungeons, gms, etc). We don't care about experience, we will teach you! You just need to be the right light level (1290+)!
We do not tolerate any bullying/harassment of any kind.
We are 18+ years of age.
If this sounds like the team for you then drop me a message or request to join us!
submitted by LilyKitty98 to DestinyClanFinder [link] [comments]
2021.12.03 20:08 SnooDoubts4128 mosin did it tonight!
2021.12.03 20:08 FunComfortable3035 What happened to r/fridaynightfunkinhijinks?
2021.12.03 20:07 ben_kayla Always bored
|submitted by ben_kayla to uncutmanmeat [link] [comments]|
2021.12.03 20:07 needsmorepepper Still have a faint pulse.
|submitted by needsmorepepper to wallstreetbets [link] [comments]|
2021.12.03 20:07 Sefu417495 Thoughts on 89 ToTGS Marquinhos price ?
2021.12.03 20:07 haber-trend Sıcak! | #DeportivoAlaves #LaLiga #GranadaCF #DeportivoAlaves #LaLiga #GranadaCF son saatin en çok aranan 1. trend haberi oldu ve an itibarıyla 2 gazetede yer alıyor.
2021.12.03 20:07 noviaccou Brim Financial Referral Code 73573 - $10 Sign up Bonus
|submitted by noviaccou to ReferralWallet [link] [comments]|
2021.12.03 20:07 VGMVinylLover I'm Too Lazy to Write An Essay for R/Venals So Rate My Collection
|submitted by VGMVinylLover to vinyljerk [link] [comments]|
2021.12.03 20:07 its_all_for_nothing Is is only for gay men?
I’ve never met a straight man (to my knowledge) that has his bellybutton pierced. I think they’re really cool but is it something straight men do too or is it usually just gay men?
submitted by its_all_for_nothing to ask [link] [comments]