3280

Discussion of challenges you have already solved

This Code sucks?!

A lot!
6
38%
Not that much...
6
38%
Quite decent for a first year college guy...
4
25%
 
Total votes: 16

dut
Posts: 2
Joined: Mon Feb 20, 2012 10:18 am

Post by dut »

fast and dirty :oops:

Code: Select all

 
f = open('rfc3280.txt')
words = []
for line in f:
    temp = line.split()
    for item in temp:
        if len(item) == 9:
            words.append(item)

for item in words:
    print item, words.count(item)
python rfc3280.py | sort -k2 -n -u | tail -n1
polocatfan
Posts: 3
Joined: Wed Feb 04, 2015 2:06 am

Post by polocatfan »

Oh was I not supposed to bruteforce it?

I typed [a-zA-Z]{9} into notepad++'s marking search function and bruteforced it :lol:
adark
Posts: 9
Joined: Fri Nov 20, 2015 2:04 pm
Contact:

Post by adark »

I'm really enjoying these. ^.^

Lua

Code: Select all

local file = io.open("rfc3280.txt")
local t = string.lower(file:read("*all"))
file:close()


local wrd, maxcount = "", 0

for word in t:gmatch("%a+") do
	if #word == 9 then

		local count = 0
		for _ in t:gmatch(word) do
			count = count + 1
		end
		if count > maxcount then
			wrd = word
			maxcount = count
		end
	end
end
AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post by AMindForeverVoyaging »

adark wrote:I'm really enjoying these. ^.^
Then wait until the hard challenges kick in :wink:

Welcome to these forums.
06kellyjac
Posts: 1
Joined: Thu Dec 31, 2015 12:34 am

Post by 06kellyjac »

FlippyDeath wrote:I entered the first nine letter word I could find in the text and it was right...

My luck...
Similar to you, I saw that it was repeated a load of times so I counted its length and it was 9
daleonpz
Posts: 1
Joined: Sat May 13, 2017 4:38 pm

Post by daleonpz »

I use this oneliner:



cat rfc3280.txt | sed 's/[,.\r]//g' | tr ' ' '\n' | sort | uniq -c | awk '{ print $1 "\t" length($2) "\t" $2}' | awk '$2==9' | sort -k1 -n | tail -1
Post Reply