instruction stringlengths 71 71.9k |
|---|
This is a simple Bash script to provide menu driven manuals and standard operating procedures.
Sops and mans with the extension .sopman.txt will be loaded.
The file motd is required, it is intended to prompt the user with a banner containing useful and or up to date information.
Use the markup +color+ to colorize a li... |
As a beginner to C++, I wanted to make something using what I was learning, so I did this to learn about arrays. This implements the Sieve of Eratosthenes to find the primes up to a limit.
I didn't use std::vector on purpose because I didn't really know how to use pointers. I want to know if I am using the pointers cor... |
I implemented the Caesar Cipher in Java, and I wanted to practice MVC.
This is my model:
package biz.tugay.caesarcipher;
import java.util.Locale;
/*
Encyrpts a clear text using Caeser Cipher (https://en.wikipedia.org/wiki/Caesar_cipher)
with given shift amount.
Provided shift amount (i.e. key) must be a ... |
I don't know how could I write smarter/more elegant code for the add function , it just seems so meaty and hard to read.
This trie only stores words and marks their end with a bool.
type trie = Node of bool * (char * trie) list
let empty = Node (false, [])
let rec add w tr = match w, tr with
| [], Node (_, lvl_l... |
I recently began learning Clojure for fun, and after completing the koans, I decide that project Euler would provide my next challenge. Here is the problem statement:
(If someone knows how to put this in spolier tags with out breaking the formatting, please feel free to edit or comment and let me know how to fix it.)
... |
This is one of my first experiences with C#. I'm trying to learn and as can be seen, I need some obvious help. I know it's only an example but I'd like to start with best practices from the beginning. This was my first experience with public and private methods.
What can I do to improve my code and why is the change be... |
Depending on how you count, this is my first Go program. I'm trying to read a CSV into a two-dimensional array of some numeric type, and then print it out.
(I want to use this to read "edge weights" to build a Graph; that is my next mission, unrelated to the code below.)
So the code below works. But particularly as I'm... |
I just started learning Rust, and this is my solution to a problem from Atcoder's Regular Contest #067, D - Walk and Teleport.
The problem can be summarized as follows:
There are N towns in a line, and you are about to visit all of them.
Town i is located at the point with coordinate xi.
You can travel either by wal... |
My code is working fine to save a file with FileChoser. But how can I make it accurate and perfect when a user doesn't select an absolute path for a file and closes it abruptly?
public class HTMLtoPDF {
@SuppressWarnings("deprecation")
public void convertHtmlToPdf() {
try {
FileChooser fil... |
I want to retrieve the row if any of the 3 integer field in a row is greater than zero. All the field has default value of zero.
Which of the following query is better?
-- Query 1
SELECT * FROM my_table WHERE number_A > 0 OR number_B > 0 OR number_C > 0
-- Query 2
SELECT * FROM my_table WHERE (number_A + number_B + nu... |
The output of the function is as desired. When Forex opens at Sunday, first candle is annotated with 1 and the number increments with every new candle, till weekend, when the imaginary counter is reset.
I am aware of those risks (it is solved elsewhere):
passed datetime must be python datetime
time must be in GMT
My... |
I need to write a function which selects a run of repeated characters from the start of a string, with the run comprising at most nine characters.
chomp :: String -> String
chomp str = takeWhile (== head str) str
munch :: String -> String
munch = take 9 . chomp
runs :: String -> [String]
runs string = extract string... |
Here's the problem: https://www.codechef.com/ZCOPRAC/problems/ZCO14001
Problem statement(modified) from CodeChef:
You are playing a video game in which several stacks of boxes are lined up on the floor, with a crane on top to rearrange the boxes, as shown in the picture below.
The crane supports the following commands... |
It's a function to split the coordinates to some small blocks. For example, some country has a coordinates of north-east and south-west, two diagonals.
If I set the interval to 0.05, it will returns all the coordinates with an interval of 0.05 (or some very close value).
Note: you could regard the blocks as square, and... |
In connection with a job application I have to progress the following task:
Create a dynamic growing pyramid. The structure has to be sorted
alphabetically (concerning the inserted values).
It has to have the following controls:
Textbox for inserting texts (used by the blocks of the pyramid).
Button which ad... |
Take in incomplete user input street addresses, clean it, segregate based on word count and run it into Google maps places api and output completed & standardised addresses based on Json object retrieved.
Looking for specific input on:
Does this code work fine at your end (as it works at mine)- i.e., does it do what i... |
This function checks if the cell of a Scrabble board is a double letter bonus. It has a 23 cyclomatic complexity, which is higher than the threshold of 20. I don't know how to do it another way, I think that this is the only way to do it. Here is my function :
checkDoubleLetterCell(row: number, column: number): boolean... |
My task:
Body Mass Index (BMI) is a measure of health based on height and weight. It can be calculated by taking your weight in kilograms and dividing it by the square of your height in meters.
Write a java code to let the user enter weight, feet, and inches and interpret the users BMI.
My code:
//import scanner
imp... |
So I've just finished doing a coding challenge that involved drawing a fractal tree. Instead of doing it recursively(which is what I did initially but it proved to be to slow for branches greater than 2^10), I went for a more iterative solution and this is what I got after everything was said and done.
import numpy as ... |
The end user will be able to see a list of staff that works at a church. The staff consists of 5 individuals with 5 different position titles (Minister, Pastor, etc.). This data is pulled from Firebase.
My code "works" correctly but I keep coming back to it with ambitions of making it better because I do not like my if... |
Today I tackled this coding challenge:
Given a circular linked list, implement a method to delete its head node. Return the list's new head node.
I would appreciate any feedback.
public ListNode deleteAtHead(ListNode head) {
if(head == null){
return head;
}
ListNode temp = head;
while(te... |
I'm relatively new to coding and was wondering if anyone could review my code? I'm trying to get my head around the concepts of Object-oriented programming in particular. This is an implementation of Conway's Game of Life I was assigned and any constructive feedback would be great. It works fine but I'd like to try and... |
Have a working version of MySQL implementation of ThorsSQL library done.
If you want to check it out you can find the whole thing on github ThorsSQL.
This is a follow on to previous code Reviews:
Part 3: Layer 5 Req/Resp
Part 3: Layer 4
Part 3: Layer 3
Part 3: Layer 2
Part 3: Layer 1
Part 2
Part 1
The documentation for... |
I've written a class that allows me to easily create sprites on the screen, and then do things like: setting an image or an animation; move the sprite as a platformer or as a top down game; and test for many things like collision and orientation. So far I've found this to be very useful, and it has made it really easy ... |
I need to know if the following lines of code represent a valid implementation of Strategy Pattern in Java 8:
public interface AIStrategy {
void play();
}
public class AIPlayer {
private AIStrategy aiStrategy;
public AIPlayer() {
}
public AIPlayer(AIStrategy aiStrategy) {
this.aiStrate... |
Have a working version of MySQL implementation of ThorsSQL library done.
If you want to check it out you can find the whole thing on github ThorsSQL.
This is a follow on to previous code Reviews:
Part 3: Layer 4
Part 3: Layer 3
Part 3: Layer 2
Part 3: Layer 1
Part 2
Part 1
The documentation for these classes is here:
P... |
I'm generating a multi-row insert/update with the MySQLdb/MySQL-python module from lists of data rows and field names. For reference, see the executemany() example in the docs.
You can see some revised code on GitHub.
def upsert(db,table,fields,object_list):
cursor = db.cursor();
placeholders = ["%s" for x in ... |
I don't know if I'm doing this correctly, using OpenCL and SFML together but I know a little about both so I decided to make something with them. I've already tried implementing a pure C++ and SFML version of a Mandelbrot Set generator but it ran for 50 minutes and generated a 1000*1000 not sufficiently detailed image.... |
This is my second project. I've wanted to create a little client for my local database, so I can get familiar with databases. I've created a client for one db table using JavaFX. I want to know what I need to change especially in terms of designing methods and classes, since I feel like it is pretty horrible, but I jus... |
Problem statement
Description:
Meera teaches a class of n students, and every day in her classroom is
an adventure. Today is drawing day!
The students are sitting around
a round table, and they are numbered from \$1\$ to \$n\$ in the clockwise
direction. This means that the students are numbered \$1,2,3,...,n-... |
Recently, I've solved the "01 Matrix" LeetCode problem and the solution was accepted by the LeetCode OJ:
Given a matrix consists of 0 and 1, find the distance of the nearest 0
for each cell.
The distance between two adjacent cells is 1.
Example:
Input:
0 0 0
0 1 0
1 1 1
Output:
0 0 0
0 1 0
1 2 1
Note:
The number... |
Here is my source code which group duplicate files together, written in Python 2.7. Any advice on smarter ideas to group duplicate files together more efficient, it will be great. Any general advice on code bugs and code style are also appreciated.
Problem statement:
I am given a list of files e.g. ["1.txt", "2.txt", "... |
I have put together a small VBScript to gather a bunch of information and email at scheduled intervals, so that one day, should it happen, and my computers are stolen, I may be able to provide relevant and accurate information to the authorities to expedite their return.
I wanted to share what I have done in an effort ... |
This is my attempt at writing a guessing game. Where can I improve my code to make it more succinct?
Link to Revision 1 (Guess a number between 1 and 100 (revision 1))
//Program.CS
namespace MidPointGame
{
class Program
{
static void Main(string[] args)
{
RunTheGame game = new RunThe... |
Here is the function I have come up with. Any improvements possible?
E.g LeetCode -> rotate by 2 -> deLeetCo
public static String rotateAntiClockWise(String s, int offset){
int i = offset%s.length();
StringBuffer prefix = new StringBuffer();
for(int j=0;j<i;j++){
prefix.append(s.charAt(s.length()-1-... |
I made a generic tree class, which is meant to be useful for generating random sequences of elements, for example, sentences (sequences of strings).
Also, I have some concernings regarding the tree's code:
Is random_tree a suitable name for the class?
Is the variadic add_children method implemented correctly?
Code:
r... |
Lately, I've been working on the Euler projects. I just started coding in C++ and could really use some feedback. Basically, I wrote a program to calculate the factorial of any number between 1 and 100 (I have not tested it above 100).
I looked into the Boost library, but it seemed a little bit to easy, so I wrote some... |
I have this PowerShell code that loops through Excel files in a specified directory; references a list of known passwords to find the correct one; and then opens, decrypts, and saves that file to a new directory. This currently processes ~40 workbooks in roughly 5 minutes, which is still longer than I'd like (but bette... |
I've created a dynamic radar chart which allows manipulation of points by clicking. My code works, but I'm sure the large amount of if.. else if statements can be processed in a loop, because it is clearly a repetition.
I thought about how I could use a loop to do it, but couldn't figure it out because of the way the ... |
I'm using the openweathermap API to get weather forecast data. I want to make sure that the forecast values are at minimum 2 hours in the future. The API is providing the forecast in 3 hour steps, so I need to make sure that the weather data are in the future.
Here is an example response provided by openweathermap API:... |
I have implemented a simple version of Karger's min cut algorithm. The algorithm takes a graph and repeatedly contracts randomly selected edges until only two nodes are left. By repeating this procedure n times and remembering the smallest number of edges between the remaining two nodes over the \$n\$ trials, the algor... |
I was told in an interview to write a program for implementing merge sort on the concept of divide-and-conquer.
var myGlobalArray = undefined;
myGlobalArray = [8,4,17,2,1,32];
example01(myGlobalArray);
myGlobalArray = [48,14,17,2,11,132];
example01(myGlobalArray);
myGlobalArray = [45,14,5,2,1,12];
example01(myGlobal... |
For today, I tackled this coding challenge question:
Given a binary tree, write a method to recursively traverse the tree in the preorder manner. Mark a node as visited by adding its data to the list - Arraylist preorderedList
ArrayList<Integer> preorderedList = new ArrayList<Integer>();
public void preorder(TreeNode ... |
This is an interactive script for selecting and reading the manual pages from the terminal command line. This is the 3rd version of this script. If you want to see the evolution of this script, follow the links for version 1 and version 2.
In previous versions of this script I had mentioned wanting to make a database o... |
I am currently working on a NodeJS server, and am switching from callbacks to promises.
Here's an example of my code:
var record = req.body.record;
var schoolId = req.body.schoolId;
var promise = BusController.addBus(record,schoolId);
promise.then(function(){
return res.json({status:"success", message : "bus succe... |
I have a list of objects. These objects have a processname, amount and a date. I need every object to have all dates (if it doesnt exist add a new one with amount 0). So if I have 2 processnames: 'Inflate' and 'Deflate' and they have different dates: 'Inflate':12-01-2017 and 'Deflate': 13-01-2017. I need them to have t... |
I am learning Rust and I decided to make a prime sieve program. It works and has comparable performance to my equivalent C program.
I am new to Rust so I would like some feedback on my code. In particular, is my code in the correct Rust style?
I am aware of some changes to make the algorithm faster, but I would prefer ... |
Works fine. Not looking for any specific input.
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 10000
void delete_str(char *s1, char *s2){
for(int i = 0; *(s1+i) != '\0'; ++i){
for(int j = 0; *(s2+j) != '\0'; ++j){
if(*(s1+i) == *(s2+j)){
for(int n = i; *(s1+n) != '\0';... |
#include <cs50.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
int k = 0;
int convUpperAsciiToAlphaIndex = 65;
int convLowerAsciiToAlphaIndex = 97;
int AlphaIndexWrap = 26;
int main(int argc, string argv[]) // get Key from user via Command-Line Argument... |
I am creating an arcade type thing in Python. Could someone suggest ways to simplify this code, or any other tips? All help is much appreciated.
I think the higherorlower function is particularly over-complicated.
import time
import random
tokens = 10000
def main():
menu = int(input("What would you like to play?(E... |
Is this good approach, to mock some domain object, for example javax.persistence.Entity, or DTO (data transfer object)? Below is simplified source code:
@Entity
public class Entity {
@Id
private int id;
private String name;
// getters and setters
}
//Spring repo for example
@Repository
public interface... |
I have coded a system where each 'Player' class requires 5 components (could be more in the future, up to 10, 20 maybe even 30, once we add more and more features). What I want some advice on is a better way of creating these components, I am not saying that my current way is bad, I am just looking for anyone who could... |
To do password exchange on the SQL server I need to use SHA-1 to generate a hash (no plain password exchange).
This is done differently on Linux/Mac so I abstracted it slightly.
ThorCryptWrapper.h
#ifndef THORS_ANVIL_MYSQL_DETAILS_THOR_CRYPTO_WRAPPER_H
#define THORS_ANVIL_MYSQL_DETAILS_THOR_CRYPTO_WRAPPER_H
#ifdef __... |
I'm very new to jQuery, and have recently converted one JavaScript function to jQuery. This function is part of a small utility that mimics click and drag for selection of text. Complete code is available on my github repo. Following is the screenshot of the utility.
The purpose of the code is to allow user to selec... |
I have an action that takes an id as a parameter and gets the corresponding item with the help of a web service. The web service's method that returns the item will either return the item with the requested id, or will create a new item (new version of the item) with a new id. So, in the case that a new item is created... |
I code this function to convert list of dict to a specific string to export last in a row table string field.
#!/usr/bin/env python
# encoding: utf-8
from __future__ import unicode_literals, print_function
import types
import collections
from collections import Iterable
def convert_to_string(input):
if isinstance(... |
I decided to make my own version of C++17's std::optional
It's basically a class that can optionally hold a variable (as the name suggests), it avoids having to resort to std::pair<bool, T> to check whether a variable is set.
I'd like some feedback regarding the overall implementation
template<typename T>
class Optiona... |
dRoll: Beginner Dice Roller
Roll dice base on a input string.
1/. Input.
<number_of_dice> d <value> [/ <modifier>]
<number_of_dice>, int indicate the number of dice.
d, delimiter.
<value>, int dice value.
/, Optional delimiter for dice modifier.
<modifier>, int only with / delimiter
Each valid input can be separate... |
I would prefer a review of:
Efficiency
Standards
Different approaches
Here's the code:
program bubbleSort;
var
toSort: array[1..5] of integer = (3, 25, 2, 69, 1);
passChanges: boolean = true;
counter, index, temp: integer;
begin
while passChanges do
begin
index ... |
On any ajax calls made that take more than 2 seconds, I want a loading icon to appear. I have css that takes care of showing the loading icon when the 'loading' class is added to the body.
And here is the relevant code:
<script>
var loadingIconOn = false;
$(document).on({
ajaxStart: function () {
... |
I have a stateful object on which I'd like client code to be able to register many event handlers. These handlers have different signatures—they usually accept the originating object and some piece of data relevant to the event.
public class StatefulObject {
@FunctionalInterface
private interface Callback {
voi... |
There was an interesting idea brought up in The 2nd Monitor where one of our regulars was trying to split a bunch of strings into a specific format.
The format should be similar to the following:
A000
A00
900
90
Where A is any alphabetical letter, 0 is any number, and 9 is any number 1-9. No result string should begin... |
The website I'm working on is essentially project-management software. Each project has a code (alphanumeric lowercase, with hyphens). The URL must include the codes and treat them as directories.
website.com/p/<code>/<page> => website.com/p/<page>?code=<code>
Each project will have files associated with it. All file ... |
I am learning c# and trying to wrap my head around OOP. This blackjack code is my first attempt. It works well enough, but it is probably terrible. Please let me know what to work on.
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
bool playGame = true... |
In earlier versions of iOS the lock screen had a 'slide to unlock' element which I'm referencing as a 'shimmer' effect.
The effect I'm looking for is simpler:
Button starts with single color (e.g. blue)
a band of color (e.g. red) sweeps across the text label from left to right
Repeat
Here's an example of my ShimmerBu... |
I wrote this JavaScript function to change an element tag name to a div.
function divilize(elem) {
var elemDiv = document.createElement("div");
var elemAttrs = elem.attributes;
for (var attr = 0; attr < elemAttrs.length; attr++)
elemDiv.setAttribute(elemAttrs[attr].name, elemAttrs[attr].value);
... |
In my open source project, I have code that uses a dictionary very intensively so a system dictionary implementation did not suit me due to performance reasons. Therefore, I decided to write my own implementation that uses unsafe code. Fortunately, I can use integers as dictionary keys and I always know the max diction... |
This data structure maps values from intervals of some type Key which satisfies LessThanComparable<Key> to values of some type T. I remembered this kind of data structure from an interview question.
My current use case is a distributed vector where I want to keep track which MPI rank owns which parts of some global ind... |
Full disclosure: I'm working on this for an online course. However, my goal is really just to get a pointer to where the issue is.
The goal is to implement the closest points problem, that is, given a set of points on a 2D plane, find the shortest distance between two points. After lots of stress-testing and debugging,... |
I was wondering if I could get some pointers on how I can improve my library, whether it be design pattern/naming convention/or any ideas on a better implementation.
GitHub
As it stands, I am using a builder pattern, so you'd go:
var sum = new Summary();
sum.ApiKey(_apikey).Url(_url);
Then you would get the JSON which... |
I am trying to develop an optimal evaluation function to use in minimax/alpha-beta algorithm for developing tic-tac-toe AI.
I am counting number of circles/crosses in a row/column/diagonal with empty space behind it (with three-in-a-row, there is no empty space). Based on number of symbols in such line, I multiply th... |
I'm learning C++ and here I've written a little toy program that is supposed to list all the arguments passed to it through the command line.
#include <iostream>;
using namespace std;
int main (int argc, char *argv[]) {
for (int number = 1; number < argc; ++number) {
cout << argv[number] << endl;
}
return 0;... |
I have to do a function called findsaw. This function searches for the longest sequence of toggled consecutive bits in an integer and returns the index of the first bit of the sequence, the sequence must start from the least significant bit.
In the case there are multiple answers(sequences with same size) choose the o... |
The returned class as result:
public class cs_HttpFetchResults
{
public bool blResultSuccess = false;
public string srFetchBody = "";
public string srFetchingFinalURL = "";
public bool bl404 = false;
}
The HttpWebRequest version:
public static cs_HttpFetchResults func_fetch... |
Today, I tackled this coding question:
Given a singly-linked list, check whether its length is even or odd in a single pass. An Empty list has 0 nodes which makes the number of nodes in it even.
Would the time complexity of my code be O(n)? Do you guys see any improvements that can be made?
public Boolean isListEven(Li... |
Here is my implementation of a Pascal program, which is used to print an n-order Pascal triangle. This is actually an exercise I came up with to familiarize myself with Python's Functional Programming Modules.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import operator
from itertools import starmap, tee
from functo... |
This is the problem:
Given a 10 digit phone number, you must return all possible words or combination of words from the provided dictionary, that can be mapped back as a whole to the number.
With this we can generate numbers like 1-800-motortruck which is easier to remember then 1-800-6686787825
The phone number mappi... |
I was inspired by another question to post another method of finding the two points in a plane that are closest to each other1.
This one is a line-sweep algorithm. It works roughly like this:
Sort the points based on their X coordinates.
Take two left-most points. They give us our first guess at the shortest distance ... |
I have decided to create a discount Pokemon battle simulator using a module called guizero. It's basically a wrapper for Tkinter that is easier to learn. Recently, I started to learn OOP and thought that this project would be a good practice for my "new-found skills". Someone in my computing group looked at my code and... |
This is my first attempt at object oriented javascript code. I have been writing JavaScript code for few years now but this is first time I am trying to write OO javascript code. I have read about OO javascript, but I am not still very confident about it.
Could you please review it and provide your comments about this ... |
I consume an API which gives me this type of JSON:
{
"data": {
"name": "Start",
"pid": "1",
"position": {
"data": {
"x": "31",
"y": "330"
},
"metadata": "empty"
}
},
"metadata": "empty"
}
I have created the classes with objects with the same structure as the abov... |
PRIME1- Prime Generator
The code is working fine and it's generating a prime number from M to N but the only problem is I'm getting TLE when I submit my answer. How do I optimise my code to pass the time limit?
number-theory
Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to ge... |
I have implemented Iterator pattern:
The interface Container.java:
public interface Container<T> {
Iterator<T> getIterator();
}
Interface Iterator.java:
public interface Iterator<T>{
boolean hasNext();
T next();
}
Class ResourceContainer.java:
public class ResourceContainer<T extends Serializable> impl... |
I was doing this HackerRank problem which basically boils down to counting overlapping substrings in a string. I used this solution from StackOverflow to build this program -
def overlapping_occurrences(string, sub):
count = start = 0
while True:
start = string.find(sub, start) + 1
if start > 0... |
I try to improve my code so that I don't have to program a try - catch block all the time.
e.g. at the moment I have to write many codeblocks like this:
try {
$login_feld = $SeleniumObj->driver->findElement(WebDriverBy::id("login_feld"));
} catch(NoSuchElementException $exception) {
$SeleniumObj->setErrorMessag... |
After reading this answer to the question "High execution time to count overlapping substrings", I decided to implement the suggested Knuth-Morris-Pratt (KMP) algorithm. I used the pseudo-code listed on Wikipedia for the functions kmp_table and kmp_search.
However, when running it on some corner-cases, I have observed ... |
I wrote this tic tac toe game in react. I am learning react now. Feedback is welcome. I deliberately used single file, to focus on React and not other aspects.
<!-- 3x3 Tic tac toe implementation in React JS. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Tic Tac Toe</title>
<!-- Import ... |
I'm learning Algorithms, Data structures and C.This is an exercise set by myself to implement a simple linked list data structure with insertion algorithm in C, to better understand the subject.
All answers are highly appreciated, here's the code.
linkedlist.h / linkedlist.c
#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_
... |
I have a JSF project composed by some Maven Modules.
I have one module that needs to read and write some files on server. To do this I need to know the "real" full path of the application/server.
The way it is coded, only the View layer can access this information by this method:
public final static String getRealPath(... |
I'm prepping for a coding interview, and am examining the task of correcting unbalanced parentheses. The finger tree seems to be the right data structure.
As a proof of concept I've used Data.Sequence to test my idea. If this is the right direction to go, I'll write more specialized finger tree code.
The code works on ... |
I'm trying to practice functional programing using JavaScript. These pure functions just work together to find the difference between two arrays. I know that this might be an impractical example of functional programing, but could you let me know where I can improve or maybe where I've misunderstood an FP technique?
"u... |
I've been through a lot of posts over the web(and in SO) saying that it is not possible. However, I did the following code:
var a = {
_sum: 0,
_timer: null,
_resetTimer: function() {
if (this._timer) {
window.clearTimeout(this._timer);
}
this._timer = window.setTimeout(this._endChain.bind(this), 0);
},... |
Given a 2D array of unsigned integers and a maximum length n, find a path in that matrix that is not longer than n and which maximizes the product of the elements in the path. The output should consist of both the path and the product.
A path consists of neighbouring integers that are either all in the same row, or in ... |
Is this good code? I do believe I improved quite a lot since last year, still I would really appriciate some feedback :)
import javax.swing.JOptionPane;
import java.util.ArrayList ;
public class IfNotRepeated {
/*
* 7.12 (Duplicate Elimination) Use a one-dimensional array to solve the following problem:
... |
I wrote this demo just for practice purpose, I would like to get some helps that could further improve my code quality. Any suggestion for improvement would be appreciated.
This code is a simple demonstration of stack implementation (by using array List).
User will be asked for the option of a function to demonstrate.... |
I built a Chrome extension. Part of point of the extension is to call a page, parse the page and see how certain values line up. I'm concerned that this could be done in a better way than what I have as far as performance is concerned and readability.
Any suggestions on this front?
chrome.runtime.onMessage.addListener(... |
I'm fairly new to Python (this is the first thing I've done that really takes advantage of classes). This works and I'm happy with it; just looking for general advice. Especially nice would be input on my comments and how 'pythonic' the code is.
#import fractions #unused, on todo
class Base:
# Dicts for getting a d... |
I need to iterate through a file of words and perform tests on them.
import multiprocessing
import datetime
class line_Worker(object):
def worker(self, chunks):
for l in chunks:
num = 0
for num in range(100):
print l, num
return
if __name__ == '__main__':
... |
I have a JavaScript function that increments a counter for each square on the chessboard as it becomes dominated by a queen and decrements it if one of the dominating queens are removed (only queens, this isn't actually a chess game with all of the pieces, it's essentially the 8 queens puzzle). If a square is dominated... |
I'm a beginner in C programming. I am current trying to work on a project requiring 1024-point FFT implementation using radix-2, Decimation-in-frequency. I attach the FFT function C code. How can I increase the performance by modifying the C code?
#include "i_cmplx.h" /* definition of the complex type */
#inc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.