Skip to content

Commit 922e9db

Browse files
author
Robb Kidd
committed
toighter
1 parent 7fe21e7 commit 922e9db

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

2022/ruby/day06.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,8 @@ def start_of_message_marker(buffer)
5858
def scan_for_length(buffer, packet_length)
5959
chars = buffer.chars
6060
scan = lookback = packet_length - 1
61-
found = false
62-
while !found || scan < chars.length do
63-
check = chars[scan-lookback..scan]
64-
if check.uniq.length == packet_length
65-
found = true
66-
break
67-
end
61+
while scan < chars.length do
62+
break if packet_length == chars[scan-lookback..scan].uniq.length
6863
scan += 1
6964
end
7065
return scan + 1

0 commit comments

Comments
 (0)