Skip to content

Repeating lines puzzle#30

Open
IsaacJurnove wants to merge 3 commits intogigamonkey:mainfrom
IsaacJurnove:main
Open

Repeating lines puzzle#30
IsaacJurnove wants to merge 3 commits intogigamonkey:mainfrom
IsaacJurnove:main

Conversation

@IsaacJurnove
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Owner

@gigamonkey gigamonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various comments. Including you need to test your solution.

Comment thread solutions/repeating-lines.sh Outdated

set -euo pipefail

cmd puzzle/duplicates.txt | uniq -c | sort -r | head -1 No newline at end of file
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cat?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you need to sort the input to uniq as uniq only looks at adjacent lines.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And head -1 gets you the right line but then you need to get rid of the count to emit only the secret.

Basically, you need to test your code by building a puzzle and then trying to use your solution to get the green checkmark.

Comment thread build/STEPS
last-line
nth-line
sha-line
backwards
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why'd you delete backwards? (You should always look at the diff of your PR to make sure the changes are what you intended.)

Comment thread build/repeating-lines.sh Outdated
set -euo pipefail

# shellcheck source=/dev/null
source "$(dirname "$0")/lines.sh"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you actually need to use these functions. Probably better is to use the fake_id function that you get automatically to make a bunch of fake secrets that are the same as the real secret but with a different number (making them not valid secrets). Then generate a file full of a fake secrets each repeated between 2 and 12 times and one instance of the real secret and shuffle it and there's your puzzle input.

Comment thread build/repeating-lines.sh Outdated
# random_fake_lines "$FILE" 12 "$1"

for ((i = 1; i <= 12; i++)); do
line=$(head -"$i" "$FILE" | tail -1)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where you can use fake_id to make a fake secret each time through the outer loop.

@IsaacJurnove
Copy link
Copy Markdown
Author

I fixed the problems, the puzzle works now. Also there might be some conflicts in the backwards puzzle, since I noticed that the backwards puzzle used both reversed.txt and backwards.txt for the file that the puzzle was in. It was probably a change I made by mistake but there's a possibility I set it to the wrong one when I fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants