---
title: "sean rodman (@srodman7689) | Hashnode"
description: "sean rodman (@srodman7689) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@srodman7689"
---

@srodman7689

# sean rodman

@srodman7689 · Joined December 2021

## Comments

[You can calculate the triangle number of Math.abs(crab - i) instead of summing a range from 1 to Math.abs(crab - i). It would look something like this: var positionCost = crabs.Select(crab => { var dist = Math.abs(crab - i); return dist \* (dist + 1) / 2; }).Sum(); It gives the same answer and it is a lot faster. I found this out after reading your post. Thanks for posting! It helped a lot!](https://hashnode.com/posts/advent-of-code-2021-day-7/61b755a90059f90a57a572a5/comment/61b763150059f90a57a573dc)

Comment · Article · Dec 13, 2021 · [Advent Of Code 2021 - Day 7](https://hashnode.com/posts/advent-of-code-2021-day-7/61b755a90059f90a57a572a5)
