instruction stringlengths 71 71.9k |
|---|
I'm trying to find out if it is possible to simplify my framework a little bit more. The current solution works, but it does cause some code duplication for me and some other issues that might come down the road.
public class Browsers {
private String Browser;
private String Windows;
private String Ver;
prote... |
This is a simple script that moves files to S3 if they are > 14 days old. It ignores files that are < 14 days old. If the file is successfully synced to AWS S3 then we can remove it from the server. If not, we leave the file where it is. The echo commands in the script are for debugging. I am aware that this could be a... |
So I was coding Prim's algorithm for practice and this is what I wrote. It works for finding the weight of the minimum spanning tree (MST) but I'm wondering if the loop I am doing to add the the edges in the frontier to the minheap is optimal.
import heapq
from collections import defaultdict
g = defaultdict(list)
weigh... |
I have two lists that I need to intersect. This is what I'm doing.
var dfuDevices = _dfuMonitor.GetDevices();
// new devices
dfuDevices.Except(Devices).AsParallel().ForAll(device => {
if (device.GetType() == typeof(DFUDeviceModel)) {
OnDfuDeviceDetected(device);
}
});
/... |
The game is designed to be a sort of foundation for any other projects I make.
#main --- This is line zero
import sys
import time
import areas
import items
def menu():
while alive:
print("\n")
menu_input = input("> ")
if menu_input == "inspect":
if position == areas.east_sword... |
Did this challenge for an employer (not under an NDA or anything) for a junior python-related position and wasn't selected. Unfortunately they couldn't offer feedback, and as this was my first stab at doing something in python, I really have no idea if maybe I missed something and it's not totally correct, or maybe it ... |
f-strings is a new feature in the upcoming python release which basically lets you do this:
>>> s = 'qwerty'
>>> f'{s} {1+2}'
'qwerty 3'
Not pleased at having to wait until f-strings are widely supported, I came up with the following function, which should work for any Python version starting with 2.6.
def f(s):
r... |
I've been experimenting with different ways of reusing (and naming) the expressions I use in Entity Framework. I've tried static fields with Expressions and extension methods but neither are perfect. In my latest attempt to solve this problem, I'm attempting to implement the specification pattern!
Firstly, I created a ... |
This is a follow on to Part 1
In order to use my new Specifications within expression trees so I can use them in projections/navigation collections I had to write an ExpressionVisitor to find Specifications and replace them with their Expression.
In order to convert an IQueryable into one that supports the specificatio... |
I have it running well and would just like any suggestions.
Note: Yes I am using global variables and would like to keep it that way, at least for now. The reason is, that I am using The Great Courses to learn computer-science concepts, and the instructor insisted on using Global Variables...since we haven't learned ab... |
What I am essentially doing is writing a snake game that everybody could play on the internet, broadcast their game if they like and so on. Now it looks like this, just websocket-based snake, no user authentication or everything. Pure and simple as possible.
Well, does my code follows best practices of coding both on s... |
This script is part of the Cameleonica project, which aims at creating a versatile filesystem. This script measures performance characteristics of a disk: how long are seeks on average, and so on.
I would appreciate if reviewers would also upload their output to gist, if convenient. I only have access to 2 hard disks ... |
Let's say I have following action:
export function signIn(data) {
return {
type: USER_SIGN_IN,
promise: api.post('/sign_in', data)
}
}
and the following middleware:
export default function promiseMiddleware() {
return next => action => {
const { promise, type, ...rest } = action
if (!promise) {
... |
I was wondering is it OK to change implementation of parent class with child class data. I have situation of creating a child class (form) which extends the parent class (other form with same elements). If I don't change implementation of parent class some HTML Elements will have the same id and both forms are on same ... |
Here's some code which, given a list of \$N\$ movie lengths, checks if there are two movies that equal the exact length of a flight. This solution runs in \$\mathcal{O}(N)\$ time since I used a hash table.
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
const int L... |
I just wrote this function for personal use only while working on a specific data project. I would be grateful for any feedback!
get.coef1 <- function(x) {
x <- as.character(x)
m.names <- paste("fit", x, letters[1:3], sep="")
models3 <- matrix(numeric(12L), 3, 4)
for (i in 1:3) {
models3[i, ] <- summary(get... |
I am new to programming and I would like some feedback. This is my first ruby program that simply adds a + b. I know it's probably more complicated than it needs to be, but I wanted to implement ideas that I was learning. Is there anything that I should do that I didn't or did that I shouldn't?
puts "<<<-----ADDITI... |
I recently answered a question that had me wondering if I could simplify this below code without creating an extra function:
for object in objects {
if let type = object["type"] where !type.isEmpty, let name = object["name"] {
print(pokemonTypeDefenseChart[type])
for weakness in pokemonTypeDefenseC... |
Given a list of time intervals, I want to return the intervals with the most overlaps (i.e. most people free). My solution runs in \$O(n \log n)\$, but I made a bunch of "tracker" variables. How can I avoid creating all these variables?
Interval class:
public class Interval {
int start;
int finish;
public ... |
This is the application for small school, which will store students' info in Firebase and also retrieve data from Firebase. I am using JSON Parser to parse the data and save the same in Access tables.
I am using this function in MS Access to connect to the Firebase. Please tell me if I am doing anything in an inefficie... |
Here is my code to print tree in a level by level way. It needs to print an empty node as well to keep tree structure like full binary tree for elegancy reasons.
I'm wondering if anything you think could improve, including the efficiency and not sure if any bugs (I did testing, not found bugs). I'm especially wondering... |
I have multiple services with a lot of methods. Every method returns an int as a result code. All methods have 2 types of signatures:
Only with IN params
n of IN params and m OUT params in the end (in most cases 1 OUT param)
Up until now I came up with this solution:
#region Decorators
#region [Getters]
#region [Vo... |
I am working on an angular application. I have written a controller for a page which gets 10 objects from an api. On clicking the next button, it gets the next 10 objects and so on. I have also added a search box in the same controller which also gets 10 results of the searched term and on clicking the next button it g... |
I've been learning about unit testing with pytest recently, trying to figure out what is and isn't a valuable thing to test. I'm very new to it, so I thought a review would be a good way to learn about holes I'm leaving and mistakes I'm making.
So, I'm primarily interested in the test functions being reviewed, though I... |
I've decided to write a common Makefile for Google benchmark library. You could say I could have taken generated Makefile, but it's not appropriate solution (or maybe I'm wrong?).
TARGET = libbenchmark.a
CXXFLAGS = -std=c++11 -Wall -Wextra -Wshadow -Werror -pedantic \
-pedantic-errors -Wfloat-equal \
... |
I'm writing a sub-routine in AppleScript to get text from a file and insert that text in a list of lists forming a dictionary.
Text File:
a:b
c:d
e:f
Expected list:
{{"a", "b"}, {"c", "d"}, {"e", "f"}}
Here's my code:
on getDictionary(filePath)
set dictionary to {}
set dictionaryFile to paragraphs of (read P... |
So I have created this function that will add a disk if needed and it takes a disk and a size as inputs. The idea is that I need to update data.disks with a few properties. Disk is called from an external request and it follows the pattern of "disk1", "disk2" and so on. Looking at it there are a few hard-coded values a... |
I have some basic code which registers functions, with given variables, to be executed after a certain time has elapsed. I will roll this code into my software project when it is ready. If it works it works but since I've never done this before I am the Padawan and one of you out there, who's written code like this bef... |
Any idea to write this code more smarter and shorter? I also expect your advice about general organisation of the code.
Object of the Game
In your version of Mastermind, the computer will be the codemaker and one player will be the codebreaker. The computer picks a sequence of 4 pegs, each one being one of any of size... |
I was trying out my hand at solving problems and came across this HackerRank problem. I have written a solution which passes for a few test cases but times out for most others (time limit - 3 seconds). I'd like to know the best way possible to achieve the same.
Any pointers as to how the code may be optimized, any appr... |
Given:
def rights[A, B](xs: Seq[Either[A, B]]): Seq[B] =
xs.flatMap {
case Right(x) => List(x)
case Left(_) => List.empty
}
def lefts[A, B](xs: Seq[Either[A, B]]): Seq[A] =
xs.flatMap {
case Right(_) => List.empty
case Left(x) => List(x)
}
def combine[A, B](xs: Seq[A], ... |
I have a MEAN Stack app in which I have been using mongoose routes to update my data. Some of those routes have a lot of back and forth in terms of updating data across multiple users and collections. So I used the standard mongoose callbacks to handle them. It all worked perfectly but it turned into Callback Hell! So ... |
Instead of having multiple statements like the following, Is it possible to club them into one liner in jQuery?
var replaced = $("#myContents").html().replace(/Employee:/g,'<b>Employee:</b>');
$("#myContents").html(replaced);
var replaced = $("#myContents").html().replace(/SSN:/g,'<b>SSN:</b>');
... |
I am new to Matlab. Now I need to find the shortest distance between a given point to a surface, which is describe with a function.
I am planing to implement the method described in the link below with Lagrange Multipliers, and have writen my code to do that. However, I found my code runs slowly.
https://math.stackexch... |
I got a four-digit positive number. I need to square the two digits in middle to generate a new number on which the same procedure is applied. The numbers get saved in a list. This loops as long as there isn't an equal number generated (the list contains the number already). If a number is generated containing less tha... |
Tracks the number of calories a person consumes in a given meal it has helper method to get the day's total. The check method Tries to find any duplicate meals within the given list. The assumption is that a day can only contain one of each type of meal.
public class Meal {
public enum Type {
BREAKFAST,
... |
(See the next iteration.)
I have this C implementation of the merge sort for sorting singly-linked lists:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct linked_list_node {
int value;
struct linked_list_node* next;
} linked_list_node;
/***********************************************... |
I wrote this program to model interactions between a user and an artificial player, both playing by the same rules (not enforced here for simplicity).
The game played is here is "your next word has to start with the last letter of mine"
module Main where
import Lib
import System.Random
import System.Exit
import Contro... |
This is my first attempt at writing a programme: a BMI calculator written in Python. Please give me feedback on the programme overall, as well as how easy the code is to interpret and adapt.
from sys import exit
bmi = ["what is bmi?", "what is bmi", "bmi", "bmi?"]
male=["male","m"]
female=["female", "f"]
def bmi_q(... |
Here is my final build of the Age Distance Calculator - Any feedback on the code would be great - This is my 2nd day of java programming and thought this was a good little project.
package dev.swift.atc;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class AgeCalc {
private int personAg... |
I'm new to C# web, I want to know how to properly create a web app using
visual studio 2015 MVC templates, and being able to customise some of its code. I want to both practice C# web and clean code...
So I have 2 projects, one for Domain and another which is the Web App.
For example: In my Domain I have a class named... |
I have a class which lazily factors numbers. It provides the user with these methods:
getFactors returns a vector<unsigned int> containing the argument's factors
getFactorCount returns the number of an argument's factors
compareFactors takes 2 arguments returning a negative integer if the 1st argument has fewer factor... |
There are two functions, sportsRunning and sportsWalking, that will render different text. For this, I am using an if condition at the bottom to display corresponding div:
{sportsDescription.sportsDate && sportsDescription.sportsDate.length > 0 && sportsDescription.sportsDate !== '2199-01-01' ?
this.spo... |
I've made my own std::vector but it's the first time that I work with template and new/delete. The code works, but surely there are a lot of things that are wrong. Can you read the code and say me if I have coded it the right way?
(main is a test.)
#ifndef __STDVECTOR__
#define __STDVECTOR__
#include <iostream>
using... |
I already learned JAVA, a few design patterns (Controllers, etc.) and OOP. I'm trying too build some PHP scripts in OOP (a blog). I want to collect some articles from the DB and store in an array. I'm doing this with a repository (like I do this is JAVA). Is this correct?
Artikel.php :
class Artikel {
private $id;
pri... |
I'm back for more community punishment review of my own scripts and code! This time, I'm looking for general code review of my approach to a Python way of getting one or more hash sums for a provided file path (unfortunately, it's one-file-at-a-time, and only accepts one file path at a time). Hash sum selection is do... |
I have this code which compares two adjacent time stamps. If they are less than 15 min apart, it adds a new time stamp (row) in between with the new time stamp equal to the previous time + 15 min and value equal to the previous time stamp. If there is more than one-time stamp missing (more than 15 min interval), it add... |
I've been trying to improve my C++ skills, and deiced to try my hand at making a interpreter for a toy language. The language is called Quartz, and so far the only thing you can do is output strings. The following keywords can be used to print out a string: output, which prints all the strings on one line, and nl_outpu... |
I am writing a program in Python that takes a folder of images and animates them.
For example, going through a list of pictures like this and animating them one by one:
Relevant features include:
Upon startup, ask user what directory they want to animate images from.
If the chosen directory has no valid images, displ... |
I've created a console based Tic-Tac-Toe game in python that has the ability to be expanded to a 9x9 playing field or more if you wanted to. By default it's 3x3.
Github link: https://github.com/Weffe/TicTacToe
Current Issues:
[Minor] Misalignment when printing a playing field of 4x4 or greater
Tried to keep the TicTa... |
I'm trying to implement round-tripping from LinkedHashMaps to Clojure collections. The implementation below works for smaller collections, but larger collections raise OutOfMemoryError: GC overhead limit exceeded. Below is a generative test that passes, when the number of tests is small (~10), but exhausts memory for l... |
I've made this coding for large web pages with lots of text, images etc. If the user scrolls down or up it shows where the current view approximately is. In relation to the overall document height.
I'm considering to put it on GitHub. What improvements have be made so that it can be used as an Plugin, so that it can be... |
Here are the relevant parts of a project I'm working on that's working perfectly. I was wondering what I should change to improve it (to respect SOLID principle for example), especially regarding my add/remove loot functions which, even though they work, don't really feel right.
public class Hero
{
private int gol... |
Randal Schwartz stole Lisp's decorate-sort-undecorate idiom when he came up with what we'd later call the Schwartzian transform. All of my Lisp knowledge disappeared through nine half lives, but I gave it a shot in SBCL. I'm aiming for an idiomatic example I can use in a presentation about the history of the Schwartzia... |
I have a vector of ints that represents a point on a N-dimensional grid. I need to find all grid points that are within a given radius. I wrote the following, but it is rather inefficient, because it iterates through all points in a cube and checks the radius for each point:
typedef std::vector<int> VectI;
bool getNex... |
I'm an EFL teacher, and I built this web app to present a random group of questions for quizzes and tests. The page opens with random questions. Clicking anywhere brings up the spinner. Clicking anywhere again brings up new questions. The app uses viewport units to scale to any device.
The app works well in recent brow... |
I want to change the background color of each section of the page when the user scrolls. The code works but I feel like it's too inefficient
var colors = ['blue','yellow','green','purple','brown'];
var myScope;
var sections = [$('#section1'),$('#section2'),$('#section3'),$('#section4'),$('#section5')];
var sectionTop =... |
I'm currently building a Windows Form Application using Visual Studio 2015 and the Visual Basic.NET programming language.
On the main form there is a Tab Control and an ActiveX PDf viewer control. The Tab Control has 4 tabs they are labled "Find", "ECO View", "ECO Edit" & "User Admin". ECO = Engineering Change Order
T... |
I am fairly new to AngularJS and I am trying to improve my knowledge of this JavaScript Framework by building small real-world web-apps.
In this case, I have built a currency converter app with harnesses an exchange rate API built by me which runs here.
I want to know whether there exists a scope of improvement and opt... |
This is an interview question which i am trying to solve.
You are given a 2D array of characters and a character pattern. WAP to find if pattern is present in 2D array. Pattern can be in any way (all 8 neighbors to be considered) but you can’t use same character twice while matching. Determine whether pattern is presen... |
I'm pretty new to Java development and have written a little POJO to "PDF Form Filler" program. I'd be interested in recommendations and suggestions about coding style, used methods and classes and so on. The project uses apache's pdfBox and can be found in total at https://github.com/baao/pdffiller.
Extra Question:
As... |
While teaching myself Wx using this GridSizerTutorial page, I suddenly realized that there was a construct in Python that would let me considerably shorten the initialization code below. The three lines at the top replace the twelve commented lines below. (Three statements now split over six lines for greater clarity).... |
I know that the below solution is not the best one and I am in the way to learn that stuff till then I have applied the brute force to see how far I can go with my intuition.
console.clear();
function allButLast(arr) {
return arr.slice(0, arr.length - 1);
}
function last(xs) {
return xs.slice(-1);
}
function ma... |
My problem/concern is that I am trying to remove duplicate code from my functional tests without breaking the Page Object Pattern that I am following.
If you look at the code below, you will notice that 4 lines are constantly repeated in my tests, breaking the DRY principle - they are marked with a "todo" comment. But... |
(See the initial iteration.)
Continuing from Merge sorting a singly-linked list in C, I have incorporated the points made by @vnp.
Now it looks like this:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct linked_list_node {
int value;
struct linked_list_node* next;
} linked_list_node;
... |
I am wondering if that is a safe and proper init, with one failable init guarded and an init.
Are the force-unwrap correct in the self.init as I know they are those types ?
struct Item: Equatable {
let id: NSNumber
let displayName: String
let amount: NSNumber
init(id:N... |
Since I am using Hackerrank codepair, I have to resort to inner classes.
Please review the code and let me know if this can be improved.
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.PriorityQueue;
public class LinkedListMerge {
private List<LinkedList<Integer>> li... |
I am trying to improve a website to be as accessible as possible to screen readers and people who want to disable JavaScript (not necessarily both at the same time) so I use a checkbox with a label to display/hide the side menu
Some of the aria attributes get changed by javascript depending on screen size and whether t... |
I am implementing fundamental data structures in C#. I have written a weighted graph in Java so my main motivation here is to sharpen my skills in C#. I have tested with various cases and there seems to be no logical issues, but I know the language could be better utilized.
The Pathfinder method is not absolutely neces... |
I was bored the other day and decided to have a crack at Project Euler Problem 54 for some fun. Given a file containing one thousand poker hands dealt to two players, the task is to count the number of hands won by Player 1.
This is the first project Euler problem i have completed and thought it would be good to get s... |
I want to override the console.log function in order to save the data other scripts log. My script executes before any other script, so I have full control over the environment. This is my current function for overwriting console.log:
+function(){
var a = Function.prototype, b = 'toString', c = a[b], d = c.apply(c)... |
There are a plethora of streams and streambuffers available today, none are as fast as a memory streambuf, that you can use for testing. Shoot away!
#ifndef MEMSTREAMBUF_HPP
# define MEMSTREAMBUF_HPP
# pragma once
#include <cassert>
#include <cstring>
#include <array>
#include <iostream>
#include <streambuf>
temp... |
I want to generate a four digit code based on the code generated before it, starting at 0000 and going to zzzz.
These are the available characters to be inside the code:
private static final char[] _availableChar = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
The first thing I do is the get the newest code or... |
I want to search for a string inserted in TextBox1 on Mainwb within a range of data located in Workbook officerA Worksheet DATA!(A2,G2000), and then paste results found into Workbook Mainwb.sheet("MAIN SCREEN").Range (A5,G500)
I am totally new to VBA and wrote this code quoting from many sources. I'd like to know how i... |
This is a simple program that opens programs from a simple spot:
import random
import webbrowser
import os
import yagmail
#importing all module ^^
greetings = ['hola', 'hello', 'hi', 'Hi', 'hey!','hey']
random_greeting = random.choice(greetings)
maps = ['maps', 'open google maps', 'open maps', 'please open google map... |
All my projects have a fairly similar package layout:
package_name/
package_name/setup.py
package_name/package_name/__init__.py
package_name/package_name/data/foo.txt
package_name/package_name/__init__.py contains:
__version__ = '0.0.1'
__author__ = 'Alec Taylor <alec.taylor6@gmail.com>'
With a setup.py like:
from se... |
Here's the school assignment I did:
Problem 1. Write a program that simulates a soft drink machine.
The program should use a structure Beverage that stores the following
data:
Drink Name
Drink Cost
Number of Drinks in Machine
The program should create an array of five structures. The elements
should be initial... |
I have this function to ease out the task of inserting data into databases.
I am not very sure if it is secure to use it this way.
Any suggestions on improving it?
function insert_into($query,$datatype) {
//$i=0; num=1; $i=1; num=2; for(i=1;)
$num=func_num_args()-1;
global $CONN;//set the g... |
I made a very simple program where you input a students grades (edit the code with the set method?) and the program will output the average. Each test has a different weight associated with it.
The problems I think I have right now are:
I am not properly utilizing my methods. The getters and setters are probably done ... |
I have this WCF data service class and I believe it is doing a lot:
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class PetSuppliesRelationalData : EntityFrameworkDataService<PetSuppliesEntities>
{
private string _TenantID
{
get
{
return H... |
With this code I am reading a XML-File that is on a server. In this XML-File are several links. I have to check them if they are accessible. For each link I add an item to a listview with a green background (accessible) or a red background (not accessible). The program is relatively slow.
Public Class frmMain
Private ... |
I have a Rails app where Loan has paid attribute. Loan should be marked as paid if total sum of payments is equal or higher than loan amount_to_pay. Problem is that it is obligatory to have paid attribute and not checking it dynamically by joining payments to loans and selecting whether it is paid or not (long story...... |
def greatest(a,b):
if a>b:
return a
return b
def odd_check(a):
return not(a%2 == 0)
def go(x,y,z):
a = odd_check(x)
b = odd_check(y)
c = odd_check(z)
if a and b and not c:
print greatest(x,y)
elif a and not b and c:
print greatest(x,z)
elif not a and b and c:
... |
I am a jQuery beginner and would like some pointers on whether the following code could be made shorter, or there is a better way to get the same result.
jQuery(document).ready(function(){
var aa=jQuery('#navigation-wrapper');
var bb=jQuery('#top');
jQuery(window).scroll(function(){
if(jQuery("b... |
Is there a simpler way with a simpler notation to do the following part of code:
void swap(char **s1, char **s2){
char *tmp=*s1;
*s1=*s2;
*s2=tmp;
}
void sort(char ***m, int dim){
int i, j, flag=1;
for(i=0; i<dim-1 && flag==1; i++){
flag=0;
for(j=0; j<dim-1; j++)
if(str... |
I am learning Java by reading source code of other authors. This Java method handles communication with SQL database. While the code does work several things concern me. For instance the try catch block at the end of the file used as a workaround. What is the correct way of doing it? What other problems can you spot?
... |
I am preparing to write a widget for the browser that is both visual and interactive. I am a newbie to Javascript/Ecmascript and prototyping. I want to encapsulate the canvas element, abstract the data, and render visuals. A major design goal is to minimize developer effort. I am looking for direction and best practice... |
I need to create a tree from a flat collection. The order of elements is defined in a specification so it's rather impossible that it will ever change... but I want the whole algorithm to be configuratble and extendable aka universal... the SOLID virus ;-) so I did the following...
Data Models
I created an attribute t... |
I'm new to Python and experimenting with some simple scripts. I would appreciate if you could give me some suggestions on how the following code can be improved or made simpler or anything in general.
#Coverts MAC Addresses into cisco format
def mac_conv(mac, sep='-'):
#split mac address into 3 groups
splitted_mac... |
I just stumbeled accross some code and I would do it in a different way. Since I am quite new to programming, I just wanted to know if I understand it right.
Original Code:
protected void FireStateChange(LightCommunicationState OldState, LightCommunicationState NewState)
{
if (StateChanged != null && OldS... |
It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after reading less than requested. It doesn't use the stack or memory variables, except for the tables and buffers, so I employed e... |
Input is a string, and the method should return repeated characters in that string and the position of these characters.
I'm currently using Java 8 Stream. The problem is I have to do it by calling 2 times collectors. I am trying to find a way to combine all these operations in 1 single collector operations if possible... |
Create a program to find all the prime numbers between 1 and 100.
One way to do this is to write a function that will check if a number is prime (i.e., see if the number can be divided by a prime number smaller than itself) using a vector of primes in order (so that if the vector is called primes, primes[0]==2, primes... |
I've just bought myself a domain and recently created a rough draft of a portfolio website.
A few of my friends have looked over the general design of it and given me some positive feedback so I thought I'd see if anyone here would have some feedback about the actual code.
It's quite a handful of code, so I'm not expe... |
There is a list consisting of zeroes and ones. I want to find out the length of the longest streak of ones. Is there a better solution?
def consecutive_one(data):
one_list = []
size = 0
for num in data:
if num == 1:
one_list.append(num)
elif num == 0 and size < len(one_list):
... |
I have a python code named seasons.py which uses inputs to open different web pages in which there are links to download Pokémon episodes.
The program has a module called seasons.py where it returns the number of episodes that has the season which was entered. It also needs a number of text files called last.txt, and s... |
First Class Functions
So, VBA doesn't support functions as first class objects - no passing functions as arguments or storing them in variables.
I eventually found a way to implement function pointers using AddressOf and DispCallFunc, but it was rather dangerous - if you pass the wrong number or type of parameters, you... |
Clojure beginner, looking to improve this code I submitted for Escape the Trolls, a Weekly Programming challenge over in reddit. No trolls yet, just walking through a maze for now.
(ns ctrollmaze.core
(:gen-class)
(:require [clojure.string :as str]))
(def sample-maze
"#####################################
# # ... |
I have completed writing a responsive menu (it uses the HoverIntent plugin) for my WordPress theme and it looks like it is working fine on desktop/tablets/phones.
You can test the code here. Just make sure that you are testing within Chrome/Opera Developer Toolbar (ctrlshiftI) and then toggle device toolbar (ctrlshiftM... |
Brief Description:
A generic extension method that performs the same function as IEnumerable.Any(), but does not throw an error when passed a parameter with a null value.
Explanation:
Often times I will come across code that performs two steps on a nullable collection to make sure it contains elements. The first step c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.