instruction
stringlengths
71
95.1k
I have an array of bytes 6144 bytes long. I want to extract a set of 4 bytes every 6th set of 4 bytes . So every 24 bytes I want to extract 4 of those bytes and join them in a new array. So arr=[a0, a1 ,a2 ,a3 ,a4 ...a6143] should become arrNew=[a0, a1, a2, a3, a24 , a25, a26, a27, ...a1020, a1021, a1022, a1023] I have...
Please review my code with the following in mind: Does anyone see a reason to make this asynchronous, why would i do that? How do i work out the maximum number of users it can handle at one time? at what point will i need to optimise it and are there any easy things i can do to handle more users. import os import sqlit...
I'm learning Rust by working through Jamis Buck's The Ray Tracer Challenge. The book instructs the reader on what to build in what order, and provides all required test cases. Included here are my implementations of 1) an RGB color representation, and 2) a canvas, which is essentially an editable 2-d array of color obj...
I have completed a solution for the below problem and uploaded it in Git Repo. I would be grateful if somebody can review in term of code quality, design and Kotlin language usage. Repo You're given the task of writing a simple console version of a drawing program. At this time, the functionality of the program is ...
I'm going through the Head First Design Patterns book and I want to check whether I'm understanding some aspects of the first chapter. Does the code below program correctly to interfaces, encapsulate changeable behavior, and employ composition in a reasonable manner? // trying to enforce some design pattern habits // ...
I've been reading Haskell tutorials and books for a while, but I never actually did serious stuff with it. This is my first attempt. It parses an OBJ-file in text format. Later on I will add some mesh-representation and more geometry stuff. Could you please review my code and check for "haskeliness" (like, best practic...
I'm a Haskell beginner, and I wanted to make a color annotator or color highlighter, one which takes a text as standard input, and outputs that text, with its color words highlighted using the colors themselves. So, it should replace all instances of the word "red" in a text with <span class="color" style="color: #ff00...
I got asked this question in an interview and I came up with a solution which I shared in the below but apparently it was not enough to pass. I'm looking forward to hearing how this problem could be solved. The question is : You are given an array of numbers e.g arr= [1, 3, 2, 0, 1, 2, 8, 4, 1] that represents a board ...
Problem Balanced number is the number that the sum of all digits to the left of the middle digit(s) and the sum of all digits to the right of the middle digit(s) are equal. The middle digit(s) should not be considered when determining whether a number is balanced or not. If the number has an odd number of digits then t...
Problem Statement An airline wants to allocate seats in their aircrafts such that each group of four passengers travelling together are to be seated next to each other in clusters of 4. A contiguous cluster can have an isle running through it - for example, you can sit one passenger on one side of the isle, and three ...
I have built a Blackjack simulator in Python. I need to decrease the execution time. I have used a profiler to identify key bottlenecks in the execution. The following function is responsible for about 15% of the total run time. def value(self): value = 0 has_ace = False for card in self.cards: val...
I am practicing coding questions on leetcode. I have been an OOP my whole career, and I am trying to wade into the dark abyss that is functional programming. So I am trying to do things purely functional, e.g. using recursion to try to get to the answer. The problem statement is this: Given a string, find the length of...
After referencing http://csharpexamples.com/tag/unsafe-bitmap-access/ I tried to put together one for 1 bit per pixel bitmaps. If you can review this, it would help me greatly in verifying this is the correct way to do it. This takes a Format1bppIndexed bitmap and locks it in memory, and directly parses the memory bit...
I have created a fractal tree based on a Lindenmayer System in Python. If you could tell me about any algorithmic or efficiency-based problems in the code, I would be grateful. import turtle import time t = turtle.Pen() branch = [] code = "1[0]0" # Change this to modify the structure of the tree t.left(90) t.up() t.b...
I've been learning C# for around 2 weeks and I'm feeling a bit more confident. I wrote this for general practice and am quite proud but hoping to make it faster and more efficient as I progress and learn more. This program allows the user to input car data i.e. "Model and Price" and then search for the stored data. (Ne...
I have recently built a class that is an implementation of kMeans from scratch. I believe there is room for improvement and I would happily receive some feedback. The project can be found at: https://github.com/EmpanS/kMeans-From-Scratch All code for the class is found below: # Import useful libraries import numpy as n...
Inspired by this answer on stackoverflow for AI implementation in 2048 game. I have been trying to make AI calculate best move by playing the game given specific times in memory preceding by one specific move first, then averaging the score and declaring move with highest score as best move. The workflow is fine, i am ...
I'm looking for some feedback on this code I wrote tackling a general solution to the age old "Add 2 numbers represented by Linked Lists". This specific one aims to be able to sum any given number of linked lists. Ofcourse, the input linked lists must contain the number in reverse order. #include<stdio.h> #include<stdl...
I wrote a simple algorithm to encrypt and decrypt files in Python using aes-256-cbc. from Crypto import Random from Crypto.Cipher import AES import base64 def pad(s): return s + b"\0" * (AES.block_size - len(s) % AES.block_size) def encrypt(message, key, key_size=256): message = pad(message) iv = Random.n...
Can someone help me how to speed up this scraping process getting all the usernames from the # 'cats' on instagram. My goal is to make this as fast as possible because currently the process is kinda slow. Maybe using multithreading? from instaloader import Instaloader HASHTAG = 'cats' loader = Instaloader(sleep=Fals...
Hey I am in the process of making this game, please could I get any feedback on how to further approach this, as I find it kind of inefficient. import pygame import time pygame.init() #Creating the Pygame window X = 500 Y = 500 win = pygame.display.set_mode((X, Y)) pygame.display.set_caption('Last to Pick') width...
I've made an iteration of the text game Hunt The Wumpus. The specification came from the text Programming Principles and Practice Using C++ by Bjarne Stroustrup. Implement a version of the game "Hunt the Wumpus". Hunt the Wumpus" (or just "Wump") is a simple (non-graphically) computer game originally invented by Grego...
I built a simple web app to manage my friends and I's six nation prediction league. This is my first go at web development so although it works I am guessing that I am not following all best practices or conventions. Any tips would be much appreciated. The stack I used is: Neo4j <-> Py2Neo <-> Flask <-> Html, JS, CSS I...
I have made a simple website and I have tried to reduce load times as much as possible. All the content that is loaded is necessary. Is there anything thing I can do to my code, such as structurally, to make it load even faster? Side Note I do not want to minify the HTML, as I want it to remain legible and I am not con...
While rewriting Array so I can practice my javascript, I looked at my implementation of .join(). It seems a little clunky to me. I've tried to cover all the edges, like making sure separator isn't null before joining, not adding the separator at the end of the string, and writing some documentation. What I'm looking fo...
Introduction: The following script contains code that performs what I would usually do when starting a new scene (add lights, camera, objects). The script will serve as a starting point for most of my future scripts. In the future, I might use more complex materials, create animations, or use the built-in physics simul...
I'm a beginner in PHP. Here my script $url1 = $chemin.'include/aaa/url1.php?param='.$param.'&page='.$p; $url2 = $chemin.'include/aaa/url1.php?param='.$param.'&page='.$total_pages; //url2.php $url3 = $chemin.'include/aaa/url2.php?page='.$p; $url4 = $chemin.'include/aaa/url2.php?page='.$total_pages; //url3.php $url5 ...
I need to learn bash at some point in the near future, so I decided to start playing around with it. This is really the first actual script that I've written and would like feedback. This finds and prints all the prime numbers up to the argument provided to the script: ./primes.sh 100 2 3 5 7 11 13 17 19 23 29 31 37 41...
I'm looking for combinations, not permutations, and have found some really great examples ranging from using flatMap such as https://stackoverflow.com/a/54329187/669843 The result of ['a', 'b', 'c'] would be an array of arrays of 3 (a, b, and c). The result I'm looking for would also contain arrays of length 1 and 2. E...
I have developed the program to rotate the array in java request you to please check it and let me know if there are any flaws in it or where further it can be improved package com.dataStructures.Arrays; // Java program for reversal algorithm of array rotation //Let the array be arr[] = [1, 2, 3, 4, 5, 6, 7], d =2...
I'm developing a Go application that has lots of packages. Many of the packages use the same type from a 3rd party library. Should an interface be defined for the type in each package, and let the interfaces only contain the methods that are used by the package? Or, we should define a single interface for the whole app...
I have a set of products(e.g. P0006, P0009, etc.) and a set of production lines (eg. L1H175, L2H175). A product can be produced on a subset of the lines set (and not necessarily all of them). If we decide to produce a product on a production line(assuming that the line can actually produce it), we need to buy the appro...
I have implemented a very simple but robust implementation of the Golomb-Rice coding. To understand my motivation, see the minimalist data compressor that is based on this. At the moment, the implementation works well. However, I intend to make it more elegant, concise, and possibly faster. Any suggestions for improvem...
I've implemented atoi function as described in leetcode problem string-to-integer-atoi. I am looking for some feedback on writing this in a more scala native way and being able to include the requirement that: If the numerical value is out of the range of representable values, INT_MAX (231 − 1) or INT_MIN (−231) is ...
I've wrote a C++ program to calculate the determinant of a matrix: #include <iostream> #include <string> double getDeterminant(double arr[], int dimension); int main() { //First, the user has to enter the dimension of the matrix int dimension; std::cout << "Please enter dimension of Matrix: "; std...
This is my implementation of Dijkstra's algorithm. It solves any order square mazes. from copy import deepcopy from math import inf import maze_builderV2 as mb def dijkstra(maze, order, pos, finalpos): mazemap = {} def scan(): # Converts raw map/maze into a suitable datastructure. for x in range(1, order+1): ...
After following some suggestions you can find here, I'd like to show you the result: #include <iostream> #include <string> #include <vector> double getDeterminant(std::vector<std::vector<double>> vect, int dimension); int main() { //First, the user has to enter the dimension of the matrix int dimension; ...
I'm working on a Slack bot for service desk which sends direct message to user on a Slack when their ticket will be on user_action_needed status. I'm using AWS Lambda to handle Jira incoming webhooks. Everything works well but I think I've got an issue with whole architecture of the app - I quess the code is not so rea...
I am writing a function to have insert a list of strings into a MySQL database and C#. The process of creating the list of Components: User has to scan multiple barcodes and have them stored in a list. The goal is to take that list and insert it into a MySQL database on the click of a submit button. Is the function be...
I've been making a simple "game engine" for fun and I had a lot of trouble designing a decent asset management system. Currently I got it working but it uses a lot of downcasting which is usually bad practise. The whole code wouldn't really fit here so I'm putting here the relevant parts and linking the whole thing on ...
I'm creating mazes, and have a Cell class (only relevant code shown)... public class Cell { public int Row { get; } public int Col { get; } public List<Cell> Links { get; } public Cell North { get; set; } public Cell South { get; set; } public Cell East { get; set; } public Cell West { get; set; } pu...
I'm working on implementing a goal-based pathfinding. first step is to set a goal and calculate the shortest walkable distance between the goal and all points in the grid, using a brushfire algorithm. I'm worried about two things here, readability and efficiency, since this is for an RTS game. int[] GenerateHeatMap...
Before I begin showing code, I have two main questions which I feel could help me. What is a service or factory, I've heard of them but why use them? Should I use one shared instance of ILogger throughout my whole application, I only plan on persisting errors and I can get the reporter from the stacktrace. So, I deci...
I have a set of unique strings, I want to create a unique integer identifier for each string. Usage I want a function to move back and forth, if I give it an integer it returns the corresponding string and vice versa. Here is how I am doing it def str_to_int(S): integers = list(range(len(S))) my_dict = dict(zi...
I got this from a practice problem set, and looking for feedback on my approach. Suppose you're given a binary tree represented as an array. Write a function that determines whether the left or right branch of the tree is larger. The size of each branch is the sum of the node values. The function should return the str...
Which of these three methods is the most efficient? Also, what is the time & space complexity of each? public class Palindrome { public static boolean isStringBased(String word) { if (word == null || "".equals(word)) { return false; } String lowerCasedWord = word.toLowerCase(); ...
Here's my algorithm / approach for transposing a 2D Matrix on the main diagonal. Before: a L M d b G c N H K e F I J O P After: a b H I L G K J M c e O d N F P My code: public class Matrix { static String[][] matrix = { {"a", "L", "M", "d"}, {"b", "G", "c", "N"}, {...
Currently trying to migrate two fields of information into one field. We have many, many objects to go through and it takes roughly 12 minutes to loop through all the objects. That would mean the website would be down for 12 minutes and we do not want that. Is there any way to speed up this migration? It works, it's ju...
I have a single image of shape img.shape = (500, 439, 3) The convolution function is def convolution(image, kernel, stride=1, pad=0): n_h, n_w, _ = image.shape f = kernel.shape[0] kernel = np.repeat(kernel[None,:], 3, axis=0) kernel = kernel.transpose() n_H = int(((n_h + (2*pad) - f) / stride) + ...
I have an Access macro that runs AfterUpdate of a form. It opens an Excel workbook and edits a few cells. I have It working the way I want, but the problem is that the code takes about 25 seconds to run. This is way too long for the users of this database to have to wait. After adding some timing messages, I found that...
Is this a good way of removing all the nodes that contains a value x? This function takes as input the head of a list and has to delete all the nodes that contain a given value taken. If there is any better way of doing this can you please show them to me? node_t *funzione(node_t *head){ int x; node_t *temp ...
So I ported a lexer I wrote in C++ over to rust, as I'm starting to learn rust. Since I'm very new though, I don't know any Idioms and good practices in rust. So if anyone could point out some (probably obvious) issues I'd be very thankful. This is my code: use std::cmp::PartialEq; use std::fmt::Debug; #[derive(Debug,...
I've been learning more about PHP Objects and Classes, and my immediate reaction was to create a Database Object for handling the MySQLi Connection, Statements and Results. Its not meant to be an ultimate do-all object, but help with WET code. Obviously this has been done before... at least a hundred times. There's...
I have a json field in a table that I want to select certain fields from into a new json field. So far I have this, which works, but I feel may not be optimal: select to_json(new_obj) from ( select big_json_field->'json_property_1' as json_property_1, big_json_field->'json_property_2' as json_property_2 f...
How can I get the date of the next occurrence of Friday the 13th? Below is my attempt. It returns the correct results. I think there must be a better way of writing this without checking thirteenth > start_date for every month. It might also be possible to exploit the fact that every calendar year has a Friday 13th. im...
I am still a beginner and I would love to hear some feedback on a small wrapper I wrote for the TMDb API (https://developers.themoviedb.org/3/getting-started/introduction). It is used for queries on a movie database. I tried to make it as simple as possible so all that is needed to get relevant information is the title...
I am making an user class which I could inherit and use in the future. (recently started learning Python and OOP) import mysql.connector as mycon class user: host = "localhost" user = "root" password = "pass" database = "USERS" table = "UserData" def __init__(self,firstName,lastName,userName,em...
I have a function that constructs a path based on a function of inputs and creates the parent directory. When writing a unit test for this function, I want to mock the I/O part of the function, namely the .exists() and .mkdir() methods of the pathlib.Path objects. However, since both are not called until the path ha...
I wrote this simple scoped thread to use it as a class member to ensure the the thread running on a class method doesn't continue running after the class has been destructed. Also to spawn threads from the main() function to ensure that I don't forget any running threads upon exit . This can be achieved by calling joi...
Here is problem: There is string (domain) divided by dots (like www.part1.partN.com) Need to build reversed by dot string (like com.partN.part1.www) Both strings are utf-8 encoded My solution: std::string reverseHost(const std::string& host) { std::string ret; ret.reserve(host.size()); size_t tail = host...
I am using the code below to pass filter selections from table A to table B in Spotfire. I am doing this to create a filtering relationship between the tables, but skipping the creation of a traditional Spotfire table relationship, as this is not advisable in this setting. The code is associated with a document propert...
In this code I calculate the statistical functions of values from different files and save them into CSV files (one filer for each statistical function). def mean(data): pass def standard_deviation(data): pass def afd(data): pass def norma_afd(data): pass def asd(data): pass def norma_asd(data)...
I want to associate an error message to a Validator and not have to in the html check for a specific error. aka *ngIf="controls.name.required". I've seen generic error message helpers that build up an javascript object with an index and a message that goes with that index. What I want is to actually associate the err...
How can I re-factorise this circular nesting dictionary function? The challenge: I recently received a data extract with a list of folder names and associated subfolders. The challenge was to produce a reusable function that could provide a summary of the unique folder names and all the nested subfolders. The data sou...
I was doing this exercise on codeabbey. Andrew and Peter play the code-guessing game. Andrew chooses a secret number consisting of 3 digits. Peter tries to guess it, proposing several values, one by one. For each guess Andrew should answer how many digits are correct - i.e. are the same in the proposed value and in hi...
I have a question regarding code quality and best practices. My task - to write a feature encoding function that will encode categorical labels, boolean labels as one-hot encoding, timestamps for further usage for ml training. Input - dictionary of several dataframes, each dataframe consist of several columns of differ...
This is my second iteration of a function to remove all nodes containing value 'x'. The previous iteration is here. This function takes as input the head of a list and has to delete all the nodes that contain a given value taken. Is this an improvement on the previous iteration? Is there anything else that can be im...
Version 1 may be found here. I have implemented the suggestions by Jon Skeet, plus some of my own. Key differences between versions: ZonedDateRange class is now immutable. LocalDate variables no longer are named with "Day". Some ToString() methods were added. ZonedDateRange.cs using System; using System.Collections....
I am built a program that will give the 7 chords that are found a given major or minor key. My program takes in first a key (C, Ab, F#, etc.) then takes in its mode (Major (input is 'M') and minor (denoted by 'm')). From there the program builds the chords in that key in a specific manner depending on the mode where yo...
I'm calculating a score based on whether or not certain colors shape is selected. Some of the shapes are in groups, some are not. For the shapes which are in groups, only one of them will count towards the score. I have figured out how, as you can see below. However, I have 9 more shapes/scores to add to the Sub. I'm s...
I have two functions which I would like to simplify. They have largely the same logic, but one is asynchronous and uses one await in a try block. I'd like to have the logic in one place, but could not figure out a clean way of doing that. Any suggestions? from requests import get, HTTPError # Dummy functions for exter...
TL;DR: The algorithm receives a string as input, allocate another string to be the final digest, and start working on them. For each char on the digest (a null character on a first moment), it XORs it with every character from the original string, also XORing it with a set of "random bytes" that are specified in the be...
I've written a basic event messenger broadcasting service. This is meant to allow for broadcasting events between loosely coupled areas of code where you may not have or care about a direct reference to the specific broadcast source (as you might if using Signals/Slots for example), and the broadcaster does not know wh...
I had a task to convert some JPG images into PNG format using Python. I successfully did it but I was wondering if somehow I could make my code better than my current one. Code - #Python Code import os from PIL import Image path1 = sys.argv[1] path2 = sys.argv[2] if not os.path.exists(path2): os.makedir...
I need to write a method that will accept a timestamp and takes an array of votes, I need to return the k leading candidates with that timestamp. I came up with the following solution, Here is the input to the methods: votes = [{'candidate':'a', 'timestamp':2},{'candidate':'c', 'timestamp': 5},{'candidate':'c', 'times...
I wonder whether I included too many libraries; also can you point out obvious beginner mistakes? Is the while loop the best for what I intend, or is there a better way? Also, is it possible to put more into functions such that the main() looks like this: int main() { call function1 call function2 etc. return 0; ...
I am new to C# and would appreciate it if you review my code. This code finds the anagrams in a list of string. Where can I be more efficient in my code? is there any way I can save memory? using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.Tr...
I am looking for general critique of my code and notice of any bugs or errors. I have included the main file and the class files. Also, I'm wondering where would I need comments. Sorry it is such a monster ;). #include <iostream> #include <string> #include <fstream> #include "rooms.h" #include "characters.h" #include...
I use the below code to get a list of columns in a table, and assign the default value to the protected var $attributes in a Laravel Model. In this code, I use the DB function because I don't know how to achieve the same result with Eloquent. Model.php protected $attributes = []; public function __construct(array $att...
Project Euler Problem 47 Find the first four consecutive integers to have four distinct prime factors each. What is the first of these numbers? This is my solution for problem 47 on Project Euler. def primes2(n): """ Input n>=6, Returns a list of primes, 2 <= p < n """ n, correction = n-n%6+6, 2-(n%6>1) ...
Since hashing algorithms isn't something to mess around with as a beginner. Several howto's explain that one should use already made solutions. Examples of such pages: https://crackstation.net/hashing-security.htm https://owasp.org/www-project-cheat-sheets/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2 So I opt...
I want to rework my current game-server engine to use some global queue of tasks which will be distributed through all the working threads. I started with task interface. I want it to be able to accept any kind of method and store it under queue for later execution. I'd like to hear your opinions on my implementation. ...
I had to make this blackjack game for school, but this is only the first part. We only had to use a random value between 2 and 11 to generate the cards, as we will have a library of cards later, and the dealer will keep pulling cards until their total value is at or equal to 17. The player needs to decide whether they ...
I built a simple Rock Paper Scissors game in Python as my first "project", and I want a feedback from you. I want your opinion on how I write my code, is it okay and readable enough? PEP8 laws, things to improve or preserve? Computer Choice - Generating a random choice with the random module and the random.randomchoice...
After following the suggestions you can find here, I'd like to show the result again (but I did not change the algorithm): #include <iostream> #include <string> #include <vector> #include <iomanip> int getDimension(); void getUserInput(std::vector<std::vector<double>>& vect, int i, int dimension); double getDetermina...
I've a method which is used to build a native sql query. I've 4 String builder as input and based on different conditions, I need to build my query. Here is the code private void appendConditions(StringBuilder query, StringBuilder condition, StringBuilder condition2, StringBuilder condition3) { if (StringUtils.isNo...
I am working as a validation technician for excel spreadsheets in a pharma company. Sadly & interestingly I don't know much about VBA and Excel. To validate those excel spreadsheet, I developped with macro-recording the following code, which helps me identifying the cell properties. The goal is to quickly obtain releva...
The code below is a custom array class that handles indexing, copying, printing, etc. explicitly. Is there a better approach for specification (declaration and definition) of the assignment operator (with swap function) and the index [] operator? Furthermore, are there any improvements that can be made to the other met...
I have recently started coding in c++ and have made a simple console application. When executed the program asks the user to position their cursor wherever they want continuous repeating clicks, after 7 seconds it then asks the user to set an interval for the clicks. Since I am fairly new I am wondering if there is any...
Long one here, but election transparency is worth a rough code review. The Iowa Caucuses have numerous errors in delegate awards because they did their computations manually (their closed-source app failed). In response I released a Swift "Caucus Report" iOS app for the upcoming Nevada caucuses. It is open sourced at ...
I am sure there will be a way to make this code simpler, can someone take a look? Basically what it does is: get now and a week ago from now then format it to utc (i.e. 2020-02-04T23:18:00Z) to enter in boto3 command as parameters import datetime end_time = datetime.datetime.now() start_time = end_time - datetime.ti...
I'm having trouble with proper naming. That issue appears when i try to apply to first class collection to my class and use sonar as well: public class Units { private final List<Unit> units = new ArrayList<>(); [...] } Here's the problem, sonar says: A field should not duplicate the name of its containing...
Was trying to implement and example code to smart pointer from link. Is it a good practice? To go with all unique pointers or should we use shared pointers in this case? How can i improve this ? #include <iostream> #include <string> #include<memory> void LOG(std::string strText) { std::cout << strText << std::endl...
I have been programming in various languages for a very long time, and this was one of my first attempts to build an Android app. Apparently this was not good enough for the challengee, could somebody please point out the most major flows and oversights in my design? The app display a list of pets in a recyclerView and...
I have a class with three similar methods. I can't consider which a pattern to use better for refactoring: template method, strategy or something else? I don't know. Can you help me? Update: This code is a little exercise to be a better programmer. I'm going to add some algorithms, but it's not a production code. I wou...
I have an input like this: x = '415,252,428,233,428,214,394,207,383,205,390,195' And I want to end up with this y = [(415,252),(428,233),(428,214),(394,207),(383,205),(390,195)] The closes I got is tmp = [int(i) for i in x.split(',')] y = zip(tmp[::2], tmp[1::2]) How do I get rid of the intermediate list? I need alt...
Goal: I am trying to get the hang of using MySQL connections within C# windows forms. These are such areas I am targeting: Loading dataGridView correctly Refresh dataGridView from an external form (See public void RefreshGrid()) Update query for MySQL connection I'd like to hear some reviews from you guys. Does the s...
This was the question given to me: Implement a function to query json_schema The goal of this exercise is to implement a function that allows you to query the type of a keypath in a JSON schema. This function will accept a valid JSON schema as dict, a key_path (eg: foo.bar.baz) and return the type of the propert...
Below the text of the exercise: We are given the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. Return the same tree where every subtree (of the given tree) not containing a 1 has been removed. (Recall that the subtree of a node X is X, plus every node that is a desc...
Hi i needed to find the max int of a list using recursion, I have done it this way I'd like to know if you think is a good way, and I have a couple of questions: int trovaMassimo(node_t *head){ int e; if(head == NULL){//this can happen just the first time right? printf("Lista vuota\n"); exit(1)...