Skip to content

Commit

Permalink
style: run fmt command
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Kulebaev committed May 25, 2024
1 parent 6cbe5d6 commit 358b025
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 44 deletions.
5 changes: 1 addition & 4 deletions src/day1/day1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { describe, expect, it } from 'vitest'
import {
findElfCarryingTheMostCalories,
findTopElvesCarryingTheMostCalories,
} from './day1.js'
import { findElfCarryingTheMostCalories, findTopElvesCarryingTheMostCalories } from './day1.js'
import { readFileDay1 } from '../utils.js'

const inputPath = 'src/day1/input.txt'
Expand Down
4 changes: 1 addition & 3 deletions src/day1/day1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { sum } from '../utils'
============== part1 ==============
*/

export function findElfCarryingTheMostCalories(
data: AllElvesCarryingCalories
): FoodCalories {
export function findElfCarryingTheMostCalories(data: AllElvesCarryingCalories): FoodCalories {
let max = 0

data.forEach(el => {
Expand Down
10 changes: 2 additions & 8 deletions src/day2/day2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export function totalScoreOfStrategyGuide(data: ShapePairs[]): Score {
return totalScore
}

function getScoreOfGame(
oppShape: RockPaperScissors,
yourShape: RockPaperScissors
): Score {
function getScoreOfGame(oppShape: RockPaperScissors, yourShape: RockPaperScissors): Score {
const yourShapeScore = RockPaperScissorsNum[yourShape]

if (oppShape === yourShape) return ResultScore.draw + yourShapeScore
Expand Down Expand Up @@ -87,10 +84,7 @@ export function totalScoreOfStrategyGuide2(data: ShapePairs[]): Score {
return totalScore
}

function getScoreOfGame2(
oppShape: RockPaperScissors,
result: ResultGame
): Score {
function getScoreOfGame2(oppShape: RockPaperScissors, result: ResultGame): Score {
switch (result) {
case ResultGame.draw:
return ResultScore.draw + RockPaperScissorsNum[oppShape]
Expand Down
7 changes: 1 addition & 6 deletions src/day3/day3.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
EncryptedString,
Alphabet,
AlphabetLetters,
AlphabetLetter,
} from './constants'
import { EncryptedString, Alphabet, AlphabetLetters, AlphabetLetter } from './constants'

import { chunkedArray } from '../utils'

Expand Down
10 changes: 2 additions & 8 deletions src/day5/day5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import type { Operation, StacksOfCrates } from './constants'
/*
============== part1 ==============
*/
export function getCrateEndsUpOnTop(
stacks: StacksOfCrates,
operations: Operation[]
): string {
export function getCrateEndsUpOnTop(stacks: StacksOfCrates, operations: Operation[]): string {
const data: StacksOfCrates = JSON.parse(JSON.stringify(stacks))

operations.forEach(operation => {
Expand All @@ -26,10 +23,7 @@ export function getCrateEndsUpOnTop(
============== part2 ==============
*/

export function getCrateEndsUpOnTop2(
stacks: StacksOfCrates,
operations: Operation[]
): string {
export function getCrateEndsUpOnTop2(stacks: StacksOfCrates, operations: Operation[]): string {
const data: StacksOfCrates = JSON.parse(JSON.stringify(stacks))

operations.forEach(operation => {
Expand Down
5 changes: 1 addition & 4 deletions src/day6/day6.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export function detectStartOfPacketMarker(
datastream: string,
uniqQuantity = 4
): number {
export function detectStartOfPacketMarker(datastream: string, uniqQuantity = 4): number {
const streamLetters = datastream.split('')
let resultIndex = -1

Expand Down
10 changes: 2 additions & 8 deletions src/day8/day8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export function getCountVisibleTrees(data: TreePlace) {
for (let j = 0; j < row.length; j++) {
const height = row[j]

const outsideEl =
i === 0 || i === data.length - 1 || j === 0 || j === row.length - 1
const outsideEl = i === 0 || i === data.length - 1 || j === 0 || j === row.length - 1

if (outsideEl) {
counter++
Expand Down Expand Up @@ -38,12 +37,7 @@ export function getCountVisibleTrees(data: TreePlace) {
continue
}

const { isVisible: isRightVisible } = checkRightVisible(
height,
i,
j,
data
)
const { isVisible: isRightVisible } = checkRightVisible(height, i, j, data)

if (isRightVisible) {
counter++
Expand Down
4 changes: 1 addition & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import type { TreePlace } from './day8/constants'
export function readFileDay1(pathFile: string): AllElvesCarryingCalories {
const inputString = readFileToString(pathFile)

const inputArray = inputString
.split(os.EOL + os.EOL)
.map(data => data.split(os.EOL).map(x => +x))
const inputArray = inputString.split(os.EOL + os.EOL).map(data => data.split(os.EOL).map(x => +x))

return inputArray
}
Expand Down

0 comments on commit 358b025

Please sign in to comment.