instruction
stringlengths
71
71.9k
I use the following code to convert ۱۲۳۴۵ to ‍12345, effectively transliterating the persian numbers into latin numbers: String.prototype.toEnglishDigits = function () { var num_dic = { '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵':...
I am a Java programmer trying to learn the ways of Swift. A few days ago, I posted the code for a very simple app that draws a Sierpinski triangle and implements a pretty buggy zoom. I was told to work on organization, delegation, and creating global functions, all of which I tried to do. I also added some new features...
This is a simple program to convert a number, from 0 up to 99999999, to English words. Example: If the input is: 1234 The output would be: one thousand two hundred thirty four I would like to get feedback regarding this small program. #include <iostream> #include <vector> #include <string> const std::vector<std::s...
I have some Field objects that need to be serialized. Their primary string identifier is called a Tag and starts with a number, so it's not suitable for use as a class name. Thus, for a field bearing tag 32A, I am using the name Field32A. However, during serialization, I need access to the literal string value "32A". I...
Deferred allocation is a memory optimizing trick of using the Node** as Node* when there is only one item in the "bucket". Thus "item" member holds either the index of such lonely item, or a negative value if the bucket is fully allocated. Cache-awareness here is merely adding a compiler's __builtin_prefetch() in the r...
My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any suggestions in regards to pretty much anything so let me have it! That said, I've been building little games to learn so far, but ...
Could anyone provide any constructive criticism? I'm trying to get a jump on data structures before classes start. One thing is that I should add a copy constructor and assignment operator. Changes made: got rid of using namespace std. As the code allows users to specify a cap, if they wish, for their stack any ideas o...
I'm trying to make a programme that reads graphs from a .txt file, puts them in a vector, and finally puts the frequent closed graphs in another resulting file. I'd like to adjust this program to make it faster and more performant for memory. #include<boost/version.hpp> #include <boost/graph/adjacency_list.hpp> #includ...
I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I only learned about some useful tools of Python just this past year, when I took a class that recommended using it. The Pro...
What it is doing basically is reading an std::string from a given pointer. I was told that using a StringBuilder as I am is not the best way to achieve this, so I would like to know how this would be best written. As additional information, that is a pointer of a std::string and I've made that because I was originally ...
I'm making a class that takes a path to a text file as an argument in its constructor, and then parses the text file and pulls out a lot of data that it stores as private members. Most of these members are vectors of ints, floats, and strings. The class will be used by different versions of VS, so my understanding is t...
My interview question was that I need to return the length of an array that removed duplicates but we can leave at most 2 duplicates. For example, [1, 1, 1, 2, 2, 3] the new array would be [1, 1, 2, 2, 3]. So the new length would be 5. I came up with an algorithm with \$O(2n)\$ I believe. def removeDuplicates(nums): ...
rags-to-riches of Convert seconds to hours, minutes and seconds. In that question, BigDecimal was chosen to be the model class, which doesn't seem like a right fit for temporal amounts. Sure, doing arithmetic should be the simpler and faster way, but I thought of using the Duration class to make this more 'API-driven'....
I want to implement an Agent-like object in C#. An Agent wraps some memory location (ideally storing an immutable object) and receives updates to that location. All these updates are performed asynchronously, but sequentially. In other words At any point in time, at most one [update submitted to an] Agent is being e...
I'm writing 2x2x2 rubics cube simulator. In my code I have a concept of Face which is individual side of the cube, and State which is agregate of all six sides. When I create new State, in addition to creating faces I need to set all neighbour faces for a given face. Currently I do this in manual way, as in: faces[Side...
For the Matasano CryptoPals Challenges Set 1 Problem 8, which states: In this file are a bunch of hex-encoded ciphertexts. One of them has been encrypted with ECB. Detect it. Remember that the problem with ECB is that it is stateless and deterministic; the same 16 byte plaintext block will always produce the same 16 b...
I have a small piece of code that checks some data but I suspect one of the if statements is unnecessary: bool meldControleGereed = false; bool allProductionDone = true; int controleBewerkingId = 0; foreach (DataRow row in controleTable.Rows) { string code = row.Field<string>("CODE"); bool productionDone = row....
I'm new to OOP, so I tried to learn from tutorials how to create a class in JavaScript/jQuery. But tutorials don't give you feedback from experienced coders. Is the approach to create a pop-up OK (see below)? I know it works (it's tested), but is it prone to errors or does it have redundancies? var Popup = function (){...
A list that contains one or more lists as elements is called a deep list. For example, [1, [2, 3], 4] is a deep list. Write a function deep_len that takes a list and returns its deep length. See the doctests for the function's behavior. Hint: you can check if something is a list by using the built-in type functi...
I have image slider with thumbnails, simple one where I account for left and right arrow clicks that show respective images and thumbnail clicks that load related image. Functions have a lot in common and I'm trying to figure out how to put them into one and use it for all 3 different events, but am having trouble as t...
A little while back I had an interview where they posed a problem, in summary: Watch a certain directory, and process incoming JSON files These JSON files have various "Type" fields Every second report out how many files of each "Type" were processed, and the average processing time (from added to disk, to added to su...
I am doing a lightsaber app for fun. I followed a tutorial to learn how to get information from the accelerometer to play lightsaber sounds. It instructed me to have the Activity where I get the accelerometer data implement the SensorEventListener interface. I have a custom dialog that I want to use which allows the ...
The following code takes either a URL or the title to an existing news article. Searches Google News using the title. Collects all links from search results. import urllib2 from lxml import html import requests def get_page_tree(url=None): page = requests.get(url=url, verify=False) return html.fromstring(pag...
I created an API to load, save and read user configuration in my application. I've a Configuration interface which provides the basic methods to read, save and read configuration data and then in the application I've the implementation JsonConfiguration. I tried to keep the Configuration interface as generic as possib...
I have this class which mostly holds a bunch of properties and their setters. I also have wrappers for some functions of another module. Here is the class: class ARCArduino(object): """ Class to manage Arduino functionality """ def __init__(self, tree_item, port, identifier): self.__i2c = Ardui...
Took me a couple of days (in between working on other projects) to get the code working, but now that I do have it working I would like to know if there is a way that I could make it work better, or clean up my act JavaScript/jQuery surrounding my JSON utilization skills. I am using ASP.NET if that means anything to th...
I need to write a very basic file/directory browser. The data structure I'm using is pretty simple - a Node with an optional parent and children. Along with the data structure I also need a simple function that will recurse a file system building up the tree of nodes. This is what I have come up with so far and I'd rea...
Following a challenge on HackerRank, I want to find the sum of all numbers that have no more than x 4's, y 5's, and z 6's module 10^9 + 7. I'd like to know how I could improve this code below both for style and performance. Also, what's the canonical way to get unique permutations of a list that can include repeated el...
This retrieves result sets from a MySQL table. The objective of this function is to correctly retrieve any number of rows (with $sql) from a MySQL table, binding the needed values accordingly ($params[]), having the possibility to choose the column/s you want to retrieve ($cols[]). $db = new PDO('mysql:host=127.0.0.1;d...
I've noticed that whenever a shader program class is implemented (from some questions on this site, as well as more reputable implementations), that: The class tries to do too much. Binding to the current context, setting attribute variable values, and much more. Use the JavaBeans pattern in one form or another, allow...
Today, I sat down to write a tiny performance test to quickly assess a hunch I had regarding an optimization. The resulting code eventually got rather large for my taste; thus I subsequently tried to abstract it to a degree that allowed me to keep ledgibility, ease of maintenance and extensibility, reduced redundancy a...
I am writing a generic C++14 multi dimensional array for computational science purpose. The "features" so far for the class tries to: store multi-dimensional grid values into a flatten array provide grid values access and flat index access from multi dim coordinates with \$O(1)\$ average complexity (worst case is \$O(...
I am trying to replicate Bruce B. de Mesquita's (BDM) results on political game theory for prediction. Based on where actors stand on issues, their capabilities, salience, BDM's method attempts to find the eventual decision point by simulating a game. He reportedly used this method with much success; and published his ...
I have managed to implement an ADTStack with a circular doubly linked list. I would like to know whether there are things I could have done better or, I should improve. public class QueueCircularDLL<T> implements ADTQueue<T> { private ListElement<T> head; private ListElement<T> tail; public QueueCircul...
After our recent election, I got elected as a moderator here on Code Review (Thank you, community members!). One of the first things I missed among the moderator tools was desktop notifications for when there were any flags. As no current tool existed, I figured that I just have to create one... Following the approach ...
I've written the following code to print all the permutations of a list. For example: \$[1, 2, 3]\$ has these permutations: \$[1,2,3]\$, \$[1,3,2]\$, \$[2,1,3]\$, \$[2,3,1]\$, \$[3,1,2]\$, and \$[3,2,1]\$. def insert_each_position(self, nums, insert_one): res, len_of_nums = [], len(nums) for idx in range(len_...
This code works, but I'm curious what feedback you have about style and doing things in a more "pythonic" way. def printUsage(): print("Usage: goodproxy.py -f <proxyfile> -u <url> -t <timeout>") def main(argv): filename = "" url = "" timeout = None try: # USE GETOPS F...
I'm new to python and created this small program. It's basically a skeleton for a simple text-based RPG. The program is one menu that allows you to: Create a Character View Character Stats/Attributes Load Character Battle Save Quit I'm looking for constructive criticism from any angle, be that if I comment too much, ...
I'm working on a grammar for the Visual Basic for Applications (VBA) programming language. I've discovered a way to make assertions about how a parse tree should be generated by using the Antlr ToStringTree method. My method is this: Create a parser and give it a code snippet. Obtain the parse tree result and turn it...
During my holiday I decided to implement a solver for those puzzles my girlfriend likes to do. They are called Takuzu, but "binero" in Dutch. The puzzle gives you a grid in which you have to fill in either a 1 or a 0. The constraints are the following: No 3 adjacent values may be the same in a row or column No two row...
This function takes an array of HTML objects and returns those currently on the screen. I try to optimize for readability and performance. I myself find this function a bit confusing. function(elements, margin) { var inViewport = []; if(elements.constructor !== Array){ elements = [elements]; } margin = mar...
I'm creating a database class. It's part academic and part something I may show in an interview. The purpose of this method is to accept a table name as a parameter, check if the PDO Object has been created (this is in an earlier method), check if the table is in the database as to white list the table for going furth...
This code checks winning conditions in Tic-Tac-Toe by checking if there is any row, column or diagonal with the same symbols. The board is a 2-dimensional array of chars. The character ' ' means that a field is empty. How can I refactor/simplify this code? public static bool SomeoneWins(char[][] board) { ...
I came up with this small implementation of an Okapi BM25+ ranker using Ruby. I cooked it up in a very short time so it's very simple but I'm trying to think whether there's a better way to write it. In particular, I'm wondering if I should have something like a Ranker class -- intuitively I feel as though I should but...
As a self-learning project, I wrote an expression parser using the shunting yard algorithm in JavaScript. It's a larger part of what I plan to be a program for handling dice expressions in tabletop games, like 2d6 (2 six-sided dice). I know a parsing library would be a better fit, but this is also a self-learning proj...
I'd like some feedback for the code I wrote. I haven't programmed in C++ for two years. #include <string> #pragma once template <class T> class StackLinkedList { public: StackLinkedList() : m_List(nullptr), m_Size(0) {} ~StackLinkedList(); void push(const T& val); void pop(); T& top(); const T&...
Currently, I'm working on a game with directional movement influenced by the numpad. The player AI should intelligently pick a direction to move (so it's not entirely random, and can be somewhat coherent). For reference, this is the numpad I'm using: 7 | 8 | 9 - - - - - 4 | x | 6 - - - - - 1 | 2 | 3 (5 is ignored as m...
In order to become more familiar with Perl I have implemented a code kata from here. The task was to write a program which prints out all anagrams for a given word. I'd appreciate your review of my solution: get_anagrams.pl use strict; use warnings; require 'anagrams.pm'; use feature 'say'; my $number_of_arguments ...
I wrote a SEDE query to list all tag wikis with a body or an excerpt under a given number of characters. I've used this to find empty wikis or wikis with very little information. The tags can be sorted by post count to make choosing which to improve easier. This is one of the first times I've written anything in SQL, I...
I've always been bothered by the fact that there weren't any built-in functions that could replace multiple substrings of a string in Python, so I created this function. Essentially, you supply it with a string, a dictionary of keys (substrings) and values (replacements), and then a few additional options. def keymap_r...
Intro I've been a desktop dev for a long time now, and have never really had to monkey with web development until very recently. I have a need to do some custom integration with Survey Monkey's Api and as a "Hello World" I came up with this simple ASP.Net MVC app that queries Survey Monkey for a list of my surveys and ...
Problem: Question 8: * Mergesort is a type of sorting algorithm. It follows a naturally recursive procedure: Break the input list into equally-sized halves Recursively sort both halves Merge the sorted halves. Using your merge function from the previous question, implement mergesort. Challenge: Implement merge...
Here's my JavaScript file that queries data from Parse and then updates my Handlebars.js template to display them. The code has 3 async calls using a Promise. It still feel like it could be improved, specifically in the Promises results loop where I check which i value it is. I'm not guaranteed that the bar we're on in...
I have written a python function that outputs scatter plots using Matplotlib after processing the data a little. It works but it's painfully slow. I was wondering if anybody had any suggestions as to how I can improve the efficiency of this function or whether its slow just because it's processing a lot of data (a 30x4...
(NOTE: Python2 only) It is part of a separate application that allows users to interact very loosely with different databases and check for possible errors and make corrections. try: import Tkinter as tk except ImportError: import tkinter as tk import tkFont import pandas class EditorApp: def __init__(s...
hashdic.h -- suggested for direct include or copy paste to your project. #include "string.h" // memcpy/memcmp typedef __uint32_t u32; typedef __int8_t i8; typedef __uint8_t u8; u32 MurMur(const char* key, int count) { #define muR(x, r) (((x) << r) | ((x) >> (32 - r))) u32 seed = 0x8e96a8f2; int n = count ...
I'm teaching myself Ruby by rewriting PHP solutions, such as this one. The program should match words in a sentence with a dictionary of synonyms and then make combinations with them. dict = { 'hello' => ['hey', 'what\'s up'], 'name' => ['nomenclature', 'epithet'] } str = 'hello, my name is' class SentenceMak...
I have implemented the heap sort algorithm which passes my tests. Although, I would like to ask you if I can improve anything from readability to performance. import java.util.List; /** * Created by Orestis on 17/07/2015 */ public class HeapSort { public static <T extends Comparable<? super T>> void sort(List<...
I've written a piece of code which utilizes a for loop to iterate this array in JavaScript. This is my first attempt and I wonder if there is an optimal way to do this. Fiddle JavaScript var gifCollection = { "gifs": [ { "gifName" : "gif-One", "gifLink" : "http://buffalogrove.sat.iit.edu/thumb/turkey_karadeniz_re...
This program is for constructing a symbol table where a key is a word and value is the frequency of the word in a text file and finding the word with maximum frequency. I did it in two ways: First I used Java's inbuilt TreeMap, which uses a red-black tree as internal data structure. Then I made my own implementation o...
I'm using io.js. I have to read some files as a stream, process them with the same function, and join them back into a stream. I decided to create my own solution with Transform streams and PassThrough streams. "use strict"; let fs=require('fs'); let filePaths=['./tmp/h.txt','./tmp/s.txt']; let Stream = requi...
Challenge: Write a program that will clean up the words from extra numbers and symbols. Specifications: The first argument is a path to a file. Each line includes a test case with a list of words: letters are both lowercase and uppercase, and are mixed with extra symbols. Print the words separated by spaces in ...
I'm trying to create a modern template class for a generic observable: typedef int SUBSCRIPTION_ID; template<typename EventType, typename Event> class Subject2 { typedef struct { std::function<void(const Event&)> method; int id; } Callable2; public: ...
Given two numbers L and R, find the highest occurring digit in the prime numbers present between L and R (both inclusive). If multiple digits have the same highest frequency print the largest of them. If there are no prime no.s between L and R, print -1. How can I optimize this code further in terms of running ...
Input given is: Each test case contains two lines. The first line contains a single integer N (1 ≤ N ≤ 105), the number of persons playing the game. The second line contains N integers i(height) (1 ≤ hi ≤ 109) the height of the i-th person. They are numbered 1 to N starting from Druid. Output given is: For each test...
Specification: Given a string (e.g., the content of an article), print the estimated reading time by bucketizing time into increasingly large chunks in the form "5-10 min" or "48 min-2 hr". Notes: Distribution of time into buckets is arbitrary, to make it "look nice" for the default 5-minute time chunks. This is oka...
I have implemented a trie data structure in my way, though it is very similar to what major implementations I found but would like to get it reviewed by experts. I don't see the need to store character in TrieContainer class as position within the series reflects the character stored. Maybe I am missing something and a...
Having written C# for half a year now, I decided to take on a fairly complex first challenge for C++: the Is it simple or it is hard? challenge from Code Golf Stack Exchange. (This is only practice, not an entry to the contest; my code is ~2,500 bytes so honestly submitting it would be a joke.) The rules of the contest...
I am upgrading a traditional jQuery based app by converting a few parts of it into ReactJs components and use Socket.io for the data transfer medium. There are a few React components spread across the page. The React components will receive updates from the socket connection in their componentDidMount method. For examp...
I'm using Google Play Services for Location in my Android app. This is my first app so I'm not expecting that I have utilized everything perfectly. My app is to get GPS/Date and send to a server database. I was hoping to learn (and everything works so far) if I've used Google Play Services code properly. I can only tes...
Here's the challenge description: A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24 hour period is $10.00. Assume that no car parks for longer than...
I have been trying out some stuff using inheritance with classes in Python 3.4. In the code below, I use the super() call to return the __str__ from the parent class. Is it correct coding practice to save the information returned by the parent class method in a variable, concatenate the __str__ from the child class to ...
I'm writing a 2D game engine, and I just wrote the physics for it to handle collisions between AABBs and circles. It's on GitHub. Some of my worries are that my code isn't OOP, because I have to do a bit of casting. As well as that, the engine doesn't seem to be deterministic, but rather depends on when the update meth...
I'm a beginner to Java and programming in general and since I'm on a holiday to the US, I thought it would be a fun idea to write a program for converting Fahrenheit to Celsius and the other way around. I'm using WindowBuilder for the gui part so I suppose my code could use some improvement. The main thing that's both...
I'm very new to Java and programming and I've written a calculator to put all the theory I've learned so far into practice. I'm sure there is a lot of room for improvement since I really just started learning. Any big mistakes you more experienced programmers notice immediately? I'm especially intrigued in how you can ...
This is a challenge question from codeeval.com: Given a sequence, write a program to detect cycles within it. Input sample: Your program should accept as its first argument a path to a filename containing a sequence of numbers (space delimited). The file can have multiple such lines. E.g 2 0 6 3 1 6 3 1 6 3 1 3...
I'm not familiar with Python but want to provide a code snippet for an SO question about Dynamic Programming. The snippet should show the bottom-up approach of DP. The function isPowerOfTwo returns True if the given number n is a power of two otherwise False. The implementation uses a button-up table results. def isPo...
I made the following program in Haskell to solve Project Euler's problem 92. The program works (i.e. the solution it yields is correct), but it's not exactly the fastest in the world. The problem is: A number chain is created by continuously adding the square of the digits in a number to form a new number until it h...
This is my attempt on the Conway's "Game of Life" using C++. The code is functional but I am sure most aspects of the code might have been poorly constructed as I am fairly new at this. Please give any suggestions on how to improve my coding standards such as coding style, syntax, naming convention, error handling (alt...
I want to get the row of data that matches the user ID I have. Then I want to return that view to my view to be displayed in my textboxes for editing. Here's the action that gets called when a get request to sent to the controller: public ActionResult EditUserAccount() { UserAccountViewModel editUserAccoun...
Challenge: Write a program which prints all the permutations of a string in alphabetical order. Specifications: Your program should accept a file as its first argument. The file contains input strings, one per line. Print the permutations of the string separated by commas, in alphabetical order. We consider...
Write a program that manipulates two strings. The program inputs two strings (string1 and string2) and a character (char1) and an integer (position) to represent a character position within a string. The program will display the following: Whether string1 is less, greater or equal to string2 string1 in upper ca...
I'm a newcomer to C++, from C#. I wrote a program that prints an ASCII checkerboard with a side length of the number passed to it (link to original Code Golf question). stdafx.h #include "targetver.h" #include <stdio.h> #include <tchar.h> #include <iostream> #include <sstream> #include <string> Checkers.cpp #include...
I am a Java programmer trying to learn the ways of Swift. I coded a Hangman game in Xcode. I was wondering what I could improve, specifically whether I used delegation correctly and if there is anything I can do more elegantly in Swift. Title View Controller import UIKit @IBDesignable class TitleViewController: UIView...
This is a Sudoku solver program which uses backtracking. It is a problem from Online Judge and I made it work after some struggle, but it needs to be faster as I'm getting a Time Limit Exceeded message. The input format: .46...9.. .3.1..... .2..6..85 ...87.... 6...3...4 ....14... 79..5..3. .....2.4. ..2...61. And then...
Today, I made a calculator in JFrame. The code is a little long but I'm still a beginner to Java. In the future I'm going to do some improvements on it, but here it is right now. This is the meat of the calculator: @SuppressWarnings("unused") public class CalcSubClass extends JFrame { private static final long seri...
Here's a function that allows you to convert an array of functions into an object of functions where each property is set to the name of the function. var _ = require("underscore") function functionName(fn){ //http://stackoverflow.com/a/17923727/340688 if(fn.name) return fn.name return /^function\s+([\w\$]+)\s*\...
I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is available. I am using the C++14 standard. #pragma once #include<memory> #include<queue> #include<mutex> #include<condition_variable> namespace alpha { temp...
I started Python 2-3 months ago, but I really haven't done much since then, just little things. Yesterday, I wrote this simple quadratic equation solver. You can give \$a, b\$ and \$c\$ any value, but they must all be integers. I really want to know what you think about it. from math import sqrt while True: tr...
HackerRank Problem Statement I have to find the largest 'decent number' having N digits. A decent number has the following properties: 3, 5, or both as its digits. No other digit is allowed. Number of times 3 appears is divisible by 5. Number of times 5 appears is divisible by 3. My code works perfect, but, I am afra...
When the user clicks the first button ('Back to List' button), I redirect the user to the Employee List page. Can you please review this and suggest if there is any better way of achieving the same? @using (@Html.BeginForm("Edit", "Employee", FormMethod.Post, new { id = "editEmployeeForm" })) { <div class="form-gro...
I was interested in the Code Golf challange about simple text. The spec is: Write a function that from a text returns the non-common words. I assumed non clean input so I cleaned it before proceding. The 'foo' 'barz' list is for easier testing. You may uncomment the line to read from a file. LETTERS = ('a'..'z').to_a...
I have a few confusions about writing Java code, and I need some clarifications: import java.util.Scanner; public class NameAbbreviation { private static String fullName; private static Scanner nameInput; public NameAbbreviation(String name) { NameAbbreviation.fullName = name; } public char getInitialLetterOfF...
I am teaching a python class to some high school seniors. I was thinking of doing an "oracle" game where the computer would come up with a number, and the player would guess it. These are brand new coders, and I'll teach them what they need to know to get there, but is this a good first project? I have my code here as ...
I'm developing an algorithm that takes structured light patterns to determine 3D properties of objects. This class builds the structured light objects. It creates a buffered image, and based upon initialization parameters and the needed iteration step, manipulates the image to form a structured light pattern that wil...
It seems that when I program in Lisp my brain goes on auto pilot and I end up solving the problem somehow. I don't even think I just do and it works out. That said, this is some horrible Lisp code that was hacked together in about 20 mins, just to see if I could do it. The C++ program that this is based off was about 1...
I am a beginner to Java and am learning about using methods. I want to make a simple calculator that uses methods effectively. I would like a review of my program, and I would also like to know if there is a better way or shortcuts to write this program better. I would like to know at the same time about good coding st...
Here's an excerpt from my migration script for my database for the new "remember me" login option for my web application. Logging in with a valid username/password combination (authenticate_user) will generate a new token and a hash of it is stored in the tokens table. When authenticating with a token (authenticate_to...
Recently I posted the following solution on Stack Overflow and comments made me to rethink about the time complexity of my solution which I am sure is \$O(V+E)\$. Please suggest reasons as to why I am wrong. import java.util.*; class Triangle { static ArrayList<LinkedList<Integer>> g; static int []visited; static i...
Is there anything specifically bad here, or anything that I could improve? Wasted lines of code, things done in a more memory intensive way than it could be, etc. from random import* b = 10 a = randint(1,b) point = 1 x = 1 while x < 2: print("Guess a number between 1 and ", b) svar = int (input()) if svar =...