Skip to main content
added 26 characters in body
Source Link
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

Python 2, score: 2*(407+56574) + 579001562262 = 692963676224

Searches for words matching the previous characters from a list of  all  most words used in the text, sorted by the number of their occurrences.

Code:

import zlib
f=open("d","rb")
l=zlib.decompress(f.read()).split()
w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";
 n=ord(c)
 if n>31:
  return list("t \n 2  sS \n  -  08........       huaoRooe oioaoheu thpih eEA \n   neo    enueee neue hteht e")[n-32]
 return"\n"

Data: https://www.dropbox.com/s/etmzi6i26lso8xj/d?dl=0

Test suite:

incorrect = 0

with open("whale"whale2.txt") as file:
    p_ch = ch = file.read(1)
    while True:
        ch = file.read(1)
        if not ch:
            break
        f_ch = f(p_ch)
        if f_ch != ch:
            incorrect += 1
        #print f_ch, ch
        p_ch = ch
        
print incorrect

Edit: Using whale2.txt gives a better score.

Python 2, score: 2*(407+56574) + 579001 = 692963

Searches for words matching the previous characters from a list of  all  most words used in the text, sorted by the number of their occurrences.

Code:

import zlib
f=open("d","rb")
l=zlib.decompress(f.read()).split()
w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";
 n=ord(c)
 if n>31:
  return list("t \n 2  sS \n  -  08........       huaoRooe oioaoheu thpih eEA \n   neo    enueee neue hteht e")[n-32]
 return"\n"

Data: https://www.dropbox.com/s/etmzi6i26lso8xj/d?dl=0

Test suite:

incorrect = 0

with open("whale.txt") as file:
    p_ch = ch = file.read(1)
    while True:
        ch = file.read(1)
        if not ch:
            break
        f_ch = f(p_ch)
        if f_ch != ch:
            incorrect += 1
        #print f_ch, ch
        p_ch = ch
        
print incorrect

Python 2, score: 2*(407+56574) + 562262 = 676224

Searches for words matching the previous characters from a list of  all  most words used in the text, sorted by the number of their occurrences.

Code:

import zlib
f=open("d","rb")
l=zlib.decompress(f.read()).split()
w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";
 n=ord(c)
 if n>31:
  return list("t \n 2  sS \n  -  08........       huaoRooe oioaoheu thpih eEA \n   neo    enueee neue hteht e")[n-32]
 return"\n"

Data: https://www.dropbox.com/s/etmzi6i26lso8xj/d?dl=0

Test suite:

incorrect = 0

with open("whale2.txt") as file:
    p_ch = ch = file.read(1)
    while True:
        ch = file.read(1)
        if not ch:
            break
        f_ch = f(p_ch)
        if f_ch != ch:
            incorrect += 1
        p_ch = ch
        
print incorrect

Edit: Using whale2.txt gives a better score.

added 428 characters in body
Source Link
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

Python 2, score: 2*188,5592*(407+56574) + 566895579001 = 944013692963

Searches for words matching the previous characters from a list of all all  most words used in the text, sorted by the number of their occurrences.

The main part of the codeCode:

import zlib
f=open("d","rb")
l=zlib.decompress(f.read()).split()
w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";n=ordw="";
 n=ord(c)
 if n>31:
  return s[nlist("t \n 2  sS \n  -  08........       huaoRooe oioaoheu thpih eEA \n   neo    enueee neue hteht e")[n-32]
 return"\n"

All code + test suiteData: https://pastebin.com/raw/xpgTSctPhttps://www.dropbox.com/s/etmzi6i26lso8xj/d?dl=0

I'll try to optimize/compress this later.

Possible optimizations:Test suite:

  • Compress the data
  • Get rid of the words that occur most rarely
incorrect = 0

with open("whale.txt") as file:
    p_ch = ch = file.read(1)
    while True:
        ch = file.read(1)
        if not ch:
            break
        f_ch = f(p_ch)
        if f_ch != ch:
            incorrect += 1
        #print f_ch, ch
        p_ch = ch
        
print incorrect

Python 2, score: 2*188,559 + 566895 = 944013

Searches for words matching the previous characters from a list of all words used in the text, sorted by the number of their occurrences.

The main part of the code:

w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";n=ord(c)
 if n>31:
  return s[n-32]
 return"\n"

All code + test suite: https://pastebin.com/raw/xpgTSctP

I'll try to optimize/compress this later.

Possible optimizations:

  • Compress the data
  • Get rid of the words that occur most rarely

Python 2, score: 2*(407+56574) + 579001 = 692963

Searches for words matching the previous characters from a list of  all  most words used in the text, sorted by the number of their occurrences.

Code:

import zlib
f=open("d","rb")
l=zlib.decompress(f.read()).split()
w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";
 n=ord(c)
 if n>31:
  return list("t \n 2  sS \n  -  08........       huaoRooe oioaoheu thpih eEA \n   neo    enueee neue hteht e")[n-32]
 return"\n"

Data: https://www.dropbox.com/s/etmzi6i26lso8xj/d?dl=0

Test suite:

incorrect = 0

with open("whale.txt") as file:
    p_ch = ch = file.read(1)
    while True:
        ch = file.read(1)
        if not ch:
            break
        f_ch = f(p_ch)
        if f_ch != ch:
            incorrect += 1
        #print f_ch, ch
        p_ch = ch
        
print incorrect
Source Link
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

Python 2, score: 2*188,559 + 566895 = 944013

Searches for words matching the previous characters from a list of all words used in the text, sorted by the number of their occurrences.

The main part of the code:

w=""
def f(c):
 global w
 if c.isalpha():
  w+=c
  try:n=next(x for x in l if x.startswith(w))
  except StopIteration:return" "
  if len(n)>len(w):
   return list(n)[len(w)]
  return" "
 w="";n=ord(c)
 if n>31:
  return s[n-32]
 return"\n"

All code + test suite: https://pastebin.com/raw/xpgTSctP

I'll try to optimize/compress this later.

Possible optimizations:

  • Compress the data
  • Get rid of the words that occur most rarely