Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://codegolf.stackexchange.com/questions/171168/without-using-numbers-get-the-highest-salary-you-can-but-dont-exaggerate
- #Code takes one of the forms:
- # "$%d"%hash( <string> )
- # "$%d"%-hash( <string> )
- # "$%d"%~hash( <string> )
- #Test strings by:
- # print("\"%s\""%(bytearray( <counters> ).decode("utf-8")))
- best = []
- maxs = []
- for i in range(64):
- best.append(0)
- if i==0: maxs.append("error")
- else: maxs.append(int( 1000000.0*(i**-0.75) ))
- counters = [0]
- while True:
- try:
- s = bytearray(counters).decode("utf-8")
- length1 = 14 + len(counters)
- length2 = length1 + 1
- length3 = length2
- h1 = hash(s)
- h2 = -h1
- h3 = ~h1
- if h1 > best[length1] and h1 <= maxs[length1]:
- print(("Best (%6d/%d=%f) for length %d by "%( h1,maxs[length1],float(h1)/float(maxs[length1]), length1 ))+str(counters)+" (type 1)")
- best[length1] = h1
- if h2 > best[length2] and h2 <= maxs[length2]:
- print(("Best (%6d/%d=%f) for length %d by "%( h2,maxs[length2],float(h2)/float(maxs[length2]), length2 ))+str(counters)+" (type 2)")
- best[length2] = h2
- if h3 > best[length3] and h3 <= maxs[length3]:
- print(("Best (%6d/%d=%f) for length %d by "%( h3,maxs[length3],float(h3)/float(maxs[length3]), length3 ))+str(counters)+" (type 3)")
- best[length3] = h3
- except UnicodeDecodeError:
- pass
- i = 0
- while True:
- counters[i] += 1
- if counters[i]==256:
- counters[i] = 0
- i += 1
- if i == len(counters):
- counters.append(0)
- break
- else:
- break
- #"$%d"%hash("")
- #"$%d"%hash("ɒ&")
- #f"${hash("ɒ&")}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement