instruction stringlengths 71 39k |
|---|
I am developing a library to easily register WordPress custom post types and taxonomies.
But the problem is I can't use one instance of object because of adding the object in WordPress hooks.
So what I have done as a solution is to re instantiate the class every time when you want to register a custom post type. Is tha... |
I'm going through the Google Foobar challenges and am currently on the first challenge of level three. I've come up with a working solution, however, it's not an acceptable solution because it runs out of time. How can I optimize it?
Problem Statement
Oh no! The mad Professor Boolean has trapped Beta Rabbit in an NxN
... |
Two strings are isomorphic if the characters in s can be replaced to get t.
Can efficiency be increased further for this code? As I am getting errors that limit is being exceeded for very large strings.
static boolean isIsomorphic(String s, String t) {
s= s.toLowerCase();
t = t.toLowerCase();
if(s.length()!=t.length()... |
I applied for a Junior .NET Developer Position recently, and I was asked to solve a problem (Sales Tax Program) and I was rejected for some reason. The question goes like this:
Basic sales tax is applicable at a rate of 10% on all goods, except food, medicines and books. For all imported goods, a tax rate of additiona... |
On my web forms page, I have this huge GridView. I make it refresh every five minutes since the data has to be up to date.
It has sort options, so upon every refresh, I use cookies through every refresh to remember the search and sort options.
In the Page_Load function, this is how I do it.
HttpCookie cookieStat = new... |
Grade 0: ++
This is so low that it is boring; the operation of grade 0 is incrementing or counting up, for example:
5++ -> 6
8++ -> 9
Grade 1: +
Addition is repeated incrementing:
4 + 3 -> 4++ ++ ++ -> 7
2 + 2 -> 2++ ++ -> 4
Grade 2: *
Multiplication is repeated addition:
3 * 4 -> 3 + 3 + 3 + 3 -> 12
5 * 2 -> 5 + 5 -... |
I have a very problematic nested if/else/for that I'm sure it could use some love. Here's how it looks originally:
function addBookmark(obj) {
var isFound = false;
var posFound;
if (bookmarks.length > 0) {
for (var j = 0; j < bookmarks.length; j++) {
if (obj.mirror == bookmarks[j].mirro... |
I have a method that basically passes in a known drawn line segment in my view and then draws parallel lines n distances away from the passed in original line. This one in particular draws two parallel lines on either side.
It seems to be a lot of repeat code here, so how can I refactor it to a smaller method and avoi... |
For a class, I need to ask the user for a double. To verify that the number can be safely passed to Double.parseDouble, I wrote the following function. I'd like to have it heavily scrutinized; including the comments.
Are my comments helpful? They're more directed towards the marker than a maintainer down the road. Sho... |
Some numbers have funny properties. For example:
$$\eqalign{89 &→ 8^1 + 9^2 &= 89 &= 89 × 1 \\ 695 &→ 6^2 + 9^3 + 5^4 &= 1390 &= 695 × 2 \\ 46288 &→ 4^3 + 6^4 + 2^5 + 8^6 + 8^7 &= 2360688 &= 46288 × 51}$$
Given a positive integer \$n\$ written in decimal as \$abcd\dotso\$, and a positive integer \$p\$, we want to find ... |
This is my implementation of a Tic Tac Toe game with Tkinter GUI. So far I've set up the game to play with another player. For an interview coming up, I am suppose to build additional feature such as play with AI.
I would like some general feedback on my code. Does my code smell? Can I organize the Player, Board... |
In a further exercise of my original Battleship test framework, I have enhanced and refactored the SmartRandom class from an earlier question and have updated GitHub project to incorporate most of the suggestions I received for the previous questions. This is the second non-trivial bombing strategy class for the May 2... |
I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice versa.
public Node<T> findKthFromTail(int kthElem) {
// length has the size of the list
int kthPos = length - k... |
I would like someone to review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand.
I used code climate and I got 4/4 and my test coverage is 96%, yet I would like a professional opinion about it.
'use strict';
var cheerio = require('cheerio');
var FeedParser =... |
I would like someone review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand.
I used code climate and I got 4/4 and my test coverage is 96%, yet I would like a professional opinion about it.
'use strict';
var PromisePolyfill = require('promise');
var http = ... |
I'm stuck with a contest problem.
Description:
What is the minimum number of moves to annihilate an int array where the possible moves are:
Remove both the first and last elements if they are equal to each other, or
Remove the first element, or
Remove the last element.
Input
The first line is the number of test case... |
I'm in the process of attempting to write a parser compiler. In this, sets play a major role. I'm in the 'lexical ambiguity' isolation phase, and to that, I need to yield a set of every possible permutation of a given set of items which represent an ambiguity.
An ambiguity is reached when there are at two or more ite... |
#include <iostream>
const int STRINGSIZE = 100;
using std::cout;
using std::cin;
using std::endl;
void IsPalindrome(char[]);
void IsAlphaStr(char[]);
void CountChar(char[]);
int main()
{
char string[STRINGSIZE] = {};
char repeat = NULL;
cout << "Would you like to perform an analysis on a string of ch... |
Cross post from stackoverflow, as suggested.
I have an ordereddict, and I need to store it in CSV file.
Input:
dic = collections.OrderedDict([('k1', 'v1'),
('k2', 'v2'),
('k3', [ [('k3a',21), ('k3b',22)],
[('k3a',23), ... |
I've managed to create a working shopping cart and my next concern is security, mostly about the architecture and session security.
Should I make sessions somehow secure, if there's no authenticated login and sessions are deleted when browser closes? or is session_start() enough in this case?
Would the server side val... |
The goal of this query is to get a list of payments where all the corresponding payment lines and transactions have the status CLOSED. These are one to many relationships. The database is Informix.
I wonder if there is a more efficient way to write this? In its current state it has a lot of repetition which, maybe beca... |
This assignment is taken from Berkeley's CS61A page here.
Introduction
In this project, you will develop a geographic visualization of twitter data across the USA. You will need to use dictionaries, lists, and data abstraction techniques to create a modular program.
The map displayed above depicts how the people in ... |
I'm pretty new to client side scripting and I'm still learning.
I've written this JS plugin which animates blocks of HTML (fade-in from left/top/right/bottom) as you scroll down the page.
Everything seems to be works correctly, but was just wondering if there is anyone who could suggest how I can improve on this?
e.g:
... |
Let's say you have a Employees table mapped to a Employee class. Now you want to code a Edit page for general information. You need a ViewModel with all the properties you need to build the page, so you create EditEmployeeViewModel. Then you make your action EditEmployee and your view EditEmployee.
So far so good, but ... |
I am writing a script that will check the set values against a .properties file and I am just wondering if there is any nicer way to write what I have here.
#!/bin/bash
# @summary Check Values
# --------------------------------------------------------------------------------------------------
function _RunChecks
{
Su... |
I am doing a game that uses nape physics in ActionScript, but my question isn't about language. It is about the use of patterns.
I had fruits in my game. I did one interface Fruit and fruits like Banana using this interface. I also made a class Fruits to get random fruits in runtime.
public interface WorldElement {
... |
Our school grading scale is from 1..10 with one decimal. If you do nothing you still get a grade of 1.0. A passing grade equals 5.5. A 'cesuur' percentage defines at what percentage of correct answers the 5.5 will be given to a student.
Examples:
List item
Grade(0,100,x) should always result in 1.0
Grade(100,100,x) sh... |
This finds a value via a stored procedure then runs a second process in the same stored procedure rather than calling a second stored procedure.
When a call is 'simple' i.e. not Where x y then... I keep the stored procedure, even when I need to get a variable, in the same procedure.
I'd like to see if the concept that ... |
The need came up the other day to be able to easily switch back and forth between making IBM DB2 queries and MS SQL queries. I didn't want to mess with NHibernate as I was on a time crunch, and I also didn't want to have a million connection strings. Lastly I learned a while ago that for classes that needed to be used ... |
A friend gave this puzzle:
Find 3 numbers (say, A B C) such that
\$ABC+ABC+ABC = CCC\$
ABC means \$((A*100) + (B*10) + C)\$. Also, these 3 digits must be distinct.
I wrote a quick code to find out the answer:
int main(void) {
// your code goes here
int hun,dec,unit;
int final_num = 0;
int temp_num = 0... |
This question is a followup to the last one.
I followed RobH's advice and his edge case bug found in my code with this solution:
private Line CreateParallelLine(Line target, int offset)
{
var parallelLine = new Line();
var xDifference = target.point1.x - target.point2.x;
var yDifference = target.point1.y ... |
Since I'm new to web development, I've decided to create this carousel, to practice a bit of JavaScript, more specifically jQuery. I'm really happy with the result, but I'm sure that to an expert my code would look like a disaster, so I would love if someone could help me make the JavaScript of this slider a bit "prett... |
Here is what the reset link looks like that goes in an email to the user:
www.webdev702.com/forgotPassword.php?empl_id=121&email=nicholasdarley@gmail.com&request_time=1432183745918&resetCode=MG4L0aBqim27wK9fAWcJ2XCBF
There are many parts to the link and they are:
empl_id: the id of the person matching the email addr... |
In order to avoid boilerplate code and make an extensible pool of actions for the same portion of code (a row of texts to edit), I've prepared this code.
var actions = {
editName: function () {
var curName = this.nameField.text();
this.nameField.data('oldName', curName);
this.nameField.ht... |
I'm pretty new to client side scripting and I'm still learning.
I've written this JS plugin which animates blocks of HTML (fade-in from left/top/right/bottom) as you scroll down the page.
Everything seems to be works correctly, but was just wondering if there is anyone who could suggest how I can improve on this...
For... |
I've written the core functions for a basic 2048 game. I know Python isn't a functional programming language, but I like the "functional style" (easier to maintain, simple to understand, more elegant), and have tried to use this rather than iteration, mutation, etc when I can.
From a functional perspective, what more ... |
Having read Can you do the maths puzzle for Vietnamese eight-year-olds that has stumped parents and teachers?, which presented the problem of filling in numbers 1 to 9 to satisfy
$$ a + 13 \frac{b}{c} + d + 12 e - f - 11 + \frac{g \cdot h}{i} - 10 = 66 $$
… I thought I'd try a Common Lisp implementation as a learning e... |
Look at the method setupCamera. I use it to reduce the size of the create method. As you can see, inside this method I instantiate camera and viewport, that are fields.
Is there any problem to do that, or exists there any surer way to do that?
public class HudCameraSample extends ApplicationAdapter {
private sta... |
This is really the first full app I've written in JavaScript minus CSS styling which I plan on adding later.
Are there any ways it can be improved? Any ways I can make it cleaner or easier to read?
"use strict";
// Constructor function for individual parts of game grid square
// Each grid square contains a state pro... |
I have a method RefreshCustomersInternal that refreshes customer data from a server and returns a Task. Since this process is very costly, I want to prevent this method from being called too many times in a short time or prevent the process from running if there's another refresh process running already. So a wrapper m... |
In my Java event bus project, I have a private generic method that retrieves a Set<Subscriber<E>> from a private Map<Class<? extends Event>, Set<Subscriber<? extends Event>>> (the subscriberMap).
/**
* A map of Event types and Subscriber Sets.
*
* That is, the Set of Subscribers set to an Event type
* is assumed ... |
Given this as a the Problem Statement
Given two numbers, find the sum of prime numbers between them, both
inclusive.
Input:
The first line contains the number of test cases T. Each test case
contains two space separated integers.
Output:
Print the answer on a new line for each case.
Constraints:
1 <= T <= 100
1 <... |
I have code which gives permutations for 10 lists. The code works fine for small number of lists with small number of values.
Result : It should return all possible permutations. I have to store the permutations instead of directly working on it and discarding.
As soon as I try for 10 lists, it errors out with OOM : h... |
Original Problem
Short Summary:
Given a \$M\$ possible characters all of which must be used at least
once, find the number of possible combinations of length (exactly)
\$N\$.
The first input contains the number of cases, followed by pairs of M,
N. Output is modulo 1000000007(\$10^9+7\$).
Example Input:
4
1 1
... |
Last night I was working on a project that I've embarked upon as a learning exercise. I decided to add a pagination feature to my blog system. I made an attempt at it and got close... but I decided to undo my changes and I searched online for other 'better' solutions. I found this example which uses PagedList.Mvc NuGet... |
Here is my first attempt to solve Jumble puzzle:
import argparse
from itertools import permutations
parser = argparse.ArgumentParser(description='Solver for Jumble')
parser.add_argument('jumbledwords', nargs='+',
help='One or more jumbled words')
argv = parser.parse_args()
# http://www-01.sil.org... |
I am solving this question:
It's not the rivers that you might be thinking about. The question
revolves around the concept of digital rivers. A digital river is a
sequence of numbers where the number following n is n plus the sum of
its digits.
FOR EXAMPLE
12345 is followed by 12360 since 1+2+3+4+5=15 and so 123... |
The next version of rubberduck is going to include a pretty nifty "goto anything" / find symbol navigation tool that lets the user enter an identifier name in a combobox:
UI
To achieve the templated dropdown I had to introduce some WPF interop. Here's the markup:
<UserControl.CommandBindings>
<CommandBinding Com... |
I have written a C program to generate a PPM (Portable Pixmap) image of the Mandelbrot set. The program implements many things in C I am fairly unfamiliar with (Structures, error handling, use of new libraries (complex.h), and files (I'm completely unfamiliar with image files)) and the purpose of writing this program i... |
Today I tried solving this problem on SPOJ, in which you reverse the digits of two numbers, add them, and print the reversed digits of the sum. (When reversing, leading zeroes in the result should be dropped, and trailing zeroes in the result shouldn't happen.)
I used C++ to write the code for this problem. My code go... |
I am in the process of writing tests for my JS code with CasperJS and Mocha. I have a function that changes the DOM and gets run on page load (through jQuery's document.ready event). I'm wondering what the best practice is for testing this kind of code. For example, I have a function removeElements that gets run before... |
I'm moving some octagons around and I found a serious bottleneck:
@win.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
for o in octagons:
o.vertices = tuple(chain.from_iterable( (o.vertices[i]+dx, o.vertices[i+1]+dy) for i in range(0, 18, 2)))
The program starts lagging when about 1000 points (1... |
I kinda got the idea after playing Adventure Capitalist, since that goes up to 10300. I found a website that explained how to go up to 10^3000, so I mainly did this as a challenge to see if I could do it.
Also, I'm fairly new to writing the documentation bits, so feedback on what I did well/not so well would be appreci... |
This code plays a note for a specific period of time using NAudio.dll 1.3.8.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NAudio.Midi;
using System.Threading;
namespace SoundVision
{
class Note
{
public Note(MidiOutWrapper mid... |
This is the code I'm using to GET the definition of a word from Wordnik's REST API. I don't want to ignore any error but this is causing the code to be ridiculously long. I'm new to Swift so I'd appreciate it if someone could explain how best to trim it down.
class func define(params: DefinitionParameters!, delegate: W... |
I have a use case which says:
Your REST service will consume a JSON object that contains a list of
emails for subscribers at the start of the subscription period, and a
list of subscribers at the end of the subscription period. Your
service must return a list of subscribers who are new, subscribers who
stayed,... |
My job is to make a specified java objects from web page that contains following text:
Companies:
[{"companyName":"Tire Systems","companyID":1},{"companyName":"IT Enterprise","companyID":2},{"companyName":"Car Manufacture","companyID":3},{"companyName":"Electro Market","companyID":4}]
Materials:
[{"name":"Winter Tire"... |
I've written a simple Diceware passphrase generator based on this Stack Overflow question and the top answer.
Briefly, in the Diceware method, a die is rolled 5 times for each word in the passphrase and the results matched to the corresponding word in the word list which is of the form:
16226 cask
16231 casket
1623... |
My project has three classes: Card, Deck, and BridgeConsole. The Card class has two fields: int rank and int suite. It has three methods: toString, getSuitAsString, and compareTo:
public class Card implements Comparable<Object>{
int suit; // 0-Hearts, 1-Clubs, 2-Diamonds, 3-Spades
int rank; // 2-10, 11-Jack, 12-Queen, ... |
I am writing some code that will serve a website and I have some questions about my "architecture".
Domain - I have a database and and at the lowest level I have the **Domain* *package that contains the classes that represent the tables of the database. I use Hibernate and lazy fetch for relationships.
Access This pac... |
I am trying to make a function for Select statements. It will give result based from the parameters passed. I tried using it and it gives the results I am expecting.
I know that it is still unpolished but I would like to know what are the critical things in it that should be fixed or improved so that it would be ready ... |
Can this code in any way be improved or optimized? I'd appreciate any clever tricks or Pythonic expressions that may remove some more brute force elements from my solution.
Also, is there possibly a more intuitive way of approaching this problem that I couldn't see?
Problem statement: Largest product in a grid
In the... |
I solved this challenge. It passes all the test cases, but I'm not very happy with my solution. I'm convinced this could be done much smoother (i.e less code)
Swap operation: Given a tree and a integer, K, we have to swap the
subtrees of all the nodes who are at depth h, where h ∈ [K, 2K,
3K,...].
You are given a ... |
I have a positive integer n. I want to lazily loop over a range of integers less than n consisting of a) integers divisible by 3 (excluding zero) in reversed sorted order and b) zero and integers not divisible by 3 in any order. Is this a very stupid solution? I couldn't think of another way of doing it without having ... |
I frequently get a situation in which I want a pretty binned column from a vector of values, so that I divide the vector in approximately even ranges and choose 'sensible' values so that it looks pretty when using the column in pivot tables or other reports. Sensible herein includes rounding values like 10123.1 to 1000... |
I just started out a new job as a C# programmer on .NET 3.5. My manager gives me total independence on how I build my modules, which is generally a good thing, but there are minuses too. Having too much "freedom" tends to make me wander to places you wouldn't have if you had some strict guidance.
My project involves ma... |
I am brushing up on my Java skills by trying to solve the below assignment problem I found on the internet:
Write a Java method that accepts two strings as parameters and returns
a string that contains all unique two-character strings whose first
character comes from the first string and second character comes from
th... |
I want to convert a one dimensional array to a two dimensional array with the following conditions and have followed the code from this question - https://stackoverflow.com/questions/1817631/iterating-one-dimension-array-as-two-dimension-array. The 2-dimensional array has to be copied from the one dimensional array and... |
I hesitated quite a bit of time before posting this question since the code to review is more or less a monster (with regards to its size). It is a basic mathematical expressions evaluator, but with one interesting additional feature: you can register callbacks that can be used in the expression to evaluate. First of a... |
This question goes hand in hand with another question about a mathematical expressions evaluator in C++. The other question is meant to be read first, this one is but a complement to expose the internals of the evaluator and the overall architecture to explain how the details work.
The tokens mechanism
A token is a han... |
Cost of nodes are represented by a matrix (called world), heuristic cost estimate/g score/f score are all represented in matrices.
The world and its size are stored in global dynamic variables. It looks like this:
1 1 1 1 1
1999 1999 1999 1999 1
1 1 1 1 1
1 1999 1999 1999 1999
1 1 1 ... |
Currently I'm developing my business entities. I feel that the structure is a tad cumbersome.
What I mean is that a store on a particular day can have different open and closing times. So it's not as simple as a store opens and closes at 09:00 and 17:00 respectively every day at the week. A store may open at 09:00 and... |
For a given set of denominations, you are asked to find the minimum number of coins with which a given amount of money can be paid. Assume that you can use as many coins of a particular denomination as necessary.
For example, given the denominations 1, 3, 4, and the target amount 6,
the algorithm should find the optim... |
I've made a simple caching function for my jQuery ajax calls.
I know about the $.ajax() cache setting, but I don't use it for various reasons. One of the most important one is it being limited to GET (and perhaps HEAD?) requests.
If a cached value is found, and is a reference type, I'm returning a deep copy rather than... |
I'm new to Python, and pretty much programming/scripting. I'm just looking for someone to critique my methods and tell me if there are more efficient ways to do things.
#!/usr/bin/env python3
#
#
# A quick script to create a civil war game
############################
# DECLARE GLOBAL VARIABLES #
####################... |
A couple months back I made a go fish game in Go, just for the sake of that pun. It was pretty poorly done and made experienced Go-ers cry when they looked at it. I rewrote some of it to be more standard, but I'd still like critiques from the 95% of the world with more Go experience than me.
For those unaware, Go Fish ... |
I have the following code to find the longest list in a list of lists:
max_len = max([len(path) for path in paths])
[path for path in paths if len(path) == max_len][0]
Each path is a list of integers. paths doesn't have to be a list. So if I have, for example:
path_a = [1, 2, 3]
path_b = [1, 4]
path_c = [3, 5, 6, 2,... |
I wrote 2 versions of problem 22 on Project Euler:
Using a text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the... |
I was inspired by Number Wizard game question and I decided to write my own version of the game. My goals were to follow the SOLID principles and make the logic UI independent. I'm a bit confused about the outcome, though.
I think my solutions reads much easier than the version in original question, but on the other h... |
I've written a simple script that takes a string filled with brackets and strings and builds them to a dictionary.
Example Input:
string_1 = '(()())'
string_2 = '((a)(b))'
string_3 = '(a(a)b(b)c)'
string_4 = 'a(a(a)b(b)c)b'
string_4 = 'a[a{a}b{b}c]b'
string_5 = 'beginning(content[word]{another word})outside'
Output fo... |
This program asks a user to input any number equal to or between 1-12. It then converts the number to a message that will be printed (Copy the program to see it yourself). Is there a way to make the code shorter by still using the switch statement?
This is homework, so using a switch is a requirement.
import javax.sw... |
Printing to stdout is thread-safe in many systems when using printf or std::cout, but not in all systems (Windows!). So I decided to make my own thread-safe and type-safe printing function with some help of C++11 variadic templates functions.
#include <iostream>
#include <iomanip>
#include <mutex>
class Mutex:private ... |
On this site this site, I have some code which you can see below which figures out the offset for each post from the top of the document and assigns a colour from each post to the header when it scrolls into view. I am having to wait for the window load event until the code works which really is not very elegant. Can a... |
Imagine a safe with a 4-digit code, and accepting a continuous stream of code entries, such that when the 4 digits are seen in the right sequence, the safe opens. Generate a short string that contains all possible code combinations, so that when you feed it to the safe, it will inevitably open. The string should be as... |
I am curious if it would ever be in good practice to omit constructor definitions from a class. Here, the intention of the Temperature class is to simply convert between one temperature scale to another. Since there are three scale measurements, kelvin, Fahrenheit, and Celsius, I decided it was best to define specific ... |
I am writing a Selenium framework that should be really easy for a tester with relatively little Java knowledge to use and write tests for. In order to keep the framework as user friendly as possible, I've noticed that I am writing a lot of statics so that the tester doesn't have to instantiate the page objects and met... |
So this code is not yet completed. The end result has to calculate the average grade by each question. A=1 b=2 etc... and checks if the question is passed or not.
this is what I got this far.
#include <stdio.h>
#define ROW 6
#define COLOMN 5
int input[ROW][COLOMN] , row, column;
int main(void)
{
float passedte... |
Just for learning and practicing I've created a completely recursive version of the merge sort algorithm.
I've tested it a little bit and it seems working, but I'm quite sure that it can be largely improved. In particular, I'm hating the long if-else conditional inside the sort function. I think it's really bad written... |
I am new to C# and develop a configurable PasswordService class. As the code works the next step is to improve the code.
Right now there are the following options:
Set alpha characters and the number of alpha characters that has to be in the password.
Set numeric and the number of numeric characters that has to be in ... |
In preparation for interviews, I have written a solution to this question:
Given a sequence of numbers (34128) and an input map such as a dial
pad on a phone (2->[a,b,c], 3->[d,e,f], 4->[g,h,i]) write an algorithm
to return all possible words from the sequence. E.g. Input: 232
Output: [ada, adb, adc, aea, aeb,... |
I wrote a program that reads a text file and then outputs the unique words, their frequency, and the line numbers that word appears on. It also counts the number of sentences in the text file. All of this information is then outputted to a text file.
I currently have all of the code in one class object. What wou... |
I am scraping a Wikipedia page, getting info from that page and instantiating a new object with the information collected:
require_relative '../config/environment'
def get_winner
award = Nokogiri::HTML(open("http://en.wikipedia.org/wiki/Academy_Award_for_Best_Picture"))
year = nil
award.css('table.wikitabl... |
My C++ was starting to get rusty and I never touched some of the newer features. Reason enough to try something simple and make it overly complicated:
FizzBuzz with bonus features. For now we'll call it FizzBuzzWoofFooBar.
The FizzBuzz idea is to check whether an integer is dividable by 3 and/or 5, the first two primes... |
I am preparing to coding interview and I met this task today:
You are given 30-bit unsigned integer N. A right cyclic shift of N by K bits is the result of performing a right cyclic shift of N by one bit K times. Leading zeros may appear.
For example:
the right cyclic shift of 9736 by one bit is 4868,
the right cyclic... |
I want to find the highest number in a time series, in the most efficient way.
To avoid iterating through all the look back periods, I'm only iterating in case the current high number has just been discarded. I'm avoiding enqueue dequeue for the same performance reasons.
What would be a faster algorithm?
class Program
... |
I have searched around but I was not able to find a complete implementation of the memoize pattern in a multithreaded context. It's the first time playing with thread synchronization. The code seems to works, but I am not able to test it extensively, in particular to find if there are race conditions. Do you think ther... |
Swift's SequenceType is a useful means of generating a sequence of values, and it makes it particularly useful iterate over these values.
I don't really have much experience with these SequenceType types, so I wanted to implement my own for some practice and learning. What better sequence to take a look at than a Fizz... |
I'd be interested in hearing what folk think are the pros and cons of the following two ways of writing classes like the following Circle, Square and Rectangle classes in Swift.
The first way has them extending a superclass (ShapeSC) with methods. The second has them implementing a protocol (ShapeP) with computed prope... |
Let's say I am trying to build an opinion poll app, such that I can create a template of an opinion poll, give it multiple sections/questions, assign multiple people to different copies of a given question, create varying measures (happiness, successfulness, greenness) and assign different questions different weights t... |
I've written a small program to detect the human language of a document or text fragment.
I tried to stick to good design principles and I tried to make it pretty robust. I would be generously described as an intermediate programmer so I'm sure there are things that are bad-smellish that didn't even register with me. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.