The TransCompilator

Solved LeetCode program · 856 of 1,000

#1154 · Day of the Year

Easy String chunk-18.md

Original English source

The date is "2019-02-10". The lengths is a list of 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, and 31. The digit is 0. The year is the digit value of character 0 of date. Set digit to the digit value of character 1 of date. Set year to year times 10 plus digit. Set digit to the digit value of character 2 of date. Set year to year times 10 plus digit. Set digit to the digit value of character 3 of date. Set year to year times 10 plus digit. The month is the digit value of character 5 of date. Set digit to the digit value of character 6 of date. Set month to month times 10 plus digit. The day is the digit value of character 8 of date. Set digit to the digit value of character 9 of date. Set day to day times 10 plus digit. The leap is 0. If year modulo 4 is 0 and year modulo 100 is not 0, set leap to 1. If year modulo 400 is 0, set leap to 1. The total is 0.
For every which from 0 to month minus 2.
Increase total by item which of lengths. Increase total by day. If leap is 1 and month is more than 2, add 1 to total.

Show total.

Open in Playground Browse all 1,000 problems

Expected stdout

41