instruction stringlengths 71 95.1k |
|---|
I have been writing a lot of jQuery plugins lately, but I don't really know if what I am doing is any good. Here is one of my most recent plugins. It allows the user to add a data attribute to any class and load a full page view window (which is written to the body on render) to e.g. open a menu on mobile or read large... |
Coming from a C/C++ background, this was my first python code I wrote to grasp a few basic concepts. The game involves giving random arithmetic operations to the users and scoring their responses. Player has 3 lives i.e he can mark 3 wrong answers at most. I've tried to time the game i.e the player gets 60 seconds to s... |
I'm learning ASP.NET Core with MVC pattern and I didn't find anything useful related to this argument.
Actually I'm looking for a way to handle all the application errors inside a single View. The first thing that I did was create the View for display the error, this is the design (pretty simple though):
<h2>@(ViewBag... |
This is a coding interview I found online, to be solved within 30 minutes:
Design an OOP concept for an application where employee can dispatch their incoming phone call according to their seniority level if they are not able to solve.
I chose to use Chain of Responsibility pattern, I also used Null pattern.
Please r... |
Although this question has been asked a lot of times, I was hoping for a feedback on my approach.
Tax Calculator Basic sales tax is applicable at a rate of 10% on all
goods, except books, food, and medical products that are exempt.
Import duty is an additional sales tax applicable on all imported
goods at a rate... |
I'm implementing a BFS traversal in a grid-like structure. Because I wanted to experiment with ES6 Generators for a long time, I thought I'd implement the search using that abstraction.
I am sure there are obvious things I could improve in the code, because it looks fishy to me, especially after some "special constrain... |
I am taking a class in mobile application development this fall. I have finished my first assignment of creating a class to divide an arbitrary dollar amount into the minimum number of bills and coins. I have completed the assignment and everything works as intended (outside of an occasional error I'm having with compu... |
I am the author of this package that turns DNA sequences into two dimensional visualizations. DNA, for the unaware, consists of four letters (A, T, G, and C). To convert the sequence, I am using this code:
import numpy as np
def transform(sequence):
running_value = 0
x, y = np.linspace(0, len(sequence), 2 * le... |
I need some advice for this task.
We've got this structure:
const scenes = {
'Node1': {
'scene1': [
{
nodeKey: 'cccc',
category: 'user',
},
{
nodeKey: 'eeee',
category: 'interface',
},
]
},
}
I need to make this:
let result = {
'Node1': {
'scene... |
I have a Raspberry Pi 3B with a USB microphone. I have used a combination of Bash and Python scripts to detect noise levels above a certain threshold that trigger a notification on my phone. The actual sound is not streamed.
The scripts are called using a command line alias for the following:
bash /home/pi/babymonitor... |
I am developing a very basic CLI flag utility library in C. The following code is a part of the main translation unit containing all the relevant functions, and is located in the global scope.
struct pair {
char name[100];
char defaultValue[100];
};
static struct pair *defaults = NULL;
void setDefault(const c... |
I wanted to try convert Peter Norvigs' Python Scheme interpreter to C++. I had tried this a few years before and failed abysmally but I saw that the latest C++ standard includes several features which might make things easier so I tried again. The tokenizing and parsing bits were easy but I struggled for a while with... |
This code allows Add, Edit and Delete a database record for the Category table. Separate Service classes are implemented to handle these operations which are called via the Web API Endpoint CategoriesController.
I want to improve the current code pattern because I am not sure calling BaseBusinessService.Execute() on C... |
I would greatly appreciate feedback on the enclosed script, which auto-generates a Markdown table of contents for Github-flavoured Markdown, with respect to:
Consistency with Ruby idiom & style
Any use of bad practices
#!/usr/bin/env ruby
def usage
puts "Usage: #{$0} FILE.md"
exit 1
end
class ToCWriter
def in... |
What do you think of my markdown previewer, which uses the marked library? I'm asking because I'm new to React. And also what do you think of app itself? Did I use React correctly and properly?
HTML:
<div id="root"></div>
CSS:
$position: absolute;
$percentage: 100%;
$color: whitesmoke;
$car: auto;
@import url("//netd... |
I'd like to read lines from a file and process them concurrently. I came up with the following code to do this:
var wg sync.WaitGroup
func main(){
file := "data/input.txt"
reader, _ := os.Open(file)
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
wg.Add(1)
go processLine(scanner.Text())
}
... |
Okay here is my maiden attempt at programming using Python 2.7. I need help or feedback on this code:
How do I know about the processing cycles this program consumes?
How do I implement this idea using recursion?
What's the best way of removing duplicate items fom a list. I am not happy with this
#remove the duplicate... |
We have pages that contain 1-3 forms. Each form does have a submit button which is styled as inactive* as long as the user didn't change the form.
Now I need to:
remove the class from the button as soon as the form changes
remove the event listener from the form
I came up with this:
for (const form of Array.from(docu... |
I would appreciate some criticsm on my code so that I could improve it. I tried making the Snake game in OOP but don't think I did it right. Any suggestions would be appreciated.
The code is is commented in my language which isn't english hope that won't be a problem :)
Here is the code:
#include <iostream>
#include <c... |
In order to practice some Haskell, I tried this kata, where the task is to add some numeric inputs that are delimited by commas or newlines.
I have the below solution in Haskell which passes my tests, but could anyone offer any improvements? It feels a bit messy to me so feedback on how to make it more functional (my e... |
There are many files [ file1.php, file2.php ] in our project & i wrote database connection code in many files instead of single file [ database.php ] , is there any problem with that ?
if it is wrong than please help me what code i need to change in file1.php to connect to database.php
Below 2 lines i used in file1.php... |
I put together a log4net wrapper that more closely resembles F#-idiomatic logging functions. The basic idea is that there's a Log module that defines a set of 8 functions for each log level, as in the following example for the Error log level:
Log.error - Log a message (string) with the Error log level
Log.errorf - Lo... |
I'm working on a python module to randomly choose a wallpaper for my desktop background among thousands of pictures in my photo library.
I though I'd make a general function:
get_random_file(ext, top)
Return the name of a random file in a directory tree with top as root.
Since I'm dealing with a very large directory... |
I am seeking a review of my codility solution.
Whilst the problem is fairly simple, my approach differs to many solutions already on this site. My submission passes 100% of the automated correctness tests.
I am looking for feedback regarding the design of my solution, and any comments in relation to how this submissio... |
I have the following function that checks a data record to see if it has met certain criteria specified separately in configuration settings. The configurations are set up as a list of dictionaries with certain trigger keywords that are used by the condition check function ('in','not in', etc).
The condition checker ha... |
I have an Angular 6 app with the following requirements:
Get data from a web service.
Load the data when the page is displayed.
Reload the data when the user requests a reload by through some UI, like a button.
Show a spinner while loading data in the header of the page. That is, not in the same place where the data i... |
Below is a sample implementation for getting the expired credit cards in the credit card list.I wrote a property and initialized it in the constructor. Need an opinion on if this is a proper way to implement it.
public class User
{
private readonly List<CreditCard> creditCards;
public int CountO... |
This code defines a MessageBus used to handle messages from many producers to a single consumer. The bus allows multiple publishers to send messages asynchronously to a single message handler. This is not a Pub-Sub model, instead, it's a many publisher and single consumer with the ability to send a result back to the p... |
I want to visualize all unlabeled trees with \$n\$ or fewer nodes, not just count them.
First idea/attempt: Take a list of all \$n-1\$ node trees, then append a new leaf to every tree in every way to get a new list of \$n\$ node trees. Clearly, this new list will contain a lot of isomorphic duplicates. To fix this, we ... |
I took a code test for acme transport company and was rejected. That's ok. I'm still learning how to code. I didn't get much feedback so that's a bit frustrating. Can anyone here provide tips on how to optimize this python code? I thought that I had done a pretty good job with it, had the correct answers, etc. But appa... |
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; th... |
I am a beginner in the programming world. This is the first big project I tackle which is the battleships game. I implemented the game to run in the console. I was hoping if you guys can check my code and help realize if I can have shortcuts or make it more efficient.
The game goes as follows:
deploy map.
user enters ... |
For many years, I have waited for function aliases in C++. They still aren't here. I've been using macros to generate wrapper functions. This is my best attempt at the perfect function alias:
#define FUN_ALIAS(NEW_NAME, ...) \
template <typename... Args> ... |
I am currently using Django (2.1) to build an API, and I have added djangorestframework-jwt to manage JWT.
Here is the configuration:
JWT_AUTH = {
'JWT_SECRET_KEY': SECRET_KEY,
'JWT_VERIFY': True,
'JWT_VERIFY_EXPIRATION': True,
'JWT_EXPIRATION_DELTA': datetime.timedelta(days=14),
'JWT_ALLOW_REFRESH'... |
I'm trying to learn some multithreading and this seems like a good example, want to apply this to frustum culling later.
The goal is to find prime numbers in randomly generated vector of numbers.
Single threaded solution is simple, multithreaded way is to divide vector of random numbers in two parts, solve each one in ... |
I am working on code to generate a screw made up of different elements and animating it by rotatation. The elements are so called conveying elements (denoted by GFA) which are helical shaped screw elements and kneading blocks (denoted by KB) which are smaller sequential sections offset by a staggering angle.
The algori... |
I've written a simple script that calculates the distance between two points in time and returns the duration.
Example: Start - 11:00, End - 11:45, Duration - 0.75
I wanted to make use of ES6 classes and I'd like feedback on the Duration class in particular. For example, should the validation of the start and end argum... |
I have found myself referencing controls on a form (think Windows forms but more proprietary) by hard-typing their names in over and over again. Often I'll have a number of similar controls which could be named coolControl1department, coolControl2department, coolControl1jobTitle, coolControl2jobTitle, etc. This becomes... |
I made a simple Mastermind clone and I'd just like some tips on what I could do better/different solutions for what I have already coded. If you're wondering what mastermind is, there are, for the original, 6 different colors and 4 different holes. I decided to make this since I had made mastermind in other things so I... |
I implemented a doubly linked list in Python. Please tell me what I can do to improve performance, what methods I should add, etc. I gave it the best Big O time perfomance/complexity I could. So, here it is:
class DoublyLinkedList():
"""
A basic class implementing a doubly linked list.
DoublyLinkedList() -... |
A server sends JSON to my webpage via a socket and the webpage creates or updates a "card" which displays the information from the JSON data. It's a one-way/read-only system.
Flow is:
Thing sends data to Server
Server receives data and does some things/logic
Server sends data via websocket to webpage
User opens webpag... |
I am getting timeout for test cases having very large input.
-= Challenge Link =-
-= Test case example =-
Code is working fine as can be checked on ideone. (Note: Here fout has been replaced with cout.)
Problem Statement :
A string is said to be a special palindromic string if either of two
conditions is met:
All ... |
I am working on a Master List, where I am copying data from various sources for each month into the columns Z, AC, AF, AI etc. (always separated by 2 columns). Then I copy that cell all the way down to update the values for each row. As you can see in the code below, the only difference from one section of the code to ... |
I've created a simple API wrapper that I intend a few developers to utilize. I decided to follow an Fluent Interface methodology, similar to this.
public class SalesAPI
{
private HttpClient _client;
private string _url;
private List<string> CompanyNums;
private List<string> CustBillT... |
I did not like that get synchronizes every time I call it - because I may be calling it more than once. So I wrote the wrapper for the future interface which keeps not synchronized local variable for completion state and caches the result. I am very sure it is thread safe.
Please have a look:
package i;
import java.ut... |
I have a small JS application that allows a user, after clicking on a canvas, to draw a picture.
Once the user clicks the mouse, the user is allowed to drag the mouse wherever they want within the canvas and a line will be drawn from where they started moving the mouse to where the mouse stopped.
Only by clicking again... |
I have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate.
I just want to see how my code stands now, I am sure there are still areas I need to improve or fix. I again want to thank this community i... |
I had been working on the implementation of closest pair algorithm in a 2-D plane.
My approach has been that of divide and conquer O(nlogn) :
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
int getval(int size)
{
... |
A simple neural network I wrote in Python without libraries. I avoided implementing it in matrix form because I sought to get a basic understanding of the way NN's work first. For that reason I'm strongly favoring legibility over efficiency. I tried to keep my code readable and pyhonic, any style feedback would be part... |
I have been working on a small game lately and I was tired of looking up and copy-pasting game loops so I tried to make one as you can see. It works perfectly so if you want to feel free to use it, but for those who are good at making these I would like to ask if I can improve it, make it more efficient and overall is ... |
Are there Rust features I could apply to optimize for simple test of a JPEG or PNG resized from 2000 x 2000 pixels to 150 x 150 pixels?
extern crate image;
use std::env;
fn main() {
let mut args = env::args();
args.next();
let file_location = args.next().unwrap();
let width = args.next().unwrap().parse... |
The entry point is the Macros module, which - for now - includes only a single procedure, at a very high abstraction level - I'm quite happy with this:
'@Folder("Macros")
Option Explicit
'@Ignore MoveFieldCloserToUsage; controller reference needs to be held at module level!
Private controller As GameController
Public ... |
I wrote a task scheduler package with data persistence in Go.
However, the logic seems super messy... even it seems passed all tests.
Is there any better way to structure the code and finish few unsolved TODO in the code? PR welcome after a review, thank you in advance.
package goscheduler
import (
"encoding/json"... |
I have an array like this:
$array = [
['id' => 1, 'content' => 'value 1'],
['id' => 2, 'content' => 'value 2'],
['id' => 3, 'content' => 'value 3'],
];
I have another array containing the actual order of ids in which $array should be sorted :
$order = [3, 1, 2];
Which means, the result should be this:
$so... |
I do a lot of PC swaps/replacements for my role. I've decided to write a script to assist with backing up the user's profile and network drives.
I'd like to see how my script stands now. I'm still working to implement more features such as backing up saved wireless networks and printers.
#get current user's ID
$userID... |
Every Month I need to make an excel sheet with travel expenses, since this is a tedious task I decided to make a little python script to do this work for me.
Everything works correctly, but any comments regarding style and functionality are welcome.
import datetime
import calendar
import re
import argparse
import open... |
the following is an implementation of the standard Metropolis Hastings Monte Carlo sampler. You can read more about it here.
At the end I am going to give you a link to the Rust playground, so you can test the code yourself!
First I start with some traits, that define probability functions:
type Float=f64;
/*Standard t... |
I'm just starting to learn programming again after a long break and decided on Python. Here's my code:
#"Code Wars: Where my anagrams at?" A program that finds all anagrams of "word" in "wordList".
import copy
def anagrams(word, wordList):
result = [] #List to store all the anagrams.
for i in wordList: #Oute... |
Today I had an interesting idea. I have been copy/pasting the following line for each kind of request method for every route.
http.Handle("/api/my/custom/route", mw.Chain(api.PostFunc, mw.Method("POST"), mw.Logging()))
It struck me that it looked very bad and unprofessional so I came up with a new idea.
type RouteInst... |
EDIT BELOW
I am trying to create resusable classes for MSSQL and MySQL queries (later also Update and Delete queries). I tried it doing the OOP-way. Here is my result:
Einstellungen.vb:
Public Class Einstellung
Private _Server As String
Public Property Server As String
Get
Return _Server
End Get
Se... |
Is there any reason to not do this?
Putting the query directly inside a foreach-statment when the only time the result is going to be used is within that location..
<select>
<?php foreach($dbh->query('SELECT id, name, so FROM Employees ORDER BY so') as $e): ?>
<option value="<?=$e['so']?>">-- after "<?=$e['name']... |
I'm working on a site running woocommerce and wp where the user will add/has added a dimension attribute.
The dimension string will take the following format originally:
Ht: 30 1⁄2" W: 22 1⁄2" D: 18"
and should return the string with html to format the fraction e.g:
Ht: 30 <sup>1</sup>⁄<sub>2</sub>" W: 22 <sup>1... |
I made a code that can find the prime sets:
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a ... |
I am writing an application which has lot of checks. Most of the logic is based on conditions. How can make such code comply with SOLID principles? I cannot give the code of my application here hence I will try to simulate problem with a simpler example.
class Person {
public String gender;
public int age;
... |
I'm totally new to coding and tried myself on a short text based adventure game. I got the feeling that the functions are the same ones all the time and the whole game is a bit monotonous... I'd be very thankful if anybody has some improvements or additional ideas!
import random
import time
def nameFunction(): #hell... |
Armstrong like numbers are those which are equal to the sum of the cubes of their 1/3rd parts. For example:
\$165033 = 16^3 + 50^3 + 33^3\$
\$166500333 = 166^3 + 500^3 + 333^3\$
Here is my code, works fine, but I want to know how I can improve it:
Method check() checks if the number is armstrong like and generate... |
My code works perfectly but it is redundant. How does one condense this? How do you use the =! operator? Any help would be greatly appreciated.
$("#about").click(function(){
$( ".home" ).hide();
$( ".headr" ).show();
$( ".about" ).show();
$( ".skills" ).hide();
$( ".experience" ).hide();
$( ".education" ).... |
We need the input number as the sum of consecutive natural numbers.
Examples:
For input 27, output should be:
2 3 4 5 6 7
8 9 10
13 14
For input 9, the output should be:
4 5
2 3 4
Here is my code. It works as it is expected to:
import java.util.*;
class Consecutives
{
static void print()
{
S... |
In the previous post I presented the MVC architecture, but all we saw of the View was the pretty bits. From the outside everything looks innocently pretty:
The guts of the worksheet's code-behind is a bit more... chaotic. Maybe not chaotic-evil, but chaotic nonetheless, despite the fact that it's really doing nothing ... |
My program generates URLs. It takes in 3 variables and substitutes them in a URL to create different working URLs. It also has 3 options for language selection, which change the language of the page to which the URL points.
However, the more options I add the more copy - pasted code there is. I know there is a way to s... |
I have written a simple download accelerator in java which downloads the same file in multiple threads and then combines them all.
I would love some feedback on my design. How the same implementation can be better written. Idioms, conventions, anything that comes to your mind. I hope I have not included a lot of code h... |
I share below my password hashing implementation with salt and pepper in C#, for your review and feedback. In my implementation methods like ValidatePassword(), ChangePassword() are in the user class.
I recommend random.org's free random bytes generator coded in hexadecimal to get a secure Pepper for each installation.... |
I did this programming challenge. Part C of the challenge, is to find the salary you have to save every month to be able to buy a house in 36 months.
This is my first time using bisection search so I just want to make sure that I did it correctly. I question the efficiency of my program because in test case 2 for part ... |
This function receives the id of an element (frame) and calculates the correct height and width so it fits inside its parent element, while keeping its aspect ratio. Before I had a way to calculate the frame ratio dynamically, but I decided it was easier to simply hard code it, it calculates it through naturalHeight an... |
I have implemented this delete function for BST. Tt takes care of all the three cases, deleting node with 0, 1, or 2 children.
I have added comments throughout to explain my decisions. Is it sloppy or acceptable? Will I get full marks if this was a question in an exam to implement the delete function of a BST?
//I am h... |
I wrote a solution to this question. The task is to take an input of n increasing positive integers (1 ≤ n ≤ 2∙105), each entry as large as 109, and find the length of the longest subsequence where each element is no more than double the previous element.
Example input
10
1 2 5 6 7 10 21 23 24 49
Example output
4
… ... |
This script sorts files from current directory into known subdirectories. it is built for speed because the keyword database used can be up to 20kb. each line of the database has subdirname,1,keywords?string where the number is how many points this keyword is worth. It then counts these points and puts the file to the ... |
1. Summary
I can't find, how I can to refactor multiple with open for one file.
2. Expected behavior of program
Program detect encoding for each file in the directory. If encoding ≠ UTF-8, file convert to UTF-8.
3. Minimal example of working code
(I'm sorry, Repl.it and another online Python interpreters incorrect wo... |
In an attempt to learn Rust, I've written up implementations of the bisection method and Newton's method for finding roots of an equation. Both methods come in two variants: the first one searches for a single root on a given interval (with assumption that there is at most one root there), and the second one tries to f... |
I created just for practice this leapyear script.
What do you think about it?
How can I make it more efficient?
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.printf("Plese enter year: ");
... |
I am doing the 100 Doors problem as an exercise to practice user input and loops. I do understand the problem can be solved by outputting every square number up to the maximum number, but it defeats the purpose of the exercise. The 100 Doors problem goes like this:
\$N\$ doors are closed. In the first pass, I open all... |
I wrote a function to convert seconds into the two biggest units of time and format it into a string. What I mean is that e.g. 134 second would be 02m14s and 3665 seconds would become 1h1m. Here is what I did:
def pprint_time(seconds):
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
d, h = divmod(h, 24)
... |
The task is to print the following series
1 2 1 3 2 5 3 7...
The elements at odd positions are Fibonacci series terms and the elements at even positions are prime numbers. Given an input 'n' the element at the nth position in the series has to be printed.
eg. when n = 4, output will be 3. n = 7, output will be 3
I'v... |
Given an array of n elements in the following format { a1, a2, a3, a4,
….., an/2, b1, b2, b3, b4, …., bn/2 }. The task is shuffle the array
to {a1, b1, a2, b2, a3, b3, ……, an/2, bn/2 } without using extra
space.
Input:
The first line of input contains an integer T denoting the
number of test cases. Then T tes... |
This is my simple implementation of the Unix cp command. It is a C++ program but makes use of some of the lower level C library I/O functions.
Any suggestions for style or performance improvements would be appreciated.
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<fcntl.h>
#include<un... |
I'm writing a simple game with multiplayer mode in C++, using the SFML framework.
Since I don't want to make it more complicated than necessary, I handle everything on a single thread, so that when the client is waiting for the remote player's turn, I check if there is an incoming message about the remote player's move... |
I read this question about the "100 Doors" puzzle, and thought that it would make for a good quick exercise.
I ended up with two implementations. The first is more straightforward and uses a vector to store the boolean state of each door.
This is quite slow though, and having a vector of true and falses seems off, so I... |
I have a simple class like
class Item {
Set<String> wordSet() {...}
}
So each item has a set of words and I need the inverse relation, i.e., for each word find all items containing it. This gets used a lot, so I want an ImmutableSetMultimap allowing me to retrieve it quickly.
I'm using
ImmutableSetMultimap<String,... |
From Code Wars:
This kata is part of a series on the Morse code. After you solve this kata, you may move to the next one.
In this kata you have to write a simple Morse code decoder. While the Morse code is now mostly superceded by voice and digital data communication channels, it still has its use in some applications... |
I have been working on my own form of validation for XML other then xpath, as a toy project.
First off, I use this class to add Validations to the graph to check for and validate they exist.
public class GraphValidation
{
public string Target { get; set; } = "";
public bool Result = false;
}
Next I use this c... |
I'm trying to create an if-else statement that pops up a modal with output in the body, and if there is no input detected then an alert pops up.
//fizzbuzz
$("#btnfb").click(function () {
var numfiz = $("#fizz").val();
var numbuz = $("#buzz").val();
var outputarray = [];
for (var loop = 1; loop <= 100; loop++) {
if... |
I hate having to format questions around here. Adding four spaces to each source file and the correct name at the top of each source file becomes a headache when I have to post longer questions.
This is a simple python question parser that takes in arguments from the console and prints out correct format for a CodeRevi... |
Can it be made faster, and I am a newbie to complexity but I'm pretty sure the average case for this would be O(n). Am I wrong?
Output for the first list should be: (1,9), (2,8), (5,5), (-11,21)
The program finds pairs of an array whose sum is equal to ten.
#find pairs of an array whose sum is equal to ten
#bonus do it... |
Here a string is taken as input and the program suppose to check whether the string is palindrome or not.
Is there any way the code can be improved? Is it okay to use foreach to break the string into character.
class Program
{
static void Main(string[] args)
{
//input a string
string orginalStr ... |
I'm a student, and most of my lab work includes writing programs (usually .cpp) run them, copy the source code and output to a word file and either mail a pdf to the concerned teacher or submit in print.
(I still don't get the point of submitting a program in print or pdf file, but this is what we're asked to do)
So I ... |
This code is working well. Is there a way to minimize the complexity of the code?
final = []
a = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]
for i in range(len(a)):
temp = []
for k in range(len(a)):
m = 0
if i != k:
for j in range(0, len(a)):
DIFFERENCE = (a[i][j] - a[... |
This is a follow up of Cleaning a file / Word Query
I incorporated the suggestions from the anwers there and turned the Word Query Programm into a GUI.
For that I used the Support code of the Book which provides some basic functions for FLTK GUI toolkit. You can find it here: http://www.stroustrup.com/Programming/PP... |
Asynchronous programming is tricky enough already, and VBA doesn't make life any easier. I wanted to create some basic functionality to allow async processes to mark completion without having to implement any complicated interfaces.
The basic idea was to raise a regular stream of events, or Ticks, and then to check the... |
Heap's algorithm
is an algorithm to generate all permutations of a given array. It
... generates each permutation from the previous one by interchanging a single pair of elements; the other n−2 elements are not disturbed.
Here is my attempt to implement this algorithm in Swift 4 as a Sequence,
so that all permutation... |
What is the expected behavior?
If there is a file in the state (file != null), then startUploadImage(file) should be executed, followed by startUpdateEvent(eventId, state).
If there is no file (file === null) then only the startUpdateEvent(eventId, state) should be executed.
What is the problem I am encountering righ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.