Sorry that I am blogging via my phone and I don't want to type too much. I will just share the finished codes. You can see all of them on [GitHub](https://github.com/locharp/code-snippets/tree/main/AdventOfCode/2022) **Part 1** ``` inputs <- readLines('https://raw.githubusercontent.com/locharp/code-snippets/main/AdventOfCode/2022/inputs/1') elves <- c() elf <- c() for (input in inputs) { if (input != '') { elf[length(elf)+1L] <- as.integer(input) } else { elves[length(elves)+1L] <- sum(elf) elf <- c() } } cat(max(elves),'\n') ``` Part 2 ``` inputs <- readLines('https://raw.githubusercontent.com/locharp/code-snippets/main/AdventOfCode/2022/inputs/1') elves <- c() elf <- c() for (input in inputs) { if (input != '') { elf[length(elf)+1L] = as.integer(input) } else { elves[length(elves)+1L] = sum(elf) elf <- c() } } cat(sum(sort(elves)[(length(elves)-2L):length(elves)])) ```
author | lochard |
---|---|
permlink | advent-of-code-2022-day |
category | adventofcode |
json_metadata | {"links":["https://github.com/locharp/code-snippets/tree/main/AdventOfCode/2022","https://raw.githubusercontent.com/locharp/code-snippets/main/AdventOfCode/2022/inputs/1","https://raw.githubusercontent.com/locharp/code-snippets/main/AdventOfCode/2022/inputs/1"],"image":[""],"tags":["adventofcode","2022","programming","code","r"],"description":"","app":"ecency/3.0.30-vision","format":"markdown+html"} |
created | 2023-01-23 11:13:54 |
last_update | 2023-01-23 11:13:54 |
depth | 0 |
children | 1 |
last_payout | 2023-01-30 11:13:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.012 HBD |
curator_payout_value | 0.011 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 957 |
author_reputation | 1,822,854,321,066 |
root_title | "Advent of Code 2022 Day 1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,122,016 |
net_rshares | 45,819,543,499 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
cwow2 | 0 | 4,502,563,647 | 2% | ||
dustbunny | 0 | 31,662,122,296 | 9.46% | ||
hivebuzz | 0 | 9,033,675,232 | 2% | ||
hixt.main | 0 | 621,182,324 | 2% |
Congratulations @lochard! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s) <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@lochard/posts.png?202301231246"></td><td>You published more than 20 posts.<br>Your next target is to reach 30 posts.</td></tr> </table> <sub>_You can view your badges on [your board](https://hivebuzz.me/@lochard) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> To support your work, I also upvoted your post! **Check out our last posts:** <table><tr><td><a href="/hive-139531/@hivebuzz/proposal-2324"><img src="https://images.hive.blog/64x128/https://i.imgur.com/RNIZ1N6.png"></a></td><td><a href="/hive-139531/@hivebuzz/proposal-2324">The Hive Gamification Proposal</a></td></tr></table>
author | hivebuzz |
---|---|
permlink | notify-lochard-20230123t133231 |
category | adventofcode |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2023-01-23 13:32:30 |
last_update | 2023-01-23 13:32:30 |
depth | 1 |
children | 0 |
last_payout | 2023-01-30 13:32:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 945 |
author_reputation | 368,370,953,085,006 |
root_title | "Advent of Code 2022 Day 1" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 120,124,115 |
net_rshares | 0 |