-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautogram.c
More file actions
12 lines (11 loc) · 6.29 KB
/
autogram.c
File metadata and controls
12 lines (11 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
/*
So, the only way to go faster is to stop using strings entirely.
Every single "wordification" has a known contribution of occurences, so we're just doing vector additions.
Given a candidate string x, we have occurences for each character [a..z], which gives `counts: [26]int`
This can be used such that from this, we can just row-wise sum `map(sum, [as_word[c] for c in counts].T)`
In python, we might use numpy, which has efficient SIMD usage for this.
In C, we can just do it directly, and even if we aren't being optimal, we're losing less in overheads.
If I keep everything to 0..255 occurences, that means we use bytes, so hashing is quick and uses a hash set
or if sacrificing collisions can use a bloom filter and save on memory (which may be nice and fast too!)
*/
char *as_word[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty-one", "twenty-two", "twenty-three", "twenty-four", "twenty-five", "twenty-six", "twenty-seven", "twenty-eight", "twenty-nine", "thirty", "thirty-one", "thirty-two", "thirty-three", "thirty-four", "thirty-five", "thirty-six", "thirty-seven", "thirty-eight", "thirty-nine", "forty", "forty-one", "forty-two", "forty-three", "forty-four", "forty-five", "forty-six", "forty-seven", "forty-eight", "forty-nine", "fifty", "fifty-one", "fifty-two", "fifty-three", "fifty-four", "fifty-five", "fifty-six", "fifty-seven", "fifty-eight", "fifty-nine", "sixty", "sixty-one", "sixty-two", "sixty-three", "sixty-four", "sixty-five", "sixty-six", "sixty-seven", "sixty-eight", "sixty-nine", "seventy", "seventy-one", "seventy-two", "seventy-three", "seventy-four", "seventy-five", "seventy-six", "seventy-seven", "seventy-eight", "seventy-nine", "eighty", "eighty-one", "eighty-two", "eighty-three", "eighty-four", "eighty-five", "eighty-six", "eighty-seven", "eighty-eight", "eighty-nine", "ninety", "ninety-one", "ninety-two", "ninety-three", "ninety-four", "ninety-five", "ninety-six", "ninety-seven", "ninety-eight", "ninety-nine", "a hundred", "a hundred and one", "a hundred and two", "a hundred and three", "a hundred and four", "a hundred and five", "a hundred and six", "a hundred and seven", "a hundred and eight", "a hundred and nine", "a hundred and ten", "a hundred and eleven", "a hundred and twelve", "a hundred and thirteen", "a hundred and fourteen", "a hundred and fifteen", "a hundred and sixteen", "a hundred and seventeen", "a hundred and eighteen", "a hundred and nineteen", "a hundred and twenty", "a hundred and twenty-one", "a hundred and twenty-two", "a hundred and twenty-three", "a hundred and twenty-four", "a hundred and twenty-five", "a hundred and twenty-six", "a hundred and twenty-seven", "a hundred and twenty-eight", "a hundred and twenty-nine", "a hundred and thirty", "a hundred and thirty-one", "a hundred and thirty-two", "a hundred and thirty-three", "a hundred and thirty-four", "a hundred and thirty-five", "a hundred and thirty-six", "a hundred and thirty-seven", "a hundred and thirty-eight", "a hundred and thirty-nine", "a hundred and forty", "a hundred and forty-one", "a hundred and forty-two", "a hundred and forty-three", "a hundred and forty-four", "a hundred and forty-five", "a hundred and forty-six", "a hundred and forty-seven", "a hundred and forty-eight", "a hundred and forty-nine", "a hundred and fifty", "a hundred and fifty-one", "a hundred and fifty-two", "a hundred and fifty-three", "a hundred and fifty-four", "a hundred and fifty-five", "a hundred and fifty-six", "a hundred and fifty-seven", "a hundred and fifty-eight", "a hundred and fifty-nine", "a hundred and sixty", "a hundred and sixty-one", "a hundred and sixty-two", "a hundred and sixty-three", "a hundred and sixty-four", "a hundred and sixty-five", "a hundred and sixty-six", "a hundred and sixty-seven", "a hundred and sixty-eight", "a hundred and sixty-nine", "a hundred and seventy", "a hundred and seventy-one", "a hundred and seventy-two", "a hundred and seventy-three", "a hundred and seventy-four", "a hundred and seventy-five", "a hundred and seventy-six", "a hundred and seventy-seven", "a hundred and seventy-eight", "a hundred and seventy-nine", "a hundred and eighty", "a hundred and eighty-one", "a hundred and eighty-two", "a hundred and eighty-three", "a hundred and eighty-four", "a hundred and eighty-five", "a hundred and eighty-six", "a hundred and eighty-seven", "a hundred and eighty-eight", "a hundred and eighty-nine", "a hundred and ninety", "a hundred and ninety-one", "a hundred and ninety-two", "a hundred and ninety-three", "a hundred and ninety-four", "a hundred and ninety-five", "a hundred and ninety-six", "a hundred and ninety-seven", "a hundred and ninety-eight", "a hundred and ninety-nine", "two hundred", "two hundred and one", "two hundred and two", "two hundred and three", "two hundred and four", "two hundred and five", "two hundred and six", "two hundred and seven", "two hundred and eight", "two hundred and nine", "two hundred and ten", "two hundred and eleven", "two hundred and twelve", "two hundred and thirteen", "two hundred and fourteen", "two hundred and fifteen", "two hundred and sixteen", "two hundred and seventeen", "two hundred and eighteen", "two hundred and nineteen", "two hundred and twenty", "two hundred and twenty-one", "two hundred and twenty-two", "two hundred and twenty-three", "two hundred and twenty-four", "two hundred and twenty-five", "two hundred and twenty-six", "two hundred and twenty-seven", "two hundred and twenty-eight", "two hundred and twenty-nine", "two hundred and thirty", "two hundred and thirty-one", "two hundred and thirty-two", "two hundred and thirty-three", "two hundred and thirty-four", "two hundred and thirty-five", "two hundred and thirty-six", "two hundred and thirty-seven", "two hundred and thirty-eight", "two hundred and thirty-nine", "two hundred and forty", "two hundred and forty-one", "two hundred and forty-two", "two hundred and forty-three", "two hundred and forty-four", "two hundred and forty-five", "two hundred and forty-six", "two hundred and forty-seven", "two hundred and forty-eight", "two hundred and forty-nine", "two hundred and fifty", "two hundred and fifty-one", "two hundred and fifty-two", "two hundred and fifty-three", "two hundred and fifty-four", "two hundred and fifty-five"};