aboutsummaryrefslogtreecommitdiff
path: root/generate.py
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-21 11:42:33 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-21 11:42:33 +0200
commitec28f3d2a263440b167b2ae44033f2eae5bab88c (patch)
tree2c170cd09786264ea5f017973f15297734268404 /generate.py
parent9af65c8ac721024d0e45a2a6bde5c3f9fe638516 (diff)
downloadproject_euler-ec28f3d2a263440b167b2ae44033f2eae5bab88c.tar.gz
project_euler-ec28f3d2a263440b167b2ae44033f2eae5bab88c.tar.bz2
project_euler-ec28f3d2a263440b167b2ae44033f2eae5bab88c.zip
problem 1 2 3 in rust
Diffstat (limited to 'generate.py')
-rw-r--r--generate.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/generate.py b/generate.py
index b186a7f..7c69961 100644
--- a/generate.py
+++ b/generate.py
@@ -25,17 +25,25 @@ def read_config():
def write_problem(index, title, sub_title, content, language_config, config):
- text = '\n'.join([language_config['comment']['top'], title, sub_title, '', content,
- language_config['comment']['bottom']])
- # *[content[i * config['line_wrap']:(i + 1) * config['line_wrap']]
- # for i in range(int(len(content) / config['line_wrap']))],
- text = ('\n'.join([language_config['comment']['prefix']
- + line for line in text.split('\n')])
- + '\n' * config['problem_padding'])
- slug = ''.join([c for c in title.lower().replace(' ', '_') if c.isalpha() or
- c.isdigit() or c == '_'])
- filename = (str(index).zfill(3) + '-'
- + slug + '.' + language_config['extension'])
+ text = '\n'.join([
+ title,
+ sub_title,
+ '',
+ content,
+ ])
+
+ text = '\n'.join(
+ [language_config['comment']['prefix'] + line for line in text.split('\n')]
+ )
+ text = language_config['comment']['top'] + '\n' + text
+ text += '\n' + language_config['comment']['bottom']
+ text += '\n' * config['problem_padding']
+
+
+ slug = ''.join([c for c in title.lower().replace(' ', '_')
+ if c.isalpha() or c.isdigit() or c == '_'])
+
+ filename = (str(index).zfill(3) + '-' + slug + '.' + language_config['extension'])
try:
with open(filename, 'w') as file:
file.write(text)