Comments (5)
Sure, that would be pretty easy to do. I'll get an update out today or tomorrow.
from word-search-generator.
Ok, in version 3.5.0 that was just released, the save()
method now honors the solution=True
argument for CSV and JSON file types. Previously, it only honored that argument for PDF files. When called with a CSV or JSON file, the saved file will only include the characters from the placed puzzle words. Example output below... Let me know if this helps. Cheers!
So using your example above...
p = WordSearch("cat, bat, rat")
p.save(path="puzzle-solution.csv", format="csv", solution=True))
...would output a CSV file like:
WORD SEARCH
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , , , , , , ,C, , ,
, , , , , , , , , , ,A, ,
, , , , , , , , , , , ,T,
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , ,B,A,T, , , ,R,A,T
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
, , , , , , , , , , , , ,
""
Word List:
BAT,CAT,RAT
"* Words can go S, NE, SE, and, E."
""
Answer Key:
"BAT E @ (6, 9)","CAT SE @ (11, 4)","RAT E @ (12, 9)"
...and...
p.save(path="puzzle-solution.json", format="json", solution=True))
...would output as JSON file like:
{
"puzzle": [
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "C", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "A", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "T", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", "B", "A", "T", " ", " ", " ", "R", "A", "T"],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "]
],
"words": ["CAT", "RAT", "BAT"],
"key": {
"CAT": {"start_row": 3, "start_col": 10, "direction": "SE", "secret": false},
"RAT": {"start_row": 8, "start_col": 11, "direction": "E", "secret": false},
"BAT": {"start_row": 8, "start_col": 5, "direction": "E", "secret": false}
}
}
from word-search-generator.
Question - is there a variable / array to access that during the script run?
puzzle.puzzle has the filler letters in them.
from word-search-generator.
Not directly. The puzzle always has the filler characters in place as they are filled in every time the puzzle is populated with words. There is a function in _formatter.py
in the word_search
that does the work of removing the filler characters.
It is a pretty simple function that check to see if every puzzle spot is part of a word and if not, changes it to an empty space.
def hide_filler_characters(game: WordSearch) -> Puzzle:
"""Remove filler characters from a puzzle."""
output: Puzzle = copy.deepcopy(game.puzzle)
word_coords = {
coord
for coords in [word.coordinates for word in game.placed_words]
for coord in coords
}
for row in range(game.size):
for col in range(game.size):
if (col, row) not in word_coords:
output[col][row] = " "
return output
from word-search-generator.
@nicolesimon13, the latest version (in the 'cli-pretty' branch) has the hide_fillers
argument in the show
method to allow printing the puzzle without the filler characters. This will be merged soon.
from word-search-generator.
Related Issues (20)
- Solution without random fill characters HOT 3
- find_a_fit does not care about secret directions HOT 1
- Outputting shortened words of a solution HOT 7
- change default path word search.exe HOT 2
- Unbake assumptions about secret words [priority, valid direction] from the Game class HOT 11
- fpdf2 required version discrepancy in dev requirements HOT 4
- Draw a rectangle around the words HOT 4
- --no-validators results in error: unrecognized arguments: --no-validators HOT 6
- Quick Questions - Solution, Diff Level and word lists. HOT 10
- Add an option to generate puzzles with lowercase letters? HOT 6
- Multilingual Support HOT 7
- Upgrade of packages required HOT 5
- Despite space, its not placing words? HOT 14
- Themed word sets
- latest cli version word-search HOT 2
- Why is there no difficulty 6 level? HOT 7
- How can i remove ans key HOT 1
- CLI doesn't work for me on MacOS 14.2 HOT 2
- Custom Filler Alphabet/Characters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from word-search-generator.