# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages
# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats
# For example, here's several helpful packages to load in 

library(ggplot2) # Data visualization
library(readr) # CSV file I/O, e.g. the read_csv function

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

system("ls ../input")

# Any results you write to the current directory are saved as output.

library(data.table)
train<-fread('../input/train.csv')
test<-fread('../input/train.csv')

prep<-function(x,y,range_x, range_y)
{
ix<-floor(range_x*x/10)
if(ix<0){ix=0}
if(ix>range_x){ix=range_x-1}

iy<-floor(range_y*y)/10
if(iy<0){iy=0}
if(iy>range_y){iy=range_y-1}
return(c(ix,iy))
}

total = 0
grid_size_x = 500
grid_size_y = 1000
grid_size_x2 = 100
grid_size_y2 = 200
# Maximum T = 786239. Take -10% of it
split_t = 707616
split_test_out_of_business = 684028 #628991

head(train)
head(test)

#  test_arr = ls()
#    grid = defaultdict(lambda: defaultdict(int))
#    grid_valid = defaultdict(lambda: defaultdict(int))
#    last10pct = dict()
#    test_out_of_business = dict()
#    grid_sorted = dict()
#    grid_sorted_valid = dict()#

    # Calc counts
    #train_samples = 0
    #test_samples = 0





