오늘은 YOLD


15

Discordian 달력은 Discordians에서 사용되는 다른 달력입니다.

  1. 불화의 해는 5 개의 계절이 있으며, 각각 73 일 지속됩니다 : 혼돈, 불화, 혼란, 관료주의, 여파.
  2. Discordian week는 Sweetmorn, Boomtime, Pungenday, Prickle-Prickle 및 Setting Orange의 5 일입니다. 매년 Sweetmorn (및 카오스)이 시작됩니다.
  3. 모든 F의 ourth 년도 (happe N은 그렉과 정렬 s 내지 o를 RIAN 도약 터무니 R 엑스트라, S) (D)의 바깥가 카오스 59라는 카오스 60 사이에 삽입 성 TIB 날 . 그것은 Discordian week의 바깥에 있습니다. 즉, St. Tib 's Day 다음 날은 Prickle-Prickle 전날 주황색으로 설정됩니다.
  4. 그레고리력과 Discordian 달력이 줄 지어 있습니다. 둘 다 같은 날에 시작되는데, 그레고리력에서는 1 월 1 일이고, 디스코 디온에서는 카오스 1입니다.
  5. 불화의 성모 (YOLD 1)의 첫해는 그레고리력에서 BC 1166 년으로 올해 (2017 AD)는 YOLD 3183입니다.
  6. Discordian 달력에는 휴일도 있지만이 도전에는 중요하지 않으므로 달력이나 달력에 관한 내용을 출력해서는 안됩니다.

오늘 날짜를 출력하거나 리턴하는 프로그램 또는 함수를 작성하십시오 (실행시).

Today is Boomtime, the 16th day of Confusion in the YOLD 3183

형식은입니다 "Today is $day_of_the_week, the $ordinal day of $season in the YOLD $year". 여기서 $ day_of_the_week는 대문자 (제목) 요일이며 $ ordinal은 서수 (1, 2, 3, 4, ...)로 계절의 요일입니다. $ season은 대문자입니다. (title-case) 시즌이며 $ year는 연도입니다.

프로그램 또는 함수가 St. Tib 's Day에서 실행되면 대신 출력하거나 반환해야합니다 "Today is St. Tib's Day in the YOLD $year".

규칙 :

  • 표준 허점이 적용됩니다.
  • 선택한 언어로 현재 날짜를 얻을 수있는 방법이없는 경우 현재 그레고리력 날짜를 적절한 형식의 입력으로 사용할 수도 있습니다.
  • 이것은 가장 짧은 코드 (언어 당)가이기는 입니다.
  • 후행 공백은 괜찮습니다.
  • 총액 사항.
  • ddate어떤 식 으로든 전화 가 금지됩니다
  • 프로그램은 3067 ~ 3265 YOLD (1901 ~ 2099 AD)에서 작동해야합니다.이 범위를 벗어나면 잘못된 값을 줄 수 있습니다

또한보십시오:


4

1
오늘은 혼란의 16 일이라고 생각합니까? 예제는 어떤 날짜를 나타 냅니까?
user202729


1
@ user202729 예.이 예의 날짜는 처음에 도전 과제를 작성한 시점부터입니다. 오늘 날짜를 표시하도록 업데이트합니다. 실제로 16 일 혼란의 날입니다.
L3via6

1
@ L3 그러한 경우에 (대형 네이티브 언어를 사용하는 사람들을 위해) a) 그레고리 안 캘에서 몇 년 동안 도약하지 않은 세기의 전환을 화합 캘리브레이션의 "4 년마다"처리하는 방법 "그레고리 언과 일치한다"b) 그레고리 안 종자를 소개하기 전에 몇 년을 어떻게 다루어야 하는가. 현재 사양에 따라 올바르게 정의 된 최대 범위를 제안하고있었습니다. 이를 거부하면 프로그램이 해당 범위 밖에서 수행해야 할 작업을 정의해야합니다. 또한 기존 답변을 무효화하지 않아야합니다. en.wikipedia.org/wiki/Gregorian_calendar
Level River St

답변:


5

Mathematica, 403401 바이트

바이트 수를 세는 버전 : (제거 된 공백과 줄 바꿈-불행히도이 부분은 매우 어렵습니다)

"Setting Orange"["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle"][[#~Mod~5]]<>", the "<>SpokenString@p[[Mod[#,73,1]]]~StringExtract~2<>" day of "<>{"Chaos","Discord","Confusion","Bureaucracy","The Aftermath"}[[⌈#/73⌉]]&;
Row@{"Today is ",#2," in the YOLD ",1166+#}&[#,If[4∣#,If[#2>60,%[#2-1],If[#2<60,%@#2,"St.Tib's Day"]],%@#2]]&@@FromDigits/@DateString@"ISOOrdinalDate"~StringSplit~"-"

읽을 버전 :

"Setting Orange"["Sweetmorn", "Boomtime", "Pungenday", 
     "Prickle-Prickle"][[#~Mod~5]] <>
   ", the " <>
   SpokenString@p[[Mod[#, 73, 1]]]~StringExtract~2 <>
   " day of " <>
   {"Chaos", "Discord", "Confusion", "Bureaucracy", 
     "The Aftermath"}[[Ceiling[#/73]]] &;
Row@{
      "Today is ",
      #2,
      " in the YOLD ",
      1166 + #
      } &[#,
   If[4 ∣ #,
    If[#2 > 60, %[#2 - 1],
     If[#2 < 60, %@#2, "St.Tib's Day"]
     ], %@#2
    ]] & @@ FromDigits /@ DateString@"ISOOrdinalDate"~StringSplit~"-"

그 대답은 대체하여, 임의의 날짜를 테스트 할 수 DateString@"ISOOrdinalDate"의해 DateString[{year,month,day},"ISOOrdinalDate"]year, monthday숫자로 대체.


Mathematica 코드를 어떻게 테스트 할 수 있습니까?
L3viathan

6
"아직 내장이 없습니까?"
Jonathan Allan

4

파이썬 2, 423 바이트

짧은 버전 :

import time
y,d=time.gmtime()[0::7]
t="Today is "
o=" in the YOLD "+`y+1166`
if y%4<1 and d>59:
 if d==60:print"%sSt. Tib's Day%s%d"%(t,o);quit()
 d-=1
s,e=divmod(d-1,73)
print t+["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"][(d-1)%5]+", the %d%s day of %s"%(e+1,'tsnrthtddh'[min(e*(e/10-1 and 1)%10,4)::5],["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"][s]+o)

더 길고 읽기 쉬운 형식 :

import time

# now = time.strptime("2017.06.11", "%Y.%m.%d")  # for testing
now = time.gmtime()
year, day_of_year = now[0::7]
leapyear = year % 4 < 1
today = "Today is "
yold = " in the YOLD " + `y+1166`

if leapyear and day_of_year>59:
    if day_of_year==60:
        print "%sSt. Tib's Day%s%d"% (today, yold)
        quit()  # dirty, but ... hey.
    day_of_year -= 1
season, day = divmod(day_of_year-1,73)

print today + \
    ["Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"][(day_of_year-1)%5] + \
    ", the %d%s day of %s" % (
        day+1,
        'tsnrthtddh'[min(day*(day/10-1 and 1)%10,4)::5],
        ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"][season] + yold
    )

업데이트 : 위대한 @Neil 및 @EriktheOutgolfer의 도움으로 수정되었습니다. 그러나 @Jonathans의 대답은 훨씬 짧습니다.


2
프로그래밍 퍼즐 및 코드 골프에 오신 것을 환영합니다!
Dada

3
이것이 21, 22, 23, 73에 올바른 접미사를 생성합니까? @ L3viathan y%4<1은 작동하지만 그렇게 생각하지 않습니다 1-y%4.
Neil


@EriktheOutgolfer e변수 를 제거하여 다른 4 바이트를 저장할 수 없습니까 ?
Neil

PPCG에 오신 것을 환영합니다! 좋은 첫 번째 게시물. 나는 여기 당신에게 조금을 제공하기 위해 계획하고, 거기에 눈치와 접미사의 문제를 해결하고 내가 그래서 난 내 자신의 버전을 제출 결국 생각했던 것보다 더 많은 코드를 golfed하지만.
Jonathan Allan

2

파이썬 2 , 346 바이트

참고 : 이것은 jammon의 대답 의 골프 (및 수정)입니다. 원래 의견을 제출한다고 생각했지만 결국에는 약간 바뀌 었습니다 (플러스와 접미사가 수정되었습니다).

import time
y,d=time.gmtime()[::7]
t="Today is %s in the YOLD "+`y+1166`
r=y%4<1<59<d
d-=r+1
e=d%73
print t%[["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"][d%5]+", the %d%s day of "%(e+1,'snrttddh'[min(e%10+3*(e/9==1),3)::4])+["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"][d/73],"St. Tib's Day"][(r*d)==58]

온라인으로 사용해보십시오! 또는 하드 코딩 된 테스트 날짜를 참조하십시오.


나는 e%10*(e/9!=1)작품을 추측하지 않습니까?
Neil

아니, 그것은 인쇄 것 11st, 12st그리고 13st(시 e/9제로 곱 것 1이고이 min선택할 것이라고 영)
조나단 앨런

2

자바 스크립트 (ES6) 387 380 바이트

f=(d=new Date(),a=d.getDate()-1,y=d.getFullYear()+1166)=>d.getMonth()?f(d,a+d.getDate(d.setDate(0))):`Today is ${y%4-2|a<59||59-a--?`Sweetmorn,Boomtime,Pungenday,Prickle-Prickle,Setting Orange`.split`,`[a%5]+`, the ${d=a%73+1}${[,`st`,`nd`,`rd`][d-10-(d%=10)&&d]||`th`} day of `+`Chaos,Discord,Confusion,Bureaucracy,The Aftermath`.split`,`[a/73|0]:`St. Tib's Day`} in the YOLD `+y

선택적 날짜 매개 변수를 사용합니다. 언 골프 드 :

function discordian(date) {
    var a = date.getDate();
    while (date.getMonth()) {
        date.setDate(0);
        a += date.getDate();
    }
    if (date.getYear() % 4 == 0) {
        if (a == 60) return "Today is St. Tib's day in the YOLD " + (date.getYear() + 1166);
        if (a > 60) a--;
    }
    var weekday = ['Setting Orange', 'Sweetmorn', 'Boomtime', 'Pungenday', 'Prickle-Prickle'][a % 5];
    var seasonday = (a - 1) % 73 + 1;
    var ordinal = seasonday % 10 == 1 && seasonday != 11 ? 'st' : seasonday % 10 == 2 && seasonday != '12' : 'nd' : seasonday % 10 == 3 && seasonday != '13' ? 'rd' : 'th';
    var season = ['Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath'][Math.floor((a - 1) / 73)];
    return "Today is " + weekday + ", the " + seasonday + ordinal + " day of " + season + " in the YOLD " + (date.getYear() + 1166);
}

1

C #, 392 바이트

using System;s=>{var t=DateTime.Now;int d=t.DayOfYear,y=t.Year,m=d%73;return"Today is "+(DateTime.IsLeapYear(y)&d==60?"St. Tib's Day":"Sweetmorn|Boomtime|Pungenday|Prickle-Prickle|Setting Orange".Split('|')[d%5-1]+", the "+ m+(m<2|m==21|m>30?"st":m==2|m==22?"nd":m==3|m==23?"rd":"th")+" day of "+"Chaos|Discord|Confusion|Bureaucracy|The Aftermath".Split('|')[d/73])+" in the YOLD "+(y+1166);}

풀 / 포맷 버전 :

using System;

class P
{
    static void Main()
    {
        Func<string, string> f = s =>
        {
            var t = DateTime.Now;
            int d = t.DayOfYear, y = t.Year, m = d % 73;

            return "Today is " + (DateTime.IsLeapYear(y) & d == 60
                   ? "St. Tib's Day"
                   : "Sweetmorn|Boomtime|Pungenday|Prickle-Prickle|Setting Orange".Split('|')[d % 5 - 1] +
                     ", the " +
                     m +
                     (m < 2 | m == 21 | m > 30 ? "st" : m == 2 | m == 22 ? "nd" : m == 3 | m == 23 ? "rd" : "th") +
                     " day of " +
                     "Chaos|Discord|Confusion|Bureaucracy|The Aftermath".Split('|')[d / 73])
                   + " in the YOLD " + (y + 1166);
        };

        Console.WriteLine(f(null));

        Console.ReadLine();
    }
}

1

Pyth , 295 바이트

J.d2A<J2Kt+s<+,31 28*2t*3,30 31tH@J2=Y&&!%G4<58K!qH3=N%K73%"Today is %s in the YOLD %d",@,++@c"SweetmornZBoomtimeZPungendayZPrickle-PrickleZSetting Orange"\Z%K5%", the %d%s day of ",+N1@c"stndrdth"2h.mb,3+%NT*3q1/N9@c." yNlSFk.»&ô?Z#u!%ô6'mçM«_ôvëû¹)+¬<"\Z/K73"St. Tib's Day"q*YK59+G1166

참고 : 바이너리가 포함되어 있으므로 여기에서 복사하여 붙여 넣기가 안전하지 않을 수 있습니다. TIO에서 복사하여 붙여 넣기가 작동합니다.

온라인으로 사용해보십시오!

다음 .d2과 같이 시작시 3 개의 튜플 (년, 월, 일) 로 바꾸어 임의의 날짜를 테스트 할 수 있습니다 (2020 2 29).

Pyth가 "일년"을 얻을 수있는 방법이 없기 때문에 약간 성가신 것이므로 직접 계산해야했습니다.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.