projects
/
riddle-generator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Removed neighbour generation out of the core library
[riddle-generator.git]
/
riddle_definitions.md
diff --git
a/riddle_definitions.md
b/riddle_definitions.md
index 402fd949012cd5aa2de4a9c13acf8f41f86cde4c..1db01f7b1bcc338759f74ee6f8e6a9569b2622e3 100644
(file)
--- a/
riddle_definitions.md
+++ b/
riddle_definitions.md
@@
-13,10
+13,6
@@
jupyter:
name: python3
---
name: python3
---
-# Definitions generally useful for the riddle solver
-
-While this file is here as a Markdown file, it's intended that Jupytext will save this file as a "percent" Python file, so that it can be imported by other notebooks here.
-
```python
import unicodedata
import re
```python
import unicodedata
import re
@@
-28,8
+24,8
@@
import random
```
```python
```
```python
-stop_words = set('my is in within lies and also always you will find the found'.split())
-negative_words = set('
but
not never neither nor'.split())
+stop_words = set('my is in within lies and also always you will find the found
but
'.split())
+negative_words = set('not never neither nor'.split())
```
```python
```
```python
@@
-111,15
+107,15
@@
def edit_distance(s: str, t: str) -> int:
return len(t)
if t == "":
return len(s)
return len(t)
if t == "":
return len(s)
- if s[
-1] == t[-1
]:
+ if s[
0] == t[0
]:
cost = 0
else:
cost = 1
res = min(
cost = 0
else:
cost = 1
res = min(
- [ edit_distance(s[
:-1], t)+
1
- , edit_distance(s, t[
:-1])+
1
- , edit_distance(s[
:-1], t[:-1
]) + cost
+ [ edit_distance(s[
1:], t) +
1
+ , edit_distance(s, t[
1:]) +
1
+ , edit_distance(s[
1:], t[1:
]) + cost
])
return res
])
return res