instruction
stringlengths
71
71.9k
I am starting to learn Rust and it seems pretty awesome but it's way different than any C based language. I want to know how can I make this code more idiomatic and also how can I improve my solution itself. Euler problem 5. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without an...
I'm trying to wrap my head around F#. I'd like your honest opinion about this simple game source code that I wrote. Rules are simple: Every player has soldiers and territory Player can recruit soldiers, gain territory or attack another player Player loses when he has no territory, wins when everybody else loses My ma...
This is part of a project to explore the Mandelbrot set. The code to graphically navigate the complex plane and allow the user to adjust the colormap and number of iterations is all written in Python, because that sort of user interface work is easiest in a scripting language. However, Python is not very good at inner ...
I was interesting in having a way to convert between dollars and cents without getting into floating point numbers and losing type safety. It's very easy to get confused when you're mixing numbers with concepts. Right now what I've built allows the following: dollars d{1}; cents c{100}; dollars d2{c}; dollars d3{2}; ...
I have been trying out AngularJS and developing a mobile application to test out its features and I wanted to see if I could somehow refactor to make my JSON response hopefully quicker in fetching the data. At the moment I have a search functionality that can display from 10 to 30.000 results and usually the applicatio...
I've created a small command-line 'Mastermind' game using Ruby. The intent of the project (aside from having fun in the build!) was to learn and emphasize OOP concepts and principles. The game has some simple AI in place. If the computer is the player making guesses, when they get the correct color in the correct inde...
This is a question about Project Euler number 2, a relatively easy one. The question is: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci seq...
I was attempting to remove items from an ArrayList while iterating through it, only to find out that Java doesn't like that. So I quickly wrote up a Delay that I could pass operations to so I could run them later. import java.util.HashSet; import java.util.Set; public class Delay { private Set<Runnable> tasks = n...
The following implementation of a lock-free fixed-size allocator is a follow-up of: Implementation of a lock-free fixed-sized allocator §1 - Introduction The purpose is self-learning of atomic types and synchronization. I would appreciate a review that does any of the following (from most important to least): Verific...
Recently, I added this class to my Spiky engine: its basic purpose is to allocate OpenGL-based objects (such as Textures, Shader, Fonts, ...) and then manage them by giving them an ID so the user can pull objects in and out. Any remarks, suggestions or other comments are welcome. Resourcemanager.h: #pragma once #inclu...
I am currently taking a compilers course where we are designing a compiler for C- (which is a subset of C). Our first step was the lexer and I have written that but I believe that it is not very "pythonic" and I was hoping someone could help me make it more "pythonic" as I believe doing this would make the future parts...
I was at CppCon last week and watched a clever talk about using ranges and calendars. This is just me trying to play around with the new technology. Step 1: dump out a calendar. Usage: cal <year> Output: January Sun Mon Tue Wed Thu Fri Sat 01 02 03 04 05 06 07 08 09 10 11 ...
This is a token generating library for Go that runs on top of Redis. I'm using it as part of a larger projects. The library needs to be able to generate and validate tokens and return the associated user IDs. If you see any bugs or obvious glaring issues, please let me know. // auth project auth.go package token impor...
I have a small gem that I've been maintaining. This gem provides a simple way to do translation using an alternative Google API. I've been working with Java last year and recently did some refactoring on that gem, but I don't think it's Rubyist enough. require_relative 'extractor' require_relative 'requester' require_r...
I have a function that compares bits from a binary representation string and a chunk of memory and returns true if they are equal. This is the function (which works as expected): I'll explain with comments what some external methods are supposed to do, accept that they work as expected for the sake of this question. si...
I'm trying to implement an Hmac in T-SQL using this question as an guide. Please critique this: create function dbo.Hmac ( @key varbinary(8000) , @message varbinary(7936) ) returns table with schemabinding as return ( select HashBytes('SHA2_256', Pads.o + HashBytes('SHA2_256', Pads.i + @message)) as [Hash]...
This converts from a number to a Spanish word for example : 100 => cien 200 => doscientos I used a divide-and-conquer approach: Constants: package numberTranslator; import java.util.Arrays; import java.util.Comparator; public enum ExSpanishSufix { ciento("s",2), mil("",3), millon("es",6), bill...
Here is some code which loops through an area in a spreadsheet and executes the code based on the condition that the source cells do not contain the value "(blank)". The code works, but it's very inefficient to run nested if statements in this manner. I've tried to have a go at making it more efficient in the long run...
I've just set up a bit of code to try and make things neater, but all I've really done, is add a whole bunch of nested if statements: public void Copy(Copy copyType) { FrmProjectChooser frm = null; if (copyType.HasFlag(Copy.Single)) { if (copyType.HasFlag(Copy.Estimations) && copyType.HasFlag(Co...
I have two classes in this project; Category: This will be responsible to hold the latest information. public class Om_Category { public Int32 CategoryID { get; set; } public String CategoryName { get; set; } public String CategorySanitized { get; set; } public Boolean IsActive { get; set; } public ...
See the next iteration. I have this C++ implementation of bottom-up mergesort (mergesort using iteration instead of recursion): bottom_up_mergesort.h: #ifndef BOTTOM_UP_MERGESORT_H #define BOTTOM_UP_MERGESORT_H #include <algorithm> #include <iterator> template <class RandomIt, class Compare> class BottomUpMergesort {...
For example, if I have the following data table layout: dt.Columns.Add("ticketid", typeof(Int32)); dt.Columns.Add("createtime", typeof(DateTime)); dt.Columns.Add("creator", typeof(string)); dt.Columns.Add("ticketText", typeof(string)); If I want to add a new entry I need to make sure that there exists none already tha...
I wrote the following code using jQuery to create a WebAlert instead of using the alert() function from jQuery: (function($){ $.fn.WebAlert = function(msg) { // If WebAlert is Availble -> First Remove this-> callback = Yes -> Now Create New WebAlert if ($('.WebAlert_Area').length) { $(t...
What changes do you recommend from the perspective of structure, logic, etc? # Checks if, for example, "2" is an integer "in disguise". class String def is_integer? to_i.to_s == self end end # Main TicTacToe game class class Game def initialize @board = (1..9).to_a @running = true end def displa...
I have some data that needs to bind to my view depending on the user selection. Example: changing the list of states in a dropdown depending on the selected country. My understanding is, there are two ways to do this: Have a global JS variable, say, var model, which has a property, "states". This contains all the rele...
Problem Statement You are given a tree (a simple connected graph with no cycles). You have to remove as many edges from the tree as possible to obtain a forest with the condition that : Each connected component of the forest should contain an even number of vertices. To accomplish this, you will remove some edges from...
I started to learn data structures. How can I improve my implementation? For example, I don't now how to push 0 or how to realize my own resize. public class Stack: IStack { private int[] s; public Stack(int N) { s = new int[N]; } public void push(int x) { int i = 0; wh...
This is the working code snippet to download file from a URL. I want to know if there is any optimization I can do to download the file faster. File localFile = new File(localUrl) localFile.withOutputStream { out -> URLConnection url = new URL(remoteUrl).openConnection() def remoteAuth = "Basic " + "${username}...
I have drawn a box within my JPanel so that it resizes appropriately when the JFrame is resized. This is how I implement it: public void drawBox(Graphics g){ int num1 = getWidth()/4, num2 = getHeight()/4, num3 = getWidth() - num1, num4 = getHeight() - num2; g.drawLine(num1, num2, num3, num2); ...
I'm building a template [Process-Tracker] spreadsheet. The idea is that, for any process where we can define what steps should occur in what order (and preferably, how far apart), there will be a spreadsheet with buttons for: Adding a new [Item] to be tracked Updating the List of [Items] and their progress and a li...
I am implementing a modal dialog in my Android application, allowing the user to either pick a player from a list, or create one with predefined traits. PlayerPickerListener public interface PlayerPickerListener { Activity getActivity(); void playerCreated(); } PlayerPicker (extends Dialog) public PlayerPicke...
I am writing code that reads data from a DB, where boolean values are stored as 0/1 nullable integers. I decided to write a simple function to encapsulate the logic which converts the integer values to boolean. Thing is, I sometimes need to regard the db null value as boolean false, and sometimes just as null. So I've ...
I wrote a little code for outputting to csv. It takes a list object named outtext and saves multiple .csv files. Each csv file contains cutoff elements of the list (except for the last), where cutoff is a specified number of elements/lines. This is useful when the user has to avoid writing to too large files (i.e. GitH...
This class is the first of an open source project I just (a couple of days ago) started. The projects is meant to simulate circuits (logic gates and stuff) and this class is meant to manage pins. I'm developing everything following the Observer design pattern. Could you take a look at the code and tell me anything you ...
Three days ago I wrote about a Java Dice Roller I wrote. I've now added a GUI to that program. Here it is: DiceRollerGUI.java: package com.egroegnosbig.dicerollergui; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class DiceRollerGUI { static JFrame frameOne = new JFrame("Dice Roller"); ...
Context Info I coded up a program that maps an executable file(.exe .dll mainly) to the program's memory space which allows for easier extraction of the PE header info. I extract the information by simply casting a structure of a certain header to a memory location of the mapped file. What I'm asking for Readability an...
I am developing a network application and therefor need to specify the packets I want to send. I have a basic interfaces class and one for the packets that implement them. public interface IPacket { } public interface IServerPacket : IPacket { } public interface IServerChatPacket : IServerPacket { ServerChatPacke...
I have created a simple component in Swing that lets me place other components such as buttons on top of each other. They fill their parent horizontally but not vertically, which is exactly as I want it. I called this parent component VerticalPanel and this is how it looks: I can't shake the feeling though that there ...
I am adding classes to some legacy code and wondering if there is a more appropriate way to be setting the properties. I am also trying to understand the trade offs, if there is another way to do this. I'm trying to find out if there is a better way to do this? If there is, why? If there isn't, why is this better than ...
I'm studying MOOC in HTML, CSS and Javascript. And did weekly assignment task which was reviewed by 5 random course learners (I reviewed 5 other student's assignments as well). Unfortunately, I received like mere 3-5 words-long reviews, though all are positive. Could anybody, please have a look at my code and point out...
This runs as is, but I'm looking for an alternative way to write it. import java.util.Scanner; public class StateBirdAndFlowerProgram { public static void main(String args[]) { // Begin Scanner for user input later on Scanner input = new Scanner( System.in ); //Begin array of information ...
As part of a larger project to generate a website with a personal list of publications, I implemented a parser for BibTeX files. The entry point is the parseFile method in PublicationListParser. This method scans the file for entries (and tags - a custom extension specific to my project). Each entry is read into a Stri...
Lindenmayer Systems or L-systems are fractals that can be constructed by applying replacement rules to a string for a certain amount of iterations. For example: Axiom (start): "FX" Rules: X -> "X+YF+" Y -> "-FX-Y" Iteration 0: FX Iteration 1: FX+YF+ Iteration 2: FX+YF++-FX-YF+ Iteration 3: FX+YF++-FX-YF++-FX+YF...
I am trying to convert this velocity into another 2 dimensional vector at some specified angle: float maximumVelocity = 1.5f; float angleInDegrees = 23f; Vector2 actualVelocityAs2DimensionalVector = {?,?} At first, I was going to take 1.5, and rotate it after converting the degrees to radians, like so: double radians ...
Search in a 2D array to check if there is a column or a row in the 2D Array thats contains all the word “error”, if yes return the index of that row or column else return 0; Exception: if the row index equals the column index then it does not matter if contains the word "error" or not. FYI, n is the size of 2D array (...
I'm a student learning Python, I made this calculator that will tell you the tuition for the next 5 years at an increase of 3% per year. How can I improve on this and did I do anything that isn't best practice? To revise my new version, Python tuition calculator 2.0 inState = 10000 outState = 24000 profGrad = 40000 ye...
Being a C++ developer, but also having been influenced by functional languages, I strongly believe that const should be the default for the vast majority of all variables when they are created and passed as arguments. C++ does provide a const keyword, but it is not "by default". Many people have asked questions about t...
I have written this function to perform a binary search on an array, given begin/end indices and a value to look for in the supplied array: def binarySearch(array, beginIndex, endIndex, value): while (beginIndex < endIndex): mid = (beginIndex + endIndex) / 2 if array[mid] < value: beginI...
I'm working on a program to handle simplifying square roots (radicals). My biggest issue is, in order to stay precise, I can't have input any longer than 15 digits. Whenever a number is longer than 15 digits, it loses precision when converted to double when I try to determine if the square is actually a factor. I reali...
You're a blind adventurer (bad luck eh). To go through the maze that'll lead you to freedom, you must first find the maze's wall, then follow this wall to find the maze's entry. Then, to get an idea about the size of the maze, you want to see how large is the said entry, so you walk until you touch another wall, which ...
I have written a simple binary tree using structures and a couple of functions in order to add, search, find the minimum and maximum values, remove a node as well as destroy the node, the problem is that I have been using recursion and dealing with it in the same way and I am having a hard time trying to comprehend if ...
I have converted some code in Python into its Haskell equivalent. Python implementation: def final_codes( bit_lengths, next_code ): tree_code = [] for i in range(len(bit_lengths)): tree_code.append( next_code[ bit_lengths[i] ] ) next_code[bit_lengths[i]] += 1 return tree_code #Inputs: bit...
Please let me know if there is any other optimal way of doing this. public class StringDistance { public static void main(String[] args) { int i, j, m, n, temp, tracker; int[][] d = new int[100][100]; String s = "kittenede"; String t = "sitting"; char u[] = s.toCharArray(); char v[] = t.toCh...
How can I improve the speed of this path finder A* implementation? #include "stdafx.h" #include <Windows.h> #include <vector> #include <algorithm> struct PathFinderNode { public: short X, Y; int H; bool IsNull = true; PathFinderNode(short x, short y, int h) : X(x), Y(y), H(h) { IsN...
I create a data collection system that has a tree-like structure built on the similarity to the pattern of the factory, and I have the difficulty in working with this structure, more stingrays lot of code to find the element opredelnie. public interface ITag : IRegister { string Name { get; set; } string Sy...
Problem Statement You are given time in AM/PM format. Convert this into a 24 hour format. Note Midnight is \$ 12:00:00AM \$ or \$ 00:00:00 \$ and 12 Noon is \$ 12:00:00PM. \$ Input Format Input consists of time in the AM/PM format i.e. hh:mm:ssAM or hh:mm:ssPM where \$ 01 \le hh \le 12 \$, \$ 00 \le mm \le 5...
I've written a simple lock-free multi-consumer/-producer FIFO queue. It's supposed to work like this: At any time many consumers may read from it At any time multiple producers can write to it, added elements will be made available later After write modification is finished, we call makePushedElementsAvailable(), so t...
For speed we sometimes return response to consumer before state is saved in DB. Sometimes (Mostly for our automated consumers) this can break because the want to make actions on the saved data before it is saved. I wrote this little helper public async Task<TEntity> GetWithRetry<TEntity>(Expression<Func<TEntity, bool>>...
I created this code while solving the Euler Project problem 83. In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right, by moving left, right, up, and down, is indicated in bold red and is equal to 2297. Find the minimal path sum, in matrix.txt (right click and "Save Link/Targe...
Introduction I have a spreadsheet in Excel, looking like this: I collect and sort the values in the column labelled "Antal dagar venting", based on the values in the columns "Nivå 1" and "Nivå 2". My current code for collecting this data is: In a class-module: Option Explicit Private pAntalDagar As Long Private pDelå...
I have this tiny library for implementing simple command line languages. It is not flexible enough for handling actual programming languages, but hopefully it may help implementing simpler REPL's faster/cleaner. CommandParser.java: package net.coderodde.commandparser; import java.util.ArrayList; import java.util.Colle...
This is a complete login activity class. What I need reviewed: I need simplify my code as much as possible. Is it wise to use the butterknife library, or is the normal way better? Hide keyboard when user touches out away from edit text, and when selecting "login." Best practise for volley library. Should I use it indi...
I am reading from a Networkstream, and the response code is: private async void GetResponse(NetworkStream stream) { while (true) { var readBuffer = new byte[4096]; var asyncReader = await stream.ReadAsync(readBuffer, 0, readBuffer.Length); var result = RemoveBytes(readBuffer, new byte[] { 130, 119, 126,...
Here is my program that calculates tuition cost for the next five years. I have had some review on it so far, but I am seeking more. Please keep in mind I am new to programming, so I may require a few extra steps to understand something. Thanks in advance! Version 1.0 is here RESIDENCY_COST = { "I":...
I have written code based on the Greedy Algorithm. The example can be found here. Problem: Make a change of a given amount using the smallest possible number of coins. Coins available are: dollars (100 cents) quarters (25 cents) dimes (10 cents) nickels (5 cents) pennies (1 cent) This outputs an array of coins: <?p...
I commented on a question and blindly asserted that a Stack based on a linked list was rather elegant (see here) I haven't ever written a Stack in C# so I thought I should back up my claim: public class Stack<T> : IEnumerable<T> { protected class StorageNode { public T Value { get; set; } publi...
I am finished with my implementation of PUB/SUB or Observer pattern, however I just want to see any ways that I may be able to improve this pattern. I wanted to be able to use the typical PubSub pattern except add performance enhancements by using the new key word to instantiate each new instance of a PubSub object, as...
I wrote a method called bringToFront, which moves an element a to the first position of a sequence seq if it exists; otherwise, seq is returned. If a appears in the sequence more than once, only the first occurrence is moved. Sample input/output: List(1, 2, 3, 4, 3).bringToFront(1) // List(1, 2, 3, 4, 3) List(1, 2,...
I have a var af_button which is a button on UI. It can be either selected or deselected, so in that case I have four possibilities, which I have implemented. I don't like this implementation, so what would be a more pythonic way of implementing this? af_button = squishtest.waitForObject("{text='AF' type='QPushButton' u...
See the previous iteration. What's new: endianness is now handled more gracefully (only one endianness check, and convertion if need be) and music is more funky. #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <stdio.h> /**************************************************** * From http://stackove...
The following function takes an object of items in the format of { 'complex-key': 'value', // Repeat } where complex-key is a key delimited by dots, and returns an object in the form of a tree, where you can access the value by traversing the parts of the complex keys as keys in the object (see examples below). Th...
I'm trying to achieve a thin controller, and I started out with a thin controller but over time as the project has progressed the controller has got more complex. Could you please review the following code and let me know if the controller is still considered a thin controller or whether any of the code should be moved...
I often find myself writing LINQ queries like this. I end up testing for Null and zero-counts pretty often, and the code sprawls out to be something like the following: // GET: api/CustomBehaviours public IEnumerable<CustomBehaviour> Get(int? orgID = null, long? userID = null) { using (PAMDatabase db = new PAMData...
I have 2 values \$N\$ and \$K\$ (\$1 \le K \lt N \le 1.000\$), where \$N\$ indicates a number of values (\$0 \le \text{value}2 \le ... \le \text{value}N \le 1,000,000\$) to be read from input. The first value isn't on the input and will always be 0. All \$N\$ values need to be organized on at most \$K\$ groups where th...
I have a DataFrame of data from a survey that was repeated over several years, asking people about their income and how much money they had in savings. For simplicity, let's pretend it looks like this: In [1]: nominal.head() Out[1]: year1 ... year11 income1 ... income11 savings1 ... savings11 0 1992 ... NaN...
When answering python tuition calculator v2, I got a little carried away, and started building a print_table() function which I don't like the resulting code for, and I would love guidance into improving (and/or enhancing) my code. My ambitions were as follows: Have a print_table() with as little formatting as possibl...
I am writing a CAD program plug-in which is used to batch translate a list of CAD files stored in a text file. After each individual CAD file is successfully processed I want to remove the CAD file from the list. The reason for doing this is because the CAD program may crash while translating the file, and I want to be...
Project Euler #19 asks: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? I'm hoping I wasn't too off course from the spirit of the exercise by making use of my favorite libraries: pandas. import pandas as pd rng = pd.date_range(start='1/1/1901', end='12/31/200...
I created a function to get the hash value of a file. Normally the output is 3 lines. My function does 3 things: extracts the hash value removes the spaces in between the hash value prints hash value Here is the output when using CertUtil -hashfile FILENAME.EXE SHA1 SHA1 hash of file FILENAME.EXE: XX XX XX XX XX XX ...
Originally, I was going to post a question about how to condense four repetitive functions into a single function, but I wound up figuring it out myself before I could even post it. However, the original idea that I had was to break down some of the repetitive sections into their own function and use those new sub-func...
I wrote a program that records how many times 2 fair dice need to be rolled to match the probabilities for each result that we should expect. I think it works but I'm wondering if there's a more resource-friendly way to solve this problem. import random expected = [0.0, 0.0, 0.028, 0.056, 0.083, 0.111, 0.139...
This is a follow-up of Comparing random number of bits. I have a function that compares bits from a binary representation string and a chunk of memory and returns true if they are equal. This is the function (which works as expected): I'll explain with comments what some external methods are supposed to do, accept that...
I need to check if there are any abbreviation of New Brunswick province in the address. Acceptable abbreviations are: "NB", "N.B.", "N-B", "N.-B." and any combination of upper-lower cases. It shouldn't be a part of another word, hence the "\b" separators. The hardest part was checking the dot in the end, because of the...
This code is for dispatching and handling certain events from GitHub (and also Bitbucket). Things like pushes, issues, etc. can be handled by this system, and strongly-typed objects will be returned. I left the XML docs out of all these, as somewhere from 2/3 to 3/4 of the files were XML docs. (We all know how much I l...
I recently read a really interesting post on adding functional pattern matching to C#. Here's a quick and dirty implementation using delegates and dictionaries. Right now, I require that Match return an object of type TReturn. Is there any way I can easily extend my current implementation to be void (i.e. Match is not...
I've implemented a functional-style list structure in C++. It seems okay so far, and doing custom allocation for list nodes improves performance greatly. I omitted that part here for simplicity. The mutability of the list is intentional, as the application I'm thinking of requires a lot of state updates. I wrote this c...
I've been working on a small game as a hobby, and I've been having trouble finding a good way to control the state of the game that could scale easily. I couldn't find a solution that I felt was correct, so I wrote my own. I created an abstract base class State that has an abstract function update that takes and retur...
I need to query MongoDB and check if an item exists or not: class MongoDBPipeline(object): def __init__(self): connection = pymongo.MongoClient( settings['MONGODB_SERVER'], settings['MONGODB_PORT'] ) db = connection[settings['MONGODB_DB']] self.collection = d...
This is notepad that works with list of files (pages w/e) that can be edited (list). You can access each file separately and edit/view it too (rewrite, append, read). Here's my implementation of it. I have 2 classes that resemble menus (list of files, and file itself) both are inherited from interface and 1 class that ...
This is a TCP server I am currently working on. It is accessed through telnet (I know it isn't secure, its just a project for uni). The server is programmed in Python 3. I am currently trying to figure out how to implement thread locking in my program, how to create user sessions, and the best way to implement a set of...
When building a working example of a class, I ended up with the following statements which is violating the 80 character rule of PEP8. The code was inside a method inside a class. Code excerpt is from PrettyTable.__init__() and PrettyTable.add_column() in my answer to Using changeable column formatting to display table...
I have a simple socket.io server written in node. Everything is working just fine, however I am curious whether what I am doing is acceptable. I am especially interested in this line listOfMessages = listOfMessages.slice(-1000); Essentially what I am doing is each time a new user connects, I resize the array and send ...
I just wrote a simple B-Tree insertion implementation, and was wondering if anyone can comment / critique on code style, readability, maintainability etc. I tested it with a few small test cases and as far as I know, there are no obvious bugs in this. I'm making extensive use of shared_ptr. I contemplated using unique_...
This is a simple web form handler in PHP that sends a completely filled web form to a email. I see lots of repeating code. What is the best way to reduce repetition? Is my way of checking for fields being empty good? The "empty()" method seems to also treat "0", "0.0" and similar values as empty. Am I doing something ...
Revision 1. This revision on GitHub In addition to the solution itself, I wrote tests for all the possible cases. It seems you have verified all execution paths are covered. You are right. I only covered all execution paths in the class AvlTree In this revision: No Android code style. In fact, it's much easier to...
To make a long story short, I must revive my Forth. It is rusty; last time I did anything serious in Forth was 30 years ago (man, I am old). As an exercise, I translated an STL-like implementation of qsort. It works (if you want to test it, install gforth). It performs well comparing to SDCC-compiled native C (I don't ...
I recently wrote a code in online recruitment test. It was very good. With each question, there were associated space and time limits check. If our code executed correctly within both limits, only then we were given full marks otherwise 0. Input: String consisting of ASCII characters. Output: True if the string is bala...
I'm calculating all possible solutions for a given Sudoku board with at least 17 values. My approach is a basic backtracking approach and it works. protected void calculateSolutions(final SudokuBoard input) { if (input.getFilledCells() == 81) { addSolution(input); return; } for (int grid =...
The code works but with an increase in data it's now slower so needs a tweak so looking for pointers. 'To import into Module Dim sConnString As String = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("SQL").ConnectionString Dim vDateNow As Date = Now() vDateNow = vDateNow.ToString(...
I am new to Python. I have built a model with randomforest in python. But I think my code is not optimized. Please look into my code and suggest if I have deviated from best practices. Overview about the data I have: The data has response columns and predictor columns. Also there is a column 'TestOrTrainingDataRandom' ...