---
title: "Discussion on \"How I solved \"Sales by Match\" on HackerRank\" | Hashnode"
description: "Discussion on \"How I solved \"Sales by Match\" on HackerRank\". Sales by Match Problem Description\nThere is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are.\nExample\n\nThere is one pa..."
url: "https://hashnode.com/posts/how-i-solved-sales-by-match-on-hackerrank/61f5feff66fcfc728be195fc"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How I solved "Sales by Match" on HackerRank](https://tob.hashnode.dev/how-i-solved-sales-by-match-on-hackerrank?utm_source=hashnode&utm_medium=feed)

Sales by Match Problem Description There is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. Example There is one pa...

Jan 30, 2022 · 4 min read · tob.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Tobías](https://hashnode.com/@juantobias)

@juantobias · Mexico City

  
[View profile](https://hashnode.com/@juantobias)

Aeronautical engineer learning to solve problems through software engineering. Sharing what I learn on the road. 🇲🇽

## Responses 1

Markdown supported · ⌘↵ to post

[Biplob Manna](https://hashnode.com/@biplobmanna)

[Jan 30, 2022](https://hashnode.com/posts/how-i-solved-sales-by-match-on-hackerrank/61f5feff66fcfc728be195fc/comment/61f62ea966fcfc728be198fe)

Nice article!

If I could provide some suggestion here, in the second for loop, all those lines of `if` conditions and `isEven()` function call can be reduced to `pairs += counts[item] / 2 | 0` to get the integer division value.

```
for (const item in counts)
    pairs += counts[item] / 2 | 0;
```
