Provided Services / Budgeted Services - sql-server

I posted a similar post yesterday but I don't think I articulated what I am trying to accomplish well.
I need calculate (1) the total amount of each WAIVER_SERVICE that was budgeted, (2) the total amount for each wavier service that was provided and (3) the % Budget Used. Grouped by WAIVER_SERVICES and
Month/Year
CLT_NBR WAIVER_SERVICES Month/Year Amount_Services_Provided Amount_Budgeted %_Budget_Used
10178 2 1 2013 1000 1100 90%
10178 2 2 2013 950 1000 95%
10178 2 3 2013 759 650 115%
10178 4 11 2012 600 1000 60%
10178 4 9 2013 100 100 100%
If a client was budgeted a service and did not receive it for a month a 0 value is needed and I need to display 0's for months with no data.
Below are 3 temp tables which are examples of the original 3 tables used for the two programs. The tables are B2H_DSP, B2H_SummaryForms and B2H_RATE . Note the B2H_Rate table is a reference table which pulls the cost of the wavier_services.
B2H_DSP TABLE
CREATE TABLE B2H_DSP (
BGT_NBR int,
CLT_NBR int,
WAIVER_SERVICES int,
WAIVER_PROGRAM int,
START_DT date,
END_DT date,
BILLABLE_UNITS_OF_SERVICE int,
UNITS_PER_MONTH int,
RATE_PER_UNIT_OF_SERVICE int,
PROJECTED_COST_PER_MONTH int,
NUMBER_OF_MONTHS_OF_SERVICES int,
PROJECTED_COST_PER_12_MONTHS int
);
INSERT INTO B2H_DSP VALUES
(1, 10178, 9, 2, '7/21/2011', '7/21/2012', 5, 16, 12.7, 203.2, 12, 2633.47),
(1, 10178, 10, 2, '7/21/2011', '7/21/2012', 5, 4, 19.55, 78.2, 12, 1013.47),
(1, 10178, 11, 2, '7/21/2011', '7/21/2012', 5, 4, 19.55, 78.2, 12, 1013.47),
(1, 10178, 5, 2, '7/21/2011', '7/21/2012', 5, 28, 12.64, 353.92, 12, 4586.8),
(1, 10178, 2, 2, '7/21/2011', '7/21/2012', 5, 8, 13.23, 105.84, 12, 1371.69),
(1, 10178, 3, 2, '7/21/2011', '7/21/2012', 5, 28, 13.23, 370.44, 12, 4800.9),
(1, 10178, 8, 2, '7/21/2011', '7/21/2012', 6, 16, 13.23, 211.68, 12, 2743.37),
(1, 10178, 1, 1, '7/21/2011', '7/21/2012', 1, 1, 2040, 2040, 12, 24480),
(406, 10178, 1, 1, '7/21/2012', '7/21/2013', 1, 1, 2040, 2040, 12, 24480),
(406, 10178, 2, 2, '7/21/2012', '7/21/2013', 5, 8, 13.23, 105.84, 12, 1371.69),
(406, 10178, 3, 2, '7/21/2012', '7/21/2013', 5, 28, 13.23, 370.44, 12, 4800.9),
(406, 10178, 5, 2, '7/21/2012', '7/21/2013', 5, 20, 19.45, 389, 12, 5041.44),
(406, 10178, 8, 2, '7/21/2012', '7/21/2013', 6, 16, 13.23, 211.68, 12, 2743.37),
(406, 10178, 9, 2, '7/21/2012', '7/21/2013', 5, 16, 19.55, 312.8, 12, 4053.89),
(406, 10178, 10, 2, '7/21/2012', '7/21/2013', 5, 8, 19.55, 156.4, 12, 2026.94),
(406, 10178, 11, 2, '7/21/2012', '7/21/2013', 5, 8, 19.55, 156.4, 12, 2026.94),
(933, 10178, 1, 1, '7/21/2013', '7/21/2014', 1, 1, 2040, 2040, 12, 24480),
(933, 10178, 2, 2, '7/21/2013', '7/21/2014', 5, 8, 13.23, 105.84, 12, 1371.69),
(933, 10178, 5, 2, '7/21/2013', '7/21/2014', 5, 16, 19.45, 311.2, 12, 4033.15),
(933, 10178, 10, 2, '7/21/2013', '7/21/2014', 5, 4, 19.55, 78.2, 12, 1013.47),
(933, 10178, 11, 2, '7/21/2013', '7/21/2014', 5, 4, 19.55, 78.2, 12, 1013.47),
(933, 10178, 3, 2, '7/21/2013', '7/21/2014', 5, 18, 13.23, 238.14, 12, 3086.29),
(933, 10178, 8, 2, '7/21/2013', '7/21/2014', 3, 3, 236.7, 710.1, 12, 9202.9),
(933, 10178, 9, 2, '7/21/2013', '7/21/2014', 5, 18, 19.55, 351.9, 12, 4560.62),
(480, 12014, 1, 1, '9/21/2011', '9/21/2012', 1, 1, 2040, 2040, 12, 24480),
(480, 12014, 1, 1, '9/21/2011', '10/21/2011', 1, 1, 2038, 2038, 1, 2038),
(480, 12014, 2, 2, '9/21/2011', '9/21/2012', 5, 8, 8.6, 68.8, 12, 891.65),
(480, 12014, 3, 2, '9/21/2011', '9/21/2012', 5, 8, 13.23, 105.84, 12, 1371.69),
(480, 12014, 5, 2, '9/21/2011', '9/21/2012', 5, 8, 19.45, 155.6, 12, 2016.58),
(480, 12014, 8, 2, '9/21/2011', '9/21/2012', 3, 2, 236.7, 473.4, 12, 6135.26),
(480, 12014, 9, 2, '9/21/2011', '9/21/2012', 5, 4, 19.55, 78.2, 12, 1013.47),
(480, 12014, 10, 2, '9/21/2011', '9/21/2012', 5, 4, 19.55, 78.2, 12, 1013.47),
(480, 12014, 11, 2, '9/21/2011', '9/21/2012', 5, 4, 19.55, 78.2, 12, 1013.47),
(481, 12014, 1, 1, '9/21/2012', '9/21/2013', 1, 1, 2040, 2040, 12, 24480),
(481, 12014, 2, 2, '9/21/2012', '9/21/2013', 5, 8, 8.6, 68.8, 12, 891.65),
(481, 12014, 3, 2, '9/21/2012', '9/21/2013', 5, 8, 13.23, 105.84, 12, 1371.69),
(481, 12014, 5, 2, '9/21/2012', '9/21/2013', 5, 8, 19.45, 155.6, 12, 2016.58),
(481, 12014, 8, 2, '9/21/2012', '9/21/2013', 3, 2, 236.7, 473.4, 12, 6135.26),
(481, 12014, 9, 2, '9/21/2012', '9/21/2013', 5, 4, 19.55, 78.2, 12, 1013.47),
(481, 12014, 10, 2, '9/21/2012', '9/21/2013', 5, 4, 19.55, 78.2, 12, 1013.47),
(481, 12014, 11, 2, '9/21/2012', '9/21/2013', 5, 4, 19.55, 78.2, 12, 1013.47)
B2H_SummaryForms TABLE
CREATE TABLE B2H_SummaryForms (
CLT_NBR int,
DOSStart date,
DOSEnd date,
BillableUnits int,
RateCode int
);
INSERT INTO B2H_SummaryForms VALUES
(12014, '3/2/2012', '3/2/2012', 10, 1312),
(12014, '3/30/2012', '3/30/2012', 4, 1312),
(10178, '4/19/2012', '4/19/2012', 4, 1312),
(12014, '5/9/2012', '5/9/2012', 0, 1300),
(12014, '5/21/2012', '5/21/2012', 1, 1300),
(10178, '6/1/2012', '6/1/2012', 0, 1300),
(10178, '5/10/2012', '5/10/2012', 4, 1312),
(12014, '6/19/2012', '6/19/2012', 2, 1319),
(10178, '6/26/2012', '6/26/2012', 2, 1312),
(12014, '7/27/2012', '7/27/2012', 1, 1300),
(10178, '8/8/2012', '8/8/2012', 1, 1300),
(12014, '7/13/2012', '7/13/2012', 0, 1300),
(12014, '7/1/2012', '7/1/2012', 8, 1312),
(10178, '7/2/2012', '7/2/2012', 0, 1300),
(10178, '5/8/2012', '5/8/2012', 0, 1300),
(12014, '5/10/2012', '5/10/2012', 4, 1312),
(10178, '5/8/2012', '5/8/2012', 0, 1300),
(10178, '4/2/2012', '4/2/2012', 0, 1300),
(10178, '3/8/2012', '3/8/2012', 1, 1312),
(10178, '5/10/2012', '5/10/2012', 14, 1319),
(12014, '4/10/2012', '4/10/2012', 1, 1300),
(12014, '2/29/2012', '2/29/2012', 2, 1312),
(12014, '3/5/2012', '3/5/2012', 0, 1300),
(10178, '2/7/2012', '2/7/2012', 0, 1300),
(10178, '2/15/2012', '2/15/2012', 1, 1300),
(10178, '2/29/2012', '2/29/2012', 4, 1312),
(10178, '3/8/2012', '3/8/2012', 0, 1300),
(10178, '5/10/2012', '5/10/2012', 4, 1312),
(12014, '3/2/2012', '3/2/2012', 10, 1312),
(10178, '3/15/2012', '3/15/2012', 1, 1300),
(12014,'3/30/2012', '3/30/2012', 1, 1300),
(10178, '4/4/2012', '4/4/2012', 4, 1312),
(12014, '4/5/2012', '4/5/2012', 0, 1300),
(10178, '4/19/2012', '4/19/2012', 10, 1319),
(10178, '4/10/2012', '4/10/2012', 1, 1300),
(10178, '5/17/2012', '5/17/2012', 1, 1300),
(10178, '6/6/2012', '6/6/2012', 1, 1300),
(12014, '6/19/2012', '6/19/2012', 2, 1312),
(12014, '6/19/2012', '6/19/2012', 2, 1319),
(10178, '7/23/2012', '7/23/2012', 1, 1300),
(12014, '8/20/2012', '8/20/2012', 0, 1300),
(10178, '8/25/2012', '8/25/2012', 28, 1309),
(10178, '9/5/2012', '9/5/2012', 0, 1300),
(10178, '8/25/2012', '8/25/2012', 55, 1309),
(12014, '9/17/2012', '9/17/2012', 1, 1300),
(12014, '9/14/2012', '9/14/2012', 0, 1300),
(12014, '9/1/2012', '9/1/2012', 1, 1318),
(12014, '8/31/2012', '8/31/2012', 1, 1300),
(10178, '8/1/2012', '8/1/2012', 0, 1300),
(12014, '5/10/2012', '5/10/2012', 4, 1312),
(12014, '6/19/2012', '6/19/2012', 2, 1312),
(12014, '6/19/2012', '6/20/2012', 1, 1300),
(12014, '5/10/2012', '5/10/2012', 4, 1312),
(12014, '6/11/2012', '6/11/2012', 0, 1300),
(12014, '4/4/2012', '4/4/2012', 2, 1312),
(12014, '2/22/2012', '2/22/2012', 1, 1300),
(12014, '3/13/2012', '3/13/2012', 4, 1312),
(12014, '3/20/2012', '3/20/2012', 1, 1312),
(12014, '2/7/2012', '2/7/2012', 0, 1300),
(12014, '9/15/2012', '9/15/2012', 1, 1318),
(12014, '9/21/2012', '9/21/2012', 4, 1312),
(10178, '9/13/2012', '9/13/2012', 1, 1300),
(12014, '9/22/2012', '9/22/2012', 1, 1318),
(10178, '1/8/2013', '1/8/2013', 1, 1300),
(12014, '9/21/2012', '9/21/2012', 4, 1312),
(12014, '10/5/2012', '10/5/2012', 0, 1300),
(12014, '10/8/2012', '10/8/2012', 1, 1300),
(10178, '10/10/2012', '10/10/2012', 1, 1300),
(10178, '10/2/2012', '10/2/2012', 0, 1300),
(12014, '10/6/2012', '10/6/2012', 16, 1308),
(10178, '10/19/2012', '10/19/2012', 1, 1318),
(10178, '10/20/2012', '10/20/2012', 16, 1319),
(10178, '10/20/2012', '10/20/2012', 16, 1319),
(10178, '10/19/2012', '10/19/2012', 1, 1318),
(10178, '11/5/2012', '11/5/2012', 0, 1300),
(12014, '11/6/2012', '11/6/2012', 0, 1300),
(12014, '9/28/2012', '9/28/2012', 16, 1308),
(12014, '10/27/2012', '10/27/2012', 16, 1308),
(12014, '11/9/2012', '11/9/2012', 1, 1300),
(12014, '10/15/2012', '10/15/2012', 4, 1312),
(12014, '10/6/2012', '10/6/2012', 16, 1308),
(12014, '9/28/2012', '9/28/2012', 16, 1308),
(12014, '10/27/2012', '10/27/2012', 16, 1308),
(12014, '11/10/2012', '11/10/2012', 16, 1308),
(10178, '11/12/2012', '11/12/2012', 1, 1300),
(12014, '11/10/2012', '11/10/2012', 16, 1308),
(12014, '11/17/2012', '11/17/2012', 12, 1308),
(12014, '10/15/2012', '10/15/2012', 4, 1312),
(12014, '11/16/2012', '11/16/2012', 4, 1312),
(12014, '11/24/2012', '11/24/2012', 16, 1308),
(12014, '11/24/2012', '11/24/2012', 1, 1307),
(12014, '11/17/2012', '11/17/2012', 12, 1308),
(12014, '11/24/2012', '11/24/2012', 16, 1308),
(12014, '12/1/2012', '12/1/2012', 16, 1308),
(12014, '11/24/2012', '11/24/2012', 1, 1307),
(10178, '12/3/2012', '12/3/2012', 0, 1300),
(12014, '11/24/2012', '11/24/2012', 16, 1308),
(12014, '12/1/2012', '12/1/2012', 16, 1308),
(12014, '11/24/2012', '11/24/2012', 1, 1307),
(12014, '12/17/2012', '12/17/2012', 0, 1300),
(10178, '12/10/2012', '12/10/2012', 1, 1300),
(10178, '12/10/2012', '12/19/2012', 1, 1300),
(12014, '11/24/2012', '11/24/2012', 1, 1307),
(12014, '12/21/2012', '12/21/2012', 1, 1300),
(12014, '12/22/2012', '12/22/2012', 16, 1308),
(12014, '11/24/2012', '11/24/2012', 1, 1307),
(12014, '1/5/2013', '1/5/2013', 1, 1318),
(10178, '1/8/2013', '1/8/2013', 1, 1300),
(10178, '1/7/2013', '1/7/2013', 0, 1300),
(10178, '1/7/2013', '1/7/2013', 0, 1300),
(10178, '5/8/2012', '5/8/2012', 0, 1300),
(12014, '1/23/2013', '1/23/2013', 0, 1300),
(12014, '1/25/2013', '1/25/2013', 1, 1300),
(10178, '2/4/2013', '2/4/2013', 0, 1300),
(12014, '2/2/2013', '2/2/2013', 1, 1318),
(12014,'2/11/2013', '2/11/2013', 0, 1300),
(12014, '2/19/2013', '2/19/2013', 1, 1300),
(10178, '2/19/2013', '2/19/2013', 1, 1300),
(12014,'2/23/2013', '2/23/2013', 8, 1308),
(10178, '3/4/2013', '3/4/2013', 0, 1300),
(12014, '3/9/2013', '3/9/2013', 1, 1318),
(12014, '3/9/2013', '3/9/2013', 1, 1318),
(12014, '3/7/2013', '3/7/2013', 0, 1300),
(12014, '3/15/2013', '3/15/2013', 1, 1300),
(10178, '3/12/2013', '3/12/2013', 8, 1306),
(10178, '3/13/2013', '3/13/2013', 3, 1312),
(10178, '3/12/2013', '3/12/2013', 1, 1300),
(10178, '3/21/2013', '3/21/2013', 2, 1308),
(10178, '3/21/2013', '3/21/2013', 4, 1319),
(10178, '3/20/2013', '3/20/2013', 2, 1312),
(10178, '3/23/2013', '3/23/2013', 1, 1318),
(12014, '4/2/2013', '4/2/2013', 0, 1300),
(10178, '4/2/2013', '4/2/2013', 0, 1300),
(12014, '4/6/2013', '4/6/2013', 1, 1318),
(10178, '4/5/2013', '4/5/2013', 1, 1300),
(10178, '4/10/2013', '4/10/2013', 4, 1312),
(10178, '4/11/2013', '4/11/2013', 6, 1308),
(12014, '4/22/2013', '4/22/2013', 1, 1300),
(10178, '5/2/2013', '5/2/2013', 0, 1300),
(10178, '5/2/2013', '5/2/2013', 6, 1319),
(10178, '5/4/2013', '5/4/2013', 1, 1318),
(10178, '5/16/2013', '5/16/2013', 1, 1300),
(10178, '5/14/2013', '5/14/2013', 6, 1312),
(12014, '5/17/2013', '5/17/2013', 0, 1300),
(12014, '5/20/2013', '5/20/2013', 1, 1300),
(10178, '6/6/2013', '6/6/2013', 0, 1300),
(10178, '6/10/2013', '6/10/2013', 1, 1300),
(10178, '6/1/2013', '6/1/2013', 1, 1318),
(12014, '6/7/2013', '6/7/2013', 0, 1300),
(12014, '6/17/2013', '6/17/2013', 1, 1300),
(12014, '6/19/2013', '6/19/2013', 4, 1308),
(12014, '6/29/2013', '6/29/2013', 1, 1318),
(12014, '6/29/2013', '6/29/2013', 8, 1308),
(10178, '7/10/2013', '7/10/2013', 0, 1300),
(12014, '7/11/2013', '7/11/2013', 0, 1300),
(12014, '7/3/2013', '7/3/2013', 4, 1308),
(12014, '7/13/2013', '7/13/2013', 1, 1318),
(10178, '7/24/2013', '7/24/2013', 1, 1300)
B2H_RATE TABLE
CREATE TABLE B2H_RATE (
RATE_CODE int,
WAIVER_SERVICES date,
RATE_AMOUNT date,
BILLABLE_UNIT int
);
(1300, 1, 2040, 1),
(1301, 1, 2038, 1),
(1302, 1, 1020, 2),
(1303, 1, 1020, 2),
(1304, 1, 2040, 1),
(1305, 1, 2040, 1),
(1306, 2, 13.23, 5),
(1307, 2, 8.6, 5),,
(1308, 3, 13.23, 5),
(1309, 3, 8.6, 5),
(1310, 4, 77, 4),
(1311, 4, 40.85, 4),
(1312, 5, 19.45, 5),
(1313, 5, 12.64, 5),
(1314, 6, 55.68, 4),
(1315, 6, 30.19, 4),
(1316, 7, 70, 4),
(1317, 8, 13.23, 6),
(1318, 8, 236.7, 3),
(1319, 9, 19.55, 5),
(1320, 9, 12.7, 5),
(1321, 10, 19.55, 5),
(1322, 11, 19.55, 5),
(1323, 12, 17.59, 6),
(1324, 12, 304.5, 3),
(1327, 1, 2040, 1),
(1328, 1, 2038, 1),
(1329, 1, 1020, 2),
(1330, 1, 1020, 2)
(1331, 1, 2040, 1),
(1332, 1, 2040, 1),
(1333, 2, 13.23, 5),
(1334, 2, 8.6, 5),
(1335, 3, 13.23, 5),
(1336, 3, 8.6, 5),
(1337, 4, 77, 4),
(1338, 4, 40.85, 4),
(1339, 5, 19.45, 5),
(1340, 5, 12.64, 5),
(1341, 6, 55.68, 4)
(1342, 6, 30.19, 4),
(1343, 7, 70, 4),
(1344, 8, 13.23, 6),
(1345, 8, 236.7, 3),
(1346, 9, 19.55, 5),
(1347, 9, 12.7, 5),
(1348, 10, 19.55, 5),
(1349, 11, 19.55, 5),
(1350, 12, 17.59, 6),
(1351, 12, 304.5, 3),
(1354, 1, 2040, 1),
(1355, 1, 2038, 1),
(1356, 1, 1020, 2),
(1357, 1, 1020, 2),
(1358, 1, 2040, 1),
(1359, 1, 2040, 1),
(1360, 2, 13.23, 5),
(1361, 2, 8.6, 5),
(1362, 3, 13.23, 5),
(1363, 3, 8.6, 5),
(1364, 4, 77, 4),
(1365, 4, 40.85, 4),
(1366, 5, 19.45, 5),
(1367, 5, 12.64, 5),
(1368, 6, 55.68, 4),
(1369, 6, 30.19, 4),
(1370, 7, 70, 4),
(1371, 8, 17.3, 6),
(1372, 8, 309.42, 3),
(1373, 9, 19.55, 5),
(1374, 9, 12.7, 5),
(1375, 10, 19.55, 5),
(1376, 11, 19.55, 5),
(1377, 12, 23.94, 6),
(1378, 12, 414.48, 3)
This is what I have so far. I've been trying but I can't figure out how to get the output above.
Budgeted
SELECT
ChildID,
WAIVER_SERVICES,
START_DT,
END_DT,
RATE_PER_UNIT_OF_SERVICE,
PROJECTED_COST_PER_MONTH
FROM [ECMS_BACKUP].[dbo].[B2H_DSP]
where WAIVER_PROGRAM=2
The budgets can be renewed once a year So the Start_Dt and End_dt are always a year long. This makes it tricky to break down the budget amount by month.
Services Provided
select
a.CLT_NBR,
b.WAIVER_SERVICES,
month(a.DOSStart) as Month,
YEAR(a.DOSStart) as Year,
sum(b.RATE_AMOUNT)as total
from
[ECMS_BACKUP].[dbo].[B2H_SummaryForms]a
left JOIN ECMS_BACKUP.dbo.B2H_RATE b ON a.RateCode=b.RATE_CODE
where DOSStart>='2013-01-01' AND DOSStart<'2013-06-30' /*I selected a 6th month time frame for services provided */
group by ChildID, month(a.DOSStart), YEAR(a.DOSStart),WAIVER_SERVICES
order by childid, month(a.DOSStart), YEAR(a.DOSStart),WAIVER_SERVICES

Related

How to change only shadow color in createTheme.js - MUI System

I want to change it with as little code as possible.
The code below can change the color, but these are long-winded.
import { createTheme } from "#mui/material/styles";
const shadowKeyUmbraOpacity = 0.05;
const shadowKeyPenumbraOpacity = 0.035;
const shadowAmbientShadowOpacity = 0.03;
function createShadow(...px: number[]) {
return [
`${px[0]}px ${px[1]}px ${px[2]}px ${px[3]}px rgba(0,0,0,${shadowKeyUmbraOpacity})`,
`${px[4]}px ${px[5]}px ${px[6]}px ${px[7]}px rgba(0,0,0,${shadowKeyPenumbraOpacity})`,
`${px[8]}px ${px[9]}px ${px[10]}px ${px[11]}px rgba(0,0,0,${shadowAmbientShadowOpacity})`,
].join(',');
}
export const theme = createTheme({
// Values from https://github.com/material-components/material-components-web/blob/be8747f94574669cb5e7add1a7c54fa41a89cec7/packages/mdc-elevation/_variables.scss
shadows: [
'none',
createShadow(0, 2, 1, -1, 0, 1, 1, 0, 0, 1, 3, 0),
createShadow(0, 3, 1, -2, 0, 2, 2, 0, 0, 1, 5, 0),
createShadow(0, 3, 3, -2, 0, 3, 4, 0, 0, 1, 8, 0),
createShadow(0, 2, 4, -1, 0, 4, 5, 0, 0, 1, 10, 0),
createShadow(0, 3, 5, -1, 0, 5, 8, 0, 0, 1, 14, 0),
createShadow(0, 3, 5, -1, 0, 6, 10, 0, 0, 1, 18, 0),
createShadow(0, 4, 5, -2, 0, 7, 10, 1, 0, 2, 16, 1),
createShadow(0, 5, 5, -3, 0, 8, 10, 1, 0, 3, 14, 2),
createShadow(0, 5, 6, -3, 0, 9, 12, 1, 0, 3, 16, 2),
createShadow(0, 6, 6, -3, 0, 10, 14, 1, 0, 4, 18, 3),
createShadow(0, 6, 7, -4, 0, 11, 15, 1, 0, 4, 20, 3),
createShadow(0, 7, 8, -4, 0, 12, 17, 2, 0, 5, 22, 4),
createShadow(0, 7, 8, -4, 0, 13, 19, 2, 0, 5, 24, 4),
createShadow(0, 7, 9, -4, 0, 14, 21, 2, 0, 5, 26, 4),
createShadow(0, 8, 9, -5, 0, 15, 22, 2, 0, 6, 28, 5),
createShadow(0, 8, 10, -5, 0, 16, 24, 2, 0, 6, 30, 5),
createShadow(0, 8, 11, -5, 0, 17, 26, 2, 0, 6, 32, 5),
createShadow(0, 9, 11, -5, 0, 18, 28, 2, 0, 7, 34, 6),
createShadow(0, 9, 12, -6, 0, 19, 29, 2, 0, 7, 36, 6),
createShadow(0, 10, 13, -6, 0, 20, 31, 3, 0, 8, 38, 7),
createShadow(0, 10, 13, -6, 0, 21, 33, 3, 0, 8, 40, 7),
createShadow(0, 10, 14, -6, 0, 22, 35, 3, 0, 8, 42, 7),
createShadow(0, 11, 14, -7, 0, 23, 36, 3, 0, 9, 44, 8),
createShadow(0, 11, 15, -7, 0, 24, 38, 3, 0, 9, 46, 8),
],
});
createShadow function and others referred to the link below.
https://github.com/mui/material-ui/blob/master/packages/mui-material/src/styles/shadows.js
So, I want to know how to change it more wisely.

VBA Optimize array handling

I ran up against the limit of the amount of items I could put into a single array... I also ran into the limit of the number of line continuation characters I was able to use... So I had to break this function into two arrays. I really hate that I had to use two arrays, but it does work. Does anyone have any suggestions how I could tighten this code up? Maybe take out the "insert character into a cell" step and just jump right to the color?...
Have fun
Sub Why_Not_Zoidberg()
Dim Inx As Long
Dim i As Long
Dim j As Long
Dim x As Long
Dim A1() As Variant
Dim A2() As Variant
Dim Rng1 As Range
Application.ScreenUpdating = False
A01 = Array(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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1, 3, 3, 3, 3, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2)
x = 0
For i = 1 To 24 'Rows
For j = 1 To 64 'Columns
ActiveSheet.Cells(i, j).Select
With Selection
.Value = A01(x)
End With
x = x + 1
Next j
Next i
x = 0
For i = 25 To 48 'Rows
For j = 1 To 64 'Columns
ActiveSheet.Cells(i, j).Select
With Selection
.Value = A02(x)
End With
x = x + 1
Next j
Next i
'SET RANGE
Set Rng1 = Range("A1:BN48")
ActiveSheet.Range("A1").Select
'Add Colors
For i = 1 To Rng1.Rows.Count
For j = 1 To Rng1.Columns.Count
Select Case Rng1.Cells(i, j).Value
Case 3
Rng1.Cells(i, j).Interior.Color = RGB(253, 3, 74)
Case 2
Rng1.Cells(i, j).Interior.Color = RGB(255, 255, 255)
Case 1
Rng1.Cells(i, j).Interior.Color = RGB(1, 1, 1)
Case 14
Rng1.Cells(i, j).Interior.Color = RGB(0, 153, 153)
End Select
'For k = 1 To 10000: Next k, adds a delay to animate
Next j
Next i
With Rng1
.ColumnWidth = 2
.RowHeight = 14.25
.ClearContents
End With
Application.ScreenUpdating = True
End Sub
Your data is highly compressible, is a shame not to make use of it!
Solving your question in a straight way, you may Split a long composed string:
Dim sa As String
sa = "2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2"
sa = sa & " " & "2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 3"
'
' ...
'
sa = sa & " " & "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2"
a = Split(sa)
Your array will be a string array, but arithmetic is not a problem in VBA.
Alternativelly, you could pack your data (4 bit). Example:
'0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 2 2 2 2 ...
Array(&H01234567, &H89ABCDEF, &H11112222, ...)
This way you could extract your data with little bit manipulation.
But really think about compression!
I am going to offer a different approach to this problem.
Create a text file with the values you want to set, arranged by rows and separated by commas (see .csv file format). For example use this pastebin file.
Read the file row by row, parse each line into an array of strings, convert the strings into numbers and use the entire array to set the values of each row on the worksheet.
Apply conditional formatting to the worksheet to display the correct colors based on the values
For Example:
Dim rng_1 As Range
Set rng_1 = Range("M26")
Dim fs As TextStream, txt_row As Variant
Dim val_row() As Variant
Dim n As Integer, i As Integer, j As Integer
Set fs = fso.OpenTextFile("data.csv", ForReading, False)
j = 0
While Not fs.AtEndOfStream
' Read a line of text and split into array of strings
text_row = Strings.Split(fs.ReadLine, ",")
'Need to convert text values into numeric type
n = UBound(text_row) + 1
ReDim val_row(0 To n - 1)
For i = 1 To n
val_row(i - 1) = Val(text_row(i - 1))
Next i
' Write values of entire row onto worksheet
rng_1.Offset(j, 0).Resize(1, n).Value = val_row
' index the row
j = j + 1
Wend
fs.Close
PS. There is rarely a case where .Select and Selection are needed. It is far easier and more robust to read/write directly from range references with the Range() object. In fact, avoid using .Cells() also and use named range references together with .Offset() and .Resize(). For example
Dim A() as Variant
A = Range("my_table").Resize(10,10).Value
A(1,1) = 1 - A(1,2)*A(2,1)
Range("my_table").Resize(10,10).Value = A

In lex.yy.c what do the lookup tables stand for? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm digging through a lexer built with flex (here to be precise) and am trying to understand what is happening. Never having looked at C, I've given up trying to find the equivalent to understand parsers made with Bison, so I'm hoping to just get some basic info here, starting with what do the lookup tables in lex.yy.c contain:
static yyconst short int yy_accept[33] =
{ 0,
0, 0, 15, 13, 12, 10, 7, 13, 13, 8,
2, 9, 13, 3, 4, 0, 11, 0, 0, 2,
1, 0, 0, 0, 0, 0, 0, 0, 0, 5,
6, 0
} ;
static yyconst int yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 4, 1, 5, 1, 6, 1, 1, 1,
1, 7, 1, 1, 1, 1, 1, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 9, 1, 1,
1, 1, 1, 10, 11, 8, 8, 8, 12, 8,
13, 8, 14, 8, 8, 8, 8, 15, 16, 8,
8, 17, 18, 8, 8, 8, 8, 8, 8, 8,
1, 1, 1, 1, 8, 1, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 19, 1, 20, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
static yyconst int yy_meta[21] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 1, 1
} ;
static yyconst short int yy_base[36] =
{ 0,
0, 0, 39, 40, 40, 40, 40, 35, 10, 40,
0, 40, 0, 40, 40, 34, 40, 18, 22, 0,
0, 16, 18, 18, 15, 17, 12, 13, 15, 40,
40, 40, 24, 21, 20
} ;
static yyconst short int yy_def[36] =
{ 0,
32, 1, 32, 32, 32, 32, 32, 33, 32, 32,
34, 32, 35, 32, 32, 33, 32, 32, 32, 34,
35, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 0, 32, 32, 32
} ;
static yyconst short int yy_nxt[61] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
11, 11, 11, 11, 11, 11, 11, 11, 14, 15,
18, 21, 20, 19, 16, 16, 31, 30, 29, 28,
27, 26, 25, 24, 23, 22, 17, 17, 32, 3,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32
} ;
static yyconst short int yy_chk[61] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
9, 35, 34, 9, 33, 33, 29, 28, 27, 26,
25, 24, 23, 22, 19, 18, 16, 8, 3, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32
} ;
Any reference to a good explanation of a generated lex.yy.c is of course also welcome. Thanks!
(Compiling the comments to an answer, only to make a Q/A pair).
These are data to describe the "(finite) automaton" or "finite state machine" used to implement the text analysis described by the lexer generation-input/config files.
Read about "finite automata", for example this: http://www.cs.man.ac.uk/~pjj/cs211/ho/node6.html
Generally they describe the behavior of a finite state machine with which the generated lexer function will process input. You might get some clues by running Flex with the -v / --verbose option and comparing the results to the tables.
The precise meaning of the tables varies depending on the table compression type (see option -C).
I (John Bollinger, but probably agreed by most) doubt anyone can tell you specifically what these tables mean without studying (or already knowing) the Flex source. It is more or less the core idea of a generated lexer to protect the user from needing to know these details.

How to divide column automatically?

I have multiple txt files (close 1000) and I want to import to excel. I used text import wizard then choose fixed width, my question is how to use the same format for each file that I don't need to adjust everytime.
This is the example link : http://www.fhwa.dot.gov/bridge/nbi/1992/AL92.txt
This is the record format: http://www.fhwa.dot.gov/bridge/nbi/format.cfm
To save you a bit of time I prepared the array (from the format web page linked above) for the querytables/import for you based on #RonRosenfeld's advice and quickly did a text file import (which I recorded).
Have to paste in here cause it is too big for comments.
You would, of course, have to edit to suit.
With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\AL92.txt", Destination:=Range("$A$1"))
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(3, 15, 1, 1, 1, 5, 1, 2, 3, 5, 24, 1, 18, 25, 4, 7, 1, 10, 2, 8, 9, 3, 1, 2, 2, 2, 4, 2, 2, 6, 4, 1, 4, 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 1, 1, 2, 1, 2, 3, 4, 3, 5, 6, 3, 3, 4, 4, 4, 1, 4, 1, 3, 3, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 6, 4, 2, 3, 3, 3, 4, 4, 4, 6, 6, 6, 4, 3, 2, 15, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 2, 1, 1, 1, 1, 6, 4, 4)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

How do I put a specific integer into the middle of a sorted array in Swift?

I am writing code where five random numbers are given a value. Those five values are then sorted in an array in numerical order. However, when one value is equaled to 1, I want that number to be in the middle of the sorted array.
When there is no number 1, the sorted array will work correctly.
let fourthRandomNumber:Int = Int(arc4random_uniform(52))
let fifthRandomNumber:Int = Int(arc4random_uniform(52))
let sixthRandomNumber:Int = Int(arc4random_uniform(52))
let seventhRandomNumber:Int = Int(arc4random_uniform(52))
let eighthRandomNumber:Int = Int(arc4random_uniform(52))
var loFourthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 1, 1, 1]
var loFifthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 1, 1, 1]
var loSixthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 1, 1, 1]
var loSeventhRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 1, 1, 1]
var loEighthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 1, 1, 1, 1]
var hiFourthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]
var hiFifthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]
var hiSixthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]
var hiSeventhRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]
var hiEighthRandomNumberOutput: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]
let loFourthRandomNumber:Int = loFourthRandomNumberOutput [fourthRandomNumber]
let loFifthRandomNumber:Int = loFifthRandomNumberOutput [fifthRandomNumber]
let loSixthRandomNumber:Int = loSixthRandomNumberOutput [sixthRandomNumber]
let loSeventhRandomNumber:Int = loSeventhRandomNumberOutput [seventhRandomNumber]
let loEighthRandomNumber:Int = loEighthRandomNumberOutput [eighthRandomNumber]
let hiFourthRandomNumber:Int = hiFourthRandomNumberOutput [fourthRandomNumber]
let hiFifthRandomNumber:Int = hiFifthRandomNumberOutput [fifthRandomNumber]
let hiSixthRandomNumber:Int = hiSixthRandomNumberOutput [sixthRandomNumber]
let hiSeventhRandomNumber:Int = hiSeventhRandomNumberOutput [seventhRandomNumber]
let hiEighthRandomNumber:Int = hiEighthRandomNumberOutput [eighthRandomNumber]
//NEED TO WORK OUT THIS ISSUE **(add ace)**
var loDealerCardsArray = [loFourthRandomNumberOutput [fourthRandomNumber], loFifthRandomNumberOutput [fifthRandomNumber], loSixthRandomNumberOutput [sixthRandomNumber], loSeventhRandomNumberOutput [seventhRandomNumber], loEighthRandomNumberOutput [eighthRandomNumber]]
//NEED TO WORK OUT THIS ISSUE **(add ace)**
var hiDealerCardsArray = [hiFourthRandomNumberOutput [fourthRandomNumber], hiFifthRandomNumberOutput [fifthRandomNumber], hiSixthRandomNumberOutput [sixthRandomNumber], hiSeventhRandomNumberOutput [seventhRandomNumber], hiEighthRandomNumberOutput [eighthRandomNumber]]
loDealerCardsArray.sort()
loDealerCardsArray[0]
loDealerCardsArray[1]
loDealerCardsArray[2]
print (loDealerCardsArray[0] + loDealerCardsArray[1] + loDealerCardsArray[2])
//NEED TO WORK OUT THIS ISSUE **(PULL IN RANDOM NUMBER FROM ARRAY SO THAT CARD APPEARS IN PROPER LOCATION when there is an ace
hiDealerCardsArray.sort()
hiDealerCardsArray[2]
hiDealerCardsArray[3]
hiDealerCardsArray[4]
print (hiDealerCardsArray[2] + hiDealerCardsArray[3] + hiDealerCardsArray[4])
////NEED TO WORK OUT THIS ISSUE **(PULL IN RANDOM NUMBER FROM ARRAY SO THAT CARD APPEARS IN PROPER LOCATION when there is an ace
var DealerCardsArray = [fourthRandomNumber, fifthRandomNumber, sixthRandomNumber, seventhRandomNumber, eighthRandomNumber]
DealerCardsArray.sort()
DealerCardsArray[0]
DealerCardsArray[1]
DealerCardsArray[2]
DealerCardsArray[3]
DealerCardsArray[4]
For example, five cards have a value of [0, 1, 2, 9, 10], and the array is sorted correctly. I am trying to sort the array so that the 1 is ALWAYS in the middle.
When an ace (value of 1 or 11) appears in the sorted array I want it to look as follows: [0, 2, 1, 9, 10]
Thank you in advance for your assistance
Something like:
var cards = [0, 1, 2, 9, 10]
// Get a list of all the aces in the array.
let aces = cards.filter { $0 == 1 || $0 == 11 }
// Now take the aces out of the array.
cards = cards.filter { $0 != 1 && $0 != 11 }
// Sort the array (unnecessary if its definitely already sorted).
cards = cards.sort()
// Re-insert the aces into the middle.
aces.forEach { cards.insert($0, atIndex: cards.count/2) }
// [0, 2, 1, 9, 10]
Might do the trick (haha)!
var dealerCardsArray = [0, 1, 2, 9, 10]
dealerCardsArray.sort()
// Only if the value 1 exists in the array, remove it and add it back in the center position
if let indexOfOne = dealerCardsArray.index(of: 1) {
dealerCardsArray.remove(at: indexOfOne)
dealerCardsArray.insert(1, at: array.count/2)
}
print(dealerCardsArray) // [0,2,1,9,10]

Resources