instruction
stringlengths
71
71.9k
I was writing code to check if any permutation of a string can make it palindrome and came up with the following logic: anagram = [ x for x in input() ] count_alphabets = [ anagram.count(x) for x in set(anagram) ] middle_element = [x for x in count_alphabets if x % 2 == 1] print("YES") if len(middle_element) == 0 or le...
The original description of the problem can be found here, its input here and its expected output here. The problem: Given a integer sequence a1 ... an (-10000 \$\leq\$ ai \$\leq\$ 10000). Where n (1 \$\leq\$ n \$\leq\$ 100),the size of the sequence, is a given number. Find the number of increasing subsequences wi...
I am making a 2D Java game at school, and at the movement I use a switch. The code works, however, my teacher won't sign my code until I have removed code duplication. Short info: My Keyactionlistener sends a String of direction that is used in the switch to move. Inside that very same switch I also check the object in...
I'm trying to solve the problems of Project Euler with Haskell within less than 10s with optimized code (ghc -O2). Unfortunately, I'm struggling to find a correct algorithm for Problem 44, which proves the correctness of the solution without setting a predefined upper limit (setting a limit and omitting the proof yield...
In lieu with several other Facebook-esque concepts I am trying to replicate, this working code will take the span of time from a given date to now, and try to convert it into the most convenient English-friendly word. For example, if I post a comment on an article or status, and I want to show when it was posted to a u...
In my code, when the index is 0, I am supplying the second template which contains the word as arif. With the rest I am supplying the first template which doesn't have the word arif. I got this result as a result of a posted question, but I am not satisfied with it because of its length. // Code goes here "use strict";...
This is a question in Udacity JS course. I am starting to like Javascript. I feel its a misunderstood language :) We learned about relational operators and how they can classify the relationship between two values. Your job is to write the function getRelationship(x,y) function, which should return a string rep...
I'm just playing with Python, trying to refamiliarize myself with it since I haven't used it in a few years. I'm using Python3, but as far as I know it could easily be Python2 with a change to the print statements. What I'm generating is something similar to GitHub's Identicons. I know of two possible issues, one is th...
Problem Statement: Extract the filename and read if filename has jQuery on it, put them aside. Second step will be to check one more and see if any jQuery files has ui in the filename. Input: script_ref1 = """<script type="text/javascript" src="js/jquery-1.9.1.min.js"/> <script type="text/javascript" src="js/jqu...
I have written this code to get the input string from the spreadsheet and search the string across the text files and state whether or not it is found in the Excel sheet. Scenario: Excel (sheet1): ColumnA AAA BBB Drive C: C: should be give in Column D5. It has subfolders TEMP1, TEMP2, ... Folder C:\TEMP1\ It has...
I am trying to write my own implementation of indexOf for learning purposes. I have an implementation of as follows. I'm sure a more efficient and shorter implementation exists. function _indexOf(needle, haystack) { var n = needle.split(""); var h = haystack.split(""); var n_len = n.length; var h_len ...
I'm writing unit-tests for my Node.js/Express application with REST endpoints which retrieve stuff via Mongoose from db. Since I'm testing only route functions I want to mock Mongoose by providing custom request and response functions etc. I also had to mock my Person mongoose schema module with mockery. Here is my ap...
I've mostly completed the prototype for my city building simulation, and now I have added the meta-game mission system to the game. You see these mission systems in a great many games these days. The basic idea is that the player is assigned a mission at the start of the game, such as Build 50 Industrial buildings, an...
Here is my Python implementation of counting neighbours of Game of Life with radius as parameter. def neighbors_count(n2d_array, radii=1): assert n2d_array.ndim == 2 row_len, col_len = n2d_array.shape nbrs_count = np.zeros_like(n2d_array) for row_idx, row_val in enumerate(n2d_array): for col_id...
This class is a stream designed to perform character encoding translation. So you instantiate it, pass an input stream, and specify the input encoding and desired output encoding, so that when you read from this stream, is will translate the source data from one encoding type to another. I'm interested in a general co...
I have a third party system that submits what I am assuming is a byte array data from OBDII port on our fleet vehicles. I was getting values like: AA== (bool) AQ== (bool) AAAaMA== (int) AAA0IQ== (int) Mjow (string) UzozLTIwNA== (string) I know what the type is for each field but the regular base64_decode() function ...
Wrote a couple of blog articles about smart pointers. Unique Pointer Shared Pointer Constructors for Smart Pointers So I suppose it time to get the result reviewed. This is not supposed to be a replacement for the standard smart pointers. It is more a simple place to start for people trying to learn some of the basic...
Array of size \$(n-m)\$ with numbers from \$1..n\$ with \$m\$ of them missing. Find all of the missing numbers. The array is sorted. Example: If arr = [1,2,4,5,6,8], result should be 3 & 7. Here is my code which I would like to get reviewed: import java.util.*; class FindMissingNumsArray { private List<Integer>...
I've written a toy neural network in Java. I ran it several million times with the same outputs with only the randomized weights changing from run to run. The average of all of the outputs is not 0.5, as I would have expected. The code is in this Github Repository. The Layer class: public class Layer extends AbstractLa...
I want to create a production-ready producer/consumer that could help me avoid thread synchronization hell. Is this thread-safe? The main issue is to be safe with exceptions that can arrive. public class AsynchSimpleProducer<T> : IDisposable { private readonly Action<Exception> error; private readonly BlockingC...
I implemented the binary search algorithm. Input vector is sorted by < than operator implemented by type T. The less than operator is expensive so we want to use it as few times as possible. I would like to know if there are any stupid mistakes, bad practices that I used and how I can improve the code. template<class T...
The problem I attempted to solve is described as: What is the largest subset of mutually non-overlapping intervals which can be selected from I? Where I is a set of N intervals where each interval has the same weight per item within the interval. I claim the algorithm runs at \$O(N \lg N)\$ and has a space comple...
I have a flat data that represent the hierarchical relationship as below: ID Name PID 0 A NULL 1 B 0 2 C 0 4 D 1 5 E 1 6 F 4 3 G 0 This table represents the 'data table', where PID indicates the parent element. For example, in the first row...
I have a Node project and am trying to make my code better, so I've created a new folder with a file like following which encapsulates the read and write file. This is working and my question is if it's good practice since I need to use the call to read and write file in several place in my code. var fs = require('fs')...
Trying to solve this combinatorics problem, I wrote some functions to count the number of unordered distinct factorizations of an integer n into k distinct parts. The following function builds up a list of unordered distinct factorizations of n with largest part at most m. duf' :: Integer -> Integer -> [[Integer]] duf'...
We have a main application made of a few separate parts - Unity and Clc. I'm writing a new tool which will be used to manage them: deploy Unity, or run some checks and a lot of other stuff. As there will be a lot of options, I want split them in to separate namespaces. Here is my implementation, it works, but I'm not s...
I am using the following method to validate if user has given any input or left an EditText empty. I am concerned about the return statement in particular, because my IDE keeps complaining about it. Environment: Android Studio 1.0 public void clientsideauth() { if (TextUtils.isEmpty(edt_name.getText().toStrin...
I was trying to solve Project Euler Problem 78: Coin Partitions. Let p(n) represent the number of different ways in which n coins can be separated into piles. For example, five coins can be separated into piles in exactly seven different ways, so p(5)=7. Find the least value of n for which p(n) is divisible by one mi...
I think that this code is very bad because it does not agree with DRY principle. Can you advise me how to improve it? public void WhatSelected(object paramaters) { string ElementToProcess = BASM.FindElement(paramaters, true); SeleсtedCurrent.Add(ElementToProcess); int i = (from x in AssetS...
In the pursuit of SQL enlightenment, I wrote a quick SEDE query to display Rep, Age and Overall Rank. Sorted by Age, then Rank (Which is generated by Rep). SELECT TOP 150 ROW_NUMBER() OVER (ORDER BY Users.Reputation DESC) AS Rank, Users.Id as [User Link], Users.Age, Users.Reputation as Rep FROM Users WHERE User...
I have some code that asynchronously loads some point in a chart when a users drag it: private void UpdateHistoryAndReSizeWhenDrag(string param, long duration) { lock (Lock) { if (Boxes.Count() > 0) { BoxStruct temp = Boxes.Where(key => key.id == param).FirstO...
I have written a program in Python 3 for the INTEST problem on Codechef (included in question). The program is taking a lot of time (55.76s) in Python 3. The same code takes almost 1/10 of the time time (4.97s) in C. The purpose of this problem is to verify whether the method you are using to read input data is suff...
My goal was to create a function as performant as possible with results being: True/False as to whether wild matches str. Optional capture of certain patterns. My purposes required: Case sensitive match. Pattern must match entire string to succeed. Assumption that * and ? do not exist in str. * matches zero or more ...
I'm curious if there is a way to slim down this code either with SQL or with C#. -- VARS declare @iagent_id int declare @quarter int declare @prev_quarter_1 int declare @prev_quarter_2 int declare @prev_quarter_3 int declare @year int declare @prev_quarter_year_1 int declare @prev_quarter_year_2 int declare @prev_quar...
I am trying to dynamically pick a parent class in Python 2.7: GLOBAL_CLASS_NAME = 'b' class A(object): def __init__(self, bar): print('this is A with {}'.format(bar)) class B(object): def __init__(self, bar): print('this is B with {}'.format(bar)) class C(object): def __init__(self, ba...
I am working on uploading files through Rest API. Tried my hand using single upload and works. I have modified to accommodate parallel uploads using Futures. Will there be any chance that this code will not end during the equivalent infinite loop in checking futures's status? Another question that I have here is that...
Here are two models - Property and Developer: class Property(models.Model): property_type = models.CharField(max_length=255, default='Apartment') specifications = models.CharField(max_length=255, default='Basic') built_up_area = models.FloatField(max_length=6, null=False) total_area = models.FloatField(...
I am new to Node.js and Socket.io. I implemented a realtime chat service that has a chatroom feature. When the actual product is launched, there will be at least 200 concurrent users with 50 groups of 4 people. I would appreciate any advice on its performance and any recommendations. Server (remote server) var expres...
I would like to improve my Reddit-scraping code to make it faster, but I don't know how. I am using deque instead of list to improve append performance. Otherwise my code calls the PRAW API and type checks one class attribute (I don't know why this is necessary but otherwise I get type errors). Is there a faster way to...
It was suggested on Meta for July 2015 Community Challenge to make a bot that can find questions with bad titles. I wrote this query to help others find examples to help them make write their code. I made it a point to document as I wrote it so that someone who is a beginner with SQL could still make changes to it eas...
I have a class that I use to manage a list to/from an API in Swift. Using a clean code approach, I'm wondering if, how, and why I should change it when I have a class that uses it for just one or two functions. Here's the class: import Foundation protocol ApiWishListManagerDelegate { func didFailWishList(failErr...
I have these invoices listed: def invoices = [ 'LEDES98BI V2', 'LINE|INVOICE_DATE|INVOICE_NUMBER|INVOICE_TOTAL', '1|20150301|INV-Error_Test1|22', '2|20150301|INV-Error_Test1|24', '3|20150301|INV-Error_Test2|26', '4|20150301|INV-Error_Test2|28,'] I am trying to do groupBy on the above collection with INVOICE_NUMBER and...
I have the following three macros all running in the same module. Each one is attached to its own button (3 buttons total). All three buttons take an average of 6-12 mins to run. As I am working on figuring out additional buttons that will check/review other criteria on the sheet, I am looking to improve this. Could an...
Below is a problem I encountered during an online course. There are a lot of similar questions asked on this, but I couldn't find a solution there as well as I believe my specific issue is a bit different from the rest. Given a string s, find the first non-repeating character in the string If there is no such charac...
This question is related to the Cactus Text Game Engine. For easy error handling in Cactus, we've put together this small decorator. Essentially, the decorator wraps any class method in a try-except block, which reports errors to a log file if something goes wrong. While it's a small file, I can't help but feel that i...
I recently stumbled across this article on how to write a spelling corrector, and figured I'd try to have a go at it in C (mainly because the link at the end of the page for the C code is broken). Here is what I would like reviewed: Accuracy: What can I do to make the program output a more accurate prediction of what ...
I'm implementing a Tic-Tac-Toe solver in Python. It contains two functions: assess to determine whether a given board position is a win for either side, and is_winner to traverse the game tree. The end goal is to use this program to construct a lookup table that will be used by a JavaScript Tic-Tac-Toe frontend. But I ...
Fairly easy way to compress a wordpress plugin (or similar) as a zip file without including all the dependencies used to create and manage the development, but which don't belong in the final product. #!/bin/bash # This script zips a directory, excluding specified files, types and subdirectories. # while zipping the d...
I am writing a c# program to build generic sort algorithm on a request to a collection of data. The data needs to be sorted based on the supplied columns.I am using Entity framework and Expression builder to achieve the required functionality. In one of the methods I see that some code is duplicated and I am not gettin...
The below code is placed in a method . But it seems too large and I would like to shorten it. Is there a better way to do what it does? ImageIcon switchoffIMG = new ImageIcon("switch1.jpg"); ImageIcon switchonIMG = new ImageIcon("switch2.jpg"); JLabel switch1 = new JLabel(switchoffIMG); JLabel switch2 = new JLabel(sw...
This is the first JavaScript code I've ever written, alert("hello, world!"); aside. This site is closing quite a lot of questions because people won't read the rulebook or pay attention to the How To Ask panel that's displayed as you're entering your question title - almost 60% of closed questions involve broken cod...
The problem is from here: The page at Wikipedia said: Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes. Set the initial node as current. Mark all other nodes unvisited. Create a set of all the unvisited nodes called the unvisited set. For the cu...
Context In an imageprocessing project of mine, I needed to do some edge detection and implemented the Theo Pavlidis algorithm which works quite well. A problem had been to get the next "good" position. Assuming an image like this (where the 1 represent the needed pixel value) 011110 111111 111111 011110 thi...
The code below works fine for me. Is there any way that I can improve this code more? Note: delimiter is single whitespace only for email address. getmail.py #!/usr/bin/python import re handleone = open("scratchmail.txt", "r") f1 = handleone.readlines() handletwo = open("mailout.txt", "a+") match_list = [ ] fo...
I found myself having to implement Bresenham's line drawing algorithm. I'm looking for feedback on effectivity and code style. Can I reduce the code somehow? template<typename Callable> void bresenham(Vec2i p0, Vec2i p1, Callable&& cb){ const auto swap_xy = std::abs(p1.y - p0.y) > std::abs(p1.x - p0.x); if (swa...
Which is best? I have a bunch of components in my projects. It's related to Ashley (a java entity system) to libgdx (a game engine). this components are like that: public class SpriteComponent extends Component { private Sprite sprite; private SpriteComponent(Sprite sprite) { this.sprite = sprite; ...
I am playing with RabbitMQ and .NET and found myself duplicating the connection initialization logic in all of the consumers. Created the Consumer in order to avoid that and add some tracing. It's far away from anything usable, but wanted to hear ideas/opinions/alternatives. public class Consumer { private static re...
Problem Description Receive a 5 digit number and print out in a large size. Sample input 32145 Sample output ##### ##### # # ##### # # ## # # # # # # # ##### ...
I am playing around with Xamarin, because there is a good chance that I might have to start a project using it in a few months. What I am mostly looking at is Xamarin Forms as I am familiar with WPF and MVVM, so I am looking to apply the same principles if possible. I usually use Caliburn.Micro but seeing as the versi...
I am trying to optimize my game written in Java and I used the VisualVM launcher for profiling and monitoring my game. What caught me by surprise was that my basic utility to play sound effects was using the most CPU in my game. I'd really appreciate some tips on improvements which I can implement, because I really do...
We're rewriting some parts of our application. We're trying to avoid the promise anti-pattern and do things properly, but I'm not certain that we did so. More precisely, we are rewriting the resolver of a state using ui-router. .state( 'catalogue', { // skipped on purpose not relevant content resolve : boxCrea...
I've got a huge dataset in R which contains (among other things) 2 columns indicating "Term Code", which are "Term Code" and "Term Code1". "Term Code" is the mostly-correct column, which usually contains a 6-digit code for year and academic term: > head(data$Term_code) [1] 201230 201230 201230 201230 201230 201230 how...
I am starting a software engineering degree soon and have been practicing the last couple months. I have posted some code I wrote for a basic Tic Tac Toe game below (C++). I have read the worst thing to do is to get into bad habits early on, so please can you read over the code and tell me what I should be doing differ...
I often create new accounts or virtual machines, and then have to load my SSH public key/signature in to the authorized keys on that account. That process can be tedious, so I created this script that pushes my authorization on the remote machine. So, typically when you ssh to a remote machine you have to enter your pa...
Basically, this is a recursive function to generate all of the permutations of an array. The idea is this: recursive case: start at the specified array index, and make a case for starting the next index (incremented one) for each of the indexes that come after the specified index by swapping the index with the next if ...
I've written a python 3 code using Bokeh. With this code you can learn howto to plot math functions and a scatter plot with regression linear functions in a webpage. The target is how to plot discontinuous functions, linear regression problems in a webpage, and how to separates the different plots in a webpage using Bo...
I have a method that I am using to remove accents from certain characters. The problem is the massive slew of characters I am expected to work with. I have to, basically, remove accents from all Latin characters that fit within the 26 English Latin characters. (A through Z.) Performance is a very large requirement. It ...
I want to go through each line of the a .csv file and compare to see if the first field of line 1 is the same as first field of next line and so on. If it finds a match then I would like to ignore those two lines that contains the same fields and keep the lines where there is no match. Here is an example dataset (no_du...
This code basically makes the dot follow a certain point on the screen. It consumes a significant amount of computing time in my game, so I'd like it to be best optimized. I wrote this code after quickly reading some pages in a high school mathematics book, so it's unlikely to be a computationally efficient solution. T...
I have two database table name called "tablestr table" and "restbookingtable": tablestr: restbooking: I want to retrieve bookingsection_id from the booking table with a few conditiona and need to remove from tablestr. I have a query for this, but I could achieve it by using subquery, which executes very slowly. SELE...
I'm working on a moderately complicated (not super basic, but not a feat of programming strength) project to create a virtual tabletop for a tabletop game I play. I'm trying to conform to good design practices and patterns, specifically I'd like to keep everything as nicely MVC-oriented as possible. My problem is, I'm ...
I have made this small text-based dice rolling game in C++. How could I improve it? Be as picky as you'd like. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; void mainGame(int &numDice); int main() { srand (time(NULL)); int gameRunning = true; int numDice; while (ga...
I have a large table with which I need to do some analysis. The table is a log of IPs: +-------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+-------+ | src | int(10) u...
Right now I'm mixing JS and jQuery. I would like to find one unique solution with JS only possibly. How can I organize the code according to best code practices? Another thing I need to add is a check at the beginning of the function. If the classes are there nothing should happen, if not there then add them just as b...
A while back, I asked a question about implementing an idiomatic iterator in C++. I've recently revisited the code, and I'm bothered by the duplication in the begin and end iterators. The code goes over a collection/iterator over a domain, and lazily produces the range using the iterator. After trimming down some code ...
I'm an iOS developer new to Android. I'm creating my first Android app and I have several questions. My app uses Android Studio, gradle, and it's based on Parse (the backend). Basically, takes messages from the backend and shows them. User has the possibility to delete them, or click them and see the detail, and of cou...
This is a solution for the June 2015 Community Challenge: a program that decrypts a monoalphabetic substitution cipher. It's written in Python 3, but should be portable to Python 2 if you use from __future__ import division. Please review! Is the technique clear and the code easy to follow? Does the code correctly impl...
I'm developing an application in which there are many short-lived tasks which are run in separate threads. I've developed a generic and reusable system to handle such a requirement. The code snippet given below is using this system code plus the example client code to show how to use the system's API. package com.demo;...
The goal is to list out some data, but the methods vary on options, and whether the user is on a touch device. This is my current function declaration. Very non-DRY. Values of isTouch and headlinesOnly don't change during loop, so I don't want to make if tests inside the loop. Edit: This is primarily meant for a memory...
I am attempting to implement the quick sort algorithm whereby the pivot will be chosen by the user, and can either be median, first, or random. I am supposed to return a long that measures the number of times comp.compare() is invoked. I am wondering if you could review for me. /** * The quick sort * @param ...
I've written a Controller for the keyboard so that I can map certain keys to callbacks within a game. A key can only call one callback, but a callback can be called by many keys. Currently, a Controller has two std::maps - one for when the key(s) is pressed/held, and one for when the key(s) are released. These maps are...
I have built Python objects to simulate a one-to-many relationship and then store the object in a MongoDB instance. I am using lots of composition to achieve what I want. The code works perfectly fine but I get the feeling that the overall design can be improved a lot. The problem statement Each Portfolio can have zer...
I'm looking for advice on how I could improve this. I'm using VS2015 to compile so whatever language features are supported in there is fair game! Problem: Create a program that reads a username and a password from the user and grants access if that username and password exists in code. Bonus points for storing the po...
Here is my switch bulb GUI program: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.ImageIcon; import javax.swing.SwingUtilities; import java.awt.Color; import java.awt.Rectangle; import java.awt.CardLayout; import java.awt.FlowLayout; imp...
I am implementing a generic repository pattern. I have done this quite a few times now but every time I do it there is something bugging me. If I have a database design like below. (All the tables relate to one another.) And I make a call like the following: public IEnumerable<Domain> GetRealEstate() { return _r...
I'm currently making my first steps into the territory of network programming, using the SFML Network library to simplify things. Later on, my bot shall post new pull requests and changes concerning issues to an IRC channel. I've got the bot to connect to a server (irc.euirc.net is hardcoded for now) and to a channel, ...
I am quite new in web application back-end development and I have an architectural question. I have defined Hibernate entities in my application and I want to send them to client. Currently for each entity I have defined data transfer object, that is almost the same as entity. Is it good practice to create DTO for eac...
I'd like to Select columns from Table 1 with a Row Filter, Select columns from Table 2 and join. This works but it's a bit verbose. I was wondering if there is a cleaner way to write this. SELECT * FROM ((SELECT JOB_NUM, ITEM_NUMBER, DATE_COMPLETED, QTY_COMPLETED, STD_USAGE, ACTUAL_USAGE FROM JOB_ROUTERS WHERE RESOU...
I am currently rewriting a legacy PHP4 application to a MVC-style object-oriented one. As the most complex part is the models, I came up with the following controller-view scheme. I wanted to use only variables in my views, using only <? if ($foo === 'bar'): ?>-like blocks if necessary. The controllers instead generate...
After moving from mysql_ to PDO I created a PDO handling function. Basically this function takes parameters, checks them and returns end result. The thing is that I created this ~1 year ago and haven't really optimized it and after looking at it again I wanted to see if I can improve it somehow, but right now I can't r...
I would like to know how to make my code better. I'm still a newbie in Android, so any tips are appreciated. The code is an AsyncTask class extender that formats data into a nice looking Spannable String. It works, but it's quite slow, even if ran on a background thread. //SlideContentType is an enumerable with 4 optio...
I read this article that I really liked and wanted to implement the ideas it had. It basically says don't use $scope or ng-controller; instead, use directives with templates that get their angular magic from the directive's controller. angular.module('myAppContestantList', []) .directive('myAppContestantList', functi...
I am wondering if someone can review my code and tell me if there is a way to enhance it and make it more efficient. import java.util.Scanner; public class apples { public static void main (String[] args){ Scanner input = new Scanner(System.in); int selection; for (int i=0; i<4;i++){ ...
I just wrote a singleton base class for a hobby project I'm currently working on. Python is not my first language, which is why I am not sure if everything is done the pythonic way. I also used multiple resources/tutorials/articles for Python2 and 3. My singleton is supposed to be Python3 compatible. The implementation...
I had to make a message queue in an android app which my thread takes messages from and processes them. There can be multiple producers and duplicate messages should be avoided. Rate of insertion is erratic but not fast. Rate of consumption is slow. I came up with the following : public class MessageQueueHolder<T> { ...
In light of the recent "SQL frenzy" of sorts in The 2nd Monitor, I decided to take a stab at writing my own SEDE query. Essentially, what it does is find questions that could be answered based on the following parameters. -- @MinQuestionVotes - The minimum amount of votes on a question. -- @MaxQuestionAnswers - The max...
I needed this to clean up a couple of similar music libraries, which also contained some empty files and duplicate files with different names. # dupFinder.py import os, sys, shutil, datetime import hashlib def findDup(parentFolder): # Dups in format {hash:[names]} dups = {} for dirName, subdirs, fileList i...
The output that I want: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 <ul> <li> <?php $i; $a = 1; $b = 0; for($i = 1; $i < 29; $i++){ echo $i; if ($i == $a){ echo "</li><li>"; $a = $i + 2 + $b; ...
For example, if we have 120, the answer should contain (2,2,2,3,5),(2,60),(4,30),... Here is my not-so-good attempt for (int[] x : getPossibleProducts(120)) { System.out.println(Arrays.toString(x)); } public static List<String> getPossibleProducts2(int n) { List<String> possprod = new ArrayList<String>(); ...
I have written a Cached-Object store with a Redis Client for persistent storage. The application that is going to use this is a heavy read application with the occasional write. I assume that entire model will contain somewhere around 500k - 1m entities. The tests I have done so far with a far more complicated model th...