34
\$\begingroup\$

You are a space tourist on your way to planet Flooptonia! The flight is going to take another 47,315 years, so to pass the time before you're cryogenically frozen you decide to write a program to help you understand the Flooptonian calendar.

Here is the 208-day long Flooptonian calendar:

Month       Days    Input Range
Qupu        22      [0-22)
Blinkorp    17      [22-39)
Paas        24      [39-63)
Karpasus    17      [63-80)
Floopdoor   1       [80]
Dumaflop    28      [81-109)
Lindilo     32      [109-141)
Fwup        67      [141-208)

Challenge

Your program, given an integer day in the year (range [0-208)) is to output the corresponding day of the month and name of the month (e.g. 13 Dumaflop).

There is an exception, however: Floopdoor a special time for Flooptonians that apparently deserves its own calendar page. For that reason, Floopdoor isn't written with a day (i.e. the output is Floopdoor, not 1 Floopdoor).

Test Cases

0   => 1 Qupu
32  => 11 Blinkorp
62  => 24 Paas
77  => 15 Karpasus
80  => Floopdoor
99  => 19 Dumaflop
128 => 20 Lindilo
207 => 67 Fwup

Rules

  • You must write a complete program.
  • You can assume that the input is always valid.
  • Your output may have a trailing newline but must otherwise be free of any extra characters. The case should also match the provided examples.
  • You may use date/time functions.
  • Code length is to be measured in bytes.
\$\endgroup\$
  • 2
    \$\begingroup\$ Is it "Floopdoor" or "Floopdor"? The first chart has the extra o, but the other instances of the name don't. \$\endgroup\$ – jwodder Jul 24 '15 at 17:11
  • 4
    \$\begingroup\$ So... in 47k years, nothing will change? \$\endgroup\$ – Not that Charles Jul 24 '15 at 19:43
  • 2
    \$\begingroup\$ @NotthatCharles furthermore, if the planet's that far away, won't it be outdated by the time you get it in the first place? \$\endgroup\$ – SuperJedi224 Jul 25 '15 at 0:56
  • 3
    \$\begingroup\$ As if the Gregorian calendar wasn't bad enough. \$\endgroup\$ – Arturo Torres Sánchez Jul 25 '15 at 3:11
  • 3
    \$\begingroup\$ @ArturoTorresSánchez Well at least there is no leap year. But are there any other stories about Flooptonia, or was the entire setting created solely for this specific puzzle? Is Fwup their word for winter? Or should I just get my tail back to Worldbuilding? \$\endgroup\$ – Damian Yerrick Jul 26 '15 at 2:31

21 Answers 21

14
\$\begingroup\$

Pyth - 105 103 90 88 bytes

Uses base conversion. Two simple lookup tables, with one for the names and one for start dates, and a ternary at the end for Floopdoor.

KhfgQhTC,aCM"mQP?'"Zcs@LGjC"îºBüÏl}W\"p%åtml-¢pTÇÉ(°±`"23\c+?nQ80+-hQhKdkreK3

Compresses the string not as base 128, but as base 23. First, it translates it to indices of the alphabet. This required the separator to be c which doesn't appear in any of the month names. Then it encodes that to base ten from a base 23 number (the highest value that appeared was w), then converts to base 256.

The start dates are their unicode codepoints, no base conversion.

K                       K =
 hf                     First that matches the filter
  gQ                    >= Q
   hT                   First element of filter var
  C,                    Zip two sequences
   a       Z            Append 0 (I could save a byte here but don't want to mess with null bytes)
    CM"..."             Map the string to its codepoints
   c          \c        Split by "c"
    s                   Sum by string concatenation
     @LG                Map to location in alphabet
      j     23          Base 10 -> Base 23
      C"..."            Base 256 -> Base 10
+                       String concatenation
 ?nQ80                  Ternary if input != 80
  +-hQhK                Input - start date + 1
  k                     Else empty string
 r  3                   Capitalize first letter
  eK                    Of month name

Try it online here.

Test Suite.

\$\endgroup\$
  • \$\begingroup\$ I'm very new to Pyth, could you break it down? I'd be very grateful. \$\endgroup\$ – Winny Jul 24 '15 at 18:34
  • 1
    \$\begingroup\$ @Winny I will, just wanted to finish the obvious golfs first. All the weird symbols are because I compressed the base 26 symbols (the alphabet) into base 256 to save space. \$\endgroup\$ – Maltysen Jul 24 '15 at 18:37
  • 1
    \$\begingroup\$ @Winny is that enough? Feel free to ping me here/in chat if you have any questions. \$\endgroup\$ – Maltysen Jul 24 '15 at 19:01
19
\$\begingroup\$

Python 3, 159 156 152 151 150 148 bytes

n=int(input())+1
for c,x in zip(b" C","Qupu Blinkorp Paas Karpasus Floopdoor Dumaflop Lindilo Fwup".split()):c>=n>0and print(*[n,x][-c:]);n-=c

The bytes object in the zip contains unprintable characters:

for c,x in zip(b"\x16\x11\x18\x11\x01\x1c C", ...): ...

(Thanks to @xnor for suggesting a for/zip loop for -3 bytes)

\$\endgroup\$
  • 11
    \$\begingroup\$ That moment when a Python answer is ---<s>going neck to neck to</s>--- beating a Pyth answer \$\endgroup\$ – Optimizer Jul 24 '15 at 17:31
  • 1
    \$\begingroup\$ The use of a bytestring is ingenious! \$\endgroup\$ – Winny Jul 24 '15 at 17:32
  • \$\begingroup\$ I feel like it should be possible to iterate over b directly with for instead of while, with something like for c in b"...":i+=n>0;n-=c. \$\endgroup\$ – xnor Jul 24 '15 at 17:39
  • 1
    \$\begingroup\$ Oh, wait, you need the right value of n to stop going down too. Still should be possible with something like x=n>c;n-=c*x;i+=x but don't know if it's worth it. \$\endgroup\$ – xnor Jul 24 '15 at 17:46
13
\$\begingroup\$

Piet 2125 bytes

It's by no means the shortest, but it's pretty and colorful...

Each pixel is placed by myself by hand. To run it go here in FireFox (Chrome won't work) and load it with a codel width of 1 (it'll appear black, don't worry), enter the number and hit the run button!

Small Program: Small Version


Enlarged (Codel width of 10): enter image description here

\$\endgroup\$
  • \$\begingroup\$ Doesn't dead chex add to the byte count? \$\endgroup\$ – Beta Decay Jul 30 '15 at 8:45
  • 1
    \$\begingroup\$ @Beta To be fair the bye count is actually the size of the smaller image on disk, so regardless the byte count is fixed \$\endgroup\$ – DeadChex Jul 30 '15 at 11:42
12
\$\begingroup\$

Pyth 178 156 153 147 bytes

J?<Q22,_1"Qupu"?<Q39,21"Blinkorp"?<Q63,38"Paas"?<Q80,62"Karpasus"?<Q81,k"Floopdoor"?<Q109,80"Dumaflop"?<Q141,108"Lindilo",140"Fwup"?nhJkjd,-QhJeJeJ

Permalink

Second golf ever, any Pyth feedback will be very helpful.

Explanation

J                       (Auto)Assign J a tuple of the first day & month name
 ?<Q22,_1"Qupu"         Recall that Q auto-initialized to raw_input()
 ?<Q39,21"Blinkorp"     ? is ternary
 ?<Q63,38"Paas"         , is a two-pair tuple
 ?<Q80,62"Karpasus"
 ?<Q81,k"Floopdoor"     Special case handled by empty string as first day
 ?<Q109,80"Dumaflop"
 ?<Q141,108"Lindilo"
 ,140"Fwup"             Since input assumed valid, no need to test for Fwup
?nhJk                   Is day not an empty string?
jd,                     join on space
   -QhJ                 Q-(first day or -1 on first month) + 1
   eJ                   The month itself
eJ                      Else print only the month name on Floopdoor
\$\endgroup\$
  • \$\begingroup\$ You should be able to use inline assignment to put the entire J=... into the ternary condition. \$\endgroup\$ – Maltysen Jul 24 '15 at 19:05
7
\$\begingroup\$

CJam, 98 96 93 bytes

0000000: 72 69 63 22 00 16 27 3f 50 51 6d 8d d0 22 66 2d  ric"..'?PQm.."f-
0000010: 5f 7b 30 3c 7d 23 28 5f 40 3d 29 53 40 22 06 32  _{0<}#(_@=)S@".2
0000020: 88 b2 ce d2 87 2f 1e 79 62 1b 7a 11 53 a6 cc 02  ...../.yb.z.S...
0000030: 40 c5 c6 82 d0 dd b7 4b ed ee 1c dc 4f f5 ec 67  @......K....O..g
0000040: 22 32 35 35 62 32 33 62 27 61 66 2b 27 63 2f 3d  "255b23b'af+'c/=
0000050: 5f 2c 39 3d 7b 5c 3f 7d 26 28 65 75 5c           _,9={\?}&(eu\

The above is a reversible hexdump, since the source code contains unprintable characters.

Most unprintable characters are no problem for the online interpreter, but the null byte in the first string is a deal breaker.

At the cost of one byte, we can fix this by adding 1 to the input and 1 to each code point of the first string. You can try this version in the CJam interpreter.

If the permalink doesn't work in your browser, you can copy the code from this paste.

Test cases

$ LANG=en_US
$ xxd -ps -r > flooptonia.cjam <<< 726963220016273f50516d8dd022662d5f7b303c7d23285f403d29534022063288b2ced2872f1e79621b7a1153a6cc0240c5c682d0ddb74bedee1cdc4ff5ec6722323535623233622761662b27632f3d5f2c393d7b5c3f7d262865755c
$ wc -c flooptonia.cjam 
96 flooptonia.cjam
$ for d in 0 32 62 77 80 99 128 207; do cjam flooptonia.cjam <<< $d; echo; done
1 Qupu
11 Blinkorp
24 Paas
15 Karpasus
Floopdoor
19 Dumaflop
20 Lindilo
67 Fwup

How it works

ric     e# Read a Long from STDIN and cast to Character.
"…"     e# Push the string that corresponds to [0 22 39 63 80 81 109 141 208].
f-      e# Subtract each character from the input char.
        e# Character Character - -> Long
_{0<}#  e# Find the index of the first negative integer.
(_      e# Subtract 1 from the index and push a copy.
@=)     e# Select the last non-negative integer from the array and add 1.
S@      e# Push a space and rotate the decremented index on top of it.
"…"     e# Push a string that encodes the months' names.
255b23b e# Convert from base 255 to 23.
'af+    e# Add the resulting digits to the character 'a'.
'c/     e# Split at occurrences of 'c' (used as separator).
=       e# Select the chunk that corresponds to the index.
_,9=    e# Check if its length is 9 (Floopdoor).
{\?}&   e# If so, swap and execute ternary if.
        e# Since the string " " is truthy, S Month Day ? -> Month.
(eu\    e# Shift out the first char, convert it to uppercase and swap.
\$\endgroup\$
5
\$\begingroup\$

SWI-Prolog, 237 232 213 bytes

a(X):-L=[22:"Qupu",39:"Blinkorp",63:"Paas",80:"Karpasus",81:"Floopdoor",109:"Dumaflop",141:"Lindilo",208:"Fwup"],nth1(I,L,A:B),X<A,J is I-1,(nth1(J,L,Z:_),Y=X-Z;Y=X),R is Y+1,(X=80,write(B);writef("%w %w",[R,B])).

Here we use Prolog's backtracking mechanism to repeatedly apply nth1/3 to the list L, to get the first element LastDay+1:MonthName of L for which X < LastDay+1 holds. We then look for the month immediately before this one in the list to evaluate the day of the month.

\$\endgroup\$
5
\$\begingroup\$

Q, 134 146 Bytes

second cut -- program (146 bytes)

v:bin[l:0 22 39 63 80 81 109 141 208;x:(*)"I"$.z.x];1(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v;

first cut -- function (134 bytes)

{v:bin[l:0 22 39 63 80 81 109 141 208;x];(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v}

testing

q){v:bin[l:0 22 39 63 80 81 109 141 208;x];(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v} each 0 32 62 77 80 99 128 207
"1 Qupu"
"11 Blinkorp"
"24 Paas"
"15 Karpasus"
"Floopdoor"
"19 Dumaflop"
"20 Lindilo"
"67 Fwup"
\$\endgroup\$
  • \$\begingroup\$ you're correct -- i edited the answer to make it a full program rather than a function and so that it prints to stdout w/o the quotation marks as per the question rules \$\endgroup\$ – scottstein37 Jul 24 '15 at 18:43
4
\$\begingroup\$

Julia, 231 216 184 175 bytes

r=readline()|>int
l=[141,109,81,80,63,39,22,0]
m=split("Qupu Blinkorp Paas Karpasus Floopdoor Dumaflop Lindilo Fwup")
i=findfirst(j->r>=j,l)
print(i==4?"":r-l[i]+1," ",m[9-i])

This reads a line from STDIN and converts it to an integer, finds the first element of a reversed list of month start days where the input is greater than or equal to the start, then prints accordingly.

\$\endgroup\$
3
\$\begingroup\$

Swift 1.2, 256 bytes

var d=Process.arguments[1].toInt()!,f="Floopdoor",n=[("Qupu",22),("Blinkorp",17),("Paas",24),("Karpasus",17),(f,1),("Dumaflop",28),("Lindilo",32),("Fwup",67)]
for i in 0..<n.count{let m=n[i]
if d>=m.1{d-=m.1}else{println((m.0==f ?"":"\(d+1) ")+m.0)
break}}

To run put the code alone in a .swift file and run it using swift <filename> <inputNumber>

\$\endgroup\$
3
\$\begingroup\$

Java, 357 339 bytes

It's not the most efficient, but I do like how it works. It creates the entire Flooptonia calendar and then looks up what date the number is.

class X{public static void main(String[]q){String n[]={"Qupu","Blinkorp","Paas","Karpasus","Floopdoor","Dumaflop","Lindilo","Fwup"},l[]=new String[209];int m=0,d=0,i,b[]={0,22,39,63,80,81,109,141,208};for(i=0;i++<208;d++){l[i]=(m==4?"":d+" ")+n[m];if(i>b[m+1]){m++;d=0;}}System.out.print(l[new java.util.Scanner(System.in).nextInt()+2]);}}

Input/Output:

77 --> 15 Karpasus 80 --> Floopdoor

Spaced and tabbed out:

class X {
    public static void main(String[] q) {
        String n[] = { "Qupu", "Blinkorp", "Paas", "Karpasus", "Floopdoor", "Dumaflop", "Lindilo", "Fwup" },
          l[]=new String[209];
        int m = 0,
          d = 0,
          i,
          b[] = { 0, 22, 39, 63, 80, 81, 109, 141, 208 };
        for(i = 0; i++ < 208; d++) {
            l[i]=(m == 4 ? "" : d + " ") + n[m];
            if(i > b[m+1]){
                m++;
                d = 0;
            }
        }
        System.out.print(l[ new java.util.Scanner(System.in).nextInt() + 2 ]);
    }
}
\$\endgroup\$
  • 1
    \$\begingroup\$ I challenge you! View my answer! =) \$\endgroup\$ – Luigi Cortese Jul 25 '15 at 13:49
3
\$\begingroup\$

Java, 275 269 266 257 256 252 246 244 243 bytes

class X{public static void main(String[]w){int x=new Short(w[0]),i=1,a[]={-1,21,38,62,79,80,108,140,207};w="Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup".split(",");while(x>a[i++]);System.out.print((i==6?"":x-a[i-=2]+" ")+w[i]);}}

Formatted:

class X {
    public static void main(String[] w) {
        int x = new Short(w[0]), 
            i = 1, 
            a[] = { -1, 21, 38, 62, 79, 80, 108, 140, 207 };
            w = "Qupu,Blinkorp,Paas,Karpasus,,Dumaflop,Lindilo,Fwup".split(",");
        while (x > a[i++]);
        System.out.print(i == 6 ? "Floopdoor" : x - a[i-=2] + " " + w[i]);
    }
}

Interestingly, it's a few bytes shorter than this

class X {
    public static void main(String[] w) {
        int x = new Short(w[0]);
        System.out.print(x < 22 ? x + 1 + " Qupu" : x < 39 ? x - 21
                + " Blinkorp" : x < 63 ? x - 38 + " Paas" : x < 80 ? x - 62
                + " Karpasus" : x < 81 ? "Floopdoor" : x < 109 ? x - 80
                + " Dumaflop" : x < 141 ? x - 108 + " Lindilo" : x < 208 ? x
                - 140 + " Fwup" : "");
    }
}
\$\endgroup\$
  • \$\begingroup\$ Well played Luigi! \$\endgroup\$ – DeadChex Jul 25 '15 at 15:50
  • 1
    \$\begingroup\$ Save 6 bytes with "new Short(w[0])" instead of "Integer.valueOf(w[0])". \$\endgroup\$ – Olivia Trewin Jul 25 '15 at 20:30
  • \$\begingroup\$ @AndrewTrewin great tip, thank you! \$\endgroup\$ – Luigi Cortese Jul 25 '15 at 20:41
3
\$\begingroup\$

JavaScript using ES6 171 164 163 bytes

I'm not the best JavaScript programmer but I tried my best and ended up with the following code

f=(n)=>[0,22,39,63,80,81,109,141,208].some((e,j,a)=>n<a[j+1]&&(r=(j-4?n-e+1+' ':'')+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[j]))&&r;

To see the result you need to refer above code in a html file and use similar to the code below

<html><body><p id="o"></p><script src="Fp.js"></script><script>t=[0,32,62,77,80,99,128,207];for(i=0;i<t.length;i++)document.getElementById('o').innerHTML+=f(t[i])+'<br/>';</script></body></html>

In the above code fp.js is the file that contains the javascript code.

Combined HTML and JavaScript code with indent is

        f=(n)=>[0,22,39,63,80,81,109,141,208].some(
          (e,j,a)=>n<a[j+1]&&(r=(j-4?n-e+1+' ':'')+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[j]))
        &&r;
        
        
        t = [0, 32, 62, 77, 80, 99, 128, 207];
        for (i = 0; i < t.length; i++) 
            document.getElementById('o').innerHTML += f(t[i]) + '<br/>';

    
<html>
<body>
    <p id="o"></p>    
</body>
</html>

Edit:

I'd like to thank Vihan for helping me remove the return statement and reduce my code by 17bytes

@ipi, thanks for helping me save 7 bytes

Note: You can see the result only in browsers Firefox version 22+ and Google Chrome 45+ because of using ES6 arrow functions

\$\endgroup\$
  • \$\begingroup\$ @vihan1086, Thanks for your suggestion \$\endgroup\$ – Anandaraj Jul 26 '15 at 10:41
  • \$\begingroup\$ I don't have access to a browser with arrow notation support right now (so I haven't tested this) but you should be able to replace your month array with "Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0) and save 7 bytes. \$\endgroup\$ – Sean Latham Jul 29 '15 at 10:17
  • \$\begingroup\$ Thanks ipi, i was splitting by a space, but the zero saved me two bytes! You must write a complete program I think this has to run alone, you might have to use something like prompt(). \$\endgroup\$ – Vartan Jul 30 '15 at 20:31
  • \$\begingroup\$ @ipi, Thanks for your comment \$\endgroup\$ – Anandaraj Jul 31 '15 at 16:08
  • \$\begingroup\$ @Vartan, Thanks to your answer, I saved 1 byte \$\endgroup\$ – Anandaraj Jul 31 '15 at 16:10
2
\$\begingroup\$

Python 2, 168 bytes

n=input();e=[-1,21,38,62,80,108,140,207];m=1
while n>e[m]:m+=1
print[`n-e[m-1]`+' '+'Qupu Blinkorp Paas Karpasus Dumaflop Lindilo Fwup'.split()[m-1],'Floopdoor'][n==80]

This treats day 80 internally as 18 Karpasus, but then ignores it when called to print. Also, Python 2's input() function (as opposed to raw_input()) was convenient here.

\$\endgroup\$
2
\$\begingroup\$

Perl 5, 140

Requires running via perl -E:

$i=<>+1;$i-=$b=(22,17,24,17,1,28,32,67)[$c++]while$i>0;say$b>1&&$i+$b.$",(x,Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup)[$c]

Test output (stolen test code from @Dennis):

$for d in 0 32 62 77 80 99 128 207; do perl -E '$i=<>+1;$i-=$b=(22,17,24,17,1,28,32,67)[$c++]while$i>0;say$b>1&&$i+$b.$",(x,Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup)[$c]' <<< $d; echo; done
1 Qupu

11 Blinkorp

24 Paas

15 Karpasus

Floopdoor

19 Dumaflop

20 Lindilo

67 Fwup
\$\endgroup\$
2
\$\begingroup\$

Haskell, 171 167 bytes

main=interact$f.read
f 80="Floopdoor"
f n=(g=<<zip[22,17,24,18,28,32,67](words"Qupu Blinkorp Paas Karpasus Dumaflop Lindilo Fwup"))!!n
g(n,s)=map((++' ':s).show)[1..n]

The program reads it's input from stdin which must not end in NL. Terminate input with EOF/^D or use something like echo -n 80 | ./what-day-is-it. (Some echos don't understand the -n switch and omit the NL by default).

How it works: The main function reads the input, converts it to an Integer and calls f which returns a literal Floopdoor in case of an input of 80 or builds up a list of all possible dates, i.e. ["1 Qupu", "2 Qupu", ... "1 Blinkorp", ... "67 Fwup"] from which it picks the nth element. I make Karpasus is one day longer. 18 Karpasus is at position 80 and fixes the missing Floopdoor in the list.

Edit: @MtnViewMark had the idea of the 18 Karpasus trick and saved 4 bytes.

\$\endgroup\$
  • \$\begingroup\$ I think you can save 4 bytes by pretending Karpasus is 18 days long, removing ,1 and ` x` - since 80 will be caught by the pattern match for it. \$\endgroup\$ – MtnViewMark Jul 25 '15 at 15:51
  • \$\begingroup\$ @MtnViewMark: very clever. Thanks a lot. \$\endgroup\$ – nimi Jul 26 '15 at 8:56
1
\$\begingroup\$

Swift 2.0, 220 bytes

Nothing clever, just filters from a collection of tuples...

func d(n:Int)->String{return n==80 ?"Floopdoor":[("Qupu",21,0),("Blinkorp",38,22),("Paas",62,39),("Karpasus",79,63),("Dumaflop",108,81),("Lindilo",140,109),("Fwup",208,141)].filter{$0.1>=n}.map{"\($0.0) \(n-$0.2+1)"}[0]}

Edited to correct bug, removed a space

\$\endgroup\$
  • 5
    \$\begingroup\$ "You must write a complete program." So it can't be a function. \$\endgroup\$ – Alex A. Jul 24 '15 at 15:54
1
\$\begingroup\$

JavaScript (ES6 on Node.js), 196 bytes

Takes one command line argument:

a=+process.argv[2];for(d of['22Qupu','17Blinkorp','24Paas','17Karpasus','01Floopdoor','28Dumaflop','32Lindilo','67Fwup']){if(a<(z=parseInt(d)))return console.log((z>1?a+1+' ':'')+d.slice(2));a-=z}

Demo

As there is no command-line argument (process.argv) in the browser, the code in the snippet has been placed in a function that accepts an argument:

// Snippet stuff
console.log = function(x){O.innerHTML += x + '\n'};

// Flooptonia function
function flooptonia(a) {
  a = +a;
  for (d in y=['22Qupu', '17Blinkorp', '24Paas', '17Karpasus', '01Floopdoor', '28Dumaflop', '32Lindilo', '67Fwup']) {
    if (a < (z = parseInt(y[d]))) return console.log((z > 1 ? a + 1 + ' ' : '') + y[d].slice(2));
    a -= z
  }
}

// Test
['0', '32', '62', '77', '80', '99', '128', '207'].map(flooptonia);
Test values: [0, 32, 62, 77, 80, 99, 128, 207]

<pre id=O></pre>

\$\endgroup\$
1
\$\begingroup\$

Swift 2.0, 215 204

let(n,t)=(Int(readLine()!)!,[(141,"Fwup"),(109,"Lindilo"),(81,"Dumaflop"),(63,"Karpasus"),(39,"Paas"),(22,"Blinkorp"),(0,"Qupu")])
print({(n==80 ?"Floopdoor":"\(n-$0.0+1) "+$0.1)}(t[t.indexOf{$0.0<=n}!]))

This is a full program which asks the user to input the number in STDIN.

\$\endgroup\$
1
\$\begingroup\$

Matlab, 187 bytes

d=input('');l=[141 109 81 80 63 39 22 0];t=find(d>=l,1);m=strsplit('Fwup Lindilo Dumaflop Floopdoor Karpasus Paas Blinkorp Qupu');f='%d %s';if t==4;f='%d\b%s';end;fprintf(f,d-l(t)+1,m{t})

Expanded version:

d=input('');
l=[141 109 81 80 63 39 22 0];
t=find(d>=l,1);
m=strsplit('Fwup Lindilo Dumaflop Floopdoor Karpasus Paas Blinkorp Qupu');
f='%d %s';
if t==4;
    f='%d\b%s';
end
fprintf(f,d-l(t)+1,m{t})

Reads a line from the console (stdin), finds the first element of a reversed list of month start days where the input is greater than or equal to the array element, then prints accordingly.

This is almost identical to the Julia answer, except for the display stage. (We can't beat their ternary operator, unavailable in Matlab). To make up having to explicit a full if statement, we use a little trick (a Backspace character in the print format) to "erase" the number 1 for the special day/month Floopdoor


In collaboration with the Matlab and Octave chat participants.

\$\endgroup\$
1
\$\begingroup\$

Javascript ES5 using 168 bytes

m=[-1,21,38,62,79,80,108,140];for(n=prompt(i=0);n>m[i+1]&&i++<8;);alert((i-4?n-m[i]+" ":"")+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[i])

Ungolfed:

m=[-1,21,38,62,79,80,108,140];   // create range of starting indexes - 1

for(                             // begin for loop
  n=prompt(i=0);                 // initialize i to zero and prompt user
  n>m[i+1] && i++ < 8;           // exit if n>0; increment i; exit if i was < 8
  );                             // end for loop

alert(
  (i-4 ? n-m[i]+" ":"") + // special floopdoor case
  "Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[i]);

  //^  create an array of strings by splitting at zero. Then, select element i
\$\endgroup\$
0
\$\begingroup\$

C, 241 bytes

Nothing too exciting. Could have shaved 27 bytes had it require to be a complete program.

main(c,s)char**s;{c=atoi(s[1]);c-80?printf("%d ",c<22?c+1:c<39?c-21:c<63?c-38:c<80?c-62:c<109?c-80:c<141?c-108:c-140):0;puts(c<22?"Qupu":c<39?"Blinkorp":c<63?"Paas":c<80?"Karpasus":c<81?"Floopdoor":c<109?"Dumaflop":c<141?"Lindilo":"Fwup");}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.