instruction
stringlengths
71
71.9k
I am currently attempting to become proficient in C++ and started by implementing a basic binary search tree. Most of the programming I have done is in Ada, Python and C. I would like to be able to program efficiently in modern C++ and become familiar with current best practices. I do not have any major questions or c...
I'm taking an intro to programming class and although I've learned some things I didn't know before (I've been using Python for about 1.5 years) I feel like I've not progressed much in writing "beautiful" code. My professor is committed to keeping this as a general intro class, and chose Python for its "friendliness" a...
I'm trying to solve this problem: A root tree is a directed acyclic graph that contains one node (root), from which there is exactly one path to any other node. A root tree is binary if each node has at most two outgoing arcs. When a binary tree is painted on the plane, all arcs should be directed from top to bott...
I have a simple class: public class AlertDialogFragment extends DialogFragment { private static final DialogInterface.OnClickListener DUMMY_ON_BUTTON_CLICKED_LISTENER = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // do nothi...
I have an already rendered template and I want to update it with some JSON data I obtain via AJAX. The template as it is before rendering looks like this (using jinja2 template engine): <table> <thead> <th> Time </th> <th> Destination </th> <th> Bus number </th> </thead> <tbody id="table-body"> {% for bus ...
I got this background console script running, which pulls all necessary XML files from the server and stores them locally for faster performance. These XML files contain Graphs full of data, which will be shown inside the application. Right now the user can get to the graphs in about 45 seconds if he directly goes tow...
Here I am doing some exercises for my studies with Python. This is a binary to decimal number converter (currently restricted to that). These are the very first steps, so there is no error handling. You can even input non-binary numbers and get a result. However it works for converting binary numbers, which is its task...
I've always struggled to write JavaScript code that I thought of as great and "correct" code. And I've struggled to find good information on how to do it. Recently I was given a task at work to write a library for displaying an information box with info on our cookie usage. Since this was a pretty small and contained t...
I think that my code isn't perfect and I need a help to understand how to optimize it. In my application I have a main form and several forms for data editing. The user can: Add a new item Edit the selected item Delete the selected item Duplicate an item with a new name You can see an example of my code below. I t...
I have been asked to refactor the below code using SOLID principles and I was just wondering how you would go about it. I am not really sure if I am winning or not. Could you have a stab at it and let me see what you come up with? public class Box { private BoxType _boxType; public double Width { g...
After my success with extending enum - I thought I would try to make Singleton creation as simple as possible since Java-8 makes Multitons comparatively easy. My aim was to create a class which is a Singleton solely by the simple fact that it implements a Singleton interface. Unfortunately there is a little baggage req...
While reading HackerNews, I learned about a data set of the first 50 million primes. This would be a lot, but his website has disclaimer: n this directory I have the first fifty million primes in blocks of one million. Usually it is faster to run a program on your own computer than to download them, but by popular d...
public function get($item) { if (isset($_POST[$item]) && $_POST[$item] != '') { $_POST[$item] = filter_var($_POST[$item],FILTER_SANITIZE_SPECIAL_CHARS); if(is_numeric($_POST[$item])) { return (int)$_POST[$item]; } return $_POST[$item]; }else if (isset($_GET[$item]) &&...
I took this code segment from existing source on Android, but it applies to anything from ASP.NET Forms to anything else where the UI has an event callback, and the logic is implemented directly in that callback. That's basically "Smart UI", aka it is the GUI itself that knows how to execute the logic. This is simple t...
My question, REST API and lazy loading objects, didn't receive any answers (or many views), so here is my attempt at the solution. Problem overview: My mobile app requests a list of objects through a HTTP REST API but only required a small subset of each item to display items in a list. Other larger properties should n...
I'm learning how to code in Java and I decided to re-write a program made in C++ into Java. All feedback is welcome. Here is the original prompt: This program generates a pseudo-random number between 1 and 100, inclusive. The user will then be presented with opportunities to guess that number. After each guess, th...
I have a problem: build a tree relationship parent/child like this one: Can you review this piece of code please since I am convinced it could be improved? struct item { char value; std::list<item*> children; }; I write a comparison function for a sort : bool compareChild(const item *first, const item *second...
Based on lots of read books, sometimes I get quite confused when things get bigger than the simple examples. Martin Fowler's clean code is good but not enough. I want some feedback on how to improve my current coding workflow, especially regarding to methods doing one thing or what is exactly one thing, does it depends...
Is there a better way to do this? var duplicate = false; for (var i = 0; i < acceptedFiles.length; i++) { for (var j = 0; j < attachments.attachments.length; j++) { if (attachments.attachments[j].name === acceptedFiles[i].name) { duplicate = true; } } ...
I am currently trying to implement a Neural Net in Julia with the goal of eventually implementing a stacked autoencoder. My code seems to work but I would appreciate any constructive criticism. If there exists a style guide for Julia, I am not concerned with that. However, any other comments would be very much welcome....
I'm working on a C++ library for Arduino and other embedded systems. I'm currently working on wrapping up function pointers and member-function pointers into two C++ template classes (function and mem_fn). Does the following code abide by good programming practices? Does it provide enough functionality? Since there se...
I'm currently preparing some basic code samples for a trainee position. I've formatted some of my older tools that I had previously written, but feel confident about. I would very much appreciate a pair of experienced eyes to look over the code and its formatting. It's written originally in Python 2.7, but I formatted ...
I have been working on a few games which all have a need to create "events" randomly over time. The intervals need to get shorter as time goes on if the event is negative or they need to get longer as time goes on if the event is positive in order to make the game harder the longer you play. In my head, this picture ...
The goal is to add a new displayValue property to each object depending on what it has available out of Firstname, Lastname, Nickname and Name. I'd like this cleaned up. var data = [ { Id: 132, Name: null, Firstname: "Sam", Lastname: null, Nickname: "Dim", }, { ...
Below is a long messy one method code for a craps game. The user can play the game multiple times and has the option to quit when ever they want. How could you break this code down into different types of methods? How many methods do you think the code can be broken down to? What types of methods should be used? imp...
After seeing this example of a "primitive" QS implementation in F# by Scott W let rec quicksort2 = function | [] -> [] | first::rest -> let smaller,larger = List.partition ((>=) first) rest List.concat [quicksort2 smaller; [first]; quicksort2 larger] He has an example...
I have implemented a recursive function that converts an object's keys according to another lookup table/map. You are able to convert back and forth using the 3rd swap_conversion_table_key_value boolean argument. My use case is to convert object keys to single characters to slim down the amount of characters generated ...
I am trying to create a bash-based inventory scanner, and was wondering if there is anything 'glaringly' incorrect about my syntax or usage. I was hoping I could get some feedback on: bash programming best practice in regards to syntax, modularity, variable passing Maybe some book suggestions? How can I do it right th...
Can you help me look through the functions below to make sure they behave similarly as these standard C++ functions (_fcvt, ltoa, atoi, CString(char*)). The reason is that I am converting some code from C++ to C# and I want to validate that the code works EXACTLY the same. These functions are used in a custom numeric r...
#!/usr/bin/env python3 from tkinter import * root = Tk() class GrowLabel(Label): def __init__(self, master): Label.__init__(self, master) self.counter = 12 self.config(text=str(self.counter), fg="blue", font=("verdana", self.counter, "bold")) self.pack() button = Button(se...
Here is a program that will parse and print XML feed URLs. I want to reuse most of it to add post date to each link. This adds a new concern of CLI and output formatting on top of parsing and (poor) error handling. I wonder how much of this code has enough value to put is in a wrapper utility and how much should be sim...
Using JavaScript/jQuery I created a simple toggle and started writing unit tests for it using Jasmine. I am not sure, however, if I should be testing for things like e.g. if "click" listener is registered when object is instantiated. Should this be done as part of unit test or rather E2E test using WebDriver or somethi...
We have numerous threads talking about the usage of interface vis-a-vis abstract class Taking reference of an answer, given by Prasun looks complete answer to me. Do you think this is complete answer? Please confirm, if my interpretation of this answer looks correct, considering below example. The toEncode() being par...
I have worked on the trinary tree problem insert and delete. Can anyone look at it and tell me how it is? TrinaryNode.java public class TrinaryNode { private int key = -1; private TrinaryNode left; private TrinaryNode middle; private TrinaryNode right; private TrinaryNode parent; public Trinary...
I wrote an implementation of the Karp-Rabin string matching algorithm in Java 7, based on the discussion in Section 32.2 of Introduction to Algorithms (CLRS). Clearly, I need more experience with numeric programming, because I spent two days wrestling with overflow issues and floating point error, but I believe it work...
Can anyone help me with checking this code? It is for connecting to a database. The method getFromDatabase is to take values from the database and put it to a dataset, and the other method getFromDatabaseToCombo is to get from the database to a comboBox. I can't shake off this feeling that the last two methods can be c...
I am trying to solve a Hacker Rank problem about string suffixes: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strings "abc" and "abd" is 2, while the similarity of strings "aaa" and "aaab" is 3. Cal...
I want to write a file which contains values for each cell of a CFD computation. This will be an input file to the program which runs the computation. Currently, the most dubious section of my code looks like: for (int y = 0; y < ycells; y++) { double yPos = yMin + (cellToY * (y + 0.5)); for (int x=0; x<xce...
I have a problem where, given N terms, the task is to find the k most frequent terms from given N terms. My code is correct, but I have a time limit 10 seconds and my code doesn't pass. Constraints: \$0 < N < 300000\$ \$0 < \textrm{term length} < 25\$ N = gets.to_i if N < 300000 and N a=[] (0...N).each do |i| ...
Help on the appropriate design pattern for this. Program details: A scheduled script that fetches all the data from various framework-based API's - executeSearch('webservice_name') - , then, collate the data and pass it to another framework-API - saveToReportTemplate('report_template_name') - which persists th...
I'm putting together a template for easy formatting of content pages, to be used in putting together a website for an online trading card game. I've been using the Bootstrap library (and finding it wonderful) and since we will be using this template for basically all pages, I want to make sure it's top-notch before we...
I am working on a library in which I need to make synchronous and asynchronous methods in my client library. My library does this: The customer will use our library and they will call it by passing user_id. We will then construct a URL by using that userId and make an HTTP client call to that URL. We will then get a JS...
Given the following algebraic data type, a Rose Tree: data Tree a = Node { rootLabel :: a, subForest :: [Tree a] } I attempted a foldTree function to fold over this list: (credit to this class's homework from 2013: treeFold :: (b -> [b] -> b) -> (a -> b) -> Tree a -> b treeFold f g tree = f (g (rootLabel tre...
The table has 4 search types and 4 radio buttons; when one radio button is clicked, other fields should be disabled. The JavaScript code seems repetitive. How can I improve it? JavaScript function Init_RadioButtonList() { $(function () { TRShow($("input:radio[id='RadioButton1']:checked").val()); ...
I have a simple gallery that hides and shows images. It works fine, however, I am not satisfied with my approach, and my code seems redundant. Can you check my code and give a better idea on how I can improve it? HTML <div class="big_img_wrapper"> <img src="<?= IMAGEPATH ?>front_page/phinfo/house_rental...
I have a dialog which populates my ConnectionStringData object with the URL of the service that I'm trying to connect to. I then consume that URL with the following property: /// <summary> /// Where the Service is located. /// </summary> public string ServiceLocation { get { ...
In the context of a Gibbs sampler, I profiled my code and my major bottleneck is the following: I need to compute the likelihood of N points assuming they have been drawn from N normal distributions (with different means but same variance). Here are two ways to compute it: import numpy as np from scipy.stats import m...
I have seen programs to solve sudoku puzzles but to be honest.. They were badly written. First of all, readability of the program itself was horrible and the code was really long and confusing. So I decided to start from scratch, using my own style to write really good solver. What I have this far is reading a board in...
I have a root class and I'd like to add an indicator to it (property, static field, readonly field, virtual method or something like that), that should give me the same string value for every instance of that class, I would rather prefer to get that value without instantiating that class. GetObjType() virtual method is...
My guts tells me that this isn't the proper way to handle views / templates, so that's why I'm asking you what could be done better. Some background: This application I'm building now is for use in a school project with people that don't have much knowledge of PHP. Therefore I'm not using a framework like Laravel, or i...
I've created a script to create a module in our MVC framework. The structure of the module is like this (for this example, the module is called test): test > Test.php controllers > IndexController.php models > TestModel.php open > css > js > views > Here's what I have ...
The story... A bit of background info and how is the database designed... Please notice you don't really have to rebuild the tables in SQL but I shared an SQL Fiddle just in case and screenshots1 of what the database looks like. I thought it was going to be easier to explain the story of what I am doing + you can alway...
I'm new to Core Animations, I want to fade out two different layers one after another.I write them in a CATransaction block. I wonder if there is better approach to make such animations. [CATransaction begin]; CABasicAnimation *fadeOutLoadingBar = [CABasicAnimation animationWithKeyPath:@"opacity"]; fadeOutLoad...
I was looking to see if anyone could help me come up with a cleaner/DRY methods in duplicate of doing something like this? I would like to get the features that repeats in the 2 controllers to generalize my code. var propertiesModule = angular.module('app.properties', []); propertiesModule.controller('PropertiesCtrl',...
I wrote a function to replace color in a bitmap image. For beginners in image processing, it could be exclusively useful, since they could use it to replace the entire gamma of a color or to replace a color with gradient/abstract lines, following the function's logic. The main problem of the function, according to perf...
This is a followup to Simple stack implementation using linked list Since my original stack implementation has lots of bugs that I did not notice, I thought I would recreate and try to improve it. Please review this version. Note about pointers: I know using std::unique_ptr is better so we don't need to do manual del...
I'm deploying a PHP project, and I always try to use prepared statements, but unfortunately, GoDaddy does not have the mod mysqlnd which I use it for the function mysqli_stmt_get_result($stmt), so I had to start using mysqli_query in order to use the classic. Example: while($row = mysqli_fetch_array($query,MYSQLI_ASSOC...
I have created a simple percentage-based random prize drop for killing certain mobs. A drop is basically what the player will get in return for killing a mob, as a reward. So I have a large list of Mobs saved in an XML file which looks like this: <?xml version="1.0" encoding="UTF-8"?> <drops> <npc id="1"> <...
I have inherited a C++ Win32 thread class which roughly works like this. I am looking for ways to improve the design; specifically I am looking for a way to get rid of the spurious Resume() call at the end of initialization. Is there a way this can be automated or omitted? Base class class CThread { public: CThread...
I have made a calculator in PHP and I need some feedback in terms of security and performance or any other general improvements. You can download a zip file with all the contents from this link if you wish to try it out for yourself! I rewrote the source and comments from Norwegian to English, except the .css file. I a...
I've written a very light wrapper around Dapper to help with unit testing and streamlining the Dapper commands I need. Execute() is a method created to remove the code duplication of opening and closing the database connection and enlisting it in a transaction. The code is very quick at inserts with this method (200,00...
Disclaimer: This is just an educational task to learn how to program in Clojure and switch brain to immutable state-way of developing (the provided snipped has some unused variables which I didn't clean up since they will be used soon and are easy to understand). The current milestone: to implement a solution that read...
Now that I've used it a lot, I think I'm starting to get the hang of jQuery and its capabilities. One thing I'm still unclear about is how global variables are initiated and used, and when the variable is in reference to a jQuery object, both cases especially in and with external JavaScript files. For example, if we ha...
I use this Bash script to rename specified files to all lowercase letters: #!/bin/bash usage() { test $# = 0 || echo "$@" echo "Usage: $0 [OPTION]... FILE..." echo echo "Rename files to all lowercase letters." echo echo " -n, --dry-run Dry run, show what would happen" echo echo...
I've read up on genetic programming yesterday so I figured I'd try to implement something myself. I would like the main focus to be on whether or not I've implemented the idea behind it correctly. The thought behind it is simple: given a number and a few parameters, generate an equation that yields that number as sol...
A lot of the sieve code floating around here and on the 'net is sloppy or broken; in fact, I've yet to see a single one that is correct, clean (in the sense of avoiding superfluous iterations etc.) and that can actually sieve up to the end of its operating range. Some state at least that they cannot sieve the full rang...
I have an interesting problem with my chess application. The application reads PGN files, and at any time while viewing a game from the file, the function below, when called, iterates over the chessboard, gets the square names for each piece, and then constructs a string containing the description of which piece is whe...
The task is simple: given N, generate a random integer with no repeating digits. ''' Generate a random number of length, N and all digits are unique ''' from __future__ import print_function import random from collections import OrderedDict # keep generating till all are unique # This is a brute force approach where I...
I attempted (incorrectly) to implement foldTree here. Recently, I updated it per Petr's help: treeFold :: (b -> [b] -> b) -> (a -> b) -> Tree a -> b treeFold f g tree = f (g (rootLabel tree)) (map (treeFold f g) (subForest tree)) I implemented toList: toList :: Tree a -> [a] toList = treeFold (\x y -> x ++ (foldr (++)...
I've recently ported an old project and made it object-oriented. However, I've noticed that rubocop points out the following status: Assignment Branch Condition size for fetch_images is too high. [22.41/15]. Can I make this method be made more efficient, perhaps? Snippit class WebCrawler ...
Because I don't like complex sequences of code for simple functions, I wrote a wrapper for http/https access in A++. Are there any bad programming practices I am using? Is there any functionality I should add? One thing I have not figured out yet is how to determine content-length if it's not specified in the header. H...
I am trying to write a premake4.lua file that builds and links to static libraries using premake. library mbm was originally designed to be built using cmake. So to go around this issue I call ./configure then I build it using premake4 gmake. library jansson was originally designed to be built using cmake. But calling...
After I wrote this question: Producer/Consumer programs, I realized that I had forgotten to write a version using mutexes. I have now solved the Producer/Consumer problem using mutexes and implementing the tips I received from answers on that question. It appears to be working correctly; however, unlike my other prog...
I want to start off by saying sorry, I wasn't able to search for this problem as I couldn't exactly describe it myself. I have a series of if-statements to account for each scenario. As you can see in the mammoth block of code below, I want arguments to come in any order. How, if possible, can I shorten this? if(args[1...
I posted this question on StackOverflow. Given this algebraic data type: data Tree a = Node { rootLabel :: a, subForest :: [Tree a] } deriving (Show) and function: treeFold :: (a -> [b] -> b) -> Tree a -> b treeFold f (Node x ts) = f x (map (treeFold' f) ts) Write a function (using treeFold) with the signat...
Assuming I have to leave the contract intact (take byte[] and return byte[]), what's the correct way to structure this asynchronous method? Will this deadlock running in ASP.NET in a web server thread? public async Task<byte[]> CompressAsync(byte[] buffer) { using (var outStream = new MemoryStream()) { ...
I'm coming from the Java world and making my first steps on Python and see how good it is to express more with less code. I'd like to know if, via Python, the size of the following code could be reduced: column_entropy = 0 for k in frequencies.keys(): p = frequencies[k] / 10 column_entropy += p * log(p, 2) if p...
I am wondering if I should use NSLog(@"Switch out of range") or NSAssert(FALSE,@"Switch out of range"); in the following example: typedef enum { kSectionFavoriteCarpark, kSectionPromotions, SectionsEnumCount } SectionsEnum; - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)s...
I am working on an image manipulation class for a project to re-size uploaded slider images to 780 X 397 and uploaded avatar pictures to 220 X 220. I am wondering if this is a good way to construct it. What would be the best way to handle an image that is smaller then 780 X 397. Should I simply re-size it or go about i...
Here I am trying to avoid hardcoding in flash messages by using I18n. Also, I have tried to use a CSS selector for submitting the form to make the tests less brittle (I don't really care that much about what the text on the button is - more what happens when submitting). Is this a good approach for making tests less br...
The following algorithm works correctly for the purposes that I need, which is to set the top side of an image with a transparent gradient blend. Any tips to optimize it for speed? void ImageUtil::sectionAlphaGradient(uint32_t* pixelBuffer, const int width, const int gradientHeight) { unsigned int pixelOffsetY, pix...
I am needing to write my own IsNullOrWhiteSpace check for Java but am wondering if this is the best method to do so public static boolean isStringNullOrWhiteSpace(String value) { if (isStringNullOrEmpty(value)){ return true; } for (Character chars : value.toCharArray()){ if (!Character.isWh...
I've created a modular structure for my Angular application. The main idea is to have a folder of modules which may be reusable later by simple copying them to the new project. With help of Gulp I created a tasks which iterates over each folder in modules and makes a final build. Here is my source and build I would ap...
I've recently been assigned to write up a CSV writer with "as much flexibility" as possible concerning pretty much all (output stream, string fields with potential new line characters, separator collisions, etc. you name it...) No specification, no design guidelines, no nothing and I'm not expecting any any time soon (...
I have a Polygon named as poly. I attempted to randomly select 5 coordinate points that lies inside the polygon. import numpy as np from shapely.geometry import Polygon, Point poly = Polygon([(141.4378366,-25.95915986), (165.4279876,-29.43400298), (163.1382942,-47.65345814), (133.1675418,-42.99807751)]) minx, miny, m...
I have a table in my database with 35000 unique URLs. I use them to create my XML sitemaps for the site. I have setup crontab jobs to create automatically new URLs, delete non existing URLs and determine if a URL is valid. For the last part I use the following function: function get_url_status($url) { $httpCode = 0...
Below you will find the specific code that I am attempting to optimize. I have a method previous to called getCount() which, based on similar parameters as below, calculates how many record sets of 75 will be pulled based on one of the below query. The Query that is executed is based on the department, projLead and sta...
I am looking for feedback and possible suggestions regarding a piece of JS code that performs transparent symmetric encryption/decryption of user specified data using the HTML5 localStorage, sessionStorage or depreciated cookie options. The project can be viewed in its entirety at here. /** * secStore.js - Encryption ...
I have Ruby models which are populated from the responses of API calls in the following way: JSON.parse converts the response to a Hash the Hash is passed into the initialize method of a class the initialize method converts camelCase hash keys and assigns underscore_case instance variables controller code works with t...
All of the other Python IRC packages I've seen out there are overly complicated for simple tasks, and they don't abstract away much of the complexity of the protocol and asynchronicity. I've taken a crack at a better interface, but I'm new to the IRC protocol. It runs under Python2 and 3. How's it look? """ simple_irc:...
I'm new to Python and I am learning database connections from here. This is the code I am using to insert e-mail subscribers into a table: conn = mysql.connector.connect(user="user", password="password", host="127.0.0.1", database="db") cursor = conn.cursor() query = ("INSERT INTO test(name,email) VALUES(%s,%s)") data ...
I need help identifying any significant design issues with some code I have generated to track status updates. I have a big task A which contains multiple small tasks and each of these small tasks updates the status of A in the data store. This is how I've implemented: For each type of Task A(A can be of multiple types...
I'm trying to convert some very simple C# string utility functions to F# as a learning exercise. Ignore the fact that the C# version is implemented as an extension method for the moment. The function adds a blank space before any upper case letters (with the exception of the very first char) - so, "ATestString" become...
I finally have a working trampoline mechanism. Would anyone care to critique it? Ideone #include <iostream> using namespace std; #include <map> template<typename T> class Base { public: typedef void (T::*PFunc)(void); typedef void (*PHandler)(void*); using method_map_t = map< string, PHandler >; ...
The idea is to have a heading for each date returned by the query. This could be any number of dates. I dynamically altered the #table which is ugly but there is no other way. Ultimately I would like to reduce the amount of cursors but I'm not sure if it is possible. This is using the Northwind database on SQL Serve...
I was working on the "Robot Name" exercise over on exercism.io (neat site, by the way), the gist of which is: Generate random, unique strings that match /[A-Za-z]{2}[0-9]{3}/, e.g. "xY123", "Gv020", and so on. So there are 2,704,000 possible names out there. Now, the exercise's tests do not do a full-on check for uniqu...
I have recently found that I needed to be able to parse multipart/form-data for PUT requests made to my REST API. This allows batch photo uploads, which has been a requested feature. As we all know, PHP (at least as of version 5.3) does not support this natively, so had to roll my own. I have tried my best to make it w...
I'm doing some practice questions from the book Cracking the coding interview and wanted to get some people to review my code for bugs and optimizations. Question: Write a method to decide if two strings are anagrams or not. /* Time complexity: O(n^2) Space complexity: O(n) */ bool IsAnagram(std::string str1, std::st...
Using the following code, I am able to neatly draw a color wheel, however, performance is barely acceptable on a high end machine. Now, I know some tricks I could employ to make it run far more smoothly, at the cost of a lot of flexibility, but I am especially interested in optimizing the code itself (thus keeping the ...
A loan calculator has to be created for the proNetBank. Method of processing the loan is as follows: Vehicle loan is given for a period of three to seven years depending on the customers preference. the current interest rate is 20% per annum. The minimum loan amount is lkr 500,000 and the maximum loan amount i...