instruction stringlengths 71 71.9k |
|---|
I'm doing another Project Euler problem, number 35:
The number, 197, is called a circular prime because all rotations of
the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31,
37, 71, 73, 79, and 97.
How many circular primes are there below one mi... |
I've just written a simple caching / memoization python decorator. It's purpose is to cache what the function returns for all the arguments combinations it's been ever invoked with.
So, if, say, we had a function my_function(a, b=2, c=3) invoked once with my_function(1, 2, c=3), the results should be then cached whenev... |
Project Euler #10:
The sum of the primes below 10 is \$2 + 3 + 5 + 7 = 17\$.
Find the sum of all the primes below two million.
My solution:
public class PrimeSumFinder {
private static final int MAX = 2_000_000;
public static void main(String[] args) {
long time = System.nanoTime();
long res... |
This is supposed to encode and decode small strings of text. Unfortunately, even on a really good laptop, it performs slowly. This might have to do with my looping, or just the sheer computation.
It takes a string, uses simple RSA, subtracts by random #, converts both to fixed binary, then compresses using base 80 "eve... |
Most of my experience is in Python, Java and embedded C, and I need to learn Scala and Play for a new job. As an exercise, I decided to create a very simple API for looking up area by postal code, backed by Redis. It's just a single controller with a couple of routes.
I'm hoping for feedback from experienced Scala or P... |
My home-made wannabe-a-parser was wet behind the ears, so I started seriously looking into more mature alternatives, and ended up adding a dependency to the ANTLR lexer/parser generator tool, and using that along with a slightly modified Visual Basic 6 grammar I was able to generate the real deal - a full-blown real pa... |
I am making a key-value database using acid-state. It has three similar "pools", one for cookie records, one for email verification of new accounts, and the last for resetting passwords.
There are three Update/Query:
1. insert a new record
2. verify using records in the db
3. delete a record
Initially, I wrote three di... |
This is an interview question from here. Specifically, the second asked for a function that took in two sorted arrays of integers with no duplicate values within a single array and which returned an array of the duplicates between the two arrays.
Here is my solution (with tests):
public class ArrayDuplicates {
pub... |
I have been programming for about ~2 years, and mostly wrote OOP and structural code. Recently, I have decided to pick up a functional programming language, and Haskell being too alien for me, looked to Racket (since it is high time I learned a LISP anyways) and am loving it. Since this is a new area of programming for... |
I have this piece of code for running a Stored Procedure, and I was wondering if there is a way of cutting code like:
uPar = .CreateParameter("@PropertyID", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput)
.Parameters.Append(uPar)
.Parameters("@PropertyID").Value = Val(lblPro... |
I required a trigger, whenever the window text selection cleared.
Finally I found this approach.
Using the same id, I have added multiple event handlers, but I am not sure my work is the best.
Is there a better way to do this?
$('#tenderContent').on('mouseup', '.tenderdocument', function (e) {
e.stopPropagation()... |
This is the problem statement for Insertion Sort - Part 2.
In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array?
Guideline: You already can place an element into a sorted array. How can you use that code to build up a sorted array, o... |
recently I've started to learn Clojure. I came up with an easy programming problem, described by this C code:
int main() {
const int N = 5;
const int M = 12;
uint8_t small[N] = { 1, 2, 3, 4, 5 };
uint8_t big[M];
memset(big, 0xff, M);
for(size_t i = 0; i < M; ++i) {
big[i] ^= small[i... |
This is supposed to search for a node in a huge Treeview. The node could be found in many places. In other words there may be many nodes and the resulting tree should be expanded depending on where nodes are found.
I was asked to avoid recursivity in this method. The only solution I was able to get is using LINQ querie... |
I'm rather new to C#, and found relevant subclassing examples surprisingly hard to come by. I've whipped up this class that appears to work, but am pretty sure this is not optimal:
private class ThrottledRestClient
{
int pause; // mininum ms between requests
double rpm; // max requests per minute
long las... |
I've been researching AES encryption a bit over the past several days. The official (MSDN) examples I've seen are encrypting and decrypting using the same AES instance. They don't go in to what to do when generating and saving an encrypted value with AES and needing to decrypt it later with another AES instance.
I came... |
How can I improve readability of this code? indentChar needs to be reused elsewhere.
toCoordinate = dropWhile ((||) <$> (not . indentChar) <*> (=='(')) >>> takeWhile(/= ' ')
indentChar = (||) <$> isAlpha <*> (=='(')
Desired result:
*Parse> toCoordinate " \\--(my.coordinate - from outerspace)"
"my.coordinate"
|
I have implemented the question #268 from Topcoder. The question is that there are 4 conditions for a lottery ticket:
CHOICES - numbers available (10 ≤ CHOICES ≤ 100)
BLANKS - number of numbers that can be chosen (1 ≤ BLANKS ≤ 8)
SORTED - are the numbers sorted
UNIQUE - are the numbers unique
The input is given as
(C... |
I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a pair.
public static int sumOfTwoExists(int[] largeArray, int a, int b) {
A: for(int count = 0; count < largeArray.length; count ++) {
for(int cou... |
Originally, I created a program that echoes files or strings to output. This is a modification of that same program and goes a step further. It does work (in both Linux and Windows), but I can NOT guarantee that it is bug free or that it is even fully compatible with both OS's.
This program writes, reads, and copies fi... |
I want to redirect all pages under a certain directory to a single file, like so:
/dir/a → /dir/new
/dir/b → /dir/new
/dir/new → /dir/new
With the straightforward
RedirectMatch 301 ^/dir/ http://example.com/dir/new
I get a redirect loop, since /dir/new redirects to itself. I replaced it with a regular expression
R... |
I have a spreadsheet with order date data:
I need to find the average interval in days between each order date. I have to both find a way to get past the blank cells in the row, and also take into account that some clients have 5-10 orders and some clients have 2 orders when calculating my average frequency (interval... |
I'm writing unit tests for a web application that has quite a lot of UI interactions. I would like some feedback regarding on how to handle click events with asynchronous code.
My goal here is to simluate users interacting with the page. That's why I'm triggering events rather than making function calls.
Here is my id... |
This below program will be further enhanced for TicTacToe game with Human and Computer as players.
Currently this program is written for choosing best move for a given grid position.
package project2.tictactoe;
enum TicTacToe{
X, O, NULL;
@Override
public String toString(){
switch(this){
... |
I made my first jQuery plugin, and was hoping to get a review. I'm especially interested in comments on whether I went about building up my html and applying the css in a reasonable manner (I chose to do it all in jQuery to keep the dependencies limited).
I welcome most of all comments regarding ways to improve the cod... |
I have an application with a recent addition that requires the removal of a struct pointer from a slice that is itself an element of another struct. A summary of the usage.
I am wondering if this is idiomatic and okay usage of the go languages. Things appear to work and this appears to be inline with the golang recomme... |
My code below ensures that only land animals can be a "representatives" for Land while only ocean animals can be representatives for Ocean, and so forth for Air, Underground, etc... Just want some feedback about whether this system I've come up with is any good or if there is a better one. Note: I'm using structs in... |
Challenge:
Given 2 lists of positive integers.
Write a program which multiplies corresponding elements in these lists
Specifications:
Your program should accept as its first argument a path to a filename.
The lists are separated with pipe char: '|' .
Numbers are separated with a space char.
The number of ele... |
I'm fairly new to MySQLi and PHP, but I've been working at it for a bit now, and reading up on how to make secure login forms, avoid SQL injection etc. I'm a mere amateur though.
I've created an index.html page (not including the code here, just a basic form though), a register.html page (not including the code here, a... |
For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle.
type Army = Int
data Battlefield = Battlefield { attackers :: Army, defenders :: Army }
deriving (Show, Eq)
In addition, Prof. Yorgey implement the following code to simulate the random throwing of dice:
... |
This is the problem statement for Lonely Integer.
There are N integers in an array A. All but one integer occur in
pairs. Your task is to find out the number that occurs only once.
Input Format
The first line of the input contains an integer N indicating number of
integers. The next line contains N space separa... |
While reviewing Multiplying Lists, I got the impression that the problem was naturally suited to Java 8 streams. Unfortunately, since there is no convenient way to zip two streams, the solution ended up being uglier than I expected.
The task is to take lines of input, in the form a0 a1 a2 … an | b0 b1 b2 … bn, where t... |
I'm trying to get table header name in excel. I tried it using index, IF and MATCH. It works but I am not sure whether my formula is the best or not.
This is how my sheet looks:
And here is my formula to get produk name (E19:E22):
=INDEX(
$C$10:$H$10,0,
IF(IFERROR(MATCH(D19,$C$12:$C$14,0),0),1,
IF(IFERR... |
This takes a dataframe as an argument, looks at all pairs of two columns in that data frame (country and year) and returns a column value of that pair in another data frame (the gini number).
get_gini <- function(year, country){
GINI = 0
SUBSETTED_WITH_COUNTRY_NAME_NOW_WITH_YEAR <- inequality[inequality$Code== ... |
This was done as an assignment in school. As I am still learning some of the basic parts of Java be merciless when it comes to my code. As it is an assignment, some things are unchangeable. The specification requires:
Swing. So no third-party library is allowed.
Cell class with getCol() and getRow() methods.
For the f... |
I've started learning C++ recently and want from what I've gathered smart pointers are the way to go when storing stuff on the free store. I want to make sure I've got the basic hang of C++(11) correctly. I've implemented a very basic vector class (a mathematical vector) and would greatly appreciate if anyone would poi... |
I'm trying to learn some OOP programming using Java, so I've created TicTacToe. Could you give me some advice on how I can improve this code?
Player.java:
package com.kamil.dude.tactoe;
import java.util.Random;
import java.util.Scanner;
public class Player {
public char currentPlayer;
public Player() {
Random ge... |
I coded this program as a challenge for /r/dailyprogrammer. Basically this program can convert any number from any base to another base including negative bases as long as the input is coherent. Did I follow the Python 3 standard or commit any obvious mistakes? I am also wondering if I can efficiently filter out nonsen... |
I have set up card, deck, hand, player, dealer, and game classes. The game class is there to keep a lot of the logic out of the interface (main.py). Let me know any thoughts on that.
I haven't ran pyflakes or a PEP8 checker on it yet, so keep that in mind!
main.py
from game import Game
from card import Card
from deck i... |
I'm dealing with data that stores its state as a String, treating the string like a stack. I also have to combine that with error handling.
To that end, I'm using the type StateT String Maybe a. I have a function to pop and to push a Char from and to the string:
pop :: StateT String Maybe Char
pop = do
x:xs <- get
... |
I'm starting to learn OOP with PHP, and all I've learned so far is just by searching and reading. So I have this need to check input data for certain things like min of chars, max of chars, spaced or not spaced, just letters or not.
So far I've just created the alpha() method which is just for letters only. I'm pretty ... |
I was trying to solve a problem which needed you to count the number of perfect squares in the given range:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int isPerfectSquare(int x)
{
float s = sqrt(x);
if (fmod(s,1) ==0)
return 1;
else
return 0;
}
int main() {
... |
I am about a month into learning Java and I'm just looking for some comments on my code. Specifically, I would like to know if I'm being as efficient as I can be. This is the most complex thing I've come up with so far (that works) and I wanted some feedback on my developing coding style.
public static void main(Stri... |
Is it possible to make the hexStr function faster?
#include <sstream>
#include <iomanip>
#include <stdio.h>
std::string hexStr(unsigned char* data, int len)
{
std::stringstream ss;
ss << std::hex;
for(int i=0;i<len;++i)
ss << std::setw(2) << std::setfill('0') << (int)data[i];
return ss.str();
}... |
This is my first program using classes. How could this be improved?
#include <iostream>
class TicTacToe
{
char m_field[3][3];
char sign;
public:
char Sign(char x) {sign=x;};
void MakeField();
void DrawField();
bool IsFree(int y, int x);
bool FindAndReplace(int x,int y);
bool Row();
... |
This is the follow up version of a previous question on combining different categories and their properties.
The home page contains the overarching company information.
The product page contains product information and links to the home page.
I do not get any error messages in Google testing tool. But I feel that the c... |
I wrote this code for Android server interaction. The way I built the client was an onSharePreference of strings includes photo encoded to a base64 String object {imei, barcode0, barcode1, photo0, photo1, time_taken0, time_taken1,..} because I had the possibility the user won't be connected to the internet all the time... |
I know I can increase the size of the heap but that seems like a poor solution.
This program runs correctly on small files but when run on large data sets it crashes with the OutOfMemory: Java heap space error.
This code executes multiple hash map operations and I'm certain that the haphazard way in which I strung the... |
I want to upload images to server from browser window. I'm using this function for image upload. Images are uploaded by GD library.
What is your opinion of this code? Is there still a way to upload a malicious file?
<?php
function imageUpload($name, $thumb = false, $max_size = 5242880, $height = null, $width = null, $T... |
I am trying to learn how branch optimization works.
For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary tables (don't know the words, will comment in code).
Is doing what I have done in the code better than using if's, it runs about 15% faster.
Is there a better... |
I am new to Python and am trying to see if there is a cleaner way to write my code. The following code take iterables as parameter it produces the first value from the first parameter, then the first value from the the second parameter, ..., then the first value from the last parameter; then the second value from the f... |
I am developing a chat program (mountreus-chat and GitHub) in Node.js using Socket.io and my code looks awful. I'm starting to use commands and now it's even worse.
Here's a code snippet (you can find every detail on the Github repo):
io.on('connection', function(socket){
if(socketConnections().length <= 1024){
... |
The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps:
Receive SMS message (with the help of SMSlib)
Extract data with regex
Push data to MySQL database
I've only been exposed ... |
I know I should use services and patterns to refactor this controller action, but I can't imagine one that could fit/be appropriate for this problem.
It seems a strategy or template, but a strategy is supposed to be changed if needed; in my case, it should be always the same:
Get the customer
If doesn't exist store t... |
Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests.
[TestMethod]
public void UniquePositionPoint_CreateUPP_UPPExistsInPPField()
{
//Setup the values to be used by this test.
CIM_Network network = new CIM_Network();
string x = "5";
string y = "10";
string expectedMRID ... |
I have developed a readline function in C and I want to know your opinion on it:
// read a the whole line, stop if encouter eof
static char *readline(FILE *in, sid_error *error)
{
#define MAX_SIZE 64
size_t size = MAX_SIZE;
char *str;
if((str = malloc(sizeof *str * size)) == NULL) {
*erro... |
I want to simplify my Rails models, current looks like this:
class User < ActiveRecord::Base
has_many :offers, dependent: :destroy
has_many :reviews, dependent: :destroy
has_many :comments, dependent: :destroy
end
class Offer < ActiveRecord::Base
belongs_to :user
has_many :documents, as: :documentable
has_... |
I wrote this DFS in Python and I was wondering if it correct. Somehow it seems too simple to me.
Each node is a class with attributes:
visited: Boolean
sons: list of nodes linked to the current node.
This code should work both for directed and undirected graphs.
def DFS(node):
node.visited = True
if node ==... |
Building on my ANTLR tree listener, I'm now starting to see how the whole thing is coming together.
As I proceed to implement the numerous Node classes I'm going to need to make sense out of the ANTLR parse tree, I feel like I'm doing more and more weird things.. oh, the tests pass. But the implementations... here, hav... |
I decided to implement most of the reddit Daily Programmer space probe challenge. My program creates a 2D space that have asteroids and gravity wells distributed (the percentage of gravity wells and asteroids is given to the SpaceProbeModel class which randomly distributes them) and finds the shortest path from a start... |
I wrote a solution for a jug problem (given two jugs of water of different sizes find the steps needed to get specific amount of water in one of the jugs). I'm hoping for some input on my code. How can I make it better? More readable?
Optional - Is there a faster or more efficient solution I should look into?
#!/usr/bi... |
What is the quality of the code I've written? Is it easy to read or is it a low-quality piece of code? Also, is there any way I can improve the algorithm itself (beside changing C parameters)?
using System;
using System.Threading;
using Un4seen.Bass;
using Un4seen.BassWasapi;
namespace Szab.BeatDetector
{
public enum ... |
I just finished a fairly easy homework assignment. Basically all I had to do was add six JPanels that were just text boxes with color names as the text. However, the color of the font had to match the text, so for instance, black had to be black, blue had to be blue, etc. It works find but it just seems like I could ... |
I have a Back function, and it is growing. I also think this is terrible, but I don't seem to get how it can be improved:
public void GoBack()
{
NavButtonUsed = true;
Forward.Insert(0, Back[0]);
Back.RemoveAt(0);
if (Back[0].Title.StartsWith(" ") && CurrentItem.Menu != Back[0].Menu)
{
swi... |
I am building my "base exception to end all base exceptions" class in C# and was looking for some opinions on my implementations so far. Ideally my usage of integrated Rethrow, Throw, and ThrowFatal methods for some syntactic sugar.
using System;
using System.Collections;
using System.Collections.Generic;
using System.... |
The following is my sample code:
String month = "09";
String year = "2014";
String monthYear = "092014";
The monthYear format is MMyyyy, I wish to format it to become MMyy. Thus, I am doing it as follows:
Method 1:
final SimpleDateFormat oriMonthYear = new SimpleDateFormat( "MMyyyy" );
final SimpleDateFormat changeM... |
I've built a modal window as seen in my modal HTML and CSS code below and was looking for any tips/advice regarding how well I've applied any best practices in both my HTML and styling with regards to building a modal window.
Here's the tutorial I followed.
Here's my modal HTML code:
<div class="modal fade" id="basicMo... |
I have a web application to manage computers. Every registered computer is locally querying the latest information and updates the database with it in a 10 minute cycle.
But the computer is only allowed to update its information and nothing else. Currently I'm identifying the computer like this:
I get its hostname from... |
I wrote this code in C++ to convert an array to a binary tree.
For instance, int nums[] = {7,5,9,1,7,3} to a binary tree (root-7, root's left child-5, root's right child-9...).
( here, I made a function named 'create_tree()' which only take one argument )
Is there any shorter way to do this?
#include <iostream>
#includ... |
I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback regarding anything that comes to mind from more experienced developers.
/**
* Attempts to create new SavedSearch (eventual POST... |
How can I speed up my app? It's very slow if I click on a button and open a new page. All data in time is local. I'm not sure if the problem is in my code or xamarinu.
foreach (var category in avm.Categories)
{
ToolbarItem ItemCategory = new ToolbarItem();
ItemCategory.Name = category.Name;
... |
To get a simple, responsive, 4-directional movement in a 2D game, I've implemented the following. When a key is pressed, the add method adds the direction to the keys array. When the key is released, the remove method removes the direction from the keys array. In my Update method, I call getLast to get the last directi... |
Introduction
I've written a simple command line todo-list in Haskell.
The full code can be found here. However, given people's time constraints, I have selected three verbose functions for review.
Function One
program :: StateT TodoList IO ()
program = do
StateT $ \xs -> do
(choice,_) <- runStateT requestCh... |
In my application I need some resources to be loaded and I have services to load each of them and then I need some point to know that all requests finished. First thought was to use $q.all with array of promises from that services. But it would be resolved only if all promises resolved which is now always the right cas... |
I made an admin login script for my own CMS website that I'm making in Code Igniter 2.2.1 and I'd like to know what are the potential threats or some holes that I might have left open.
This is how it goes:
user submits form to admin_login page where the script collects the post data
the script checks if the admin use... |
When integration testing Rails applications HTTP request helpers can take a string or a named route as the first argument.
I find myself writing:
test "user visits edit page" do
homer = users(:homer)
get "users/#{homer.id}/edit"
assert_response :success
end
But I can also write:
test "user visits edit page" do
... |
I have this script for creating SQLite backups, and I was wondering whether you'd have any suggestions on how to improve this. I was thinking that maybe it should create the backup dir if it doesn't exist, but not sure if it's necessarily better.
Besides functionality/performance tips, any styling/formatting tips are a... |
I find that I often want to calculate summary statistics from collections of data and decided to create a template to do that. I'm interested in a general review, but I also have some specific questions.
Is the use of the lambda "too clever?"
Is std::accumulate OK? Specifically, I'm thinking of the potential for ove... |
Below I have code that calculates epoch seconds. It is built to try to change run time checks into asserts in order to give performance in production. I want to make sure all the edge cases are correct, though.
#define DAYSPERWEEK (7)
#define DAYSPER... |
I am going to use the following class which is very simple to use and get user info in pages:
<?php
ini_set("display_errors", "on");
class LoginSystem {
/* Start Config */
private $dbhost = "localhost"; // Host Name
private $dbport = "8889"; //Port
private $dbuser = "root"; // MySQL Database Username
... |
I am working on a small app to help my kids study their multiplication and addition. And I have various preferences I want to be persisted between visits. What do you think of the below to get the settings out of local storage? I know I could do it even more simply by simply stringifying the whole object at once, bu... |
In preparing a solution for the CodeChef "Will India Win" challenge, I am trying to find out the xor of list of numbers.
The first line of input contains the number of test cases, 1 ≤ T ≤ 106.
Subsequent lines contain fifteen space-delimited numbers (each between 1 and 231), to be XORed together.
def main():
t = in... |
I wrote a tool to store text as colors in a image around the border. I then saved the resulting image to file. To use the resulting file I set it's path to a the src attribute of a tag and call DrawImage and colorToText OnLoad to read the contents and remove the messy data around the edges of the image, thereby presen... |
I'm a bit lost with implementing MCV pattern on javascript.
Where should events (such as 'click','change') come in on MVC in javascript?
I have this event function,
var EventExample = function (controller, view) {
this.controller = controller;
this.view = view;
return this;
};
EventExamp... |
What do you think? In particular, I'm not sure about my exception handling approach to raise errors when posting objects; but I couldn't come up with anything better.
public class Thing
{
public Thing(int number)
{
Number = number;
}
public int Number { get; set; }
}
class Program
{
stati... |
I have written this code base on AsciiEngine. How can I improve this code?
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <memory>
#include <algorithm>
#include <unordered_map>
#include <type_traits>
#include <random>
#include <chrono>
#include <cassert>
#include <Windows.h>
enum ... |
I would appreciate any opinions and critiques anyone has on my code.
My code allow you to read a ini file.
parser.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "parser.h"
// read a the whole line, stop if encouter eof
static char *readline(FILE *in, sip_error *error)
{
... |
I have recently made two kinds of linked lists in Java. I know that there is one with generic and one without. However, what I am really concerned about is which style should be used mostly (or which style should be used as the main style to implement the LinkedList structure). When talking about these two styles, coul... |
Ultimately, my goal is to take two lists and then generate a third consisting of items that the first two lists do NOT share. I am able to get the results I want using two foreach loops, but I am hoping to learn about some magical List tool that will do it more cleanly.
public List<string> removeMatchingItems(List<stri... |
I'm trying to implement a mathematical expression evaluator and equation solver, and based on extensive online research and my own experimentation have come to the conclusion that the best way of writing one is by first parsing the expression and breaking it down and then feeding it into an evaluator/parser.
Note I wan... |
I've never written on VKScript (and on Javascript). I need high performance code to get more friend lists faster.
var targets = Args.t; // get params (ids)
// prepare all variables before loop
var all_friends = {};
var req;
var parametr = "";
var start = 0;
var q = {};
var user_friends = {};
// get each target from al... |
I rarely program C++ in anger, and considered myself somewhat rusty, and certainly not up to speed on C++11. For a bit of exercise, I thought I'd try implementing sha1sum, as wasn't really up to speed with topics such as cryptographic hash functions either.
(Yes, yes, you shouldn't use SHA-1 in new code, understood!).
... |
This code goes to the website containing the PDF, downloads the PDF, then it converts this PDF to text. Finally, it reads this whole file (Over 5000 lines) into a list, line by line, and searches for my name in it.
import mechanize
import os
br = mechanize.Browser()
br.open("http://sttm.org/Bulletin/Bulletins2015/tabid... |
I came up with an idea for a userscript to simplify writing answers on Stack Exchange while writing a previous answer.
This userscript adds "Review"-links on the top of each code segment. When clicked, it adds checkboxes in front of every code line. You select the checkboxes for the lines you want to comment about, cli... |
Now I'm reading C Premier Plus by Stephen Prata and there's an exercise 4 in chapter 6 which has no solution in the book, so I can't check if I did it properly. My code works like it should, but I want to know maybe there are some better or cleaner solutions.
Here's the description:
Have a program request the user to ... |
I am looking to create a simple column based responsive framework, and would like to call my classes something like:
<div class="col col-4-2-1"></div>
where the div would display as 4 columns on a desktop browser, 2 columns on a tablet and one column on a phone (these breakpoints are hypothetical).
or
<div class="col... |
I have a dict of stock tickers (KEY) and a data point (VALUE; e.g. dividend yield).
I want to know which tickers have a value between a specified min and max value.
Given
data = {'KO': 1, 'WMT': 0, 'IBM': 3, 'PG': 2}
gte = 1
lte = 2
Func1
def func1(data, gte=None, lte=None):
data_set = set(data)
gte_set = set(... |
This is fairly simple, so I'm just looking for ideas on anything that can be cleaned up, places it can be extended, and suggestions regarding style/naming (I'm terrible at naming).
It allows you to write something like:
object TimerTest extends App {
import Timers._
val time: Long = TimeBlock { timer =... |
I finished my Blackjack OO game and I'd like to get my OO skills reviewed.
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <string>
class Card
{
private:
char m_card; // 'A' ,'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q'
int m_value, //... |
After much trial and error, I finally came up with this code to call on other classes to perform their function. This code works and does what I want it to do, so I am looking for some comments on the code efficiency.
What I want to happen is have the user input which calculator they would like to use and have that ca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.