How old is that map? Referencing xkcd 1688:

Your task is to deduct the age of a map by asking the user questions. These question must be exactly the same as in the xkcd guide, except from the capitalisation and additional newline(s). Additionally, you should give the user some options to choose from, which don't have to be in the order as in the xkcd image. If the input doesn't match any of the expected answers, your program/function may behave in any undefined way. At the end, you should output the year/timespan the map was created.

Examples (> denotes input, but you may choose something else):

Example 1:

ISTANBUL OR CONSTANTINOPLE?
(CONSTANTINOPLE, NEITHER, ISTANBUL)

>ISTANBUL

DOES THE SOVIET UNION EXISTS?
(YES, NO)

>NO

ZAIRE?
OR: 'HONG KONG (UK)'
(YES, NO)

>NO

SERBIA / MONTENEGRO ARE?
(ONE COUNTRY, TWO COUNTRIES)

>TWO COUNTRIES

HOW MANY SUDANS ARE THERE?
(ONE, TWO)

>ONE

2007-11

Example 2:

ISTANBUL OR CONSTANTINOPLE?
(CONSTANTINOPLE, NEITHER, ISTANBUL)

>how are you

error

Game Maker Language (GM 8.0), 10262 10228 10152 10115 8746 1 + 8699 = 8700 bytes

We define a script named X (1 byte). Each question is labelled with an integer. X takes such an integer, prompts the user with the corresponding question, and either returns the appropriate message or calls the next question. At each question, the user is prompted for an integer corresponding to the possible options. If the user does not match any of the options, then the prompt is exited.

A=argument1 Y="##YES (1), NO (2)"I="IS THERE A BIG LAKE IN THE MIDDLE OF "H="HOW MANY "switch argument0{case H:return show_message(A)break
case I:return get_integer(A,1)break
case 1:switch X(I,"ISTANBUL OR CONSTANTINOPLE##CONSTANTINOPLE (1), NEITHER (2), ISTANBUL(3)"){case 1:X(2)break case 2:X(19)break case 3:X(74)}break
case 2:switch X(I,"DO ANY OF THESE EXIST?#- INDEPENDENT CANADA#- US TERRITORY OF ALASKA#- TOKYO"+Y){case 2:X(3)break case 1:X(11)}break
case 3:switch X(I,"THE HOLY ROMAN EMPIRE?"+Y){case 1:X(H,"1805 OR EARLIER (BEFORE THIS POINT, THE MODERN IDEA OF A COMPLETE POLITICAL MAP OF THE WORLD GETS HARD TO APPLY.)")break case 2:X(4)}break
case 4:switch X(I,"THE UNITED STATES?"+Y){case 2:X(H,"HOW SURE ARE YOU THAT THIS MAP IS IN ENGLISH")break case 1:X(5)}break
case 5:switch X(I,"TEXAS IS...##PART OF MEXICO (1), INDEPENDENT (2), PART OF THE US (3)"){case 1:X(6)break case 2:X(H,"1834-45")break case 3:X(9)}break
case 6:switch X(I,"FLORIDA IS PART OF...##SPAIN (1), THE US (2)"){case 1:X(7)break case 2:X(8)}break
case 7:switch X(I,"PARAGUAY?"+Y){case 2:X(H,"1806H0")break case 1:X(H,"1811H7")}break
case 8:switch X(I,"VENEZUELA AND/OR ECUADOR?"+Y){case 2:X(H,"1818-29")break case 1:X(H,"1830-33")}break
case 9:switch X(I,"DOES RUSSIA BORDER THE SEA OF JAPAN?"+Y){case 2:X(10)break case 1:X(H,"1858-67")}break
case 10:switch X(I,"THE US'S SOUTHERN BORDER LOOKS...##WEIRD (1), NORMAL (2)"){case 1:X(H,"1846-53")break case 2:X(H,"1854-56")}break
case 11:switch X(I,"SOUTH AFRICA?"+Y){case 2:X(12)break case 1:X(16)}break
case 12:switch X(I,"RHODESIA?"+Y){case 2:X(13)break case 1:X(15)}break
case 13:switch X(I,"IS BOLIVIA LANDLOCKED?"+Y){case 2:X(14)break case 1:X(H,"1884-95")}break
case 14:switch X(I,'"BUDA" AND "PEST" OR "BUDAPEST"?##BUDA AND PEST (1), BUDAPEST (2)'){case 1:X(H,"1868-72")break case 2:X(H,"1873-83")}break
case 15:switch X(I,"IS NORWAY PART OF SWEDEN?"+Y){case 1:X(H,"1896H905")break case 2:X(H,"1906-09")}break
case 16:switch X(I,"AUSTRIA-HUNGARY?"+Y){case 1:X(17)break case 2:X(18)}break
case 17:switch X(I,"ALBANIA?"+Y){case 2:X(H,"1910H2")break case 1:X(H,"1913H8")}break
case 18:switch X(I,"LENINGRAD?"+Y){case 2:X(H,"1919-23")break case 1:X(H,"1924-29")}break
case 19:switch X(I,"DOES THE OTTOMAN EMPIRE EXIST?"+Y){case 1:X(2)break case 2:X(20)}break
case 20:switch X(I,"THE SOVIET UNION?"+Y){case 2:X(21)break case 1:X(63)}break
case 21:switch X(I,"NORTH KOREA?"+Y){case 2:X(22)break case 1:X(56)}break
case 22:switch X(I,"SAINT TRIMBLE'S ISLAND?"+Y){case 2:X(23)break case 1:X(H,"NO, I MADE THAT ONE UP.")}break
case 23:switch X(I,"IS JAN MAYEN PART OF THE KINGDOM OF NORWAY?##NOT YET (1), WHAT? (2), YES (3)"){case 1:X(2)break case 2:X(24)break case 3:X(49)}break
case 24:switch X(I,"CAN YOU SEE THE FAMILIAR CONTINENTS?"+Y){case 1:X(25)break case 2:X(31)}break
case 25:switch X(I,"THIS SOUNDS LIKE A PHYSICAL MAP OR SATELLITE PHOTO.##YES, THAT'S IT (1)"){case 1:X(26)}break
case 26:switch X(I,"IS LAKE CHAD MISSING?"+Y){case 2:X(27)break case 1:X(30)}break
case 27:switch X(I,"HOW FAR EAST DO THE AMERICAN PRAIRIES REACH?##INDIANA (1), THE MISSISSIPPI (2), NEBRASKA (3), WHAT PRAIRIES? (4)"){case 1:X(H,"BEFORE 1830")break case 2:X(H,"1830s-80s")break case 3:X(28)break case 4:X(29)}break
case 28:switch X(I,I+"SOUTHERN CALIFORNIA? (CREATED BY MISTAKE)"+Y){case 2:X(H,"1860sH900s")break case 1:X(H,"1910s")}break
case 29:switch X(I,I+"GHANA? (CREATED ON PURPOSE)"+Y){case 2:X(H,"1920s-50s")break case 1:X(H,"1960s-70s")}break
case 30:switch X(I,"IS THE ARAL SEA MISSING?"+Y){case 2:X(H,"1970s-90s")break case 1:X(H,"2000s+")}break
case 31:switch X(I,'RIVERS "SIRION" OR "ANDUIN"?'+Y){case 1:X(32)break case 2:X(36)}break
case 32:switch X(I,"MORDOR?"+Y){case 2:X(33)break case 1:X(34)}break
case 33:switch X(I,"BELERIAND?"+Y){case 1:X(H,"FIRST AGE")break case 2:X(H,"EARLY SECOND AGE")}break
case 34:switch X(I,"NÚMENOR?"+Y){case 1:X(H,"LATE SECOND AGE")break case 2:X(35)}break
case 35:switch X(I,"THE FOREST EAST OF THE MISTY MOUNTAINS IS...##GREENWOOD THE GREAT (1), MIRKWOOD (2), THE WOOD OF GREENLEAVES (3)"){case 1:X(H,"EARLY THIRD AGE")break case 2:X(H,"LATE THIRD AGE")break case 3:X(H,"FOURTH AGE")}break
case 36:switch X(I,"CAIR PARAVEL?"+Y){case 1:X(37)break case 2:X(41)}break
case 37:switch X(I,"CALORMEN?"+Y){case 2:X(38)break case 1:X(40)}break
case 38:switch X(I,"LOTTA ISLANDS?"+Y){case 2:X(39)break case 1:X(H,"DAWN TREADER")}break
case 39:switch X(I,"BERUNA##FORD (1), BRIDGE (2)"){case 1:X(H,"THE LION, THE WITCH, AND THE WARDROBE")break case 2:X(H,"PRINCE CASPIAN")}break
case 40:switch X(I,"WEIRD RECURSIVE HEAVEN?"+Y){case 2:X(H,"ONE OF THE RANDOM LATER BOOKS")break case 1:X(H,"THE LAST BATTLE")}break
case 41:switch X(I,"MOSSFLOWER?"+Y){case 1:X(H,"REDWALL")break case 2:X(42)}break
case 42:switch X(I,"IS THE WORLD ON THE BACK OF A TURTLE?"+Y){case 1:X(H,"DISCWORLD")break case 2:X(43)}break
case 43:switch X(I,"ARE YOU SURE THIS IS A MAP?"+Y){case 1:X(44)break case 2:X(46)}break
case 44:switch X(I,"DID YOU MAKE IT YOURSELF?##YES (1)"){case 1:X(45)}break
case 45:X(I,"IT'S VERY NICE.##THANK YOU! (1)")break
case 46:switch X(I,"IS IT TRYING TO BITE YOU?"+Y){case 2:X(47)break case 1:X(48)}break
case 47:switch X(I,"IS IT LARGER THAN A BREADBOX?"+Y+", ABOUT THE SAME (3)"){case 1:X(H,"TUBA")break case 2:X(H,"STAPLER")break case 3:X(H,"BREADBOX")}break
case 48:switch X(I,"IF YOU LET IT GO, WHAT DOES IT DO?##HISSES AND RUNS AWAY (1), SCREECHES AND FLAPS AROUND THE ROOM BREAKING THINGS (2)"){case 1:X(H,"CAT")break case 2:X(H,"SEAGULL")}break
case 49:switch X(I,"PAKISTAN?"+Y){case 2:X(50)break case 1:X(52)}break
case 50:switch X(I,H+"GERMANYS ARE THERE?##ONE (1), ONE, BUT IT'S HUGE (2), TWO (3)"){case 1:X(51)break case 2:X(H,"1941-45")break case 3:X(H,"1946-47")}break
case 51:switch X(I,"PERSIA OR IRAN?##PERSIA (1), IRAN (2)"){case 1:X(H,"1930-34")break case 2:X(H,"1935-40")}break
case 52:switch X(I,"CAMBODIA?"+Y){case 2:X(53)break case 1:X(55)}break
case 53:switch X(I,"ERITREA IS A PART OF...##ITALY (1), ETHIOPIA (2)"){case 1:X(54)break case 2:X(H,"1952-53")}break
case 54:switch X(I,"CANADA IS...##MISSING A PIECE (1), FINE (2)"){case 1:X(H,"1948")break case 2:X(H,"1949-52")}break
case 55:switch X(I,"THE UNITED ARAB REPUBLIC?"+Y){case 2:X(H,"1954-57")break case 1:X(H,"1958-60")}break
case 56:switch X(I,'ZAIRE? OR: "HONG KONG (UK)"'+Y){case 1:X(H,"1992-96")break case 2:X(57)}break
case 57:switch X(I,"SERBIA AND MONTENEGRO ARE...##ONE COUNTRY (1), TWO COUNTRIES (2)"){case 1:X(58)break case 2:X(59)}break
case 58:switch X(I,"EAST TIMOR?"+Y){case 2:X(H,"1997-2001")break case 1:X(H,"2002-06")}break
case 59:switch X(I,H+"SUDANS ARE THERE?##ONE (1), TWO (2)"){case 1:X(H,"2007H1")break case 2:X(60)}break
case 60:switch X(I,"IS CRIMEA DISPUTED?"+Y){case 1:X(61)break case 2:X(H,"2012H3")}break
case 61:switch X(I,'"COLORADO" OR "DANGER-RADIOACTIVE EXCLUSION ZONE-AVOID"?##COLORADO (1), DANGER (2)'){case 1:X(H,"2014-21")break case 2:X(62)}break
case 62:switch X(I,"DOES THE WARNING MENTION THE SPIDERS?"+Y){case 2:X(H,"2022")break case 1:X(H,"2023 OR LATER")}break
case 63:switch X(I,"SAUDI ARABIA?"+Y){case 2:X(H,"1922-32")break case 1:X(64)}break
case 64:switch X(I,"IS MOST OF WEST AFRICA A GIANT FRENCH BLOB?"+Y){case 1:X(49)break case 2:X(65)}break
case 65:switch X(I,H+"VIETNAMS ARE THERE?##TWO (1), ONE (2)"){case 1:X(66)break case 2:X(69)}break
case 66:switch X(I,"BANGLADESH?"+Y){case 2:X(67)break case 1:X(H,"1972-75")}break
case 67:switch X(I,"IS THE AREA SOUTH OF LAKE VICTORIA...##BRITISH (1), TANGANYIKA (2), TANZANIA (3)"){case 1:X(68)break case 2:X(H,"1961-64")break case 3:X(H,"1965-71")}break
case 68:switch X(I,"THE TOWN ON I-25 BETWEEN ALBUQUERQUE AND EL PASO IS...##HOT SPRINGS (1), TRUTH OR CONSEQUENCES (2)"){case 1:X(H,"1948-49")break case 2:X(H,"1950-52")}break
case 69:switch X(I,"JIMMY CARTER IS...##BEING ATTACKED BY A GIANT SWIMMING RABBIT (1), FINE (2)"){case 1:X(H,"APRIL 20, 1979")break case 2:X(70)}break
case 70:switch X(I,"THE SINAI IS PART OF WHAT COUNTRY?## ISRAEL (1), MOSTLY ISRAEL (2), MOSTLY EGYPT (3), EGYPT (4)"){case 1:X(H,"1976-79")break case 2:X(H,"1980")break case 3:X(H,"1981")break case 4:X(71)}break
case 71:switch X(I,"WHAT'S THE CAPITAL OF MICRONESIA?## KOLONIA (1), PALIKIR (2)"){case 1:X(72)break case 2:X(73)}break
case 72:switch X(I,"REPUBLIC OF THE UPPER VOLTA OR BURKINA FASO?## UPPER VOLTA (1), BURKINA FASO (2)"){case 1:X(H,"1982-84")break case 2:X(H,"1985-88")}break
case 73:switch X(I,"(NUMBER OF YEMENS)+(NUMBER OF GERMANYS)=?## FOUR (1), THREE (2), TWO (3)"){case 1:X(H,"1989-EARLY 1990")break case 2:X(H,"MIDH990")break case 3:X(H,"LATE 1990H991")}break
case 74:switch X(I,"DOES THE SOVIET UNION EXIST?"+Y){case 1:X(64)break case 2:X(56)}break}

# is the newline character.

How to run

New .gmk file
Create a script X with contents as above
Create an object O with Create Event: execute code: X(1)
Create a room R and put one instance of O in it
Run the game

Golfing

The option YES now always precedes NO, and we define the string Y="##YES (1), NO (2)" for reuse.
"IS THERE A BIG LAKE IN THE MIDDLE OF " and "HOW MANY " are long enough and occur sufficiently many times for abbreviation to pay off. They are assigned to I and H.
In Game Maker, any user-defined function usually must be done in a separate script. The consensus on the policy for counting bytes for multi-file programs, was that "If files are reused ... count the contents of that file as many times as you use it". As such, we use X itself, rather than a separate script, to abbreviate get_integer and show_message. Explicitly,

If X is called with zeroth argument H, then it returns show_message of the first argument.
If X is called with zeroth argument I, then it returns get_integer of the first argument, showing default input 1.

Ungolfed, with options in the original order and no abbreviations at all:

// script X, takes node number, prompts question and returns message or calls X with next node number

switch argument0
{
case 1: switch get_integer("ISTANBUL OR CONSTANTINOPLE##CONSTANTINOPLE (1), NEITHER (2), ISTANBUL(3)",1)
  {
    case 1: X(2); break;
    case 2: X(19); break;
    case 3: X(74); break;
  }; break;
case 2: switch get_integer("DO ANY OF THESE EXIST?#- INDEPENDENT CANADA#- US TERRITORY OF ALASKA#- TOKYO##NO (1), YES (2)",1)
  {
    case 1: X(3); break;
    case 2: X(11); break;
  }; break;
case 3: switch get_integer("THE HOLY ROMAN EMPIRE?##YES (1), NO (2)",1)
  {
    case 1: show_message("1805 OR EARLIER (BEFORE THIS POINT, THE MODERN IDEA OF A COMPLETE POLITICAL MAP OF THE WORLD GETS HARD TO APPLY.)"); break;
    case 2: X(4); break;
  }; break;
case 4: switch get_integer("THE UNITED STATES?##NO (1), YES (2)",1)
  {
    case 1: show_message("HOW SURE ARE YOU THAT THIS MAP IS IN ENGLISH"); break;
    case 2: X(5); break;
  }; break;
case 5: switch get_integer("TEXAS IS...##PART OF MEXICO (1), INDEPENDENT (2), PART OF THE US (3)",1)
  {
    case 1: X(6); break;
    case 2: show_message("1834-45"); break;
    case 3: X(9); break;
  }; break;
case 6: switch get_integer("FLORIDA IS PART OF...##SPAIN (1), THE US (2)",1)
  {
    case 1: X(7); break;
    case 2: X(8); break;
  }; break;
case 7: switch get_integer("PARAGUAY?##NO (1), YES (2)",1)
  {
    case 1: show_message("1806-10"); break;
    case 2: show_message("1811-17"); break;
  }; break;
case 8: switch get_integer("VENEZUELA AND/OR ECUADOR?##NO (1), YES (2)",1)
  {
    case 1: show_message("1818-29"); break;
    case 2: show_message("1830-33"); break;
  }; break;
case 9: switch get_integer("DOES RUSSIA BORDER THE SEA OF JAPAN?##NO (1), YES (2)",1)
  {
    case 1: X(10); break;
    case 2: show_message("1858-67"); break;
  }; break;
case 10: switch get_integer("THE US'S SOUTHERN BORDER LOOKS...##WEIRD (1), NORMAL (2)",1)
  {
    case 1: show_message("1846-53"); break;
    case 2: show_message("1854-56"); break;
  }; break;
case 11: switch get_integer("SOUTH AFRICA?##NO (1), YES (2)",1)
  {
    case 1: X(12); break;
    case 2: X(16); break;
  }; break;
case 12: switch get_integer("RHODESIA?##NO (1), YES (2)",1)
  {
    case 1: X(13); break;
    case 2: X(15); break;
  }; break;
case 13: switch get_integer("IS BOLIVIA LANDLOCKED?##NO (1), YES (2)",1)
  {
    case 1: X(14); break;
    case 2: show_message("1884-95"); break;
  }; break;
case 14: switch get_integer('"BUDA" AND "PEST" OR "BUDAPEST"?##BUDA AND PEST (1), BUDAPEST (2)',1)
  {
    case 1: show_message("1868-72"); break;
    case 2: show_message("1873-83"); break;
  }; break;
case 15: switch get_integer("IS NORWAY PART OF SWEDEN?##YES (1), NO (2)",1)
  {
    case 1: show_message("1896-1905"); break;
    case 2: show_message("1906-09"); break;
  }; break;
case 16: switch get_integer("AUSTRIA-HUNGARY?##YES (1), NO (2)",1)
  {
    case 1: X(17); break;
    case 2: X(18); break;
  }; break;
case 17: switch get_integer("ALBANIA?##NO (1), YES (2)",1)
  {
    case 1: show_message("1910-12"); break;
    case 2: show_message("1913-18"); break;
  }; break;
case 18: switch get_integer("LENINGRAD?##NO (1), YES (2)",1)
  {
    case 1: show_message("1919-23"); break;
    case 2: show_message("1924-29"); break;
  }; break;
case 19: switch get_integer("DOES THE OTTOMAN EMPIRE EXIST?##YES (1), NO (2)",1)
  {
    case 1: X(2); break;
    case 2: X(20); break;
  }; break;
case 20: switch get_integer("THE SOVIET UNION?##NO (1), YES (2)",1)
  {
    case 1: X(21); break;
    case 2: X(63); break;
  }; break;
case 21: switch get_integer("NORTH KOREA?##NO (1), YES (2)",1)
  {
    case 1: X(22); break;
    case 2: X(56); break;
  }; break;
case 22: switch get_integer("SAINT TRIMBLE'S ISLAND?##NO (1), YES (2)",1)
  {
    case 1: X(23); break;
    case 2: show_message("NO, I MADE THAT ONE UP."); break;
  }; break;
case 23: switch get_integer("IS JAN MAYEN PART OF THE KINGDOM OF NORWAY?##NOT YET (1), WHAT? (2), YES (3)",1)
  {
    case 1: X(2); break;
    case 2: X(24); break;
    case 3: X(49); break;
  }; break;
case 24: switch get_integer("CAN YOU SEE THE FAMILIAR CONTINENTS?##YES (1), NO (2)",1)
  {
    case 1: X(25); break;
    case 2: X(31); break;
  }; break;
case 25: switch get_integer("THIS SOUNDS LIKE A PHYSICAL MAP OR SATELLITE PHOTO.##YES, THAT'S IT (1)",1)
  {
    case 1: X(26); break;
  }; break;
case 26: switch get_integer("IS LAKE CHAD MISSING?##NO (1), YES (2)",1)
  {
    case 1: X(27); break;
    case 2: X(30); break;
  }; break;
case 27: switch get_integer("HOW FAR EAST DO THE AMERICAN PRAIRIES REACH?##INDIANA (1), THE MISSISSIPPI (2), NEBRASKA (3), WHAT PRAIRIES? (4)",1)
  {
    case 1: show_message("BEFORE 1830"); break;
    case 2: show_message("1830s-80s"); break;
    case 3: X(28); break;
    case 4: X(29); break;
  }; break;
case 28: switch get_integer("IS THERE A BIG LAKE IN THE MIDDLE OF SOUTHERN CALIFORNIA? (CREATED BY MISTAKE)##NO (1), YES (2)",1)
  {
    case 1: show_message("1860s-1900s"); break;
    case 2: show_message("1910s"); break;
  }; break;
case 29: switch get_integer("IS THERE A BIG LAKE IN THE MIDDLE OF GHANA? (CREATED ON PURPOSE)##NO (1), YES (2)",1)
  {
    case 1: show_message("1920s-50s"); break;
    case 2: show_message("1960s-70s"); break;
  }; break;
case 30: switch get_integer("IS THE ARAL SEA MISSING?##NO (1), YES (2)",1)
  {
    case 1: show_message("1970s-90s"); break;
    case 2: show_message("2000s+"); break;
  }; break;
case 31: switch get_integer('RIVERS "SIRION" OR "ANDUIN"?##YES (1), NO (2)',1)
  {
    case 1: X(32); break;
    case 2: X(36); break;
  }; break;
case 32: switch get_integer("MORDOR?##NO (1), YES (2)",1)
  {
    case 1: X(33); break;
    case 2: X(34); break;
  }; break;
case 33: switch get_integer("BELERIAND?##YES (1), NO (2)",1)
  {
    case 1: show_message("FIRST AGE"); break;
    case 2: show_message("EARLY SECOND AGE"); break;
  }; break;
case 34: switch get_integer("NÚMENOR?##YES (1), NO (2)",1)
  {
    case 1: show_message("LATE SECOND AGE"); break;
    case 2: X(35); break;
  }; break;
case 35: switch get_integer("THE FOREST EAST OF THE MISTY MOUNTAINS IS...##GREENWOOD THE GREAT (1), MIRKWOOD (2), THE WOOD OF GREENLEAVES (3)",1)
  {
    case 1: show_message("EARLY THIRD AGE"); break;
    case 2: show_message("LATE THIRD AGE"); break;
    case 3: show_message("FOURTH AGE"); break;
  }; break;
case 36: switch get_integer("CAIR PARAVEL?##YES (1), NO (2)",1)
  {
    case 1: X(37); break;
    case 2: X(41); break;
  }; break;
case 37: switch get_integer("CALORMEN?##NO (1), YES (2)",1)
  {
    case 1: X(38); break;
    case 2: X(40); break;
  }; break;
case 38: switch get_integer("LOTTA ISLANDS?##NO (1), YES (2)",1)
  {
    case 1: X(39); break;
    case 2: show_message("DAWN TREADER"); break;
  }; break;
case 39: switch get_integer("BERUNA##FORD (1), BRIDGE (2)",1)
  {
    case 1: show_message("THE LION, THE WITCH, AND THE WARDROBE"); break;
    case 2: show_message("PRINCE CASPIAN"); break;
  }; break;
case 40: switch get_integer("WEIRD RECURSIVE HEAVEN?##NO (1), YES (2)",1)
  {
    case 1: show_message("ONE OF THE RANDOM LATER BOOKS"); break;
    case 2: show_message("THE LAST BATTLE"); break;
  }; break;
case 41: switch get_integer("MOSSFLOWER?##YES (1), NO (2)",1)
  {
    case 1: show_message("REDWALL"); break;
    case 2: X(42); break;
  }; break;
case 42: switch get_integer("IS THE WORLD ON THE BACK OF A TURTLE?##YES (1), NO (2)",1)
  {
    case 1: show_message("DISCWORLD"); break;
    case 2: X(43); break;
  }; break;
case 43: switch get_integer("ARE YOU SURE THIS IS A MAP?##YES (1), NO (2)",1)
  {
    case 1: X(44); break;
    case 2: X(46); break;
  }; break;
case 44: switch get_integer("DID YOU MAKE IT YOURSELF?##YES (1)",1)
  {
    case 1: X(45); break;
  }; break;
case 45: switch get_integer("IT'S VERY NICE.##THANK YOU! (1)",1)
  {
    case 1: break;
  }; break;
case 46: switch get_integer("IS IT TRYING TO BITE YOU?##NO (1), YES (2)",1)
  {
    case 1: X(47); break;
    case 2: X(48); break;
  }; break;
case 47: switch get_integer("IS IT LARGER THAN A BREADBOX?##YES (1), NO (2), ABOUT THE SAME (3)",1)
  {
    case 1: show_message("TUBA") break;
    case 2: show_message("STAPLER") break;
    case 3: show_message("BREADBOX") break;
  }; break;
case 48: switch get_integer("IF YOU LET IT GO, WHAT DOES IT DO?##HISSES AND RUNS AWAY (1), SCREECHES AND FLAPS AROUND THE ROOM BREAKING THINGS (2)",1)
  {
    case 1: show_message("CAT") break;
    case 2: show_message("SEAGULL") break;
  }; break;
case 49: switch get_integer("PAKISTAN?##NO (1), YES (2)",1)
  {
    case 1: X(50); break;
    case 2: X(52); break;
  }; break;
case 50: switch get_integer("HOW MANY GERMANYS ARE THERE?##ONE (1), ONE, BUT IT'S HUGE (2), TWO (3)",1)
  {
    case 1: X(51); break;
    case 2: show_message("1941-45") break;
    case 3: show_message("1946-47") break;
  }; break;
case 51: switch get_integer("PERSIA OR IRAN?##PERSIA (1), IRAN (2)",1)
  {
    case 1: show_message("1930-34") break;
    case 2: show_message("1935-40") break;
  }; break;
case 52: switch get_integer("CAMBODIA?##NO (1), YES (2)",1)
  {
    case 1: X(53); break;
    case 2: X(55); break;
  }; break;
case 53: switch get_integer("ERITREA IS A PART OF...##ITALY (1), ETHIOPIA (2)",1)
  {
    case 1: X(54); break;
    case 2: show_message("1952-53"); break;
  }; break;
case 54: switch get_integer("CANADA IS...##MISSING A PIECE (1), FINE (2)",1)
  {
    case 1: show_message("1948"); break;
    case 2: show_message("1949-52"); break;
  }; break;
case 55: switch get_integer("THE UNITED ARAB REPUBLIC?##NO (1), YES (2)",1)
  {
    case 1: show_message("1954-57"); break;
    case 2: show_message("1958-60"); break;
  }; break;
case 56: switch get_integer('ZAIRE? OR: "HONG KONG (UK)"##YES (1), NO (2)',1)
  {
    case 1: show_message("1992-96"); break;
    case 2: X(57); break;
  }; break;
case 57: switch get_integer("SERBIA AND MONTENEGRO ARE...##ONE COUNTRY (1), TWO COUNTRIES (2)",1)
  {
    case 1: X(58); break;
    case 2: X(59); break;
  }; break;
case 58: switch get_integer("EAST TIMOR?##NO (1), YES (2)",1)
  {
    case 1: show_message("1997-2001"); break;
    case 2: show_message("2002-06"); break;
  }; break;
case 59: switch get_integer("HOW MANY SUDANS ARE THERE?##ONE (1), TWO (2)",1)
  {
    case 1: show_message("2007-11"); break;
    case 2: X(60); break;
  }; break;
case 60: switch get_integer("IS CRIMEA DISPUTED?##YES (1), NO (2)",1)
  {
    case 1: X(61); break;
    case 2: show_message("2012-13"); break;
  }; break;
case 61: switch get_integer('"COLORADO" OR "DANGER-RADIOACTIVE EXCLUSION ZONE-AVOID"?##COLORADO (1), DANGER (2)',1)
  {
    case 1: show_message("2014-21"); break;
    case 2: X(62); break;
  }; break;
case 62: switch get_integer("DOES THE WARNING MENTION THE SPIDERS?##NO (1), YES (2)",1)
  {
    case 1: show_message("2022"); break;
    case 2: show_message("2023 OR LATER"); break;
  }; break;
case 63: switch get_integer("SAUDI ARABIA?##NO (1), YES (2)",1)
  {
    case 1: show_message("1922-32"); break;
    case 2: X(64); break;
  }; break;
case 64: switch get_integer("IS MOST OF WEST AFRICA A GIANT FRENCH BLOB?##YES (1), NO (2)",1)
  {
    case 1: X(49); break;
    case 2: X(65); break;
  }; break;
case 65: switch get_integer("HOW MANY VIETNAMS ARE THERE?##TWO (1), ONE (2)",1)
  {
    case 1: X(66); break;
    case 2: X(69); break;
  }; break;
case 66: switch get_integer("BANGLADESH?##NO (1), YES (2)",1)
  {
    case 1: X(67); break;
    case 2: show_message("1972-75"); break;
  }; break;
case 67: switch get_integer("IS THE AREA SOUTH OF LAKE VICTORIA...##BRITISH (1), TANGANYIKA (2), TANZANIA (3)",1)
  {
    case 1: X(68); break;
    case 2: show_message("1961-64"); break;
    case 3: show_message("1965-71"); break;
  }; break;
case 68: switch get_integer("THE TOWN ON I-25 BETWEEN ALBUQUERQUE AND EL PASO IS...##HOT SPRINGS (1), TRUTH OR CONSEQUENCES (2)",1)
  {
    case 1: show_message("1948-49"); break;
    case 2: show_message("1950-52"); break;
  }; break;
case 69: switch get_integer("JIMMY CARTER IS...##BEING ATTACKED BY A GIANT SWIMMING RABBIT (1), FINE (2)",1)
  {
    case 1: show_message("APRIL 20, 1979"); break;
    case 2: X(70); break;
  }; break;
case 70: switch get_integer("THE SINAI IS PART OF WHAT COUNTRY?## ISRAEL (1), MOSTLY ISRAEL (2), MOSTLY EGYPT (3), EGYPT (4)",1)
  {
    case 1: show_message("1976-79"); break;
    case 2: show_message("1980"); break;
    case 3: show_message("1981"); break;
    case 4: X(71); break;
  }; break;
case 71: switch get_integer("WHAT'S THE CAPITAL OF MICRONESIA?## KOLONIA (1), PALIKIR (2)",1)
  {
    case 1: X(72); break;
    case 2: X(73); break;
  }; break;
case 72: switch get_integer("REPUBLIC OF THE UPPER VOLTA OR BURKINA FASO?## UPPER VOLTA (1), BURKINA FASO (2)",1)
  {
    case 1: show_message("1982-84"); break;
    case 2: show_message("1985-88"); break;
  }; break;
case 73: switch get_integer("(NUMBER OF YEMENS)+(NUMBER OF GERMANYS)=?## FOUR (1), THREE (2), TWO (3)",1)
  {
    case 1: show_message("1989-EARLY 1990"); break;
    case 2: show_message("MID-1990"); break;
    case 3: show_message("LATE 1990-1991"); break;
  }; break;
case 74: switch get_integer("DOES THE SOVIET UNION EXIST?## YES (1), NO (2)",1)
  {
    case 1: X(64); break;
    case 2: X(56); break;
  }; break;
}

Numbering system

Version 1: before reordering of YES, NO options to save bytes
Version 2 (current): (reordered option numbers in black)


Find the discrete logarithm Task
Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists.
A reference implementation can be found here.
Constraints
You can expect \$a\$ and \$b\$ to be less than \$m\$.
Scoring
This is code-golf so shortest bytes wins.
Sample Testcases
# a, b, m -> x

10, 10, 50 -> 1
10, 100, 200 -> 2
10, 1, 127 -> 42
35, 541, 1438 -> 83
35, 541, 1438 -> 1519
1816, 2629, 3077 -> 223
3306, 4124, 5359 -> 1923
346, 406, 430 -> None
749430, 2427332, 2500918 -> 8025683
3442727916, 3990620294, 6638635157 -> 5731137125

Note: in the third testcase the solution cannot be 0 since the solution has to be a positive number

C (gcc), 59 53 51 bytes
Saved 6 bytes thanks to the man himself Arnauld!!!
Saved 2 bytes thanks Dominic van Essen!!!

p;x;f(a,b,m){for(p=a,x=1;p-b&&++x<m;)p=p*a%m;x%=m;}

Try it online!
Inputs positive integers \$a,b,m\$ with \$a,b<m\$.
Outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or \$0\$ if no such \$x\$ exists.


Shortest code to make a Too-low --- Too-high game You have to make a game Too-low --- Too-high (TLTH) in shortest code (in bytes)

Game rules:

Computer will choose a random number out of integer range (-32768..32767).
Now you will think of a number and input it.
The computer will tell if your number is lower (TOO LOW) or higher (TOO HIGH) than the chosen number.
When you guess the number, the computer should display Congrats! You found the number!.

Code Rules:

Do not use the characters T, O, L, W, H, I and G (neither lowercase nor uppercase) in string or character literals.
For instance:

tolower(T);  // Acceptable
cout<<"T";   // Unacceptable
char ch='T'; // Unacceptable

Remove 300 bytes if your code can display the game rules before starting the game.
Remove 50 bytes if your code can count number of turns and display number of turns taken in the end of game like this:

"Congrats! You found the number in n turns!"

where n is number of turns taken, instead of

"Congrats! You found the number!"

Remove 25 bytes from your score if your code can tell user that the number you input is out of integer range.
For example:

Enter the number: 40000
Sorry! This number is out of range
Please Enter the number again:

Remove 25 bytes If your code takes the random number not from any built-in random function.
Remove 10 bytes If your code display "congrats" in color (pick any color except default white).

Submission Rules:

Add a heading with your language name and score with all bounty calculation and its explanation.
Post your golfed and ungolfed code.

Winner

The answer with least bytes wins.
If there is a tie, the answer with the more votes wins.
The winner will be chosen after 5 days.

EDIT:Please show your code's output.
EDIT-2: You can ignore Rule-1 for Rules-2,3 & 4 in Code Rules

Best Of Luck :]

Perl 5.10+: 159 144 bytes − 350 = −206 points

say"Guess 16 bit signed number";$==32767-rand 65536;say(TOO.$",$_<0?LOW:HIGH)while++$i,$_=<>-$=;say"Congrats! You found the number in $i turns!"

Edit 2: With the recent rules change that allows me to use any string literal for the "congrats" message, I can save 15 bytes from my original 159-byte solution.  There's nothing particularly novel or interesting about the new code above as compared to the old code (I just got rid of the p function, and call say directly instead), so the remainder of this post will describe the original code, shown below:

sub p{say join$",@_}p Guess,16,bit,signed,number;$==32767-rand 65536;p(TOO,$_<0?LOW:HIGH)while++$i,$_=<>-$=;p Congrats."!",You,found,the,number,in,$i,turns."!"

Yeah, I'm abusing the hell out of rule 1.  Who needs strings, when you can have barewords? ;-)

Run with perl -M5.010 to enable the Perl 5.10+ say feature (or replace the body of the p function with print join$",@_,$/ for an extra cost of 5 bytes).

Bonus scores:

−300 points: "display the game rules before starting the game"
−50 points: "display number of turns taken in the end of game"

The code contains no string literals in a strict sense, so I'd say that rule 1 is, technically, not violated.  The trick is that, in Perl, without use strict, any identifier that doesn't correspond to a known language keyword or subroutine will simple evaluate to its own name.  The function p then simply takes a list of words and prints them out, separated by spaces.

Example play-through:

Guess 16 bit signed number
0
TOO HIGH
-10000
TOO LOW
-5000
TOO HIGH
-7500
TOO LOW
-6250
TOO HIGH
-6875
TOO LOW
-6553
TOO HIGH
-6700
TOO HIGH
-6790
TOO LOW
-6745
TOO HIGH
-6767
TOO LOW
-6756
TOO HIGH
-6761
Congrats! You found the number in 13 turns!

Edit: Oh, right, the rules say I need to post an un-golfed version of the code too, so here it goes.  Technically, it's "de-golfed", since I usually compose my code golf programs in more or less fully golfed form from the beginning, and it can sometimes be tricky to remove all the "golfy" optimizations without fundamentally changing how some parts of the program work.  Still, I've at least tried to add whitespace, comments and more meaningful function / variable names:

sub output {
    # print all arguments separated by spaces, plus a newline:
    # (in the golfed code, I use the special variable $" instead of " " for a space)
    say join " ", @_;
}

# print the rules:
output Guess, 16, bit, signed, number;

# choose a random number between -32768 and 32767 inclusive:
# (in the golfed version, using the special variable $= allows
# the int() to be left out, since $= can only take integer values)
$number = int( 32767 - rand 65536 );

# loop until the input equals the chosen number, printing "TOO LOW / HIGH":
# (the loop ends when $diff == 0, since 0 is false in Perl)
output (TOO, $diff < 0 ? LOW : HIGH) while ++$count, $diff = (<> - $number);

# print congratulations, including the loop count:
output Congrats."!", You, found, the, number, in, $count, turns."!";

Ps. As an alternative, if just using barewords instead of strings feels too cheaty for you, here's a 182-byte solution that doesn't use the letters TOLWHIG even in barewords (but does use them in a transliteration operator).  It still gets the same bonuses, for a total score of 182 − 350 = −168 points:

sub t{pop=~y/kpqvxyz/tolwhig/r}say"Guess 16 bit signed number";$==32767-rand 65536;say uc t"kpp ".($_<0?qpv:xyzx)while++$n,$_=<>-$=;say t"Cpnzraks! Ypu fpund kxe number yn $n kurns!"

The output looks exactly the same as above.  Per the (original) rules, I do use the letters t and i in printing the rules, since it's allowed; eliminating even those uses would only cost two extra bytes, though.  Conversely, making all the output uppercase (which, based on comments above, seems to be allowed) would let me save three bytes.


Generate a Nine-Ball Pool rack Introduction

Nine-Ball is a popular pool game played casually and as a competitive sport.

There is one of each numbered ball, with the numbers 1 to 9.
The game starts with all 9 of the balls in a diamond shaped rack, like so:

  1
 2 3
4 9 6
 5 7
  8

The 1 ball is always at the front of the diamond, and the 9 ball is always in the middle, with all the other balls placed randomly (the "X"s in this diagram):

  1
 X X
X 9 X
 X X
  X

Challenge

Your challenge, given no input, is to generate and output random 9-ball pool racks in the text format of the examples. Extra surrounding whitespace is allowed.

Output may be through any convenient method, standard loopholes apply. A new rack MUST be generated on each run, you cannot just produce a single randomly-chosen rack every time. Extra surrounding whitespace is allowed.

Example Outputs

  1
 2 3
4 9 5
 6 7
  8

  1
 8 3
2 9 7
 4 6
  5

  1
 2 8
3 9 7
 5 4
  6

Least bytes per language wins.

R, 61 bytes

cat(paste0(c("  1
 ","","
","9 ","
 ","","
  "),sample(2:8)))

Try it online!

Prints alternately the proper whitespace/newline (with 1 and 9 included) and elements of a random permutation of \$\{2,\ldots,8\}\$.


Ascii smiley face challenge I made this because, although we have a bunch of other questions involving smiley faces, there is nothing for just printing an ASCII smiley face with as little code as possible.
Anyway, print this exactly (Trailing spaces allowed):
        **********
    ******************
  **********************
 *******  ******  *******
 ************************
**************************
**************************
*****   **********   *****
 *****   ********   *****
 ******            ******
  **********************
    ******************
        **********

This is code-golf, so fewest bytes wins. Yes, you have to use asterisks.

Python 3, 97 bytes
The string has a leading and trailing unprintable with value 5.

for c in"wç¿ğŗŗĵý6çw":c=ord(c);s=c%8*'*'+c//8%7*' '+c//56*'*';print(f'{s+s[::-1]:^26}')

Try it online!


Let's build a race car track! Introduction

My niece wants to make a race car track. She has wooden parts that fit together to form the track. Each part is square shaped and contains a different shape. I'll use the pipe drawing characters to illustrate:

│: the road that goes vertically
─: the road that goes horizontally
┌ ┐ └ ┘: the roads that turn in a direction
┼: A bridge with an underpass

Curiously, there are no t-junction pieces.

Here's an example of a possible race car track:

┌─┐
│ │┌─┐
│ └┼─┘
└──┘

The rules for a valid race car track are as follows:

There can't be any roads that go to nowhere.
It must form a loop (and all the pieces must be part of the same loop).
At the bridges / underpasses, you can't turn (so you have to go straight through them).

Unfortunately, the race car track pieces my niece and I have are limited. But we definitely want to use all of them in the track. Write a program that, given a list of what pieces are in our inventory, outputs a race car track that uses all of those pieces.

Input Description

We'd like the input to come in via STDIN, command line arguments, file reading, or a user input function (such as raw_input or prompt). The input is comma separated positive integers in the form

│,─,┌,┐,└,┘,┼

where each of those represent the amount of that particular piece we have. So for instance the input:

1,1,1,1,1,1,1

would mean that we had one of each piece.

Output Description

Output a race car track using the pipe drawing characters listed above. The race car track should use exactly the number of each piece specified in the input -- no more, and no less. There will be at least one valid race car track for every input.

Example Inputs and Outputs

Input: 3,5,2,2,2,2,1

A possible output:

┌─┐
│ │┌─┐
│ └┼─┘
└──┘

Input: 0,0,1,4,4,1,3

A possible output:

 ┌┐
 └┼┐
  └┼┐
   └┼┐
    └┘

Ruby 664 671 677 687 701 (678 bytes)

_={│:[1,4],─:[2,8],┌:[4,8],┐:[4,2],└:[1,8],┘:[1,2],┼:[1,4,2,8]}
s=->a,l,b{l==[]&&a==[]?b:(l.product(l).any?{|q,r|q,r=q[0],r[0];(q[0]-r[0])**2+(q[1]-r[1])**2>a.size**2}?!0:(w,f=l.pop
w&&v=!a.size.times{|i|y=_[x=a[i]]
f&&y&[f]==[]||(k=l.select{|p,d|w!=p||y&[d]==[]}
(y-[f]).map{|d|z=[w[0]+(d<2?-1:(d&4)/4),w[1]+(d==2?-1:d>7?1:0)]
g=d<3?d*4:d/4
b[z]?_[b[z]]&[g]!=[]||v=0:k<<[z,g]}
v||r=s[a[0...i]+a[i+1..-1],k,b.merge({w=>x})]
return r if r)}))}
c=eval"[#{gets}]"
r=s[6.downto(0).map{|i|[_.keys[i]]*c[i]}.flatten,[[[0,0],nil]],{}]
h=j=k=l=0
r.map{|w,_|y,x=w
h>x&&h=x
j>y&&j=y
k<x&&k=x
l<y&&l=y}
s=(j..l).map{|_|' '*(k-h+1)}
r.map{|w,p|y,x=w
s[y-j][x-h]=p.to_s}
puts s

This is not the shortest program I could come up with, but I sacrificed some brevity for execution speed.

You can experiment with the program here. Note that ideone has an execution time limit, so for inputs consisting of more than about 12 pieces, the program will probably time out.

There's also a test suite for the program. Note that the last two tests are disabled on ideone, due to the time limit mentioned above. To enable these tests, delete the x_ prefix from their names.

The program finds a solution using Depth-first search; it places pieces one at a time and keeps tracks of loose ends. The search stops when there are no more loose (unconnected) ends and all pieces have been placed.

This is the ungolfed program:

N, W, S, E = 1, 2, 4, 8

# given a direction, find the opposite
def opposite (dir)
  dir < 3 ? dir * 4 : dir / 4
end

# given a set of coordinates and a direction,
# find the neighbor cell in that direction
def goto(from, dir)
  y, x = from

  dx = case dir
  when W then -1
  when E then 1
  else 0
  end

  dy = case dir
  when N then -1
  when S then 1
  else 0
  end

  [y+dy, x+dx]
end

CONNECTIONS = {
  ?│ => [N, S],
  ?─ => [W, E],
  ?┌ => [S, E],
  ?┐ => [S, W],
  ?└ => [N, E],
  ?┘ => [N, W],
  ?┼ => [N, S, W, E],
}

BuildTrack =-> {
  piece_types = CONNECTIONS.keys
  piece_counts = gets.split(?,).map &:to_i

  pieces = 6.downto(0).map{|i|piece_types[i]*piece_counts[i]}.join.chars

  def solve (available_pieces, loose_ends=[[[0,0],nil]], board={})

    return board if loose_ends==[] and available_pieces==[]

    # optimization to avoid pursuing expensive paths
    # which cannot yield a result.
    # This prunes about 90% of the search space
    c = loose_ends.map{ |c, _| c }
    not_enough_pieces = c.product(c).any? { |q, r|
      ((q[0]-r[0])**2+(q[1]-r[1])**2) > available_pieces.size**2
    }
    return if not_enough_pieces

    position, connect_from = loose_ends.pop

    return unless position

    available_pieces.size.times do |i|
      piece = available_pieces[i]

      remaining_pieces = available_pieces[0...i] + available_pieces[i+1..-1]

      piece_not_connected_ok = connect_from && CONNECTIONS[piece] & [connect_from] == []
      next if piece_not_connected_ok

      new_loose_ends = loose_ends.select  { |pos, dir|
        # remove loose ends that may have been
        # fixed, now that we placed this piece
        position != pos || CONNECTIONS[piece] & [dir] == []
      }

      invalid_placement = false

      (CONNECTIONS[piece]-[connect_from]).map do |dir|
        new_pos = goto(position, dir)
        new_dir = opposite(dir)

        if board[new_pos]
          if CONNECTIONS[board[new_pos]] & [new_dir] != []
            # do nothing; already connected
          else
            # going towards an existing piece
            # which has no suitable connection
            invalid_placement = true
          end
        else
          new_loose_ends << [new_pos, new_dir]
        end
      end

      next if invalid_placement

      new_board = board.merge({position => piece})

      result = solve(remaining_pieces, new_loose_ends, new_board)
      return result if result
    end
    nil
  end

  def print_board board
    min_x = min_y = max_x = max_y = 0

    board.each do |position, _|
      y, x = position
      min_x = [min_x, x].min
      min_y = [min_y, y].min
      max_x = [max_x, x].max
      max_y = [max_y, y].max
    end

    str = (min_y..max_y).map{|_|
      ' ' * (max_x - min_x + 1)
    }

    board.each do |position, piece|
      y, x = position
      str[y-min_y][x-min_x] = piece
    end
    puts str
  end

  print_board(solve(pieces))
}


How many fingers does bad pianist need? Challenge

Premise

Bob is a novice pianist who can only play sequences of single notes. In addition, he does quite an interesting thing: for every note after the first, if it's higher than the previous note was, he uses the finger directly to the right of the previous finger used; if lower, to the left; if the same pitch, well, the same finger.

Let's take Auld Lang Syne as an example, and arbitrarily suppose, only for the sake of this example, that Bob uses the very right side of his right hand.

Pitch: Should < auld = ac- = quain- < tance > be > for- < got
Digit: mid      ring   ring  ring     pinky   ring mid    ring

Alice wants to convince him of the stupidity of his playing...

Task

Input: a sequence of \$n\$ MIDI note numbers (which are integers between 0 and 127 inclusive), where \$2\leq n\leq10000\$.

Output: the number of fingers required to finish the melody with the playing style outlined in 'Premise'.

Please note that the answer may be more than 5.

No consideration of the starting finger is needed. Assume that the choice is optimal for playable melodies and has nothing (else) to do with the number of fingers required.

Example 1

Input: 0 0 0 0

Output: 1

Example 2

Input: 43 48 48 48 52 50 48 50

Output: 3

Example 3

Input: 86 88 84 81 83 79 74 76 72 69 71 67 62 64 60 57 59 57 56 55

Output: 9

Example 4

Input: 82 79 78 76 78 76 74 73 70 67 66 64 66 64 62 61

Output: 12

Remarks

This is code-golf, so fewest bytes wins.
Standard rules, I/O rules and loophole rules apply.
If possible, link an online demo of your code.
Please explain your code.

Perl 6, 27 bytes

{+minmax [\+] @_ Z<=>0,|@_}

Try it online!
Explanation
@_ Z<=>0,|@_ uses the zip metaoperator (Z) with the compare operator (<=>) to zip the list with itself offset by 1 and return the result of the comparison., e.g. [43, 48, 48, 48, 52, 50, 48, 50] -> (More More Same Same More Less Less More)
[\+] Reduces the list by summing over it (More = 1, Same = 0, Less = -1), however the \ does a 'triangular reduction' which produces a list of each calculation instead of the end result, e.g. (More More Same Same More Less Less More) -> (More 2 2 2 3 2 1 2)
minmax returns the range of smallest..largest, effectively removing duplicates. (More 2 2 2 3 2 1 2) -> Order::More..3
+ just returns the length of this range (list), which is the result


Swap out some periodic and non-periodic parts In the decimal representation of every rational number p/q, you have a periodic tail, a non-periodic head, and a section before the decimal point in the following format:

(before decimal point).(non-periodic)(periodic)

Some examples include:

1/70 = 0.0142857... = (0).(0)(142857)
10/7 = 1.428571... = (1).()(428571)            ## no non-periodic part
1/13 = 0.076923... = (0).()(076923)
3/40 = 0.075 = (0).(075)()                    ## no periodic part
-2/15 = -0.13... = -(0).(1)(3)                ## negative
75/38 = 1.9736842105263157894... = (1).(9)(736842105263157894)
                                              ## periodic part longer than float can handle
25/168 = 0.148809523... = (0).(148)(809523)
120/99 = 40/33 = 1.212121... = (1).()(21)
2/1 = 2 = (2).()()                            ## no periodic, no non-periodic
0/1 = 0 = (0).()()
0/2 = 0 = (0).()()
299/792 = 0.37752... = (0).(377)(52)
95/-14 = -6.7857142... = -(6).(7)(857142)
-95/-14 = 6.7857142... = (6).(7)(857142)

The challenge is to swap the periodic and non-periodic parts, leaving the before decimal point alone, to create a new number. For example:

25/168 = 0.148809523... = (0).(148)(809523)
       => (0).(809523)(148) = 0.809523148148... = 870397/1080000

If a number has no periodic part like 0.25 turn that number into a new periodic number, and vice versa.

1/4 = 0.25 = (0).(25)() => (0).()(25) = 0.252525... = 25/99
4/9 = 0.444444... = (0).()(4) => (0).(4)() = 0.4 = 2/5
5/1 = 5 = (5).()() => (5).()() = 5 = 5/1

The challenge

Take a fraction x as input, as a string, two inputs, a rational number, or whatever method suits your language.
Swap the periodic and non-periodic parts of the decimal representation of x to create a new number, leaving the part before the decimal alone. The periodic part always starts as soon as possible so that the non-periodic part is as short as possible. Examples are below.
Return the swapped number as a new fraction. The input is not necessarily reduced though the output should be. Input format is allowed to differ from output format.
The numerator p of x will be an integer with absolute value of one million or less and the denominator q of x will be a non-zero integer with absolute value of one million or less.
The numerator r and denominator s of the result is not guaranteed to be less than one million. Given the length of the periodic parts of these numbers, it is recommended that you avoid directly converting to floats.
This is code golf. Shortest answer in bytes wins.

Examples

1/70 = (0).(0)(142857)     => (0).(142857)(0) = (0).(142857)() = 0.142857 = 142857/1000000
10/7 = (1).()(428571)      => (1).(428571)() = 1.428571 = 1428571/1000000
1/13 = (0).()(076923)      => (0).(076923)() = 0.076293 = 76923/1000000
3/40 = (0).(075)()         => (0).()(075) = 0.075075... = 75/999 = 25/333
-2/15 = -(0).(1)(3)        => -(0).(3)(1) = -0.311111... = -28/90 = -14/45
75/38 = (1).(9)(736842105263157894)
      => (1).(736842105263157894)(9) = (1).(736842105263157895)()  ## since 0.999... = 1
      = 1.736842105263157895 = 1736842105263157895/1000000000000000000
      = 347368421052631579/200000000000000000
25/168 = (0).(148)(809523) => (0).(809523)(148) = 0.809523148148... = 870397/1080000
120/99 = (1).()(21)        => (1).(21)() = 1.21 = 121/100
2/1 = (2).()()             => (2).()() = 2 = 2/1
0/1 = (0).()()             => (0).()() = 0 = 0/1
0/2 = (0).()()             => (0).()() = 0 = 0/1
299/792 = (0).(377)(52)    => (0).(52)(377) = 0.52377377... = 2093/3996
95/-14 = -(6).(7)(857142)  => -(6).(857142)(7) = -6.857142777... = -12342857/1800000
-95/-14 = (6).(7)(857142)  => (6).(857142)(7) = 6.857142777... = 12342857/1800000

Python 2, 292 bytes
def x(n,d):
 L=len;s=cmp(n*d,0);n*=s;b=p=`n/d`;a={};n%=d
 while not n in a:
  a[n]=p;q=n/d;n=n%d
  if q==0:n*=10;p+=' '
  p=p[:-1]+`q`
 p=p[L(a[n]):];a=a[n][L(b):]
 if n==0:p=''
 n=int(b+p+a);d=10**L(p+a)
 if a!='':n-=int(b+p);d-=10**L(p)
 import fractions as f;g=f.gcd(n,d);return(n/g*s,d/g)

Ungolfed version, works in both python 2&3. Also prints decimal representation.
def x(n,d):
# sign handling
 s=n*d>0-n*d<0
 n*=s
# b, a, p: BEFORE decimal, AFTER decimal, PERIODIC part
 b=p=str(n//d)
 a={}
 n%=d
# long division
 while not n in a:
  a[n]=p
  q=n//d
  n=n%d
  if q==0:
   n*=10
   p+=' '
  p=p[:-1]+str(q)
# a/p still contain b/ba as prefixes, remove them
 p=p[len(a[n]):]
 a=a[n][len(b):]
 if n==0: p=''
# print decimal representation
 print("(" + b + ").(" + a + ")(" + p + ")")
# reassemble fraction (with a and p exchanged)
 n=int(b+p+a)
 d=10**len(p+a)
 if a!='':
  n-=int(b+p)
  d-=10**len(p)
# reduce output
 from fractions import gcd
 g=gcd(n,d)
 return(n//g*s,d//g)


Maze generating one liner The famous C64 basic one liner

10 PRINT CHR$(205.5+RND(1)); : GOTO 10

prints a maze of slashes and backslashes.

\\/\\\//\/\////\\/\/
\/\///\\///////\//\/
/\\\//\//\////\\//\\
\////\//\//\/\\\\\\/
/\/\\///\\\\/\\\\/\\
\/\//\\\\\\//\/\////
/\//\\///\/\///\////
\/\\\//\\/\\\//\\/\/
//////\\/\\/\/\/\///
\\/\/\\////\/\/\\/\/

Read in such maze made of diagonal walls from stdin and print out the same maze with horizontal and vertical walls consisting of the wall character "#"

For example the small maze

/\\
\\/
///

translates to

     #####
     #   #
     # # # #
     # # # #
 ##### # # #
       #   #
   #########

     #####

To be precise, each isolated wall segment has the length of five characters, adjacent wall segments share a corner. Moving a character to the right/left/top/down in the matrix of slashes and backslashes corresponds to a diagonal translation by 2 characters in vertical and 2 characters in horizontal direction in the #-matrix.

Python 3, 226 224 bytes

My first Python golf, so probably very sub-optimal.
It produces a whole lot of trailing whitespace, but there are no preceding newlines, and at most two preceding spaces.
The input needs to be given by hand from command line (maybe someone knows a shorter way to get multiline input in Python...).

e,z,s=enumerate,'0',list(iter(input,""))
p=''.join(s)*5
r=[len(p)*[' ']for _ in p]
for y,l in e(s):
 for x,c in e(l):
  for i in range(-2,3):r[2*(x+y+(s>[z]))+i*(c>z)][2*(x+len(s)-y)+i*(c<z)]='#'
for l in r:print(''.join(l))

The idea is to initialize a huge array of spaces r, then iterate through the input and replace the spaces with # as needed, and finally print the whole array.
A trick I used is to compare characters to z = '0' instead of testing equality to '/' or '\', which saves a bunch of bytes.


Find the follow sets The challenge below requires you to be familiar with formal parser theory. If you don't know what the question is asking because you don't know what the terms mean, context-free grammars and first/follow sets are covered in a lot of university courses.

I can recommend this Stanford course, in particular handouts 08 and 09 (from page 7). I've extracted also extracted a cheat sheet from these handouts  - I recommend anyone attempting this challenge to read it.

Write a program or function that given a context-free grammar finds the follow set of every nonterminal. Informally, the follow set of a nonterminal is a set of terminals and $ (meaning end-of-input) that you can possibly find after that terminal in a valid sentence.

The input is given as a single printable ASCII string or array of printable ASCII lines. You may output the sets in any reasonable format, using $ (either as literal output, or string inside a set, etc) to indicate the end of input. You may assume that the input is always valid according to the format below.

The context free grammar is given in a very simplified manner. Every line contains a single production. Every production is a space separated list of symbols. A terminal is a string of characters surrounded by apostrophes (e.g. '**'). For simplicity you may assume that terminals do not contain spaces, but it would be nice if your program allows it. A nonterminal may be any string not containing spaces or $. The empty production (normally indicated with ε) is simply a line containing only the left hand side nonterminal. The first line is the production defining the start symbol.

As an example, the following grammar:

S → aSa | bSb | ε

Will be given as:

S 'a' S 'a'
S 'b' S 'b'
S

Example input / outputs:

In:
S 'a' S 'a'
S 'b' S 'b'
S

Out:
S {'a', 'b', $}

In:
S A B C
A 'a'
A C 'b'
A
B C
B 'd' A
B
C 'e'
C 'f'

Out:
S {$}
A {'d', 'e', 'f'}
B {'e', 'f'}
C {'b', 'e', 'f', $}

In:
Start Alice Bob
Alice Charlie 'a'
Alice
Bob Bob 'a' Alice Charlie
Bob '!!!'
Charlie 'b'
Charlie

Out:
Start {$}
Alice {'a', '!!!', 'b', $}
Bob {'a', $}
Charlie {'a', $}

Shortest code in bytes wins.

Perl, 257 bytes

Includes +4 for -0p

Give grammar on STDIN (without trailing spaces. Make sure to remove the extra space in the second example). Assumes non-terminal names only contain letters, digits and _. Uses # instead of $ to indicate end of input. Can handle literals containing spaces

perl -M5.010 follow.pl
E T e
e '+' T e
e
T F t
t '*' F t
t
F '(' E ')'
F 'id'
^D

Outputs the follow sets as a list of non-terminal literal in no particular order. For the example above it outputs:

F ')'
F #
t ')'
t #
T ')'
T #
F '+'
t '+'
T '+'
F '*'
e ')'
e #
E ')'
E #

follow.pl:

#!/usr/bin/perl -0n
s/'.*?'/~$&/eg;s% (?=(\w.*\n))%$_.=">$1"%reg;/\s/;$_.=">$` #\n";s%^((\w+)\K ?\S*).*%$s{$1}++||"\$a.=s/ $2\\b/$&/rg"%eemgr,s%^(\w+ ).*?(\w+)$%"\$a.=s/>$1/>$2 /rg"%eermg,$_.=$a,s%>.*\xd8\K .*%%g,s%.+\n%$&x!/\n$&/g%eg until$$_++;s/\xd8.*?\xd8/~$&/eg;say/>(\w+ \W\S*\n)/g

Works as shown, but replace \xd8 and \n by their literal versions to get the claimed score.

It should be possible to improve this since converting the first sets to the follow sets is currently very awkward.


Overlapping Line Ordering (Inspired while drawing on a dry erase board)

Challenge:

Given an input string containing characters that represent different colors of dry erase markers on a white board, output the order in which they were drawn, from first to last.

Input:

A string which contains dry erase marker colors which are represented by alphabetical letters (upper ones are different than lowercase, you may substitute any characters used in my examples as long as each color has a distinct letter).  The rest of the whiteboard will be white-space.  There will only be one line of each color per board. There won't be inputs where all lines overlap each other (See test case 4).  All lines will be straight and either horizontal or vertical.

Output:

The order in which the lines were drawn on the board, from the first one drawn to the last one.  If there are multiple solutions for any input, you may output any one of them.  The output can be formatted anyway you'd prefer:  single string of characters or separated by spaces, newlines, etc. as long as the characters used match the ones used in your input.

Test Cases:

Input 1:

  R
  R
BBRBB
  R

Output 1:

BR

Input 2:

    GY
    GY
RRRRGYRRR
    GY
    GY
BBBBBBBB
    GY
    GY

Output 2:

RGYB // or RYGB

Input 3:

    R    P
    R    P
AAAARAAAAPA
    R    P
    R    P
GGGGRGGG P
    R

Output 3:

AGPR // or APGR

Input 4:

 O Y
RRRYR
 O Y
GOGGG
 O Y

Output 4:

// Undefined, does not need to be handled by your program

Input 5:

YYYB
   B
   B

Output 5:

// YB or BY

Rules:

This is code-golf, so shortest code in bytes wins.

Perl, 103+2 = 105 bytes

s/$/$"x y===c/gem;$a=$_;$_.=$"while$a=~s/^./!($_.=$&)/gem;s/$1/-/g,$b="$&$b"while/\s(\w)(\1|-)+ /;say$b

Run with -n0 (2 byte penalty).
Explanation:
# -n0: read entire input into `$_` at start of program
# (technically speaking it reads to the first NUL byte, but there aren't any)

# We want to be able to extract columns from the input, so we need to add spaces
# to the ends of each line such that each column is complete. Adding too many
# space is OK, so to ensure we have enough, we add a number of spaces equal to the
# length of the input.
s/$/             # At the end of {something},
$" x             # append a number of spaces ($" is a space by default)
y===c            # obtained by counting the characters in $_
/gem;            # where {something} is each (g) line (m)

$a = $_;         # store a copy of the transformed input in $a

# The next step is to create a transposition of the input. To do that, we
# repeatedly extract the first column of $a and append it to $_. This will lead to
# a bunch of junk whitespace at the end of $_ (of varying lengths, because once a
# line is empty it's omitted from the extracted column), but we're OK with that.
# To transpose properly, we'd want to place newlines between the extracted
# columns; however, it happens that the rest of the program treats space the same
# way it would newline, and separating via spaces is shorter, so we do that.

while (          # keep looping as long as there are matches
  $a =~ s/^./    # replace the first character of {something related to $a}
  !(             # with the null string (NOT of something truthy)
    $_.=$&)      # but append that character ($&) to $_
  /gem) {        # {something} is each (g) line (m) of $a
  $_.=$"         # append a space ($", equivalent to newline here) to $_
}

# Finally, we repeatedly replace every character in the topmost line with the -
# character (treating a line as continuous through the - character but not through
# other characters), thus finding the lines from top to bottom. Because we
# appended the transpose of $_ to $_ above, each line appears twice: once
# horizontally, once vertically. We find only the horizontal copy, but replace
# both with hyphens.
# (Note: I rewrote the regex into a bit more readable of a form in this ungolfed
# version, because the original version wouldn't allow me room to write comments
# inside it. The two should be equivalent; I tested the golfed version.)
while (          # keep looping as long as there are matches
  /\s(\w)        # match a space or newline, $1 (a letter/digit/underscore),
    (\1|-)+      # any positive number of $1s and hyphens,
    \ /x) {      # and a space
  s/$1/-/g,      # changes all $1s to spaces; set $& to $1, $1 becomes invalid
  $b = "$&$b"    # prepend $& to $b
}

# We need to output the lines from first (i.e. bottom) to last (i.e. top).
# We found them in the opposite order, but reversed them via prepending
# (not appending) the partial results to $b.
say $b           # output $b

One slight subtlety here comes with input like this:

   ABC
DDDDDDDDD
   ABC
   ABC
   ABC

Look at the fourth line here. If the order of writing were BACBD, there could genuinely be a horizontal line of Bs along there without violating any of the assumptions of the problem (other than that there's only one line of each colour, something that we don't check). In order to get around this, we ensure in the last regex that each line starts with a letter (or digit or underscore, but those are impossible), and rely on the fact that parallel lines will be found left-to-right and top-to-bottom (because the regex will find the first match within the string). As such, the first character of each ambiguous line here gets overwritten before the line itself is seen as a match, and that prevents the regex matching.


Code Injection works in C# too! Given the following C# program outputting False, inject a 'malicious' line of code such that the program outputs True.

class Program
{
    static void Main()
    {
        System.Console.Write("False");
        ;
    }
}

Your answer should consist of a string that replaces the second semicolon, and causes the program to output True, the whole True and nothing but True (not even a newline). It must do this if stdout is printed to the console, and if stdout is redirected to a file.

The shortest answer wins.

52 characters

}static Program(){System.Console.Write(0<1);for(;;);

so the whole thing becomes:

class Program
{
    static void Main()
    {
        System.Console.Write( "False" );
    }
    static Program()
    {
        System.Console.Write( 0 < 1 );
        for ( ; ; ) ;
    }
}


Create a binary ruler Given a number n, generate the first n columns of this pattern:

                               #
               #               #
       #       #       #       #
   #   #   #   #   #   #   #   #
 # # # # # # # # # # # # # # # #
################################ ...

The height of the column at (1-indexed) n is the number of trailing 0 bits in n's binary representation, plus one. As a result, the bottom layer has every column filled in, the second layer every second column, the third layer every fourth column, etc.

Rules

You may input and output through any standard method.
You may assume the input is an integer between 1 and 999, inclusive.
The output may contain any amount of whitespace, as long as the pattern is intact.
The pattern must be 1-indexed, and in the same format as shown here.
You may use any single non-whitespace character in place of #, but you may not change the space character.

Test cases

1
#

2
 #
##

3
 #
###

4
   #
 # #
####

5
   #
 # #
#####

7
   #
 # # #
#######

32
                               #
               #               #
       #       #       #       #
   #   #   #   #   #   #   #   #
 # # # # # # # # # # # # # # # #
################################

A few larger test cases can be found here.

Scoring

This is code-golf, so the shortest code in bytes in each language wins.

Python 2, 54 bytes

i=n=input()
while i:i-=1;print((' '*~-2**i+'#')*n)[:n]

Try it online!

Prints with lots of leading whitespace. Each row i counting down from n repeats a pattern of 2**i-1 spaces followed by a #. This pattern is repeated up to the width of the ruler, which is the input n. This is done by multiplying the pattern string by n and taking the first n characters with [:n].

The pattern can be made by string formatting for an equal length alternative.

i=n=input()
while i:i-=1;print('%%%ds'%2**i%'#'*n)[:n]

A cute slicing method is longer.

n=input();s=~-2**n*' '+'#'
exec"s=s[1::2]*2;print s[:n];"*n


Day of the week of the next Feb 29th Write a function which takes a date and returns the day of the week of the next February 29th after that date.

The input is a string in the ISO Extended format: YYYY-MM-DD (e.g. May 27th, 2010 would be "2010-05-27").
The output is a string which is the name of the day of the week (e.g. "Monday"). Capitalization doesn't matter, but do give the full name in English.
If the given date is February 29th, then return the day of the week of the next Feburary 29th.
Use the calculations for the Proleptic Gregorian Calendar (so, it uses the Gregorian leap year calculations for it's entire length). Don't worry about the Julian Calendar or when the switch from Julian to Gregorian occurred. Just assume Gregorian for everything.
The function should work for at least the range of "0001-01-01" - "2100-01-01".
Feel free to use whatever standard libraries your language of choice provides, but do not use 3rd party libraries unless you want to include that code as part of your solution.
Shortest code (fewest characters) wins.

Examples:

func("0001-01-01") -> "Sunday"
func("1899-12-03") -> "Monday"
func("1970-01-01") -> "Tuesday"
func("1999-07-06") -> "Tuesday"
func("2003-05-22") -> "Sunday"
func("2011-02-17") -> "Wednesday"
func("2100-01-01") -> "Friday"

(and no, you don't have to name the function func)

Hints:

Remember that years ending in 00 which aren't divisable by 400 aren't leap years.
January 1st, 0001 is a Monday.

Windows PowerShell, 65
Fairly straightforward.
filter f{for($d=date $_;($d+='1').day*$d.month-58){}$d.dayofweek}

As usual, we can shave off two bytes if we are willing to wait a long time till completion:
filter f{for($d=date $_;($d+=9).day*$d.month-58){}$d.dayofweek}

Test:
> '0001-01-01','1899-12-03','1970-01-01','1999-07-06','2003-05-22','2011-02-17','2100-01-01'|f
Sunday
Monday
Tuesday
Tuesday
Sunday
Wednesday
Friday

History:

2011-02-18 00:06 (65) First attempt.


Automatically anti-predictably assemble an alliterative aria Thanks to @ComradeSparklePony for the title.

This challenge should be very simple. You are given three lists.

The first is a list of first names, in title case.

The second is a list of adjectives, in lower case.

The third is a list of nouns, in lower case.

Please randomly select a name, optional adjective, and noun, and output <Name>'s <adjective> <noun>. However, each word must begin with the same letter. You can assume that all words begin with a letter. You can also assume (but note in your answer if you do):

that all words are composed solely of alphabetic characters
that there is at least one noun for each name
that there is at least one name for each noun

You cannot however assume that an adjective exists for a particular pair of name and noun, as the adjective is optional so the output will still be valid.

You do not have to select the shared letter uniformly, although all available letters must have a non-zero chance of occurring. You must however ensure that all outputs for a given letter have as near equal chance of occurring as possible within the limits of your language's random number generator. In the case of the adjective, this is equivalent to having an extra entry meaning "no adjective for this letter" which has the same chance as all of the other adjectives for that letter.

Example input lists:

Joan Neil Nicola Oswald Sherman Stephanie
new novel old original second silent
jeep noun novel output second sheep snake

Example outputs for these inputs (each line is a separate example):

Stephanie's second second
Sherman's silent snake
Oswald's original output
Nicola's novel novel
Neil's noun
Joan's jeep

Note no extra space between words in the last two examples.

This is code-golf, so the shortest code that breaks no standard loopholes wins!

In the unlikely event that it helps, you can input everything in upper case, but you still need to output in sentence case.

Jelly,  27 25  24 bytes

-1 thanks to Erik the Outgolfer (use a zero instead of a space character)

Ż€2¦Œpḟ€0ZḢŒuEƲƇXż“'s“”K

A full program accepting an argument in the form of a Python formatted list of lists of strings which prints the output to STDOUTt.

Try it online!

How?

Ż€2¦Œpḟ€0ZḢŒuEƲƇXż“'s“”K - Main Link: list of lists of lists of characters
 € ¦                     - sparse application...
  2                      - ...to indices: [2]
Ż                        - ...action: prepend a zero (place holder for no adjective)
    Œp                   - Cartesian product (all choices, including invalid ones)
       €                 - for each:
      ḟ 0                -   filter out any zeros
               Ƈ         - filter keep those for which:
              Ʋ          -   last four links as a monad:
         Z               -     transpose
          Ḣ              -     head
           Œu            -     upper-case
             E           -     all equal?
                X        - random (uniform) choice  e.g. [['B','o','b'],['b','l','u','e'],['b','a','g']]
                 ż       - zip with:
                  “'s“”  -   list [["'", 's'], []]       [[['B','o','b'],["'", 's']],[['b','l','u','e'],[]],['b','a','g']]
                       K - join with spaces              [['B','o','b'],["'", 's'],' ',['b','l','u','e'],[],' ','b','a','g']
                         - implicit (smashing) print     Bob's blue bag


Let's abbreviate those numbers! Now reverse? Introduction:

Like Twitter and Instagram and others, I wanted to display numbers like 1.2K and 3.8 M instead of 1,222 or 3,823,456.

But that's not all! As we all know, there might be some human beings which undoubtely won't like these abbreviations and will try to reverse them. So, 1.2k will become 1,200 and 3.8 M will become 3,800,000.

The task:

your task is to write a program or a function that converts a list of numbers (which are given as strings) into their abbreviate pairs and vice-versa.

For example, if the input list (or any STDIN) was ['1.4k', '1,234,567', '7.99M'], then you should output:

['1,400', '1.2M', '7,990,000']

You can follow the next schema for abbreviations:

103 -> one kilo -> K
106 -> one million -> M
109 -> one billion -> B

Your code may assume all lowercase, all uppercase, mixed case or undefined case for input and use any of these for output, but should be consistent.

Rules and restrictions:

you may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
input may be in any convenient list or string format. You may assume that the ai are less than 231 each and that the list contains at least one element.
each abbreviated number will contain only one . while a normal number will contain as many , as necessary (you may assume that this numbers won't be altered).
you MAY NOT enter a number as '123456' but rather 123,456
standard code-golf rules apply.

Test cases:

Input: ['1.5M', '77.6k', '123,456,789']         Output: ['1,500,000', '77,600', '123.4M']
Input: ['3,000,000,000', '581k', '2b']          Output: ['3B', '581,000', '2,000,000,000']
Input: ['0.1k']                                 Output: ['100']
Input: ['888', '33']                            Output: ['0.888k', '0.033k']

Clarifications:

for numbers < 1000 after the decimal point in abbreviation output you should have as many digits as required to get the correct result. (e.g: 2 -> will become 0.002k) - that means 3 decimals at most; for numbers > 1000 you can have a maximum of 1 decimal.
the abbreviation may be in both lower or upper case
I removed the built-ins restriction as suggested in the comments

The shortest code in bytes wins!

PHP, 234 224 213 201 205 bytes
for(;$x=$argv[++$n];){$y=str_replace(",","",$x)/1e3;for($i=0;$y>999;$i++)$y=($y|0)/1e3;echo(A<$c=substr($x,strlen($x)-1))?number_format($x*[k=>1e3,m=>1e6,b=>1e9][$c]):($i?($y*10|0)/10:$y).kmb[$i]," ";}

6 bytes saved by insertusernamehere, 4 bytes inspired by that.

takes input from command line arguments, prints results space-separated with a trailing separator
expects lower case abbreviation
run with -r

-2 bytes if underscore as separator is ok: Replace " " with _.
-1 byte if correct rounding is ok: Replace ($y*10|0)/10 with round($y,1).
-17 bytes for PHP 7.1: Replace substr($x,strlen($x)-1) with $x[-1].

80 (63) bytes for expanding one argument only:
<?=number_format(($x=$argv[1])*[K=>1e3,M=>1e6,B=>1e9][substr($x,strlen($x)-1)]);

save to file, then execute (or replace <?= with echo +space and run with -r.


Proper Divisor mash-up A proper divisor is a divisor of a number n, which is not n itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6.
You will be given an integer x, x ≥ 2, x ≤ 1000. Your task is to sum all the highest proper divisors of the integers from 2 to x (inclusive) (OEIS A280050).
Example (with x = 6):

Find all the integers between 2 and 6 (inclusive): 2,3,4,5,6.

Get the proper divisors of all of them, and pick the highest ones from each number:

2 -> 1
3 -> 1
4 -> 1, 2
5 -> 1
6 -> 1, 2, 3.

Sum the highest proper divisors: 1 + 1 + 2 + 1 + 3 = 8.

The final result is 8.

Test Cases

Input  |  Output
-------+---------
       |
 2     | 1
 4     | 4
 6     | 8
 8     | 13
 15    | 41
 37    | 229
 100   | 1690
 1000  | 165279

Rules

Default Loopholes apply.

You can take input and provide output by any standard method.

This is code-golf, the shortest valid submission in each language wins! Have Fun!

Oasis, 4 bytes
Code:
nj+U

Try it online!
Explanation:
Extended version:
nj+00

    0   = a(0)
   0    = a(1)

a(n) =

n       # Push n
 j      # Get the largest divisor under n
  +     # Add to a(n - 1)


Tips for golfing in Clean What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean.

If you've never heard of Clean, you can find out more here.
Or, you can join the chat room.

Avoid import StdEnv when possible

To access built-in functions, even seemingly basic ones like (==) or map, an import statement is needed, usually import StdEnv because it imports the most common modules like StdInt, StdBool and so on (see here for more info on StdEnv).

However it can be possible to avoid this import for some challenges and just use the core language features like list comprehensions and pattern matching.

For example, instead of

import StdEnv
map f list

one can write

[f x\\x<-list]

List of alternatives:

Some functions or function invocations that need import StdEnv, an alternative that does not need the import and a rough estimate of bytes saved.

hd -> (\[h:_]=h), ~6 bytes
tl -> (\[_:t]=t), ~6 bytes
map f list -> [f x\\x<-list], ~10 bytes
filter p list -> [x\\x<-list|p x], ~11 bytes
(&&) -> %a b|a=b=a;%, ~6 bytes
(||) -> %a b|a=a=b;%, ~6 bytes
not -> %a|a=False=True;%, ~1 byte
and -> %[a:r]|a= %r=a;%_=True, ~0 bytes
or -> %[a:r]|a=a= %r;%_=False, ~0 bytes

The last few are unlikely to actually save bytes, because a direct replacement yields more bytes than the import, but it might be possible in cases where the recursion over the list is needed anyway.

This tip has successfully been used here.


Targeted duplicate removal The task
In this challenge, you are given a number and a list.
Your task is to remove from the list all occurrences of the given number except the first (leftmost) one, and output the resulting list.
The other elements of the list should be left intact.

The number will be a positive integer below 1000, and the list will only contain positive integers below 1000.
The list is not guaranteed to contain any occurrences of the given number. It may even be empty. In these cases you should output the list as-is.
Input and output formats are flexible within reason. You can output by modifying the list in place.
The lowest byte count wins.

Test cases
5 [] -> []
5 [5] -> [5]
5 [5,5] -> [5]
10 [5,5] -> [5,5]
10 [5,5,10,10,5,5,10,10] -> [5,5,10,5,5]
2 [1,2,3,1,2,3,1,2,3] -> [1,2,3,1,3,1,3]
7 [9,8,7,6,5] -> [9,8,7,6,5]
7 [7,7,7,7,7,7,7,3,7,7,7,7,7,7,3,7,1,7,3] -> [7,3,3,1,3]
432 [432,567,100,432,100] -> [432,567,100,100]

Husk, 5 4 bytes
üoEė

Try it online!

Saved 1 byte thanks to Razetime
Saved 2 bytes thanks to Jo King

Thanks to Razetime for suggesting ü and Jo King for letting me know I could leave the superscript arguments out, saving me 2 bytes. It removes duplicates with a custom predicate that makes sure both arguments are equal to the number to be removed.
Explanation:
üoEė
ü     Remove duplicates by binary function (implicit second argument)
 o    Compose 2 functions
   ė  Make a list of 3 elements (first element is implicitly added)
  E   Are they all equal?


The game of Sevens! Who said what? The game of Sevens is played as follows: n players sit in a circle, and start counting up from 1, passing to the left (or from player A to player B).

When a number p that has a 7 in it OR is divisible by 7 is reached, then the player who spoke the number p-1, after the next player says p, must say p+1 and the order of people speaking reverses. For example, if player B speaks 6, player C says 7, B says 8, and player A says 9.

Note: For those who want to play in real life, if a person forgets a number (or in the version where sevens are not said, accidentally says a seven), they are eliminated from the circle, but we will omit this detail from this challenge.

The challenge itself is to print which numbers each player should say in a perfect game of Sevens up to an input m for an input n players.

As an example, where five people, A, B, C, D, and E, are to play till they reach 30. They play in this manner

A: 1 6 8 13    15 19       23    30
B: 2 7*  12    16 18       24
C: 3     11    17*         25
D: 4     10          21*   26 28*
E: 5      9 14*      20 22 27*29

where sevens are marked with *. Note that at 27 and 28, we're reversing twice, and play continues "as normal" from D to E.

Please note that the output does not have to be in the above format. I simply printed it that way for some clarity.

Rules

The input is two integers in any order, m representing the last number to say, n representing the number of players.
The output can be several arrays or several strings, one for each player. If you use strings, you do not have to use separators (though, if you could add some in your code tests, we would appreciate the readability). If you can actually print them in a circle somehow, that is acceptable as well, and it would be pretty cool too.
The output does not have to designate which players are which (it's fairly obvious that the first player is the one who says 1), though if the output isn't sorted for whatever reason, you should make clear which player is speaking which set of numbers. Omitting players who do not say anything is also allowed if you make it clear which players are speaking. I will add some more examples of possible outputs below.
This is code golf, so the smallest number of bytes wins.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Examples

>>> sevens_string(30, 5, " ")
'1 6 8 13 15 19 23 30'
'2 7 12 16 18 24'
'3 11 17 25'
'4 10 21 26 28'
'5 9 14 20 22 27 29'
>>> sevens_string(42, 5)
'16813151923303539'
'27121618243140'
'31117253241'
'410212628333742'
'591420222729343638'
>>> sevens_array(20, 3)
[1, 4, 7, 10, 13, 15, 19]
[2, 5, 9, 12, 16, 18]
[3, 6, 8, 11, 14, 17, 20]
>>> sevens_array(18, 10)
[1, 13, 15]
[2, 12, 16, 18]
[3, 11, 17]
[4, 10]
[5, 9]
[6, 8]
[7]
[]
[]
[14]


Falsify brief truths Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.
Input, output
A list; any usual format (e.g., a delimited list as a string).
Details
True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).
If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.
Examples
input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0

(directly from https://stackoverflow.com/q/37447114)

Jelly, 8 bytes

ṣ0¬¬M¦j0

Try it online! or verify all test cases.

How it works

ṣ0¬¬M¦j0  Main link. Argument: A (list of Booleans)

ṣ0        Split at zeroes. This leaves a 2D list of ones.
  ¬       Negate each 1, replacing it with 0.
     ¦    Conditional application:
    M       Yield all maximal indices.
            In lexicographical list comparison, a shorter list of zeroes is less
            than a longer one, so this identifies the longest runs.
   ¬        Negate the items in those lists, changing zeroes back to ones.
      j0  Join, separating by single zeroes.


Count the lucky tickets within the given range In Russia we have something like a tradition: we like to look for lucky tickets.

Here's what a regular ticket looks like:

As you can see, the ticket has a six-digit number.

A six-digit number is considered lucky if the sum of the first three digits is equal to the sum of the last three.

The number on the photo is not lucky:

038937
038 937
0 + 3 + 8 = 11
9 + 3 + 7 = 19
11 != 19

Challenge

Given the limits of a range (inclusive), return the number of lucky ticket numbers contained within it.

Parameters

Input: 2 integers: the first and last integers in the range
The inputs will be between 0 and 999999 inclusive
Output: 1 integer: how many lucky numbers are in the range
You may take the inputs and return the output in any acceptable format
Assume leading zeros for numbers less than 100000.

Examples

0, 1 => 1
100000, 200000 => 5280
123456, 654321 => 31607
0, 999999 => 55252

This is code-golf so the shortest answer in bytes in every language wins.

Update: here's the lucky one

05AB1E, 8 (or 10?) 11 (or 13?) bytes
Ÿʒ₄n+¦S3ôOË

Try it online or verify some more test cases.
NOTE: In 05AB1E strings and integers are interchangeable, so the output numbers doesn't contain leading zeroes. This could however be fixed with 1 additional byte (12 bytes):
Ÿ₄n+€¦ʒS3ôOË

Try it online or verify some more test cases.
+3 bytes to bug-fix numbers with a length of 3 or less (range [000000, 000999]).
Explanation:

Ÿ          # Create an inclusive (on both sides) range from the two inputs
           #  i.e. 038920 and 038910 →
           #   [38910,38911,38912,38913,38914,38915,38916,38917,38918,38919,38920]
 ʒ         # Filter this list by:
  ₄n+      #  Add 1,000,000 to the number
     |     #  And remove the leading 1
           #   i.e. 38910 → 1038910 → '038910'
  S        #  Transform it to a list of digits
           #   i.e. '038910' → ['0','3','8','9','1','0']
   3ô      #  Split it into chunks of length 3
           #   i.e. ['0','3','8','9','1','0'] → [['0','3','8'],['9','1','0']]
     O     #  Sum the digits in both parts
           #   i.e. [['0','3','8'],['9','1','0']] → [11,10]
      Ë    #  Check if they are equal (if they are, they remain in the filtered list)
           #   i.e. [11,10] → 0

EDIT: Seems I (and most other answers) slightly misread the challenge and the amount of numbers is being asked instead of the numbers themselves within the range. In that case a trailing }g can be added (close the filter; and get the amount of numbers left in the filtered list), so it's 10 13 bytes instead:
Ÿʒ₄n+¦S3ôOË}g

Try it online or verify some more test cases.


Count up by Syllables Backstory

I've always found it quite annoying how some numbers in English don't have the same number of syllables even though they have the same number of digits. Example: seven has 2 syllables whereas all of the other digits have one (other than zero).

So, when I'm counting in time to something (like a drill cadence in cadets or in the military), it doesn't sound as nice because you have a random extra syllable.

But I appear to have found a solution to this!

Instead of counting the regular way, we omit the number eight. That way, the second syllable of seven carries into where eight would have been. So, we get the following:

1     2     3     4     5     6     7     8     9     10
one   two   three four  five  six   se   -  ven nine  ten

But, it's hard to count this way for higher numbers, so I need your help to make a program to help me figure out which numbers to count!

Challenge Details

Input

Input will be given as a single positive integer. For the purposes of this challenge, you may assume that all numbers are less than or equal to 999 999 999 999 999 (1 quadrillion - 1) This is because "quadrillion" has a different number of syllables than "million", "billion", and "trillion", and I needed to specify an upper bound somewhere. Since as @HelkaHomba pointed out most languages have a cap at 2^32 which is somewhere around 4 billion, you can use your language's integer bound as the limit (this must be at least 1 million to be considered valid).

Output

Output will be given as a list of integers (to be specified below). The exact formatting will not be specified, but as long as it is easy to see what the list is and it does not contain arbitrary numbers everywhere, it is pretty flexible.

What's in the list

Pretty much, starting from i = 1, append i to the list. Then, take the number of syllables in i (let this be s) and omit the next s - 1 numbers. Keep doing this until i > n where n is the input.

For the purposes of this challenge, assume that the word and is never present (so 101 is one hundred one).

Test Cases

Input -> Output
10 -> 1 2 3 4 5 6 7 9 10
7 -> 1 2 3 4 5 6 7
8 -> 1 2 3 4 5 6 7
25 -> 1 2 3 4 5 6 7 9 10 11 14 16 18 20 22 25

Additionally, since I need to be able to carry this around on a cue card when counting things in time, your program needs to be as short as possible (in bytes)!

Mathematica, 117 bytes

For[t=1,t<=#,t+=Length[Join@@(#~WordData~"Hyphenation"&/@StringSplit[Echo@t~IntegerName~"Words",{"‐",", "," "}])]]&

Pure function taking a nonnegative integer as input; it echoes the appropriate integers to the standard output one at a time.

There might well be a shorter implementation in Mathematica, but this is the lazy one  :)  t~IntegerName~"Words" gives the English name of the integer t; then StringSplit[...,{"‐",", "," "}] divides this name into a list of individual words. (Mathematically annoyingly uses the 3-byte character ‐ (U+2010) for the hyphen in names of integers.) #~WordData~"Hyphenation"&/@ splits each of those words into a list of its syllables, and Length[Join@@(...)] counts these syllables.

Thus the function, after initializing t=1, loops as long as t doesn't exceed the input; each time, it prints t and then augments it by the number of syllables in the English name of t. In principle, this algorithm works up to 1036–1, at which point the hyphenation dictionary doesn't have an entry for "undecillion".


Print this maximally long URL Task

This one is simple.  We want to compress a URL, but don't trust URL shorteners.

Write a program that prints to stdout (or a 0-argument function that returns) the following, working URL:

http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.oo.pp.qqq.rrrr.ssssss.tttttttt.uuuuuuuuuuu.vvvvvvvvvvvvvvv.wwwwwwwwwwwwwwwwwwwwww.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.me

Code golf, standard rules.

You may output uppercase or lowercase.

Leading or trailing whitespace is ok.

Context

Explanation taken from the website:

  The domain is created to reach the maximum number of allowed characters (255 (really 253)) with an exponential curve in the length of the letters as you proceed through the alphabet. The formula used is "1 + 62 * (10/7)^(x-26)". To help illustrate this curve, reference the distribution on this spreadsheet. It's colorful because I like colors and wanted to do a progressive "rainbow" animation in CSS3.

Python 3, 86 \$\cdots\$ 81 77 bytes

Saved 3 bytes thanks to mypetlion!!!
Saved 4 bytes thanks to Shieru Asakoto!!!

print(f"http://{'.'.join(chr(i+97)*int(1+.7**-i/120)for i in range(26))}.me")

Try it online!

Uses Shieru Asakoto's 0-based formula.


Jolly Jumper Sequence A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.

So the sequence [4,1,2,4] has absolute differences [3,1,2] which is equivalent to the set [1,2,3] (1 to n-1 where n is the length of original sequence) so it is therefore a jolly jumper.

Sequences have length n>0.

Assume n=1 is a jolly jumper.

Easy mode: Don't worry about stdin/stdout. Just a function that accepts arguments however and returns something that indicates jolly or not

Hard mode: Input on stdin (space separated), and output is "Jolly" / "Not jolly". Capitalization matters.

This is code golf.

EDIT: Sequences can contain negative integers and input on stdin is space separated.

$ jolly 2 -1 0 2
Jolly

$ jolly 19 22 24 25
Jolly

$ jolly 19 22 24 21
Not jolly

Haskell
Easy 4 characters
Returns a list of jolly integers if and only if a list of jolly integers is given as input. This is legal based on "Just a function that accepts arguments however and returns something that indicates jolly or not".
j=id

Alternative easy solution with 61 characters:
Takes in a list and returns the empty list if the sequence is jolly.
import List
j n=zipWith(\x->abs.(x-))n(tail n)\\[1..length n]


Test a polyomino against Conway criterion Background

Conway criterion is a method to test if a given polygon can tile (i.e. cover without overlapping) an infinite plane. It states that a polygon can tile the plane if the following conditions are met:

The given polygon does not have any holes in it.
It is possible to choose six consecutive1 points \$A,B,C,D,E,F\$ on its perimeter, so that

The boundary part of \$A\$ to \$B\$ must be equal to that of \$E\$ to \$D\$ in its size, shape, and orientation;
Each of the boundary parts \$BC\$, \$CD\$, \$EF\$, and \$FA\$ must have 180-degrees rotational symmetry; and
At least 3 out of the six points must be distinct from each other.

1) By consecutive, the six points must appear in the given order if you walk around the shape in one direction (either CW (clockwise) or CCW (counter-clockwise)). A boundary part between two consecutive points may contain zero, one, or multiple line segments.

If all the conditions are met, the given shape can tile the plane using only translation and 180-degree rotation. However, failing the condition doesn't mean the piece can't tile the plane. This happens when the tiling involves 90-degree rotations and/or reflections, or the tiling does not use 180-degree rotation at all.

The following is one example that satisfies Conway criterion:

with its plane tiling:

Task

Given a polyomino without holes as input, determine if it satisfies Conway criterion.

You can take the input in any sensible ways, including but not limited to

a 2D grid;
a list of coordinates of the cells;
a list of coordinates on the boundary (including non-vertices or not);
a list of steps starting from some point on the perimeter in NSEW notation, ...

If you use the input format that describes the perimeter (e.g. the last two formats above), you can assume that the input (the sequence of points or steps on the perimeter) is given in certain direction (either CW or CCW), but you cannot assume that it starts at any certain position.

Standard code-golf rules apply. The shortest code in bytes wins.

Test cases

The test cases are given as 2D grid, where O is a part of the polyomino and . is an empty space.

True

the example above
OO........
OOOOOOOOOO
OOOOOOOOOO
....OOOOOO
....OOOOOO
....OOOOOO
....OOOOOO
....OOOOOO

the F pentomino
.OO
OO.
.O.
one possible set of points:
  A---E=F
  |   |
+-+ +-+
|   |
B-+ D
  | |
  +-C

OOO.
O.OO
E---D-C
|     |
F +-+ +-+
| | |   |
+-+ A---B

a nonomino that can tile with or without 180 degrees rotation
.O..
.OOO
OOO.
.OO.
.O..

can you spot ABCDEF here? (hint: two points out of ABCDEF are not on the vertices)
OOOO...
.OOOO..
OO.O...
O..OOOO

how about this? (hint: AB and DE are zero-length)
...OOOO.
OO.OO...
O..OOO..
OOOO....
..OOOOOO
..OO....

False

can tile the plane, but needs 90 deg rotation
.OOO.
OO.OO

cannot tile the plane at all
OOOO
O...
O.OO
OOO.

can tile with only translation, but not with 180 degrees rotation
...O
.OOO
OOO.
..OO

Python 3.8 (pre-release), 371 ... 338 336 bytes

Takes as input a list of complex numbers, denoting the boundary coordinates in counterclockwise order.

-9 bytes thanks to @ovs
-2 bytes thanks to @Bubbler

import itertools as Z
def f(P):Q=P*2;I=Q.index;L=len;return any(L({*map(complex.__sub__,T:=(J:=lambda x,y:Q[(j:=I(p[x])):I(p[y],j)+1])(0,1),U:=J(3,4)[::-1])})<2<L({*p})and(L(T)==L(U))&all((B:=J(a,-~a%6))==[B[L(B)//2]-E+B[~L(B)//2]for E in B][::-1]for a in[1,2,4,5])for S in zip(*[Q[I(i):]for i in P])for p in eval('Z.'+dir(Z)[11])(S,6))

Try it online!


Generate the galaxies of elite Introduction

Elite was the first space trading video game, written and developed by David Braben and Ian Bell and published by Acornsoft for the BBC Micro and Acorn Electron computers in in September of 1984.

The Elite universe contains eight galaxies, each with 256 planets to explore. Due to the limited capabilities of 8-bit computers at the time, these worlds were procedurally generated. A single seed number is run through a fixed algorithm the appropriate number of times and creates a sequence of numbers determining each planet's complete composition (position in the galaxy, prices of commodities, and name and local details; text strings are chosen numerically from a lookup table and assembled to produce unique descriptions, such as a planet with "carnivorous arts graduates"). This means that no extra memory is needed to store the characteristics of each planet, yet each is unique and has fixed properties. Read more about this here: Elite random number generator

Challenge

Like the Elite game did, write a script which can procedurally generate a list of 8 galaxies each of which contains 256 planets. (You need to generate a total of 2048 planet names).

The 8 galaxy names can be defined before hand or procedurally generated. This is your choice.

Output

Please post your script here and perhaps use paste bin or an equivalent to host your output.

Rules

At a minimum your script must generate 2048 planet names and 8 galaxy names.
Each 256 planets should be nested within the array of a galaxy.
This is a popularity-contest! Try to make your code clever, interesting, slick or retro.
This is not code-golf. As such, readable code is appreciated. Still, try to keep size low remember the original programmers only had 32Kb or memory to work within for the whole game.
Repeats of planet names of more than 3 in a row is not allowed and a single planet name must not appear more than 5 times in the total 2048 planets.
Input is optional and not required.
Standard Loopholes apply.

How to get kudos

If your script also generates economy, government, tech level, population, gross productivity, average radius and comments about each planet.
If your planet names look organic (doesn't have to be in English) but for example 'Lave' looks better and is easier to read than 'Esdqzfjp'.
If your planet names don't contain profanity such "Arse". I only mention this because the original programmers had to do this.
If you do this challenge in BBC Basic.


Print This Question ↓ The basic idea of a kolmogorov-complexity challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from Borromean Rings to The Gettysburg Address.
##Your Task
This question is similar, except that it requires printing of a special text - the text of this question. Specifically, the very Markdown code that I am typing right now.
To prevent an infinite recursion in the question, the exact text you have to print can be found here.
##Clarifications

You are not allowed to use any external sources like the internet.
This means that the purpose of this question is not to download this question text and parse it, but instead to store it in you program.
This is code-golf, so shortest code in bytes wins!


Verifying a horizontal ASCII pet snake Recently there have been a couple of ASCII pet snake challenges (e.g. here)
            0 0
  0        0 0 000
00 0     00       000 0      0
    000 0            0 0   00
       0                000

This challenge is to take a randomly generated horizontal pet snake (height of five lines, length of 30), and verify that :

Each column has only one 0
Each 0 is "connected" to the 0 before and after it (vertically spaced by 0 or 1 line only)

Final output can be true or 1 if the snake is valid, or false or 0 if the snake is invalid
Edit—Clarification
Assume the input:

Is a string
Contains only ' ', '0', and '\n'
Has exactly 30 characters each line
Has exactly 5 lines

I.e. verify whether the snake is connected, and that there are no stray chars. No need to validate the "canvas" that the snake is printed on.

JavaScript (ES2018), 62 54 bytes

s=>!/0(.{30}|.{60,62}(.{31})*)0|( .{30}){4} /s.test(s)

Input is a single string:

without trailing new line
contain only space, '0', and '\n'
30 characters each line, 5 lines, 154 character in total

Flag s means a dot match anything (including '\n'). This feature currently supported by Chrome 63+, Opera 50+, Safari 11.1+, based on compat-table. You may test this function with these supported browser. You will get an exception when loading the page if your browser do not support this feature.

How it works:

No column with no 0:

do not match /( .{30}){4} /

No two 0s in one column:

do not match /0.{30}(.{31})*0/

No 0 not connect to its neighbors:

do not match /0.{60}(.{31})*0/, /0.{62}(.{31})*0/

Merge all these regex, and you will finally got this one.

f =

s=>!/0(.{30}|.{60,62}(.{31})*)0|( .{30}){4} /s.test(s)
<textarea id=i style="width:100%;height:100px">            0 0
  0        0 0 000
00 0     00       000 0      0
    000 0            0 0   00
       0                000   </textarea>
<button onclick="o.value=f(i.value.slice(0,154))">Validate</button>
Result: <output id=o></output>

Thanks to Martin Ender point out that do a single ! operator may save 8 bytes.


The smallest Chess arbiter Write a program, which, upon gazing at a chess table, can say whether there is a check or a checkmate.

Input: a chess table in text form, the last line of the input being the first rank (the starting line of White)

The starting position in this input would look like this (space is an empty square, capital letters are White): why aren't the spaces displayed here?

rnbqkbnr
pppppppp

PPPPPPPP
RNBQKBNR

The program should print one or more of the following (without quotes, of course), depending on the situation:

"The White King is in check!" (if already in checkmate, don't display this!)
"The Black King is in check!" (if already in checkmate, don't display this!)
"The White King is in checkmate!"
"The Black King is in checkmate!"
"White is in stalemate!" (There would be a stalemate if White moved - optional)
"Black is in stalemate!" (There would be a stalemate if Black moved - optional)
"Both kings are safe for now." (if none of the above apply)

The input is guaranteed to be correct and be a legal chess position (no two kings of the same color, no two kings in check, etc.).

Score:

The score is the character count, lowest wins, not sooner than 10 days after the first valid answer. If the optional stalemate evaluation is implemented, the size will be decreased by 20% (for this situation, assume en-passant cannot be performed).


Lumberjaxe Code Golf Tom the lumberjack is going to do his daily routine: chop trees. After all, it's his job to do so. His boss has ordered him to chop trees in a straight line marked with a special tape to identify them, so he knows which trees he is going to have to chop. However, Tom quickly realizes he has a problem. His axe will only chop so much wood before breaking, and he forgot to bring a spare with him. Plus, the trees are different sizes. A small tree, marked with an i, will take 2 swings of the axe to chop, and a large tree, marked with an | will take 4 swings. Can Tom chop all of the assigned trees?
The Objective
Given two inputs, a string that determines the sequence of small and large trees and an integer that determines the durability of the axe, create a program that determines not only if Tom's axe will break or not, but also determine how many of each tree type he chopped down. It's code-golf, so the shortest code in bytes wins!
Example
Input 1 example:i||iii| This input string determines the sequence of trees.
Input 2 example:50 This input integer determines the durability of the axe.
The outputs for this particular example will be a boolean and a string as follows(True means Tom's axe broke):
False
4 small, 3 big

JavaScript (Node.js), 52 bytes
Takes input as (b)(n), where b is a Buffer (using the characters described in the challenge) and n is the durability of the axe.
Returns a Boolean value and 2 integers as [ broken, [ small, big ]].
b=>n=>[b.some(c=>(n-=6&c+1)<0||!++a[c%3],a=[0,0]),a]

Try it online!
How?
Given an ASCII code c, we use 6 & (c + 1) to get the number of swings needed to chop the tree, and c % 3 to get an index into the tree-counting array a[] (0 for small, 1 for big).
 char. | c = ASCII code | 6 & (c + 1) | c % 3
-------+----------------+-------------+-------
  'i'  |       105      |      2      |   0
  '|'  |       124      |      4      |   1