my widget math formula doesn't calculate correctly - algorithm

I have a question which may not be your area of expertise but I was trying to help out a friend on their site by making a numerology calculator that would calculate someones birthday, or life path number. Birthday january 13, 1970. Lifepath is 1+(1+3)+(1+9+7+0)=13 1+3=4 so 4 is the number i'm looking for. This is the formula I used Mod(Mod(n,45),9), n=[//math:${input1}//]. And that works on every birthday except one that is supposed to end in 9 in which case it says the lifepath number is 0. Any ideas? One of our users bday is May 1, 1965 which is a 9 and it returns 0 as do all the combos i tried that equal 9. And here it is on the site.http://www.kryschendo.com/numerology_reports.html

First of all, if I'm understanding your example, it should be:
1+(1+3)+(1+9+7+0)=22
2+2=4
Try this:
Mod((n-1),9) + 1, n=[//math:${input1}//]

Related

algorithm: get next year date work shift type according week number

I work in 3 shifts, each week different one. The order is morning shift (m), night one (n) and afternoon one (a). The order i fixed, i.e. it never changes, even if one won't work that week.
I created a function to get ISO week number. When I throw it a date, it returns week number.
This week (no. 48), for example, I work morning, therefore 48 % 3 = 0 → m = 0; n = 1; a = 2.
I saved this into array shifts = ["m", "n", "a"].
This is the easy part. But as the end of the year comes, I need to solve a problem. As 52 (the total number of weeks in 2017) is not divisible by 3 and there are different number of weeks in different years, modulo 0 (which for year 2017 means m), means something else in different years.
So, the actual question is what would be the fastest and simplest algorithm (rather fastest than simplest), doesn't need to be human-readable, with explanation (if necessary) why/how does it do what it does.
I thought of one (which is neither fast nor simple): to the known week no. & shift type combo add the number of weeks following that week until the end of the year, and recalculate the array shifts.
Why do you want to use ISO week numbers ?
Let's say that your weeks start on some specific day (monday, sunday, you decide). You decide of a starting date d0, also a week start, for shift 0. Then for any date d your shift is:
shift = floor(nbdays(d - d0) / 7) mod 3
Problems may arise if your system work in different locales where the starting day for a week is not the same. In that case you should have a specific d0 for each locale. If your shift is the same worldwide you have no problem.

How to find out product(with his characteristics) using barcode?

Is there a way to decrypt the goods? For example, if I received the product barcode then, using some libraries, find out what it is product? For example, apple juice, one liter of a particular company.
What is the way to solve this problem? Now I'm is not interested decision on some platform. I asking show me some decisions this problem.
Read this: GSDN Database which listed 11 million items as of about 18 months ago. I've no doubt you would be able to gain access to this database if required - it's managed by the world-wide authority.
Item barcodes may be 13, 12 or 8 digits long - there are formulæ to convert the shorter code to 13-digit. All systems were supposed to be converted to 13-digit many years ago so that there was no need for a product bearing a 13-digit barcode to also require a UPC-A (12-digit) code for use in the US.
The general scheme is to use the first 2, sometimes 3 digits for a country code, then allot a company code and item number (assigned by the company) and then a check digit. The actual number of digits assigned to the company code and item varies with the local GS1 office, but the total of country+company+item digits must be 12 + 1 check digit=13.
As an example, Australia uses country 93, then either 5 or 7 digits for company code (depending on expected number of products) then 5 or 3 digits for the item code.
Product barcodes (12 or 13 numbers long, depending on location) are just an item number, they do not carry any information about what the product is. There is some basic information you can get from these barcodes:
The first 3 digits tell you which country the barcode is from. you can look here
http://en.wikipedia.org/wiki/List_of_GS1_country_codes for a list.
The next 9 digits are made of 4 to 6 digits tell you which company the barcode comes from,
and then there are 3 to 5 digits which are the particular SKU's item number
and finally a check digit.

How to count how many times a rule appears in a specific month.Exce;

I want to count how many times in a specific month(for example:January) the red cell with the rule: equal or more than 15 days -> red cell , appears. How can I do that?
My table looks like this
A B
16.02.2013 15
17.01.2012 20
01.02.2013 4
26.04.2012 10
01.01.2012 21
20.04.2012 7
The answer for January is 2
How can I do if I want to make the count by month and year?
Thank you in advance!
Lygia
You can use the countifs function for this. (Link)
Assuming C1 holds start date you want to count from, and C2 holds end date you want to count too.
=COUNTIFS(A:A;">="&C1;A:A;"<="&C2;B:B;">15")
Not sure if you can tie the condition directly to the formating rule.
I'm guessing that entries in ColumnB greater than or equal to 15 have been formatted red. (Which could imply a flaw in #Taemyr's answer, where >15 should perhaps be >=15.) Also, that the likes of "(for example:January)" implies that a solution that works conveniently for many months would be appreciated, so suggest a PivotTable.
Due to PT constraints, identification of values greater than a cutoff is easier in the source data. In this case should only require filtering to select values that have already been formatted red, and adding a flag, say x, to these.
Then the PT could be filtered for x only and the ColumnA values (ROWS) Grouped by Years and Months. The sum of VALUES field being Count of B.

Bowling Counting algorithm from InterviewStreet

I don't know if this is the right section... but here goes:
Last weeks contest on interviewstreet (Code Sprint 3) had a problem called bowling. (10 pin bowling, N frames). The point is to count the number of ways to score M points by playing N frames.
Problem Statement is here: http://pastebin.com/cyeLML8U
I'm pretty sure I've solved the problem using 2 dimensional DP. However, I get the 3rd sample data wrong (1 Frame, 25 points). The sample answer is 1, however I get 6.
This is their explanation of the sample answer:
For the third case, there is only 1 way. Score a strike in the first frame, score another strike with the first extra ball, and an additional 5 with the second extra ball.
However, can't you score a strike in the first (and only) frame, then score any of the following in the subsequent extra frames?
10 5
9 6
8 7
7 8
6 9
5 10
I can't wrap my head around why "1" is the right answer.... I've looked on wikipedia for the rules too.
Their answer is probably right, and I'm probably overlooking something REALLY obvious. Can anyone tell me what's wrong with my answer?
You cannot get 9 pins with the first extra ball and then 6 pins with the second extra ball because there is only 1 pin left standing when you bowl the second extra ball.
But if you don't get a strike on the second ball, you only have the opportunity to "pick up the spare." That is, you only get 10 pins. So if you get a strike on the first ball and then 9 pins on the second ball, the most you can get on the third ball is 1.
The way I read it, your answer is technically correct, but I don't think the question was asked correctly.
Within the constraints as set out in the link in your question, I can't see what's wrong with your solution. In real life, the pins won't actually be reset unless you've knocked them all down or have bowled twice (or both), so - as others have said - the only way you can score 25 from a 1 ball frame in real life is strike, strike, 5.
Basically, the question didn't give you the correct constraints. I don't think it's valid to say you got the answer wrong, because the question was poorly phrased.

Question about pseudocode for HW

I have the following question, and what I'm most confused on, is how to do the logic for determining if a check is one month late or not.
Question is:
"Write pseudocode for a program that calculates the service charge of a customer owes for writing a bad check. The program accepts a customer's name, the date the check was written (year, month and day), the current date (year, month and day), and the amount of the check in dollars and cents. The program continues until an eof value is encountered. The service charge is $20 plus 2 percent of the amount of the check, plus $5 for every month that has passed since the check was written. A check is one month late as soon as a new month starts-so a bad check written on September 30 is one month overdue on October 1."
So far what I have write now is:
Start
string Name
num AmountOwed
num DateCheckWritten
num CurrentDate
num CheckAmount
get Name, DateCheckWritten, CurrentDate, CheckAmount
while eof
Since you don't have to deal with days, the algorithm is very straightforward:
MonthsLate = (CurrentDate.Year - DateCheckWritten.Year) * 12
+ (CurrentDate.Month - DateCheckWritten.Month)
Good luck with the rest of the problem!
I'm not sure where your problem lies, but I think you have two issues to deal with:
What is the definition of late?
How many months late is this check?
So in my pseudocode, I would have a step that determines how late a check is, and then another step to calculate the fee. Inside the first step, you could just subtract the days and divide. But the directions say as soon as a new month comes along, it is one month late. So all you really have to do is subtract months.
Not sure what else you are asking, but it appears you are asking for guidance, not code. Hope this helps.
I'm going to assume this is homework, and as such I'll try to just point you in the right direction.
If you assign numbers to each month (Jan = 1, Feb = 2, etc) then the number of months between two dates is easy to determine - how many months are there between September (= 9) and May (= 5)?
The other thing to take into account is the year - for each year the check is late, you'll also have to add another twelve months. This works the same as for months.
Need any extra detail, feel free to let me know.
Simplify, hit the main points and then break it down more and more, write it how you would tell your grandma it worked.
you might start out with something like
Start
While there are more bad checks
get the service charge
add the service charge to the account
record the updates
get the service charge
charge starts at $20
add to the charge $5 multiplied by number of months

Resources