Skip to content

Instantly share code, notes, and snippets.

@koomai
Created July 26, 2018 13:58
Show Gist options
  • Save koomai/9dd23b0346571946ade760fc6a8e9935 to your computer and use it in GitHub Desktop.
Save koomai/9dd23b0346571946ade760fc6a8e9935 to your computer and use it in GitHub Desktop.
Tighten Laracon Challenge (https://challenge.tighten.co)
<?php
echo str_rot13('ynenpba vf tbvat gb or jbaqebhf guvf lrne.');
// laracon is going to be wondrous this year.
<?php
/**
* http://usefulphp.blogspot.com/2010/04/convert-integers-to-roman-numerals.html
*/
function getRomanNumerals($decimalInteger)
{
$n = intval($decimalInteger);
$res = '';
$roman_numerals = array(
'M' => 1000,
'CM' => 900,
'D' => 500,
'CD' => 400,
'C' => 100,
'XC' => 90,
'L' => 50,
'XL' => 40,
'X' => 10,
'IX' => 9,
'V' => 5,
'IV' => 4,
'I' => 1);
foreach ($roman_numerals as $roman => $numeral)
{
$matches = intval($n / $numeral);
$res .= str_repeat($roman, $matches);
$n = $n % $numeral;
}
return $res;
}
function getLaraconBudget($numbers)
{
$romanNumerals = array_map('getRomanNumerals', explode(' ', $numbers));
$count = substr_count(implode('', $romanNumerals), 'X');
return $count * 10;
}
echo getLaraconBudget('1683 314 241 1430 947 226 888 693 726 1277 685 1264 621 1938 1839 1223 1898 685 766 683 256 1464 1176 1307 1374 1176 426 1328 1868 1473 1990 192 334 541 79 1022 1960 1895 957 616 325 375 1664 1573 1327 507 685 1812 1567 1016 566 1702 646 1850 1436 43 1970 204 1701 1396 1557 472 802 336 621 778 1340 1017 1238 1808 339 1148 710 1941 1925 907 1645 182 1174 1233 604 1622 368 148 368 755 928 494 1860 448 1361 813 1441 768 41 1246 943 953 1716 234 1271 840 1287 637 1503 774 289 984 1541 1053 168 977 1510 588 423 1919 776 1794 1376 1255 1956 1450 1674 398 1232 1991 69 1068 1590 1413 963 318 1387 953 5 950 355 1714 922 1842 1101 348 1624 1256 1207 827 1714 339 1131 1299 237 811 1640 363 257 1761 1631 118 1574 1320 202 1295 525 1454 929 1270 1234 645 1264 1048 1313 439 259 703 1906 869 672 472 1565 1012 1510 1984 540 1799 1407 1936 739 875 1826 1688 152 1266 1659 492 975 1351 1316 908 1782 1618 1217 1330 714 935 857 1626 1974 539 254 1297 941 1630 1675 807 57 196 1912 1302 1538 376 362 1434 1096 941 1648 1025 1653 1078 1369 1654 1876 1139 1078 680 1018 886 1683 431 1178 1426 1172 1142 1152 1512 752 419 911 1757 275 1753 1572 1421 617 230 163 1909 298 1906 1383 293 384 135 1811 619 328 1644 1106 921 349 457 1983 190 405 45 34 1342 1506 1277 639 774 7 840 527 1067 1232 1700 1942 1560 1090 1872 868 513 834 737 316 1768 1205 21 1591 1471 1131 373 442 1622 945 588 1351 199 1481 591 1687 1100 686 223 711 22 1213 1645 342 1851 1982 1646 387 894 250 1844 1521 305 837 475 1434 654 1462 1887 1555 916 1456 1754 875 539 901 400 179 520 541 1132 985 1856 1907 1867 505 1560 1448 498 986 1029 1476 1886 1017 1979 782 878 1149 25 1321 1112 1059 1896 1551 1840 879 584 1002 948 1936 1654 1921 465 1544 1451 138 431 1586 437 1858 905 1147 1245 1200 808 44 470 1028 72 1809 1405 1881 284 422 982 393 1066 1201 1401 1294 779 602 177 1990 669 1690 1633 1584 223 1416 1040 1509 325 1754 229 1567 346 877 939 1509 1007 703 914 1609 1920 154 124 475 1324 1028 1457 1397 1017 673 1855 1135 14 802 449 582 1063 1270 522 17 1681 1104 881 548 116 89 2000 1994 166 1406 1016 378 405 692 1453 1250 642 351 922 1771 597 1873 1043 221 821 1574 287 361 770 1243 163 153 939 651 39 235 128 1754 279 827 1014 1806 1317 172 283 1364 15 751 1538 1643 373 978 1622 1702 894 1218 1008 634 480 140 1290 1642 888 1450 1443 572 136 1015 623 128 1741 543 835 1118 1704 645 1833 1029 925 746 722 1345 1780 1259 1509 1765 257 1609 1882 557 645 1065 539 1000 1435 15 788 1186 1954 1618 438 984 746 180 1576 1414 1949 717 821 1752 1846 1184 1424 179 14 1039 394 299 954 661 1066 1764 49 615 978 1557 238 898 1304 1728 585 468 267 436 1472 10 936 737 1004 1147 126 1886 420 582 1947 382 919 795 1632 1934 1804 71 849 482 902 320 1492 87 86 1634 947 1675 1052 519 857 1607 1419 1634 1926 1054 819 1711 219 1627 1034 629 1823 1221 1864 816 1339 400 1949 589 726 1665 565 412 159 736 1684 842 1095 1751 280 711 809 464 329 682 807 1980 1018 815 49 1153 738 897 638 1904 1590 1016 1421 1377 539 870 973 197 77 1408 614 670 1609 1627 492 820 1088 1834 1690 470 1397 1327 1943 1420 1595 920 483 703 10 758 671 883 311 1352 278 826 1075 1001 519 1712 1045 1639');
// 10740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment