1. The code loads an Excel workbook with a template sheet and multi-input sheet.
2. It then copies the template sheet for each row of data in the multi-input sheet, renaming the copy with the row ID.
3. Input cell values on the copied sheet are linked to the multi-input sheet.
4. Output cell formulas on the copied sheet are defined relative to the sheet name.
5. The workbook is saved, closed.
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
The following is my code for a connectn program. When I run my code in the tester, I failed two
out 10 tests. I was hoping for some help in finding what causes these errors. I have included the
homework prompt and test failed results. Thank you so much!
#include
#include
#include
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win);
void create_board(int num_rows, int num_cols, char*** board, int* turn);
void print_board(int num_rows, int num_cols, char** board);
void destroy_board(int num_rows, char*** board);
void play_game(int num_rows, int num_cols, int num_pieces_to_win, int turn, char** board);
void check_move();
void get_play(int num_rows, int num_cols, char** board, int* user_move);
void make_move(int num_rows, char**board, int user_move, char pieces);
bool play_is_valid(int num_cols, int num_rows, char** board, int user_move_num, int
user_move);
bool game_over(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_won(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_tied(int num_rows, int num_cols, int num_pieces_to_win, char**board);
bool row_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool col_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool right_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool left_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win) {
//reads command input and ensures there are exactly three numbers
if (argc > 4) {
printf(\"Too many arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else if (argc < 4) {
printf(\"Not enough arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else { //puts user input into variables
sscanf(argv[1], \"%d\", &*num_rows);
sscanf(argv[2], \"%d\", &*num_cols);
sscanf(argv[3], \"%d\", &*num_pieces_to_win);
}
return;
}
void create_board (int num_rows, int num_cols, char*** board, int* turn) {
//set up the connect-n board
const char BLANK_SPACE = \'*\';
int i, j;
*turn = 0; //player 1 always goes first
*board = (char**)malloc(num_rows * sizeof(char*)); //creates pointers to the rows
for (i = 0; i < num_rows; ++i){ //for each row
(*board)[i] = (char*)malloc(num_cols * sizeof(char)); //create it
for (j = 0; j < num_cols; j++) { //fill in the row with blanks
(*board)[i][j] = BLANK_SPACE;
}
}
}
void print_board (int num_rows, int num_cols, char** board) {
//displays connect-n board
int i, j;
int k = 0;
for(i = 0; i < num_rows; i++){
printf(\"%d \", ((num_rows- i) - 1));
for(j = 0; j < num_cols; ++j){
printf(\"%c \", board[i][j]);
}
printf(\"\ \");
}
printf(\" %d \", k);
for(j = 1; j <.
There are a number of errors in the following program- All errors are.docxclarkjanyce
There are a number of errors in the following program.
All errors are located in main() and structure definitions.
Function declarations and definitions are correct!
Locate all errors, fix them (as shown below), run the program and save its output
as a comment at the end of the source file.
Example:
int num = 10;
int *ptr;
num = &ptr; // <== Error: Comment the line and write the correct line below
// Write a short justification where appropriate
// num = &ptr; // Error #1
ptr = #
Name:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define DUMMY_TRAILER '\177'
// octal ASCII code of the
// last character in the ASCII table
#define NUM_CITIES 10
typedef struct
{
char name[12];
int temperature[5];
} CITY;
// Stack and Queue Node
typedef struct node NODE;
struct node
{
CITY city;
node *next;
};
// Doubly Linked List Node
typedef struct d_node D_NODE;
struct d_node
{
CITY city;
NODE *forw;
NODE *back;
};
// Stack Functions
NODE *push(NODE *stack, const CITY *pStu);
NODE *pop(NODE **stack);
// Queue Functions
void enqueue(NODE **queue, NODE **rear, const CITY *pStu);
NODE *dequeue(NODE **queue, NODE **rear);
// Doubly Linked List Functions
D_NODE *init_list(void);
int insert(D_NODE *list, const CITY *pStu);
void traverse_forw(D_NODE *list);
void traverse_back(D_NODE *list);
// Other Functions
void printCity(const CITY *pCity);
int main (void)
{
CITY cList[NUM_CITIES] =
{
{"Cupertino", {88, 89, 87, 85, 89}},
{"Flagstaff", {81, 80, 88, 89, 89}},
{"Los Angeles", {87, 88, 89, 89, 90}},
{"Philadelphia", {96, 99, 99, 90, 95}},
{"Phoenix", {106, 109, 109, 100, 105}},
{"Portland", {89, 90, 85, 89, 90}},
{"Reno", {108, 105, 109, 100, 108}},
{"Salem", {85, 90, 85, 89, 90}},
{"Tucson", {107, 100, 109, 100, 108}},
{"Yreka", {101, 109, 100, 108, 109}}
};
NODE *stack = NULL;
NODE *top = NULL;
NODE *queue = NULL, *rear = NULL;
NODE *front;
D_NODE *list;
list = init_list();
// build stack and queue with data from an array of CITY structures
srand((unsigned int)time(NULL));
int count = rand() % 10;
for ( int n = 0; n < count; n++)
{
int i = rand() % NUM_CITIES;
int duplicate = insert(list, &cList[i]);
if(duplicate)
{
// already in the list!
push(stack, &cList[i]);
enqueue(&queue, &rear, cList[i]);
}
}
// display list
printf("\nLIST contents (forwards):\n");
traverse_forw(list);
printf("\nLIST contents (backwards):\n");
traverse_back(list);
// display stack
if (top)
{
printf("\nSTACK contents from top to bottom:\n");
while ((top = pop(stack)))
{
printCity(top->city);
}
}
else
printf ("Empty Stack!\n");
// display queue
if (front)
{
printf("\nQUEUE contents from front to rear:\n");
while ((front = dequeue( queue, rear)))
{
printCity(front->city);
}
}
else
printf ("Empty Queue!\n");
return 0;
}
/***************************************************
Displays the fileds of a CIS_CLASS structure
Pre pCls - a pointer to a CIS_CLASS structure
Post
*/
void printCity(const CITY *pCity)
{
printf("%-20s %3d\n", pCity->name, pCity->temperatur.
Objectives Create a Java program using programming fundamentals (fi.docxamit657720
Objectives: Create a Java program using programming fundamentals (file I/O, loops, conditional statements, arrays, functions)
Problem: In an effort to win a coding competition, you decided to create an awesome Obstacle Warrior game. The game is played on a 2-dimensional board similar to a Chess board, but the dimensions may be different. The minimum size of the board is 2x2. The board will have a Start square and an Exit square that are not stored on the board. Start and Exit squares cannot be the same. Other board squares may contain obstacles in the form of an integer that will define how the warrior position and score will be affected. The obstacle squares can have values from 0 to -10 only. The Start square is always a clear square. All clear squares are marked with # on the board. The Exit square may contain an obstacle that is not a zero. The size of the board, number of obstacles, and Start and Exit squares are all unknow to your code prior to running. This information is stored in a file that your code will read at the beginning of the game. The board.dat file must be read into a 2-D array.
A warrior must start at the Start square and find their way to the Exit square. The warrior can move on the board in any direction including diagonally, one square at a time. A warrior has a running score (integer) maintained from the start of the game until the warrior exits the board. If the warrior lands on an obstacle square with a value of zero, the warrior is sent back to the starting position and the obstacle square will become a normal square (obstacle removed). If the obstacle square has a negative number, that number will reduce the warrior's score by the value of the obstacle, and the obstacle square will become a clear square (obstacle removed). Each VALID move that the warrior makes without landing on an obstacle will earn the warrior one point. The moves for the warrior are randomly generated by your code in the form of a direction (0-UP, 1-DOWN, 2-LEFT, 3-RIGHT, 4-UPRIGHT, 5-DOWNRIGHT, 6-UPLEFT, 7-DOWNLEFT). If the warrior is at the boundary of the board and your code generates an invalid move, that move will be ignored. Your code will keep generating moves until the warrior exits at the Exit square. Once the warrior exits, your program will store the updated board information to a new file ResultBoard.dat as single-space separated data. The program will also display the total number of valid moves, the total time elapsed in milliseconds since the first move until the warrior exited the board, the final score of the warrior and the formatted board information (right aligned columns with total of 5 spaces).
Output Format:
Each column in the final board display must be of total width of 5 spaces
Data in each column must be right aligned
Enter the board data file path: C:\board.dat //Repeat prompt until valid file OR show error and exit.
Type "Start" to start the game or "Exit" to exit the game: exit //Your program must exit
E.
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
The following is my code for a connectn program. When I run my code in the tester, I failed two
out 10 tests. I was hoping for some help in finding what causes these errors. I have included the
homework prompt and test failed results. Thank you so much!
#include
#include
#include
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win);
void create_board(int num_rows, int num_cols, char*** board, int* turn);
void print_board(int num_rows, int num_cols, char** board);
void destroy_board(int num_rows, char*** board);
void play_game(int num_rows, int num_cols, int num_pieces_to_win, int turn, char** board);
void check_move();
void get_play(int num_rows, int num_cols, char** board, int* user_move);
void make_move(int num_rows, char**board, int user_move, char pieces);
bool play_is_valid(int num_cols, int num_rows, char** board, int user_move_num, int
user_move);
bool game_over(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_won(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool game_tied(int num_rows, int num_cols, int num_pieces_to_win, char**board);
bool row_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool col_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool right_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
bool left_diag_win(int num_rows, int num_cols, int num_pieces_to_win, char** board);
void read_args(int argc, char *argv[], int* num_rows, int* num_cols, int *num_pieces_to_win) {
//reads command input and ensures there are exactly three numbers
if (argc > 4) {
printf(\"Too many arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else if (argc < 4) {
printf(\"Not enough arguments entered\ \");
printf(\"Usage connectn.out num_rows num_columns
number_of_pieces_in_a_row_needed_to_win\");
exit(0);
}
else { //puts user input into variables
sscanf(argv[1], \"%d\", &*num_rows);
sscanf(argv[2], \"%d\", &*num_cols);
sscanf(argv[3], \"%d\", &*num_pieces_to_win);
}
return;
}
void create_board (int num_rows, int num_cols, char*** board, int* turn) {
//set up the connect-n board
const char BLANK_SPACE = \'*\';
int i, j;
*turn = 0; //player 1 always goes first
*board = (char**)malloc(num_rows * sizeof(char*)); //creates pointers to the rows
for (i = 0; i < num_rows; ++i){ //for each row
(*board)[i] = (char*)malloc(num_cols * sizeof(char)); //create it
for (j = 0; j < num_cols; j++) { //fill in the row with blanks
(*board)[i][j] = BLANK_SPACE;
}
}
}
void print_board (int num_rows, int num_cols, char** board) {
//displays connect-n board
int i, j;
int k = 0;
for(i = 0; i < num_rows; i++){
printf(\"%d \", ((num_rows- i) - 1));
for(j = 0; j < num_cols; ++j){
printf(\"%c \", board[i][j]);
}
printf(\"\ \");
}
printf(\" %d \", k);
for(j = 1; j <.
There are a number of errors in the following program- All errors are.docxclarkjanyce
There are a number of errors in the following program.
All errors are located in main() and structure definitions.
Function declarations and definitions are correct!
Locate all errors, fix them (as shown below), run the program and save its output
as a comment at the end of the source file.
Example:
int num = 10;
int *ptr;
num = &ptr; // <== Error: Comment the line and write the correct line below
// Write a short justification where appropriate
// num = &ptr; // Error #1
ptr = #
Name:
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define DUMMY_TRAILER '\177'
// octal ASCII code of the
// last character in the ASCII table
#define NUM_CITIES 10
typedef struct
{
char name[12];
int temperature[5];
} CITY;
// Stack and Queue Node
typedef struct node NODE;
struct node
{
CITY city;
node *next;
};
// Doubly Linked List Node
typedef struct d_node D_NODE;
struct d_node
{
CITY city;
NODE *forw;
NODE *back;
};
// Stack Functions
NODE *push(NODE *stack, const CITY *pStu);
NODE *pop(NODE **stack);
// Queue Functions
void enqueue(NODE **queue, NODE **rear, const CITY *pStu);
NODE *dequeue(NODE **queue, NODE **rear);
// Doubly Linked List Functions
D_NODE *init_list(void);
int insert(D_NODE *list, const CITY *pStu);
void traverse_forw(D_NODE *list);
void traverse_back(D_NODE *list);
// Other Functions
void printCity(const CITY *pCity);
int main (void)
{
CITY cList[NUM_CITIES] =
{
{"Cupertino", {88, 89, 87, 85, 89}},
{"Flagstaff", {81, 80, 88, 89, 89}},
{"Los Angeles", {87, 88, 89, 89, 90}},
{"Philadelphia", {96, 99, 99, 90, 95}},
{"Phoenix", {106, 109, 109, 100, 105}},
{"Portland", {89, 90, 85, 89, 90}},
{"Reno", {108, 105, 109, 100, 108}},
{"Salem", {85, 90, 85, 89, 90}},
{"Tucson", {107, 100, 109, 100, 108}},
{"Yreka", {101, 109, 100, 108, 109}}
};
NODE *stack = NULL;
NODE *top = NULL;
NODE *queue = NULL, *rear = NULL;
NODE *front;
D_NODE *list;
list = init_list();
// build stack and queue with data from an array of CITY structures
srand((unsigned int)time(NULL));
int count = rand() % 10;
for ( int n = 0; n < count; n++)
{
int i = rand() % NUM_CITIES;
int duplicate = insert(list, &cList[i]);
if(duplicate)
{
// already in the list!
push(stack, &cList[i]);
enqueue(&queue, &rear, cList[i]);
}
}
// display list
printf("\nLIST contents (forwards):\n");
traverse_forw(list);
printf("\nLIST contents (backwards):\n");
traverse_back(list);
// display stack
if (top)
{
printf("\nSTACK contents from top to bottom:\n");
while ((top = pop(stack)))
{
printCity(top->city);
}
}
else
printf ("Empty Stack!\n");
// display queue
if (front)
{
printf("\nQUEUE contents from front to rear:\n");
while ((front = dequeue( queue, rear)))
{
printCity(front->city);
}
}
else
printf ("Empty Queue!\n");
return 0;
}
/***************************************************
Displays the fileds of a CIS_CLASS structure
Pre pCls - a pointer to a CIS_CLASS structure
Post
*/
void printCity(const CITY *pCity)
{
printf("%-20s %3d\n", pCity->name, pCity->temperatur.
Objectives Create a Java program using programming fundamentals (fi.docxamit657720
Objectives: Create a Java program using programming fundamentals (file I/O, loops, conditional statements, arrays, functions)
Problem: In an effort to win a coding competition, you decided to create an awesome Obstacle Warrior game. The game is played on a 2-dimensional board similar to a Chess board, but the dimensions may be different. The minimum size of the board is 2x2. The board will have a Start square and an Exit square that are not stored on the board. Start and Exit squares cannot be the same. Other board squares may contain obstacles in the form of an integer that will define how the warrior position and score will be affected. The obstacle squares can have values from 0 to -10 only. The Start square is always a clear square. All clear squares are marked with # on the board. The Exit square may contain an obstacle that is not a zero. The size of the board, number of obstacles, and Start and Exit squares are all unknow to your code prior to running. This information is stored in a file that your code will read at the beginning of the game. The board.dat file must be read into a 2-D array.
A warrior must start at the Start square and find their way to the Exit square. The warrior can move on the board in any direction including diagonally, one square at a time. A warrior has a running score (integer) maintained from the start of the game until the warrior exits the board. If the warrior lands on an obstacle square with a value of zero, the warrior is sent back to the starting position and the obstacle square will become a normal square (obstacle removed). If the obstacle square has a negative number, that number will reduce the warrior's score by the value of the obstacle, and the obstacle square will become a clear square (obstacle removed). Each VALID move that the warrior makes without landing on an obstacle will earn the warrior one point. The moves for the warrior are randomly generated by your code in the form of a direction (0-UP, 1-DOWN, 2-LEFT, 3-RIGHT, 4-UPRIGHT, 5-DOWNRIGHT, 6-UPLEFT, 7-DOWNLEFT). If the warrior is at the boundary of the board and your code generates an invalid move, that move will be ignored. Your code will keep generating moves until the warrior exits at the Exit square. Once the warrior exits, your program will store the updated board information to a new file ResultBoard.dat as single-space separated data. The program will also display the total number of valid moves, the total time elapsed in milliseconds since the first move until the warrior exited the board, the final score of the warrior and the formatted board information (right aligned columns with total of 5 spaces).
Output Format:
Each column in the final board display must be of total width of 5 spaces
Data in each column must be right aligned
Enter the board data file path: C:\board.dat //Repeat prompt until valid file OR show error and exit.
Type "Start" to start the game or "Exit" to exit the game: exit //Your program must exit
E.
import os import matplotlib-pyplot as plt import pandas as pd import r.docxBlake0FxCampbelld
import os
import matplotlib.pyplot as plt
import pandas as pd
import random
import string
from numpy.random import default_rng
import datetime
def run(low=None, high=None, number_values=None):
"""
'main' function for hw1 lecture
creates some data then saves it in a folder
"""
# User enters low, high, n integer
print("Creating random data.")
if type(low) != int:
while(True):
low = input("Please enter lowest possible value as integer:\n")
low_int = confirm_integer(low)
if low_int:
break
else:
continue
else:
low_int = low
if type(high) != int:
while(True):
high = input("Please enter highest possible value as integer:\n")
high_int = confirm_integer(high)
if high_int:
break
else:
continue
else:
high_int = high
if type(number_values) != int:
while(True):
n = input("Please enter number of values to create:\n")
n_int = confirm_integer(n)
if n_int:
break
else:
continue
else:
n_int = number_values
random_df = make_random_df(low_int, high_int, n_int)
# make output dir
local_dir = os.getcwd()
output_dir = os.path.join(local_dir, "Random_Files") # complete path to new folder
try:
os.mkdir(output_dir) # make folder
except FileExistsError:
pass # Do nothing if folder exists
output_df_os_mod_examples(random_df, output_dir)
def confirm_integer(input_val):
"""
Converts input val to integer, returns False if exception
:param input_val:
:return: integer or False
"""
try:
convert_int = int(input_val)
except Exception as e:
print("invalid integer")
return False
return convert_int
def make_random_df(lower_int, upper_int, number_idx):
"""
Creates Random DataFrame from bounds [lower_int, upper_int].
Creates 5 column DataFrame [Integers, Floads, Random Ascii (Ul#), Random Ascii (l), Random Ascii (U#)] number_idx rows
:param lower_int: lower bounds for random integers
:param upper_int: upper bounds for random integers
:param number_idx: number of random_df index
:return: rand_df: Pandas Dataframe (5 cols) number_idx rows
"""
# create n random data
rng = default_rng()
ints = rng.integers(low=lower_int, high=upper_int, size=number_idx)
floats = ints * rng.random() # multiply integers by random float [0,1]
# create some characters
rand_upper_lower_digit = random.choices(string.ascii_letters + string.digits, k=number_idx)
rand_lower = random.choices(string.ascii_lowercase, k=number_idx)
rand_upper_digit = random.choices(string.ascii_uppercase + string.digits, k=number_idx)
# make dataframe
rand_df_dict = {
"Integers": ints,
"Floats": floats,
"Random Ascii (Ul#)": rand_upper_lower_digit,
"Random Ascii (l)": rand_lower,
"Random Ascii (U#)": rand_upper_digit
}
rand_df = pd.DataFrame.from_dict(rand_df_dict, orient='columns')
return rand_df
def output_df_os_mod_examples(random_df, output_dir):
"""
Output dataframe in many file types.
Examples of os and os.path
:param random_df: pandasDataFrame cols:[Integers, Floads, Random Ascii (Ul#), Random Ascii (l), Random Ascii (U#)]
:param output_dir: path of output folder, exists==True
:return: None
"""
cwd = os.getcwd()
files = os..
Program In C You are required to write an interactive C program that.pdfamitbagga0808
Program In C You are required to write an interactive C program that prompts the user for
commands, accepts commands from the keyboard (stdin) and executes those commands. When a
command requires output, it must be written to stdout. The program must continue to accept and
process commands until the user types the end command ourput, it must be writen to stdout. The
program must continue to accept and proces.commands The program deals with linked lists.
Each node of such a list contains a string of length at most 10, a positive integer (i.e., an integer
value 2 1) and a pointer to the next node of the list. For any node, the string and the integer
stored in that node will be referred to as the symbol and count for that node respectively. At all
times, the list must satisfy the following two important properties. 1. The symbols appearing in
the list are all distinct; that is, no two nodes have the same symbol. 2. When the list is scanned
from left to right, the counts must be in non-increasing order. An example of such a linked list is
shown below. Search 4 Maxval4 begin/ Loop head
Solution
/**********************************************/
/****** NAMES ******************** COMMANDS ***/
/* Insert Command : ins str */
/* Delete Command : del str */
/* Forced Delete Command : fde val */
/* Print Statistics Command : pst */
/* Print List Command : prl */
/* Print using Count Range Command: pcr v1 v2 */
/* Print Prefix Command : ppr str */
/* Print Suffix Command : psu str */
/* End Command : end */
/***********************************************/
#include
#include
#include
#define CSIZE 4
#define SSIZE 11
/* Struct for each node in the linked list */
struct node
{
int count;
char symbol[SSIZE];
struct node *next;
};
struct node *head;
/* Prototypes for the functions */
void insert(char *);
void delete(char *);
void forced_delete(int value);
void print_stats();
void print_list();
void print_count(int, int);
void print_prefix(char pre[]);
void print_suffix(char suf[]);
void sort_list();
/****************
** Main Method **
****************/
int main(void)
{
int count;
char symbol[SSIZE];
char cmd[CSIZE];
int v1;
int v2;
/* Enter commands */
printf(\"Command? \"); fflush(stdout);
scanf(\"%s\", cmd);
/* Check for command*/
while(strcmp(cmd,\"end\") != 0)
{
/* check which function to use */
if(strcmp(cmd,\"ins\") == 0) { scanf(\"%s\", symbol); insert(symbol); }
if(strcmp(cmd,\"del\") == 0) { scanf(\"%s\", symbol); delete(symbol); }
else if(strcmp(cmd,\"fde\")==0){scanf(\"%d\",&count); forced_delete(count); }
if(strcmp(cmd,\"pst\") == 0) { print_stats();}
if(strcmp(cmd,\"prl\") == 0) { print_list(); }
if(strcmp(cmd,\"pcr\") == 0) { scanf(\"%d %d\",&v1,&v2); print_count(v1,v2); }
if(strcmp(cmd,\"ppr\") == 0) { scanf(\"%s\", symbol); print_prefix(symbol);}
if(strcmp(cmd,\"psu\") == 0) { scanf(\"%s\", symbol); print_suffix(symbol);}
printf(\"Command? \"); fflush(stdout);
scanf(\"%s\", cmd);
}// End of While Loop
return 0;
}// End of main method
/*********.
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
/* Task 2: Debugging a program with stacks, queues, and doubly-linked lists There are a number of errors in the following program. All errors are located in main() and structure definitions. Function declarations and definitions are correct! Locate all errors, fix them (as shown below), run the program and save its output as a comment at the end of the source file. Example: int num = 10; int *ptr; num = &ptr; // <== Error: Comment the line and write the correct line below // Write a short justification where appropriate // num = &ptr; // Error #1 ptr = # Name: */ #include #include #include #include #define DUMMY_TRAILER '\177' // octal ASCII code of the // last character in the ASCII table #define NUM_CITIES 10 typedef struct { char name[12]; int temperature[5]; } CITY; // Stack and Queue Node typedef struct node NODE; struct node { CITY city; node *next; }; // Doubly Linked List Node typedef struct d_node D_NODE; struct d_node { CITY city; NODE *forw; NODE *back; }; // Stack Functions NODE *push(NODE *stack, const CITY *pStu); NODE *pop(NODE **stack); // Queue Functions void enqueue(NODE **queue, NODE **rear, const CITY *pStu); NODE *dequeue(NODE **queue, NODE **rear); // Doubly Linked List Functions D_NODE *init_list(void); int insert(D_NODE *list, const CITY *pStu); void traverse_forw(D_NODE *list); void traverse_back(D_NODE *list); // Other Functions void printCity(const CITY *pCity); int main (void) { CITY cList[NUM_CITIES] = { {"Cupertino", {88, 89, 87, 85, 89}}, {"Flagstaff", {81, 80, 88, 89, 89}}, {"Los Angeles", {87, 88, 89, 89, 90}}, {"Philadelphia", {96, 99, 99, 90, 95}}, {"Phoenix", {106, 109, 109, 100, 105}}, {"Portland", {89, 90, 85, 89, 90}}, {"Reno", {108, 105, 109, 100, 108}}, {"Salem", {85, 90, 85, 89, 90}}, {"Tucson", {107, 100, 109, 100, 108}}, {"Yreka", {101, 109, 100, 108, 109}} }; NODE *stack = NULL; NODE *top = NULL; NODE *queue = NULL, *rear = NULL; NODE *front; D_NODE *list; list = init_list(); // build stack and queue with data from an array of CITY structures srand((unsigned int)time(NULL)); int count = rand() % 10; for ( int n = 0; n < count; n++) { int i = rand() % NUM_CITIES; int duplicate = insert(list, &cList[i]); if(duplicate) { // already in the list! push(stack, &cList[i]); enqueue(&queue, &rear, cList[i]); } } // display list printf("\nLIST contents (forwards):\n"); traverse_forw(list); printf("\nLIST contents (backwards):\n"); traverse_back(list); // display stack if (top) { printf("\nSTACK contents from top to bottom:\n"); while ((top = pop(stack))) { printCity(top->city); } } else printf ("Empty Stack!\n"); // display queue if (front) { printf("\nQUEUE contents from front to rear:\n"); while ((front = dequeue( queue, rear))) { printCity(front->city); } } else printf ("Empty Queue!\n"); return 0; } /*************************************************** Displays the fileds of a CIS_CLASS structure Pre pCls - a pointer to a CIS_CLASS structure Post */ void printCity(const CITY *pCity) { printf("%-20s %3d\n",.
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
1. The design of a singly-linked list
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define defaultSize 100
void Assert(bool val, string s)
{
if (!val)
{ // Assertion failed -- close the program
cout << "Assertion Failed: " << s << endl;
exit(-1);
}
}
template <typename E>
class Link {
public:
E element; // Value for this node
Link *next; // Pointer to next node in list
// Constructors
Link(const E& elemval, Link<E>* nextval = NULL)
{ element = elemval; next = nextval; }
Link(Link<E>* nextval =NULL) { next = nextval; }
};
template <typename E>
class LList: public Link<E> {
private:
Link<E>* head;// Intialization helper method
Link<E>* tail;// Pointer to last element
Link<E>* curr;// Access to current element
int cnt;// Size of list
void init(){// Intialization helper method
curr = tail = head = new Link<E>;
cnt = 0;
}
void removeall() {// Return link nodes to free store
while(head != NULL) {
curr = head;
head = head->next;
delete curr;
}
}
public:
LList(int size=defaultSize) { init(); }// Constructor
~LList() { removeall(); }// Destructor
void print() const;// Print list contents
void clear() { removeall(); init(); }// Clear list
// Insert "it" at current position
void insert(const E& it) {
curr->next = new Link<E>(it, curr->next);
if (tail == curr) tail = curr->next; // New tail
cnt++;
}
void append(const E& it) { // Append "it" to list
tail = tail->next = new Link<E>(it, NULL);
cnt++;
}
// Remove and return current element
E remove() {
Assert(curr->next != NULL, "No element");
E it = curr->next->element; // Remember value
Link<E>* ltemp = curr->next; // Remember link node
if (tail == curr->next) tail = curr; // Reset tail
curr->next = curr->next->next; // Remove from list
delete ltemp; // Reclaim space
cnt--; // Decrement the count
return it;
}
void moveToStart()// Place curr at list start
{ curr = head; }
void moveToEnd() // Place curr at list end
{ curr = tail; }
void prev(){
if (curr == head) return;
Link<E>* temp = head;
while (temp->next!=curr) temp=temp->next;
curr = temp;
}
void next(){ if (curr != tail) curr = curr->next; }
int length() const { return cnt; }
int currPos() const {
Link<E>* temp = head;
int i;
for (i=0; curr != temp; i++)
temp = temp->next;
return i;
}
void moveToPos(int pos){
Assert ((pos>=0)&&(pos<=cnt), "Position out of range");
curr = head;
for(int i=0; i<pos; i++) curr = curr->next;
}
const E& getValue() const {
Assert(curr->next != NULL, "No value");
return curr->next->element;
}
};
completed this code to fulfill the requirement below:
Write a function to insert an integer into a singly-linked list of elements arranged from largest to
smallest. Requires that elements remain ordered after insertion.
2. The design of array-based stack
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string.h>
#.
import os import matplotlib-pyplot as plt import pandas as pd import r.docxBlake0FxCampbelld
import os
import matplotlib.pyplot as plt
import pandas as pd
import random
import string
from numpy.random import default_rng
import datetime
def run(low=None, high=None, number_values=None):
"""
'main' function for hw1 lecture
creates some data then saves it in a folder
"""
# User enters low, high, n integer
print("Creating random data.")
if type(low) != int:
while(True):
low = input("Please enter lowest possible value as integer:\n")
low_int = confirm_integer(low)
if low_int:
break
else:
continue
else:
low_int = low
if type(high) != int:
while(True):
high = input("Please enter highest possible value as integer:\n")
high_int = confirm_integer(high)
if high_int:
break
else:
continue
else:
high_int = high
if type(number_values) != int:
while(True):
n = input("Please enter number of values to create:\n")
n_int = confirm_integer(n)
if n_int:
break
else:
continue
else:
n_int = number_values
random_df = make_random_df(low_int, high_int, n_int)
# make output dir
local_dir = os.getcwd()
output_dir = os.path.join(local_dir, "Random_Files") # complete path to new folder
try:
os.mkdir(output_dir) # make folder
except FileExistsError:
pass # Do nothing if folder exists
output_df_os_mod_examples(random_df, output_dir)
def confirm_integer(input_val):
"""
Converts input val to integer, returns False if exception
:param input_val:
:return: integer or False
"""
try:
convert_int = int(input_val)
except Exception as e:
print("invalid integer")
return False
return convert_int
def make_random_df(lower_int, upper_int, number_idx):
"""
Creates Random DataFrame from bounds [lower_int, upper_int].
Creates 5 column DataFrame [Integers, Floads, Random Ascii (Ul#), Random Ascii (l), Random Ascii (U#)] number_idx rows
:param lower_int: lower bounds for random integers
:param upper_int: upper bounds for random integers
:param number_idx: number of random_df index
:return: rand_df: Pandas Dataframe (5 cols) number_idx rows
"""
# create n random data
rng = default_rng()
ints = rng.integers(low=lower_int, high=upper_int, size=number_idx)
floats = ints * rng.random() # multiply integers by random float [0,1]
# create some characters
rand_upper_lower_digit = random.choices(string.ascii_letters + string.digits, k=number_idx)
rand_lower = random.choices(string.ascii_lowercase, k=number_idx)
rand_upper_digit = random.choices(string.ascii_uppercase + string.digits, k=number_idx)
# make dataframe
rand_df_dict = {
"Integers": ints,
"Floats": floats,
"Random Ascii (Ul#)": rand_upper_lower_digit,
"Random Ascii (l)": rand_lower,
"Random Ascii (U#)": rand_upper_digit
}
rand_df = pd.DataFrame.from_dict(rand_df_dict, orient='columns')
return rand_df
def output_df_os_mod_examples(random_df, output_dir):
"""
Output dataframe in many file types.
Examples of os and os.path
:param random_df: pandasDataFrame cols:[Integers, Floads, Random Ascii (Ul#), Random Ascii (l), Random Ascii (U#)]
:param output_dir: path of output folder, exists==True
:return: None
"""
cwd = os.getcwd()
files = os..
Program In C You are required to write an interactive C program that.pdfamitbagga0808
Program In C You are required to write an interactive C program that prompts the user for
commands, accepts commands from the keyboard (stdin) and executes those commands. When a
command requires output, it must be written to stdout. The program must continue to accept and
process commands until the user types the end command ourput, it must be writen to stdout. The
program must continue to accept and proces.commands The program deals with linked lists.
Each node of such a list contains a string of length at most 10, a positive integer (i.e., an integer
value 2 1) and a pointer to the next node of the list. For any node, the string and the integer
stored in that node will be referred to as the symbol and count for that node respectively. At all
times, the list must satisfy the following two important properties. 1. The symbols appearing in
the list are all distinct; that is, no two nodes have the same symbol. 2. When the list is scanned
from left to right, the counts must be in non-increasing order. An example of such a linked list is
shown below. Search 4 Maxval4 begin/ Loop head
Solution
/**********************************************/
/****** NAMES ******************** COMMANDS ***/
/* Insert Command : ins str */
/* Delete Command : del str */
/* Forced Delete Command : fde val */
/* Print Statistics Command : pst */
/* Print List Command : prl */
/* Print using Count Range Command: pcr v1 v2 */
/* Print Prefix Command : ppr str */
/* Print Suffix Command : psu str */
/* End Command : end */
/***********************************************/
#include
#include
#include
#define CSIZE 4
#define SSIZE 11
/* Struct for each node in the linked list */
struct node
{
int count;
char symbol[SSIZE];
struct node *next;
};
struct node *head;
/* Prototypes for the functions */
void insert(char *);
void delete(char *);
void forced_delete(int value);
void print_stats();
void print_list();
void print_count(int, int);
void print_prefix(char pre[]);
void print_suffix(char suf[]);
void sort_list();
/****************
** Main Method **
****************/
int main(void)
{
int count;
char symbol[SSIZE];
char cmd[CSIZE];
int v1;
int v2;
/* Enter commands */
printf(\"Command? \"); fflush(stdout);
scanf(\"%s\", cmd);
/* Check for command*/
while(strcmp(cmd,\"end\") != 0)
{
/* check which function to use */
if(strcmp(cmd,\"ins\") == 0) { scanf(\"%s\", symbol); insert(symbol); }
if(strcmp(cmd,\"del\") == 0) { scanf(\"%s\", symbol); delete(symbol); }
else if(strcmp(cmd,\"fde\")==0){scanf(\"%d\",&count); forced_delete(count); }
if(strcmp(cmd,\"pst\") == 0) { print_stats();}
if(strcmp(cmd,\"prl\") == 0) { print_list(); }
if(strcmp(cmd,\"pcr\") == 0) { scanf(\"%d %d\",&v1,&v2); print_count(v1,v2); }
if(strcmp(cmd,\"ppr\") == 0) { scanf(\"%s\", symbol); print_prefix(symbol);}
if(strcmp(cmd,\"psu\") == 0) { scanf(\"%s\", symbol); print_suffix(symbol);}
printf(\"Command? \"); fflush(stdout);
scanf(\"%s\", cmd);
}// End of While Loop
return 0;
}// End of main method
/*********.
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
/* Task 2: Debugging a program with stacks, queues, and doubly-linked lists There are a number of errors in the following program. All errors are located in main() and structure definitions. Function declarations and definitions are correct! Locate all errors, fix them (as shown below), run the program and save its output as a comment at the end of the source file. Example: int num = 10; int *ptr; num = &ptr; // <== Error: Comment the line and write the correct line below // Write a short justification where appropriate // num = &ptr; // Error #1 ptr = # Name: */ #include #include #include #include #define DUMMY_TRAILER '\177' // octal ASCII code of the // last character in the ASCII table #define NUM_CITIES 10 typedef struct { char name[12]; int temperature[5]; } CITY; // Stack and Queue Node typedef struct node NODE; struct node { CITY city; node *next; }; // Doubly Linked List Node typedef struct d_node D_NODE; struct d_node { CITY city; NODE *forw; NODE *back; }; // Stack Functions NODE *push(NODE *stack, const CITY *pStu); NODE *pop(NODE **stack); // Queue Functions void enqueue(NODE **queue, NODE **rear, const CITY *pStu); NODE *dequeue(NODE **queue, NODE **rear); // Doubly Linked List Functions D_NODE *init_list(void); int insert(D_NODE *list, const CITY *pStu); void traverse_forw(D_NODE *list); void traverse_back(D_NODE *list); // Other Functions void printCity(const CITY *pCity); int main (void) { CITY cList[NUM_CITIES] = { {"Cupertino", {88, 89, 87, 85, 89}}, {"Flagstaff", {81, 80, 88, 89, 89}}, {"Los Angeles", {87, 88, 89, 89, 90}}, {"Philadelphia", {96, 99, 99, 90, 95}}, {"Phoenix", {106, 109, 109, 100, 105}}, {"Portland", {89, 90, 85, 89, 90}}, {"Reno", {108, 105, 109, 100, 108}}, {"Salem", {85, 90, 85, 89, 90}}, {"Tucson", {107, 100, 109, 100, 108}}, {"Yreka", {101, 109, 100, 108, 109}} }; NODE *stack = NULL; NODE *top = NULL; NODE *queue = NULL, *rear = NULL; NODE *front; D_NODE *list; list = init_list(); // build stack and queue with data from an array of CITY structures srand((unsigned int)time(NULL)); int count = rand() % 10; for ( int n = 0; n < count; n++) { int i = rand() % NUM_CITIES; int duplicate = insert(list, &cList[i]); if(duplicate) { // already in the list! push(stack, &cList[i]); enqueue(&queue, &rear, cList[i]); } } // display list printf("\nLIST contents (forwards):\n"); traverse_forw(list); printf("\nLIST contents (backwards):\n"); traverse_back(list); // display stack if (top) { printf("\nSTACK contents from top to bottom:\n"); while ((top = pop(stack))) { printCity(top->city); } } else printf ("Empty Stack!\n"); // display queue if (front) { printf("\nQUEUE contents from front to rear:\n"); while ((front = dequeue( queue, rear))) { printCity(front->city); } } else printf ("Empty Queue!\n"); return 0; } /*************************************************** Displays the fileds of a CIS_CLASS structure Pre pCls - a pointer to a CIS_CLASS structure Post */ void printCity(const CITY *pCity) { printf("%-20s %3d\n",.
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
Here's my Computer Science Board Practical File. I hope you find it as useful as it was to me.This file is however of CBSE class 12th 2020-2021 syllabus.
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
1. The design of a singly-linked list
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define defaultSize 100
void Assert(bool val, string s)
{
if (!val)
{ // Assertion failed -- close the program
cout << "Assertion Failed: " << s << endl;
exit(-1);
}
}
template <typename E>
class Link {
public:
E element; // Value for this node
Link *next; // Pointer to next node in list
// Constructors
Link(const E& elemval, Link<E>* nextval = NULL)
{ element = elemval; next = nextval; }
Link(Link<E>* nextval =NULL) { next = nextval; }
};
template <typename E>
class LList: public Link<E> {
private:
Link<E>* head;// Intialization helper method
Link<E>* tail;// Pointer to last element
Link<E>* curr;// Access to current element
int cnt;// Size of list
void init(){// Intialization helper method
curr = tail = head = new Link<E>;
cnt = 0;
}
void removeall() {// Return link nodes to free store
while(head != NULL) {
curr = head;
head = head->next;
delete curr;
}
}
public:
LList(int size=defaultSize) { init(); }// Constructor
~LList() { removeall(); }// Destructor
void print() const;// Print list contents
void clear() { removeall(); init(); }// Clear list
// Insert "it" at current position
void insert(const E& it) {
curr->next = new Link<E>(it, curr->next);
if (tail == curr) tail = curr->next; // New tail
cnt++;
}
void append(const E& it) { // Append "it" to list
tail = tail->next = new Link<E>(it, NULL);
cnt++;
}
// Remove and return current element
E remove() {
Assert(curr->next != NULL, "No element");
E it = curr->next->element; // Remember value
Link<E>* ltemp = curr->next; // Remember link node
if (tail == curr->next) tail = curr; // Reset tail
curr->next = curr->next->next; // Remove from list
delete ltemp; // Reclaim space
cnt--; // Decrement the count
return it;
}
void moveToStart()// Place curr at list start
{ curr = head; }
void moveToEnd() // Place curr at list end
{ curr = tail; }
void prev(){
if (curr == head) return;
Link<E>* temp = head;
while (temp->next!=curr) temp=temp->next;
curr = temp;
}
void next(){ if (curr != tail) curr = curr->next; }
int length() const { return cnt; }
int currPos() const {
Link<E>* temp = head;
int i;
for (i=0; curr != temp; i++)
temp = temp->next;
return i;
}
void moveToPos(int pos){
Assert ((pos>=0)&&(pos<=cnt), "Position out of range");
curr = head;
for(int i=0; i<pos; i++) curr = curr->next;
}
const E& getValue() const {
Assert(curr->next != NULL, "No value");
return curr->next->element;
}
};
completed this code to fulfill the requirement below:
Write a function to insert an integer into a singly-linked list of elements arranged from largest to
smallest. Requires that elements remain ordered after insertion.
2. The design of array-based stack
below is a picture of the function that needs to be used
below is the code of the above picture:
#include <string.h>
#.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Thesis Statement for students diagnonsed withADHD.ppt
Automate ANY Excel Design Sheet Using python’s openpyxl.pdf
1.
2. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
3.
4.
5.
6. Input Cells
Cell Description
Q14 Project Name
Q16 Item Name
U16 ID
C4 Lb_in
C5 Lb_out
C6 L_LTB
C7 Cb
C10 Type
C11 Rolled Profile
A26 h
A27 b
A28 tf
A29 tw
C14 Pu
C15 Mux
C16 Muy
C17 Vu
C20 fy
C21 fu
C22 E
Output Cells
Cell Description
U19 Compactness
U20 Compression
U21 Flexure
U22 Shear
U23 Interaction
K27 P Utilization
O24 Mx Utilization
G6 Section Area
7.
8.
9. 1. Prepare Workbook with Template and Multi-input Sheets
2. Open Workbook → wb
3. Open Multi-input Sheet → multi_input_sheet
4. Open Template Sheet → template_sheet
5. Get input/output cell titles (row 2 in multi_input_sheet) → input_titles; output_titles
6. Foreach data_row in multi_input_sheet:
7. Create Copy of template_sheet → iter_sheet where iter_sheet.title equals data_row.id
8. Get input cells in row → input_cells
9. Get output cells in row → output_cells
10. Foreach input_cell in input_cells:
11. iter_sheet.cell(idx_of(input_title)).value equals "='Multi Input'!" + idx_of(input_cell)
12. Foreach output_cell in output_cells:
13. output_cell.value equals "=" + data_row.id + "'!" + output_title
14. Save wb
15. Close wb
10. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
11. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
12. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
13. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
14. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
15. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
16. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
17. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
18. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
19. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)
20. from openpyxl import *
sheet_path, input_end, output_end, non_temp_sheets = file.xlsx", 'U', 'AB', 4
def col2num(col):
num = 0
for c in col:
if c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
num = num * 26 + (ord(c.upper()) - (ord('A')-1))
return num
def make_sheets(sheet_path, input_end, output_end, non_temp_sheets):
wb = load_workbook(sheet_path)
numeric_input_end = col2num(input_end)
numeric_output_end = col2num(output_end)
template_sheet = wb["Template"]
multi_input_sheet = wb["Multi Input"]
# removing excess sheets from previous runs
for name in wb.sheetnames[non_temp_sheets:]:
wb.remove(wb[name])
rows = [_ for _ in multi_input_sheet.iter_rows()]
for row in rows[3:]:
row_id = str(row[2].value)
if row_id == "None": continue
# make a copy of the template & name the sheet with the id
iter_sheet = wb.copy_worksheet(template_sheet)
iter_sheet.title = row_id
print("Processing member ID: " + row_id)
# inputting
for input_cell in row[:numeric_input_end]:
iter_sheet[rows[1][input_cell.column - 1].value] = "='Multi Input'!" + utils.cell.get_column_letter(input_cell.column) + str(input_cell.row)
# outputting
for output_cell in row[numeric_input_end:numeric_output_end]:
output_cell.value = "='" + iter_sheet.title + "'!" + rows[1][output_cell.column - 1].value
print("Saving...")
wb.save(sheet_path)
wb.close()
print("Done.")
make_sheets(sheet_path, input_end, output_end, non_temp_sheets)