Helper tool to calculate the price for a given amount of users within a graduated pricing model.

Related tags

Miscellaneous lithic
Overview

Lithic

Hi Lithic,

This small piece of software is a coding exercise I asked some candidates to solve and is based on the pricing model of Atlassian products. In the manner of "eat your own dog food", I wrote a version for you.

Here's the original task for javascript candidates:

We're offering the following flexible per-user pricing, so our clients never pay for more than they need.

  • $10 flat monthly fee for small teams of up to 10 users
  • $7 per user/month for the first 100 users
  • $5 per user/month for the next 150 users
  • $1.10 per user/month for each additional user over 250

We want to build a function that accepts an integer users and returns the final price.

pricing(1) // $10
pricing(10) // $10
pricing(100) // $700
pricing(123) // $815
pricing(1234) // $2,532.40

Considerations

There's room for improvement, and I will release 1.1.0 with a builder pattern style functionality and some tweaks as soon as I find some time to do it.

Here are some considerations I had during this task:

Format of input

What interface do I want to provide to other developers? It should be easy to read and easy to work with. Do I use a custom pair object (e.g., Apache Commons tuples, Object arrays...). In the end, I went with a trade-off. I wanted to have fewer dependencies and provide input types that one can use right out-of-the-box (e.g., array). The trade-off is that one needs to understand that the array has semantics. Every two entries are a pair (like key-value pairs in Map.of()). To account for a different usage style, I want to overload the calculate method and provide an alternative with a builder pattern and a custom object.

Exception handling

What kind of exceptions do I want to cover? Is it runtime or checked exceptions? For now, I check for two argument errors and one early exit. However, I already see that a checked exception that I pass on to the user makes more sense for certain things. This will also be part of the 1.1.0 version.

Configurability

How configurable shall this utility be? For now, I went with a flag to consider flat pricing as the lowest price. If this flag is set to false, there's no flat pricing, and every tier will be considered equally.

Sorting of input pairs

Do I want to sort the input, or does this meddle with the expected output of the user? I couldn't see an issue right away, so I went with sorting to have a clean data set for the calculation. Each pair will be sorted by its amount/limit (e.g., price-limit pair).

You might also like...

Option-Price Calculator - Black-Scholes Option Pricing Model With Option Greeks

Option-Price_Calculator Black-Scholes Option Pricing Model With Option Greeks To begin with, an option is like any other financial instrument, should

Jan 13, 2022

Vigour - An Android Fitness App that rewards users with Crypto for walking a certain amount of steps.

Vigour Group Project for 2022 Mobile Application Development. Our app rewards user with crypto after walking for a certain amount of steps. We will be

Sep 12, 2022

A tool that can calculate the average solution set for a first guess in the game of Wordle

word-distances A tool that can calculate the average solution set for a first guess in the game of Wordle. Yes, the name isn't great -- I initially ha

May 2, 2022

BitBase is a Client-Server based Crypto trading platform which offers live pricing, dynamic charts, user portfolio, account settings... and much more!

BitBase is a Client-Server based Crypto trading platform which offers live pricing, dynamic charts, user portfolio, account settings... and much more!

BitBase-Crypto-Trading-Platform BitBase is a Client-Server based Crypto trading platform which offers live pricing, dynamic charts, user portfolio, ac

Feb 11, 2022

A fun way to learn Camunda and win a small price

A fun way to learn Camunda and win a small price

Camunda-Coding-Challenge A fun way to learn about Camunda and win a small prize. The coding challenge is designed for the Camunda Code Studio. Results

Oct 2, 2021

mBERT is a mutation testing tool that uses a pre-trained language model (CodeBERT) to generate mutants.

mBERT is a mutation testing tool that uses a pre-trained language model (CodeBERT) to generate mutants.

Oct 22, 2022

Elite Dangerous Odyssey Materials Helper

Elite Dangerous Odyssey Materials Helper

Elite Dangerous Odyssey Materials Helper This application reads the journal files to track which materials you have and make it instantly visible. It

Jan 7, 2023

📺 一个基于BILIBILI-HELPER 的集中化平台。

Bilibili Helper Hub 📺 Bilibili Helper Hub,一个基于BILIBILI-HELPER 的集中化平台。 Notice 该项目不会在你不知情的情况下存储你提供的Cookie数据以及通过B站官方接口获取的用户数据。 Thanks 该项目基于 JunzhouLiu/B

Dec 29, 2022

Parser of the table of contents file of the 1C platform syntax helper

Parser of the table of contents file of the 1C platform syntax helper

Парсер файла оглавления синтакс-помощника платформы 1С Что делает? Парсит вот это: Оглавление представляет собой файл без расширения, лежит в файле sh

Jan 27, 2022

A helper for creating inventories in minecraft with greater ease and flexibility in order to promote integration with objects

A helper for creating inventories in minecraft with greater ease and flexibility in order to promote integration with objects

Dec 27, 2022

A Java Redis PubSub helper which let you send full objects without need of manual serializing

A Java Redis PubSub helper which let you send full objects without need of manual serializing

Nov 30, 2022

eWordle: an extended version of Wordle with full-featured helper.

eWordle An extended version of Wordle (Mini Project of EBU4201) with full-featured helper. How to Play Guess the Wordle word in tries just one more th

Jun 11, 2022

A little helper to complete homework #4 "Graph planarization" in discrete mathematics at ITMO University in the second semester.

A little helper to complete homework #4

graph_planarization A little helper to complete homework #4 "Graph planarization" in discrete mathematics at ITMO University in the second semester. A

Dec 8, 2022

FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.

FlexyPool adds metrics and failover strategies to a given Connection Pool, allowing it to resize on demand.

Introduction The FlexyPool library adds metrics and flexible strategies to a given Connection Pool, allowing it to resize on demand. This is very hand

Jan 1, 2023

Test if a request/response matches a given raml definition

raml-tester Test if a request/response matches a given raml definition. Versioning Version Contents 0.8.x Stable version, uses RAML parser 0.8.x and s

Mar 21, 2022

Program finds average number of words in each comment given a large data set by use of hadoop's map reduce to work in parallel efficiently.

Program finds average number of words in each comment given a large data set by use of hadoop's map reduce to work in parallel efficiently.

Finding average number of words in all the comments in a data set 📝 Mapper Function In the mapper function we first tokenize entire data and then fin

Aug 23, 2021

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)

OpenAPI Generator Master (5.4.x): 6.0.x (6.0.x): ⭐ ⭐ ⭐ If you would like to contribute, please refer to guidelines and a list of open tasks. ⭐ ⭐ ⭐ ‼️

Dec 30, 2022

👨‍💻This repository gives you the solution of everyday problems given in 30DaysOfCode contest which is held on Hackerrank

👨‍💻This repository gives you the solution of everyday problems given in 30DaysOfCode contest which is held on Hackerrank

👨‍💻30DaysOfCode-PhoenixClub This repository gives you the solution of everyday problems given in 30DaysOfCode contest which is held on Hackerrank. N

Jan 30, 2022

It creates a Trie with given input and perform character based operations

It creates a Trie with given input and perform character based operations

Trie-with-character-based-operations It creates a Trie with given input and perform character based operations Boolean Search(String arg): This functi

Jul 3, 2022
Releases(v1.0.1)
Owner
Stefan Antal
Scientist at Mad Scientists - https://mad-scientists.com
Stefan Antal
A Local implementation of a java library functions to create a serverside and clientside application which will communicate over TCP using given port and ip address.

A Local implementation of java library functions to create a serverside and clientside application which will communicate over TCP using given port and ip address.

Isaac Barry 1 Feb 12, 2022
A Parser That parses OpenAPI definitions in JSON or YAML format and Generates Pact files That contain HTTP request/response interactions by parsing Given Open API specifications

This is a Parser That parses OpenAPI definitions in JSON or YAML format and Generates Pact files That contain HTTP request/response interactions by parsing Given Open API specifications.

dev-rgupta 2 Mar 19, 2022
This service checks the Co-WIN public API at a specific interval and send update to users specified telegram bot.

COVID VACCINE TELEGRAM BOT USING SPRING BOOT This application is a covid vaccine slot notifier via telegram bot. This application uses public CO-WIN A

Hardeek Sharma 6 Oct 4, 2022
This project is a specialized fork of Checkstyle to support older runtime environments of users who can't upgrade

checkstyle-backport-jre8 The latest release version can be found at GitHub releases or at Maven repo. This project is a specialized fork of Checkstyle

null 3 Apr 21, 2022
A demo web application that authenticates users via Wultra Mobile Token.

Demo of Wultra Mobile Token A demo web application that authenticates users via Wultra Mobile Token. Installation Install JDK 11 Install Maven 3.6 Ins

Wultra 1 Jan 31, 2022
A Java to iOS Objective-C translation tool and runtime.

J2ObjC: Java to Objective-C Translator and Runtime Project site: https://j2objc.org J2ObjC blog: https://j2objc.blogspot.com Questions and discussion:

Google 5.9k Dec 29, 2022
The open-source Java obfuscation tool working with Ant and Gradle by yWorks - the diagramming experts

yGuard yGuard is an open-source Java obfuscation tool. With yGuard it is easy as pie ( ?? ) to configure obfuscation through an extensive ant task. yG

yWorks GmbH 265 Jan 2, 2023
ThirdEye is an integrated tool for realtime monitoring of time series and interactive root-cause analysis.

ThirdEye is an integrated tool for realtime monitoring of time series and interactive root-cause analysis. It enables anyone inside an organization to collaborate on effective identification and analysis of deviations in business and system metrics. ThirdEye supports the entire workflow from anomaly detection, over root-cause analysis, to issue resolution and post-mortem reporting.

null 87 Oct 17, 2022
A tool to help Barcelonian people get various immigration-related appointments via the Cita previa process

NIEBot A tool to help Barcelonian people get various immigration-related appointments via the Cita previa process. Requirements A Windows or Linux PC.

Conor Rynne 49 Dec 10, 2022
A simplified and multi-functional tool for spigot developers

A simplified and multi-functional tool for spigot developers. There are dozens of features you can use in it, and it is completely open source code. hCore supports all versions from 1.8.x to 1.18.2. Also you can find all these APIs usages from here.

Hakan Kargın 57 Jan 1, 2023