Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import random
- # Define Panzer III variants with their production numbers
- variants_production = {
- 'Ausf. A': 10,
- 'Ausf. B': 10,
- 'Ausf. C': 15,
- 'Ausf. D': 75,
- 'Ausf. E': 96,
- 'Ausf. F': 450,
- 'Ausf. G': 594,
- 'Ausf. H': 286,
- 'Ausf. J': 1521,
- 'Ausf. L': 1470,
- 'Ausf. M': 517,
- 'Ausf. N': 614,
- 'Command D': 30,
- 'Command E': 45,
- 'Command H': 175,
- 'Command J': 81,
- 'Command K': 50,
- 'Flame Tank': 100
- }
- # Total production limit
- total_production_limit = 5774
- # Define the production periods with their overlaps
- production_periods = {
- 'Ausf. A': ('1937-01', '1937-12'),
- 'Ausf. B': ('1937-01', '1937-12'),
- 'Ausf. C': ('1937-07', '1938-06'),
- 'Ausf. D': ('1938-01', '1940-12'),
- 'Ausf. E': ('1939-01', '1941-12'),
- 'Ausf. F': ('1939-06', '1941-12'),
- 'Ausf. G': ('1940-06', '1943-06'),
- 'Ausf. H': ('1941-06', '1943-12'),
- 'Ausf. J': ('1942-01', '1943-12'),
- 'Ausf. L': ('1941-01', '1942-12'),
- 'Ausf. M': ('1942-01', '1943-12'),
- 'Ausf. N': ('1942-01', '1943-12'),
- 'Command D': ('1938-01', '1939-12'),
- 'Command E': ('1939-01', '1940-12'),
- 'Command H': ('1940-01', '1941-12'),
- 'Command J': ('1941-01', '1942-12'),
- 'Command K': ('1942-01', '1943-12'),
- 'Flame Tank': ('1943-01', '1943-12')
- }
- def generate_serial_numbers(start_serial_number, total_produced, limit):
- """Generate a range of unique serial numbers based on total production."""
- end_serial_number = min(start_serial_number + total_produced - 1, limit)
- if end_serial_number < start_serial_number:
- return []
- num_serials = min(4, end_serial_number - start_serial_number + 1)
- return random.sample(range(start_serial_number, end_serial_number + 1), num_serials)
- # Create an empty DataFrame to hold the serial numbers
- serials_data = {
- 'Variant': [],
- 'Serial Numbers': []
- }
- # Initialize the starting serial number
- current_serial_number = 1
- for variant, total_produced in variants_production.items():
- # Adjust total_produced if it exceeds the remaining production limit
- if current_serial_number + total_produced - 1 > total_production_limit:
- total_produced = total_production_limit - current_serial_number + 1
- # Generate serial numbers for the current variant
- if total_produced > 0:
- serial_numbers = generate_serial_numbers(current_serial_number, total_produced, total_production_limit)
- else:
- # If total_produced is 0 or the range is too small, generate 4 random serial numbers within the remaining limit
- remaining_range = range(current_serial_number, total_production_limit + 1)
- if len(remaining_range) < 4:
- serial_numbers = list(remaining_range)[:4]
- else:
- serial_numbers = random.sample(remaining_range, 4)
- # Handle case when there are fewer than 4 available numbers
- if len(serial_numbers) < 4:
- additional_numbers = random.sample(range(1, total_production_limit + 1), 4 - len(serial_numbers))
- serial_numbers.extend(additional_numbers)
- # Store the serial numbers in the DataFrame
- serials_data['Variant'].append(variant)
- serials_data['Serial Numbers'].append(serial_numbers)
- # Update the current serial number to the next available number
- current_serial_number += total_produced
- # Create a DataFrame to hold the serial numbers
- serials_df = pd.DataFrame(serials_data)
- # Save the DataFrame to a CSV file
- serials_df.to_csv('panzer_iii_serials.csv', index=False)
- # Print the DataFrame
- print(serials_df)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement