title: The Bowlers-Golfers Fraction War

text:
# Question
Title: The Bowlers-Golfers Fraction War
# Introduction

Let's start by arranging all fractions from 0 to 1 in order of lowest denominator, then lowest numerator:

1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7...

Note that duplicates aren't counted, so I haven't listed 2/4, 2/6, 3/6, or 4/6, since they already appeared in their simplified forms (1/2, 1/3, and 2/3).

Your task is now simple: given a positive integer `n`as a command line argument, print to standard output the `n`th fraction in the list. Thus, an input of `5` should yield an output of `3/4` (**not** 0.75).

# Bowlers

Your goal is to solve this in the longest program possible. Your score is the number of characters.

# Golfers

Your goal is to take existing answers, and golf them. When golfing those answers, remove one or more characters from the code, and optionally rearrange the remaining characters, in such a way that the resulting code is still a valid solution in the same language. Your score is the product of all the reductions. (So if you remove 10 characters from one answer, and 15 from another, your score is 150.)

# Rules

1. A valid program must have at least three unique characters.
2. Only ASCII characters may be used.
3. If your program's size is reduced, your score is reduced accordingly.
4. When golfing a program...
    1. Edit the code in the text of the answer
    2. Change the character count listed
    3. Leave the following comment: `**Removed X characters (from Y to Z)**` (in bold)
5. You may not golf a valid program into an invalid one.
6. The golfed program must work in some version of the language listed. So if the original answer is marked as Python, and the code only works in Python 2, you may golf it to a program that only works in Python 3.
    1. Therefore, it is recommended (but not required) that you be specific in titling your answer, mentioning the version and/or compiler used.
7. If you already golfed an answer, you may golf it again.
8. If you golf the same answer multiple times, your score for that answer is the *sum* of your reductions.
    1. For example, if you reduce 10 characters from a program, and later remove another 15, and also golf 7 characters from another answer, your total score is (10+15)\*7=175.
    2. This applies regardless of whether someone else golfed the program in between your golfings.
9. You may golf your own answer, but you do not receive any points for doing so.

# Winners

I will try to keep this leaderboard periodically updated. If I make a mistake, please let me know, or else you can edit this post yourself.

## Top bowlers

1. Dennis (CJam): 1.17 × 10678
2. Pppery (CPython 3.6.2): 25984
3. OldCurmudgeon (Java): 278

## Top golfers

1. jimmy23013: 105.2 * 10152
2. Martin Ender: 2.8 * 1014484
3. Pppery: 2 * 104111

# Answer
# CJam, 1.17 × 10678 bytes

```
",,,",KK#b:c~

```

Well, the string should actually contain 1,167,015,602,222,203,651,546,923,533,233,456,645,527,427,020,625,754,322,603,554,937,551,735,592,092,356,520,085,507,613,447,896,812,875,213,856,544,974,386,642,866,232,121,069,637,599,975,236,272,634,227,913,998,493,360,693,139,149,236,571,503,883,331,020,249,908,672,008,574,221,022,612,893,546,658,640,986,973,481,700,267,591,531,514,666,040,606,217,610,439,998,612,592,897,511,421,801,308,639,396,208,196,301,077,376,577,788,009,239,468,384,204,073,426,482,794,344,190,683,235,393,373,061,689,668,389,239,477,158,591,879,792,606,717,529,814,802,500,558,822,508,662,266,027,694,882,649,391,373,447,012,817,270,871,840,254,480,631,579,732,459,294,193,158,457,158,597,836,239,348,386,288,579,699,763,150,579,966,400,972,286,547,196,034,472,447,664,813,466,769,145,983,290,696,497,053,781,354,086,441,505,174,165,846,491,136,000,001,121,501,860,331,520,000,000,000,004,508,876,800,000,000,000,000,000,126 commas, but the editor didn't let me post the entire code... :(
> 24 votes

# Answer
# Python, 176 bytes

Not a bowler, but...

```
import sys,fractions
def f(t):
 c=0
 for i in range(t+10):
  for j in range(1,i):
   if fractions.gcd(j,i)==1:c+=1
   if c==t:return str(j)+'/'+str(i)
print f(int(sys.argv[1]))

```
> 15 votes

# Answer
# CJam, 9.44 × 10284

```
"ddd",'iib:c~

```

The string actually contains 943,611,762,745,112,544,157,801,937,289,871,933,621,396,073,807,297,328,579,826,246,436,861,144,651,900,144,172,793,266,430,374,467,343,433,363,000,182,294,622,535,895,774,344,720,689,882,873,880,571,351,234,260,849,874,055,687,224,065,790,608,381,303,357,434,711,286,607,328,858,338,155,948,406,237,564,203,055,794,077,541,968,210,416,550,049,644,382,519,576,532,604,460,863,849 d's.

Note that the decoded program is slow in the online interpreter.
> 12 votes

# Answer
# CJam, 3.8 × 1087 bytes

```
"ddd",'#i,(;(bb:c~

```

The string contains 3,795,999,425,660,798,101,493,706,445,244,921,058,557,321,207,441,420,808,131,205,973,714,113,789,081,612,593,756,565 d's.

The generator script for the previous version of this answer, which might be useful later:

```
"'/ea(i(_)),:)_m*{_~{_@\%}h!=\~>&},=~o"
"'bi,(;(;{#}*b":B~'d*`',B":c~"

```
> 10 votes

# Answer
# CJam, 9.44 × 10284

```
",,,",'iib:c~

```

The string actually contains 943,611,762,745,112,544,157,801,937,289,871,933,621,396,073,807,297,328,579,826,246,436,861,144,651,900,144,172,793,266,430,374,467,343,433,363,000,182,294,622,535,895,774,344,720,689,882,873,880,571,351,234,260,849,874,055,687,224,065,790,608,381,303,357,434,711,286,607,328,858,338,155,948,406,237,564,203,055,794,077,541,968,210,416,550,049,644,382,519,576,532,604,460,863,849 commas.
> 7 votes

# Answer
# Java - 278

```
import java.math.*;void m(String a){BigInteger i=null;BigInteger n=i.ONE;BigInteger d=n.add(n);BigInteger e=n;for(i=e;i.compareTo(i.valueOf(Integer.parseInt(a[0])))<0;i=i.add(e))do if((n=n.add(e)).compareTo(d)>=0)d=d.add(n=e);while(!n.gcd(d).equals(e));System.out.print(n+"/"+d);}}

```

Ungolfed:

```
import java.math.*;
void m(String args[]){
        BigInteger i=null;
        BigInteger n=i.ONE;
        BigInteger d=n.add(n);
        BigInteger e=n;
        for(i=e; i.compareTo(i.valueOf(Integer.parseInt(args[0])))<0; i=i.add(e))
            do
                if((n=n.add(e)).compareTo(d)>=0)
                    d=d.add(n=e);
            while(!n.gcd(d).equals(e));
        System.out.println(n +"/"+d);
    }
}

```

### Original version

I have made no attempt to arbitrarily extend this solution. Not sure if that will gain me or lose me points. It is, however, a correct solution that will work for very large numbers.

```
public class Test {

    static class Fractions implements Iterator<String> {

        // Start at 1.
        BigInteger numerator = BigInteger.ONE;
        // Start at 2.
        BigInteger denominator = BigInteger.ONE.add(BigInteger.ONE);

        @Override
        public boolean hasNext() {
            // Never ending!
            return true;
        }

        @Override
        public String next() {
            String next = numerator + "/" + denominator;
            do {
                // Keep selecting the next one.
                step1();
                // Until they are relatively prime.
            } while (!numerator.gcd(denominator).equals(BigInteger.ONE));
            return next;
        }

        private void step1() {
            // Take a single step.
            numerator = numerator.add(BigInteger.ONE);

            if (numerator.compareTo(denominator) >= 0) {
                // num >= den - step denom up and num rewinds to 1.
                numerator = BigInteger.ONE;
                denominator = denominator.add(BigInteger.ONE);
            }
        }

    }

    // Returns the nth fraction.
    public String nthFraction(BigInteger n) {
        Iterator<String> f = new Fractions();
        for (BigInteger i = BigInteger.ONE; i.compareTo(n) < 0; i = i.add(BigInteger.ONE)) {
            f.next();
        }
        return f.next();
    }

    // Returns the nth fraction.
    public String nthFraction(long n) {
        return nthFraction(BigInteger.valueOf(n));
    }

    public void test() {
        Iterator<String> f = new Fractions();
        for (int i = 1; i < 100; i++) {
            System.out.println(i + "=" + f.next());
        }
    }

    public static void main(String args[]) {
        try {
            //new Test().test();
            if (args.length >= 1) {
                System.out.println(new Test().nthFraction(Integer.parseInt(args[0])));
            } else {
                System.out.println(new Test().nthFraction(5));
            }
        } catch (Throwable t) {
            t.printStackTrace(System.err);
        }
    }
}

```
> 2 votes

# Answer
# CPython 3.6.2, 25984 bytes

```
t=int().__sub__(int()==int())
t=t.__sub__(int().__sub__(t));t=t.__sub__(int().__sub__(t));t=t.__sub__(int().__sub__(t));t=t.__sub__(int().__sub__(t));t=t.__sub__(int().__sub__(t));t=int().__sub__(t).__sub__(int()==int())
d=__builtins__.__dict__;l=list(d);
c=d[l[t]]((d,d,d,d,d,d,d,d,d,d,d,d,d))
_=d[l[t]]((d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d))\ndd=d[    l[_]].__dict__
ll=list(dd)
d[l[d[l[t]]((d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d))]](dd[ll[d[l[t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,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d))),d[l[c]](d[l[t]]((d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d))),d[l[c]](d[l[t]]((d,d,d,d,d,d,d,d,d,d))))))

```

This answer was created by porting the code of Soham Chowdhury's Python answer through the cracker I wrote for wizzwizz4's cop answers to restricted mini challengs.

I hope I'm not violating some rule against posts to old challenges.
> 1 votes

# Answer
# Ruby, ~~488 412 377 347 341~~ 214 bytes

Starting with a more "regular-looking" program; Curious to see what awful things you can do to it.

```
require 'set'
g=Enumerator.new do|y|
v=Set.new
d=2
loop do
(1...d).each do|n|
x=n.to_f/d
if v.include?(x)==false
v.add(x)
y.yield(n.to_s+'/'+d.to_s)
end
end
d+=1
end
end
i=0
$*[0].to_i.times do
i=g.next
end
puts i

```
> 1 votes

---
Tags: code-challenge, math, code-bowling, rational-numbers, cops-and-robbers
---


title: Is it a new highscore?

text:
# Question
Title: Is it a new highscore?
## Challenge:

In the language of your choice, write a program that generates a leaderboard with random scores and outputs it, then take a new score as input and check if it can be placed in the leaderboard, and output which place it is in.

## Specifications:

* You must **generate a list of 50 "random" scores, in descending order and output it**
* The "random" scores will range from **0 to 255**
* If 2 scores are the same, it doesn't matter which is placed first in the descending order
* If the input score isn't higher than any of the scores in the list, **output 0 or a falsy statement.** (the input will be 0 to 255, no need to check)
* If the score **IS** higher than a score in the list, output the position it would take in the leaderboards.
* Generate and output the leaderboards/list first in descending order, before taking input.

## Example I/O:

Random list: (the three dots are so I don't have to add 50 line text here. You should output each score. 12 is the 50th place)

```
201
192
178
174
...
...
12

```

Input:

```
180

```

Output:

```
3

```

(because this score would place no.3 in the leaderboards)

Input 2:

```
7

```

Output 2:

```
0

```

(because it is lower than everything on the leaderboard)

This is a so shortest code wins.

# Answer
# Python 2, 102 bytes

```
from random import*
lambda n,l=[randint(0,255)for i in[0]*50]:(l,[sorted(l+[n]).index(n),0][n>max(l)])

```

Try it online!
> 3 votes

# Answer
# Python 3**, 125 128 127 126 125 119 115 bytes**

```
from random import*;x=sorted(choices(range(256),k=50));print(x[::-1]);print((sum(map(int(input()).__lt__,x))+1)%51)

```

Could probably be golfed quite a bit

Edit: Changed from sample to choices, as sample does not allow repetition. Pointed out by @Arnold Palmer

-2 bytes, thanks to @Arnold Palmer

-4 bytes, thanks to @Jonathan Allan

Try it online!
> 3 votes

# Answer
# , 69 bytes

```
n=scan();cat(r<-sort(sample(256,50,T)-1,T));`if`(any(r<n),sum(r>n),0)

```

reads `n` from STDIN; prints the list to STDOUT, and returns the index or `0`.

Try it online!

Cleaner output format
> 2 votes

# Answer
# Jelly, 18 bytes

```
⁹ẋ50ḶX€ṢṚṄ€>ƓS‘%51

```

Try it online!

-3 thanks to Jonathan Allan.

*Now with interactive I/O!*

Full program. First 50 lines are the scores, last line is the index.
> 2 votes

# Answer
## Javascript, ~~155~~ ~~148~~ ~~134~~ ~~115~~ 101 bytes

Not very short, but:

```
l=[...Array(50)].map(x=>Math.random()*256|0).sort((a,b)=>b-a);console.log(l);f=x=>l.findIndex(v=>x>v)

```

Returns position when higher than at least one score. Otherwise `-1`.

Edit: apparently you don't have to output scores line by line. So shorter now.

```
l=[...Array(50)].map(x=>Math.random()*256|0).sort((a,b)=>b-a);console.log(l);f=x=>l.findIndex(v=>x>v)

console.log(f(200))
console.log(f(60))
console.log(f(30))
console.log(f(2))
```

14 bytes saved by @Downgoat
> 1 votes

# Answer
# Charcoal, 48 bytes

```
ＡＥ⁵⁰‽²⁵⁶ηＦ⁵⁰«⊞υ⌈ηＡ§η⌕η⌈η⁰»ＩυＤ⎚ＮθＩ﹪⁺¹Ｌ⪫Ｅυ× ›ιθω⁵¹

```

Try it online! Link is to verbose version of code. There's no `Sort` function in Charcoal, so I loop 50 times extracting the highest remaining element and then setting it to zero each time, using the ambiguous `AssignAtIndex` command. There is an experimental `Reduce` function in Charcoal but I'm too wary of it so I'm taking the length of a string instead. Unfortunately this gives me a 0-indexed answer to I have to add 1 modulo 51 to give the desired answer. At least generating the 50 random numbers was easy.
> 1 votes

# Answer
## TXR Lisp, ~~78~~ 76 bytes

```
(opip(pos-if(op > @@1)(prinl[sort[(gun(rand 256))0..50]>]))(if @1(+ 1 @1)0))

```

Run:

```
1> (opip(pos-if(op > @@1)(prinl[sort[(gun(rand 256))0..50]>]))(if @1(+ 1 @1)0))
#<intrinsic fun: 0 param + variadic>
2> [*1 3]
(247 243 238 237 234 209 204 202 196 193 183 181 179 177 174 174
 164 159 156 155 143 141 138 134 134 132 131 117 105 98 89 88
 82 77 75 66 65 64 55 52 46 34 32 28 28 26 24 21 18 5)
0
3> [*1 3]
(252 250 241 236 234 229 228 219 210 206 205 204 193 188 184 168
 166 164 163 160 158 158 148 138 137 130 123 118 111 103 97 93
 92 85 81 73 69 60 60 53 52 44 38 31 19 16 15 12 10 1)
50
4> [*1 245]
(251 248 244 238 237 228 225 223 222 220 219 216 208 197 196 192
 191 176 159 157 155 149 140 138 121 119 115 113 108 106 105 101
 87 82 79 69 67 59 54 42 40 38 34 19 18 12 11 9 4 4)
3
5> [*1 255]
(255 241 228 228 226 224 222 222 217 214 211 197 197 193 191 185
 176 175 173 166 162 142 141 139 132 132 122 122 110 110 109 106
 104 83 82 81 81 79 74 69 69 65 61 60 59 51 41 37 25 14)
2
6> [*1 255]
(248 244 240 234 231 220 214 211 207 206 205 200 197 188 187 184
 183 182 173 153 150 149 144 130 127 126 122 113 109 98 94 89
 74 66 60 60 58 54 54 51 49 45 21 15 12 12 10 8 7 3)
1

```
> 1 votes

# Answer
# Mathematica, 105 bytes

```
(P=Position;Print[If[(d=Min@Nearest[s=Reverse@Sort@RandomSample[Range@251-1,50],#])<#,s~P~d,s~P~d+1],s])&

```

Try it online!
> 1 votes

# Answer
# Ruby, 78 bytes

```
puts h=[*0..255].sample(50).sort.reverse
s=gets.to_i
p (h.index{|i|i<s}||-1)+1

```
> 1 votes

# Answer
# Gaia, 17 bytes

```
{256ṛ(}₅₀]ȯv:q<∆q

```

There was a small bug with the random function, so this won't work quite properly on the version on TIO, but will work locally.

Try it online!

### Exaplanation

```
{256ṛ(}            Get a random integer from 1 to 256 and decrement it.
       ₅₀          Do that 50 times.
         ]         Collect the results in a list.
          ȯv       Sort in descending order.
            :q     Copy and print.
              <∆   Find the index of the first score that is less than the input (input
                   won't be read until this point).
                q  Print that index.

```
> 0 votes

# Answer
# Haskell, 176 bytes

Haskell is certainly the wrong tool for this job, far too long..

```
(sequence(randomRIO(0,255)<$[1..50])::IO[Int])>>=g.sort
import System.Random
import Data.List
g l=mapM_ print(reverse l)>>getLine>>=print.(#l).read
x#l=1+length(takeWhile(<x)l)

```

Try it online!
> 0 votes

# Answer
# Bash + GNU utilities, 76

```
shuf -i0-255 -n50|sort -nr|tee s
sed 1i$1i s|sort -nr|sed -n /i/=|dc -e?51%p

```

Try it online.

### Explanation

```
shuf -i0-255 -n50                            # generate random leaderboard
                 |sort -nr                   # sort it in descending numerical order
                          |tee s             # output and save to file s
sed 1i$1i s                                  # insert new score with an "i" suffix
           |sort -nr                         # sort again
                    |sed -n /i/=             # output line number of line containing "i"
                                |dc -e?51%p  # mod 51 of line number

```
> 0 votes

# Answer
# Perl 5, 77 + 1 (-p) = 78 bytes

```
@a=sort{$b<=>$a}map{int rand 255}1..50;say"@a";1while$a[$i++]>$_;$_=$i<51&&$i

```

Try it online!

Outputs the scoreboard space separated on the first line. Outputs the position for the new input on the second line. Second output is blank (falsy) if the new score isn't high enough to make the leaderboard.
> 0 votes

# Answer
# Röda, 112 bytes

```
{a=[seq(1,50)|[-abs(randomInteger()%256)]for _|sort]a|print-_
parseInteger _|indexOf-_,[sort(a+-_1)]|[(_+1)%51]}

```

Try it online!

This reads the input from the input stream as a string (like if it was stdin). The answer could obviously be shorter if I can suppose that the input is a number object, as the `parseInteger _` call would not be needed. I'm not sure if I can do that.
> 0 votes

# Answer
# MATL, 18 bytes

*Thanks to Jonathan Allan for removing 1 byte and for a correction!*

```
8W50&YrqSPtD<sQ51\

```

### Example run

The leaderboard is shown as a line of numbers separated by spaces. The gif only shows the first few, to keep image size reasonable.

### Explanation

```
8W   % Push 2 raised to 8, that is, 256
50   % Push 50
&Yr  % Random vector of 50 integers from 1 to 256, independently uniformly distributed
q    % Subtract 1 to each result. This makes the integers go from 0 to 255
SP   % Sort, reverse. This sorts in descending order
tD   % Duplicate and immediately display
<    % Implicit input. Is it less than each entry in the sorted random vector?
s    % Sum. This counts how many entries are less than the input
Q    % Add 1
51\  % Modulo 51. Implicitly display

```
> 0 votes

# Answer
# Java 8, 208 + 19 = 227 bytes

It's golfs like these that make me question my choice of language.

The I/O order specification prohibits the use of lambda parameters and return values for I/O, but I use a lambda anyway to avoid the main class boilerplate. The lambda can be assigned to `Runnable`.

Byte count includes lambda and required import.

```
import java.util.*;

```

```
()->{int n,p=0;List<Integer>l=new Stack();for(;p++<50;l.sort((a,b)->b-a))l.add(new Random().nextInt(256));System.out.print(l);n=new Scanner(System.in).nextInt();for(int o:l)if(n>o)p--;System.out.print(p%51);}

```

## Ungolfed lambda

```
() -> {
    int n, p = 0;
    List<Integer> l = new Stack();
    for (; p++ < 50; l.sort((a, b) -> b - a))
        l.add(new Random().nextInt(256));
    System.out.print(l);
    n = new Scanner(System.in).nextInt();
    for (int o : l)
        if (n > o)
            p--;
    System.out.print(p % 51);
}

```

It's pretty readable once ungolfed. My favorite part about this solution is that it sorts the scoreboard 50 times (whenever a new score is generated) in order to save one byte. This results in a noticeable delay while the board is generated.

`p` is incremented to 51 as the scoreboard is populated, and then is decremented to the input score's ranking. The remainder by 51 is taken so that rank 51 is displayed as 0.

Since each initial score is produced by a newly-seeded generator, the scores probably don't have the usual guarantees of randomness. But they seem random enough to me.
> 0 votes

# Answer
# Ly, 58 bytes

```
(50)[>0(255)?<1-]>ar&s&ulrns>1<[L[>"\n"ou;]ppl>1+<]"\n"o0u

```

Try it online!

Outputs a space-separated list of scores, then the position of the given input after a newline.

Explanation:

```
(50)[>0(255)?<1-]>    # simple loop to create list of 50 scores
ar&s&ulr              # arrange the list, reverse it, print it, then reverse it back
ns                    # take input and save it
>1<                   # prepare counter
[                     # while the stack is not empty
    L[>"\n"ou;]       # check if the value is lower than the input, if so, output a newline and the counter, then terminate
    ppl>1+<           # otherwise, pop a value off the stack and increase the counter
]
"\n"o0u               # output a newline and 0 if we finished the loop without terminating

```
> 0 votes

# Answer
# PHP, 119 bytes

```
<?php while($c++<50)$l[]=rand(0,255);rsort($l);foreach($l as$s)echo"$s ";for($i=fgets(STDIN);$i<$l[++$p-1];);echo$p%51;

```

Try it online!

Please note, when trying it online, you are required to give the input *before* you have seen the starting leaderboard, but this is not how it actually runs from a CLI: the leaderboard is printed first and the program waits for the user input.

**Explanation**

```
<?php

```

Generate 50 random numbers and store in the leaderboard, `$l`.

```
while ($c++ < 50) $l[] = rand(0, 255);

```

Sort them in descending order.

```
rsort($l);

```

Print them out space-separated.

```
foreach ($l as $s) echo "$s ";

```

A loop, comparing the user input score `$i` with the score in position `$p` in the leaderboard.

```
for (

```

Before we start, get the user input.

```
        $i = fgets(STDIN);

```

We loop from the top of the board (`$l[0]`) and keep looping for as long as `$i` is less than the score in that position.

`$p` is initially undeclared so we increment it *before* each comparison (so it starts as an integer), but have to subtract 1 for a 0 start.

```
        $i < $l[++$p - 1];
);

```

Print the resulting position. If `$i` is less than any score on the leaderboard `$p` will equal 51. Using modulus 51, results in 51 becoming 0, but the other positions remaining unchanged,

```
echo $p % 51;

```
> 0 votes

---
Tags: code-golf, random, sorting
---


title: What's the date, in Usenet time?

text:
# Question
Title: What's the date, in Usenet time?
September 1993 is known on Usenet as the September that never ended. Thus, for example, the day this question is being posted is Saturday, September 8740, 1993.

Your program or function should take any Gregorian date (with positive year) as input and return the same date as output if it's prior to September 1993 or the date on the September 1993 calendar if thereafter.

You may accept YYYY-MM-DD, YYYY/MM/DD, MM/DD/YYYY, DD/MM/YYYY, D-Monthnameabbr-YYYY, or any other popular format that uses the entirety of the year (as opposed to the year modulo 100). You need only accept one such format, of your choosing. Output format must match the input format.

Sample input → output:

* Sunday, 6 August 2017 → Sunday, 8741 September 1993
* Tuesday, 28 January 1986 → Tuesday, 28 January 1986

Or:

* 2017-08-06 → 1993-09-8741
* 1986-01-28 → 1986-01-28

In the interest of more interesting answers, the use of a built-in function designed for this purpose (such as the UN\*X `sdate` command) is disallowed. Aside from that and the standard exceptions, this is golf, so the shortest answer wins.

# Answer
## JavaScript (ES6), 48 bytes

```
f=
s=>(d=new Date(s)/864e5-8643|0)>9?'1993-09-'+d:s
```

```
<input size=10 oninput=o.textContent=/\d{4}(-\d\d){2}/.test(this.value)?f(this.value):``><pre id=o>
```

Based on @Mr.Xcoder's algorithm.
> 2 votes

# Answer
# Python 3, 109 bytes

```
from datetime import*
i=input()
z=date(*map(int,i.split())).toordinal()-727806
print([i,'1993 09 %d'%z][z>9])

```

Try it online!

-59 bytes thanks to notjagan
-3 bytes thanks to Mr. Xcoder
-2 bytes thanks to officialaimm
-12 bytes thanks to Jonathan Allan
> 3 votes

# Answer
# Mathematica, 55 bytes

```
If[(s=#&@@{1993,9}~DateDifference~#)>0,{1993,9,s+1},#]&

```

**I/O**

> {2017, 8, 6} -\>{1993, 9, 8741}
> {1986, 1, 28}-\>{1986, 1, 28}

*-6 bytes thanx to user202729*
> 2 votes

# Answer
# Perl 5, 102 + 16 (-MTime::Local -F-) = 118 bytes

```
$,='-';say @F=($t=timelocal(0,0,0,$F[2],$F[1]-1,$F[0]-1900)-749433599)>0?(1993,'09',31+int$t/86400):@F

```

Try it online!

Takes the date as "YYYY-MM-DD"

I think I did the count right on the command line options. I'm sure someone will correct me if I didn't.
> 1 votes

# Answer
# C# (.NET Core), 107 bytes

```
s=>{var d=(System.DateTime.Parse(s)-new System.DateTime(1993,8,31)).TotalDays;return d<1?s:"9/"+d+"/1993";}

```

Try it online!

Takes dates as M/D/YYYY (numbers below 10 written with only 1 digit). Written from my mobile phone using the API by heart.
> 1 votes

# Answer
# Gaia, 78 bytes

```
ℍZ¤∨4Ė
:'//d¦[1993₉31];>\{\‡:(…1993>↑¦365+¦¤ṇ↑∂K∂k,=;((<¤)-243]_ḥΣ“1993/09/”¤+}?

```

Try it online!

### Explanation

First, we have a helper function that determines if a year is a leap year.

```
ℍ       100
 Z      Divmod year by 100, pushing the first 2 digits, then the second 2 digits
  ¤     Swap
   ∨    Logical OR, gives the left-most non-zero number
    4Ė  Check for divisibility by 4

```

The main function does the rest of the work:

```
:              Push two copies of the input.
'//            Split the top on on slashes.
d¦             Parse each section as a number.
[1993₉31]      Push the list [1993 9 31].
;>             Copy the date and check if its less than that.
\              If it is, delete the list and leave the input string on top.
{              Else:
 :(             Copy the date and get the year.
 …1993>         Get the range from 1993 to year-1.
 ↑¦365+¦        Map each to 365+(whether it's a leap year).
 ¤              Swap, bring the date back to the top.
 ṇ↑             Pull out the year and check if it's a leap year.
 ∂K∂k,          Push the pair of lists [[days in months in a leap year] [days in months]]
 =              Index the result of checking if the year is a leap year into the pair.
 ;((<           Get the first (month number - 1) elements.
 ¤              Swap, bring date back to the top.
 )              Get the day.
 -243           Push -243 (243 is the number of days between Jan 1 1993 and Sept 1 1993).
 ]              Wrap everything in a list.
 _              Flatten the list.
 ḥ              Remove the first element (the input string).
 Σ              Sum it.
 “1993/09/”¤+   Append the resulting number to "1993/09/".
}?             (end if)
               Implicitly display whatever is on top of the stack.

```
> 1 votes

---
Tags: code-golf, date
---


title: Can you count the number of rectangles?

text:
# Question
Title: Can you count the number of rectangles?
One of my favorite mathematical pastimes is to draw a rectangular grid, then to find all of the rectangles that are visible in that grid. Here, take this question, and venture for yourself!

**Can you count the number of rectangles?**

```
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+

```

The total number of rectangles for this *4* x *4* minichess board is exactly

> `100`

Were you correct?

**Related math:** How many rectangles are there on an 8×8 checkerboard?

## The Challenge

Write the shortest **function/program** that counts the total number of visible rectangles on a non-toroidal **grid/image**.

**Related challenges:** Count the Unique Rectangles!, Find number of rectangles in a 2D byte array.

## Input Format

Your function or program can choose to work with either text-based input or graphical input.

### Text-based Input

The grid will be an *m*-by-*n* (*m* rows, *n* columns) ASCII grid consisting of the following characters:

* spaces,
* `-` for parts of a horizontal line segment,
* `|` for parts of a vertical line segment, and
* `+` for corners.

You can introduce this ASCII grid as the input/argument to your program/function in the form of

* a single string delimited by line-breaks,
* a string without newlines but with one or two integers encoding the dimensions of the grid, or
* an array of strings.

**Note:** The text-based input contains at least *1* row and at least *1* column.

### Graphical Input

Alternatively, the grids are encoded as black-and-white PNG images of *5\*n* pixels wide and *5\*m* pixels high. Each image consists of *5 px * 5 px* blocks that correspond to the ASCII input by:

* Spaces are converted to white blocks. These blocks are called the *whitespace* blocks.
* Line segments and corners are converted to *non*-whitespace blocks. The center pixel of such blocks are black.
* **Edit:** If two corners (in the ASCII input) are connected by a line segment, the corresponding block centers (in the graphical input) should be connected by a black line, too.

This means that each block could only be chosen from (Click here for larger image).

**Note:** The blue boundaries are only for illustration purposes. Graphical input is at least *5* px wide and *5* px high. You can convert the graphical input to any monochrome image, potentially of other image file formats). If you choose to convert, please specify in the answer. There is no penalty to conversion.

## Output Format

If you are writing a program, it must display a non-negative number indicating the total number of rectangles in the input.

If you are writing a function, it should also return a non-negative number indicating the total number of rectangles in the input.

## Example Cases

**Case 1,** Graphic:  (*30* px * *30* px), ASCII: (*6* rows, *6* cols)

```
+--+
|  |
| ++-+
+-++ |
  |  |
  +--+

```

Expected output: `3`

**Case 2,** Graphic:  (*20* px * *20* px), ASCII: (*4* rows, *4* cols)

```
++-+
|+++
+++|
+-++

```

Expected output: `6`

**Case 3,** Graphic:  (*55* px * *40* px), ASCII: (*8* rows, *11* cols)

```
  +++--+
+-+++  |
|  |  ++--+
+--+--++ ++
      |  ||
      |  ||
++    +--++
++

```

Expected output: `9`

**Case 4,** Graphic:  (*120* px * *65* px), ASCII: (*13* rows, *24* cols)

```
+--+--+ +--+  +--+  +--+
|  |  | |  |  |  |  |  |
+--+--+ |  |  |  |  |  |
|  |  | +--+--+--+--+--+
+--+--+    |  |  |  |
           |  |  |  | ++
+-+-+-+-+  +--+  +--+ ++
| | | | |
+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+

```

Expected output: `243`

**Case 5,** Graphic:  (*5* px * *5* px. Yes, it *is* there!), ASCII: Just a single space.

Expected output: `0`

**Case 6,** Graphic:  (*35* px * *20* px), ASCII: (*4* rows, *7* cols)

```
+--+--+
|++|++|
|++|++|
+--+--+

```

Expected output: `5`

## Assumptions

To make life easier, you are guaranteed that:

* By being *non-toroidal*, the grid does not wrap either horizontally or vertically.
* There are no loose ends, *e.g.* `+---` or `+- -+`. All line segments have two ends.
* Two lines that meet at `+` must intersect each other at that point.
* You do not have to worry about invalid inputs.

Rules against standard loopholes apply. Please treat squares as rectangles. Optionally, you could remove the trailing spaces on each row of the grid.

This is , so make your entry as short as possible. Text-based and graphical solutions will compete together.

## Leaderboard

```
var QUESTION_ID=137707,OVERRIDE_USER=11933;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```

```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

# Answer
## Grime, ~~31~~ 28 bytes

```
T=\+[+\-]*\+/[+|]/+$
n`T&To2

```

Try it online!

Takes input in ASCII format.

## Explanation

Grime's syntax is very close to regular expressions. Each line defines a pattern that may or may not match a rectangle of characters. `T` matches a rectangle whose top row and left column look valid.

```
T=\+[+\-]*\+/[+|]/+$
T=                    Define T as
  \+[+\-]*\+          a row that matches this regex
            /         and below that
             [+|]/+   a column of + or |
                   $  with anything to its right.

```

The second row is the "main program".

```
n`T&To2
n`       Print number of rectangles that match
  T      the pattern T
   &     and
    To2  T rotated 180 degrees.

```
> 4 votes

# Answer
## JavaScript (ES6), ~~176~~ 171 bytes

```
g=a=>Math.max(...b=a.map(a=>a.length))-Math.min(...b)?``:f(a);f=
a=>a.map((b,i)=>[...b].map((_,j)=>n+=a.join`
`.split(eval(`/\\+(?=[-+]{${j}}\\+[^]{${l=b.length+~j}}([|+].{${j}}[|+][^]{${l}}){${i}}\\+[-+]{${j}}\\+)/`)).length>>1),n=0)|n
```

```
<textarea rows=8 cols=8 oninput=o.textContent=g(this.value.split`\n`)></textarea><pre id=o>
```

Takes input as an array of strings of equal length. Explanation: Creates a series of regular expressions that match rectangles of all possible widths and heights (and some impossible widths and heights, but that's code golf for you) and counts how many matches they all produce. Because there's a capturing group in the regexp, `split` returns `2n+1` for `n` matches, so I right shift by 1 to get the number of matches, as that saves a byte over making the group non-capturing.
> 6 votes

# Answer
# , ~~103~~ ~~95~~ ~~86~~ ~~80~~ ~~76~~ 70 bytes

```
[:+/@,]*/@('-|++'*/@(e.,&'+')~&>]({.,{:)&.>@;|:;{.;{:);._3"$~2+$#:i.@$

```

Try it online!

Takes input as an array of strings with trailing spaces (so that each string is the same size). Uses the *full* subarray operator `;._3` to iterate over every possible subarray size larger than 2 x 2, and counts the subarrays that are valid rectangles. Completes all test cases almost instantly.
> 4 votes

# Answer
# Mathematica, ~~136~~ ~~134~~ 132 bytes

```
S=Tr@*Flatten;S@Table[1-Sign@S@{d[[{i,j},k;;l]],d[[i;;j,{k,l}]]},{i,($=Length)[d=ImageData@#]},{j,i+1,$@d},{k,w=$@#&@@d},{l,k+1,w}]&

```

Usage: (for old 136-byte version, but the new version is basically identical)

Note:

* This runs in time O(m2 n2 max(m, n)), so only use small inputs.
* Although this is supposed to work with binary images, apparently it can work with non-binary images. (but black must be identically zero)
* The graphics doesn't necessarily be constructed with 5x5 blocks, the blocks can be smaller.
* `@*` is new in version 10. In older versions, use `Tr~Composition~Flatten` instead of `Tr@*Flatten`.
> 3 votes

# Answer
# Jelly,  ~~60 53 52 51~~  50 bytes

```
ÑFQe⁹ṚẆ;W¤
Ḣ,Ṫ
=”+ÇÇ€Ạȧ1ŀ
Zç⁾+-ȧç⁾+|$
Ẇ;"/€Ẇ€Ç€€FS

```

A full program accepting a list of strings (equal length rows) and printing the count.

**Try it online!**
...or for ease of copy & pasting input use this full program (with an extra byte to split lines)
\- do note the lines are required to contain trailing spaces for the program to function correctly though.

### How?

```
ÑFQe⁹ṚẆ;W¤   - Link 1, sidesAreValid?: list of lists, area; list allowedSideCharacters
Ñ            - call the next link (2) as a monad (get the sides in question
             -   note: these sides do not include the corners since the area was modified
             -   to not include the other sides by the first call to link 2 inside link 3.
 F           - flatten into a single list
  Q          - de-duplicate (unique characters)
         ¤   - nilad followed by link(s) as a nilad:
    ⁹        -   right argument (either "+-"                or "+|"               )
     Ṛ       -   reverse        (either "-+"                or "|+"               )
      Ẇ      -   all sublists   (either ["-","+","-+"]      or ["|","+","|+"]     )
        W    -   wrap           (either ["+-"]              or ["+|"]             )
       ;     -   concatenate    (either ["-","+","-+","+-"] or ["|","+","|+","+|"])
   e         - exists in?

Ḣ,Ṫ          - Link 2, topAndTail helper: list
Ḣ            - head (get the first element and modify the list)
  Ṫ          - tail (get the last element and modify the list)
 ,           - pair (the elements together)

=”+ÇÇ€Ạȧ1ŀ   - Link 3, isPartlyValid?: list of lists, area; list allowedSideCharacters
=”+          - equal to '+'? (vectorises across the whole area, 1 if so, 0 otherwise)
   Ç         - call the last link (2) as a monad (gets the values for two edges)
    Ç€       - call the last link (2) as a monad for €ach (...values for the four corners)
      Ạ      - all? (all corners are '+' 1 if so, 0 if not)
        1ŀ   - call link number 1 as a dyad with sideCharacters as the right argument
             -    ...and the modified area on the left
       ȧ     - logical and (both all corners are '+' and the sides in question look right)

Zç⁾+-ȧç⁾+|$  - Link 4, isValidSquare?: list of lists, area
Z            - transpose
 ç⁾+-        - call the last link (3) as a dyad with right argument "+-"
          $  - last two links as a monad:
      ç⁾+|   -   call the last link (3) as a dyad with right argument "+|"
     ȧ       - logical and (1 if so 0 otherwise)

Ẇ;"/€Ẇ€Ç€€FS - Main Link: list of lists of characters, rows
Ẇ            - all sublists (= all non-zero length runs of rows)
   /€        - reduce €ach by:
  "          -   zip with:
 ;           -     concatenation (= all non-zero length vertical edges)
     Ẇ€      - all sublists for €ach (= all possible areas)
       Ç€€   - call the last link (4) as a monad for €ach for €ach (for each area)
          F  - flatten
           S - sum

```
> 3 votes

# Answer
## Haskell, ~~180~~ ~~167~~ 166 bytes

```
l=length
a%b=[a..b-1]
h c a g b=all(`elem`c)$g<$>[a..b]
f s|(#)<-(!!).(s!!)=sum[1|y<-1%l s,x<-1%l(s!!0),i<-0%y,j<-0%x,h"+|"i(#x)y,h"+-"j(y#)x,h"+|"i(#j)y,h"+-"j(i#)x]

```

Try it online!

Go through all possible corner positions with four nested loops and check if all the chars on the lines between them consist of `+-` (horizontal) or `+|` (vertical).
> 3 votes

# Answer
# Slip, 32 29 bytes

```
$a([+`-]*`+>[+`|]*`+>){2}$A

```

Try it online!

27 bytes of code + 2 bytes for the `n` and `o` flags. Takes input in the same format provided in the question (i.e. newline-delimited block of lines).
> 2 votes

# Answer
# Jelly, ~~41~~ ~~39~~ ~~34~~ 33 bytes

```
,Z;.ị$⁺€ḟ€"⁾-|Fḟ”+
ẆḊÐfZ€µ⁺€ẎÇÐḟL

```

Try it online! or View all cases.

Based on my answer in J.

## Explanation

```
,Z;.ị$⁺€ḟ€"⁾-|Fḟ”+  Helper. Input: 2d array of characters
 Z                  Transpose
,                   Pair
  ;                   Concatenate with
     $                The tail and head
   .ị                   Select at index 0.5 -> Select at index 0 and 1
                        Jelly uses 1-based modular indexing, so
                        0 means to select the tail
      ⁺€              Repeat on each - This selects the last and first rows,
                      last and first columns, and the 4 corners
           ⁾-|       The string array ['-', '|']
          "          Vectorize
        ḟ€             Filter each
              F      Flatten
                ”+   The character '+'
               ḟ

ẆḊÐfZ€µ⁺€ẎÇÐḟL  Main. Input: 2d array of characters
      µ         Combine into a monad
Ẇ                 Generate all sublists
  Ðf              Filter for the values that are truthy (non-empty)
 Ḋ                  Dequeue
    Z€            Transpose each
       ⁺€       Repeat on each
         Ẏ      Tighten, join all lists on the next depth
          ÇÐḟ   Discard the values where executing the helper returns truthy
             L  Length

```
> 1 votes

---
Tags: code-golf, ascii-art, image-processing
---


title: Convert CMYK values to RGB

text:
# Question
Title: Convert CMYK values to RGB
Given Color codes in CMYK, convert it to RGB value.

**Input:**
*string of 4 integers(ranging from 0-100) separated by space*

```
86 86 0 43
28 14 0 6
0 41 73 4

```

**Output:**

```
#141592
#ABCDEF
#F49043

```

Shortest code wins!

> ***HINT:** For converting CMYK to RGB you may use formula such as:*
>
> ```
> Red   = 255 x (1 - Cyan/100)    x (1 - Black/100)
> Green = 255 x (1 - Magenta/100) x (1 - Black/100)
> Blue  = 255 x (1 - Yellow/100)  x (1 - Black/100)
>
> ```
>
> and use these three variables to get the value in `#RRGGBB` format

# Answer
> 5 votes
# PHP, 90 bytes

```
<?="#";for($c=explode(" ",$argn);$i<3;)printf("%02X",255*(1-$c[+$i++]/100)*(1-$c[3]/100));

```

Try it online!

# Answer
> 2 votes
# Python 3, ~~100~~ 98 bytes

*-2 bytes thanks to Rod.*

```
lambda s:'#'+''.join('%02X'%int(.0255*(100-int(i))*(100-int(s.split()[3])))for i in s.split()[:3])

```

Try it online!

# Answer
> 2 votes
# Retina, 103 bytes

```
\d+
$*1;100$*
(1*);\1

1(?=.* (1*))|1
$1
1
51$*
(1{32000})*(1{2000})*1*.
;$#1;$#2
T`d`L`1\d
;B\B|;

^
#

```

Try it online! Note: This code is *very* slow, so please don't hammer Dennis's server. Explanation:

```
\d+
$*1;100$*
(1*);\1

```

Convert each number to unary and subtract from 100.

```
1(?=.* (1*))|1
$1

```

Multiply all the numbers by the last number, which is deleted.

```
1
51$*

```

Multiply by 51, so that once we divide by 2000, we get `100 * 100 * 51 / 2000 = 255` as desired.

```
(1{32000})*(1{2000})*1*.
;$#1;$#2

```

Divide by 32000 and floor divide the remainder by 2000, thus generating a pair of base 16 values, although sadly themselves still written in base 10.

```
T`d`L`1\d
;B\B|;

```

Convert from base 10 to base 16.

```
^
#

```

Insert the leading `#`.

# Answer
> 2 votes
# Jelly, 24 bytes

```
ḲV÷ȷ2ạ1×Ṫ$×255ḞṃØHṙ1¤ṭ”#

```

A full program which prints the result.

**Try it online!**

*Note:* rounding rather than flooring may be used by inserting the two bytes of code `+.` between `255` and .

### How?

```
ḲV÷ȷ2ạ1×Ṫ$×255ḞṃØHṙ1¤ṭ”# - Main link: list of character, s
Ḳ                        - split at spaces (makes a list of lists of characters)
 V                       - evaluate as Jelly code (makes a list of the decimal numbers)
   ȷ2                    - literal 100
  ÷                      - divide (vectorises to yield [C/100, M/100, Y/100, K/100])
     ạ1                  - absolute difference with 1 -> [1-(C/100),...]
         $               - last two links as a monad:
        Ṫ                -   tail (this is 1-(K/100))
       ×                 -   multiply (vectorises across the other three)
          ×255           - multiply by 255 (vectorises)
              Ḟ          - floor to the nearest integer
                    ¤    - nilad followed by link(s) as a nilad:
                ØH       -   hex-digit yield = "0123456789ABCDEF"
                  ṙ1     -   rotate left by 1 -> "123456789ABCDEF0"
               ṃ         - base decompress (use those as the digits for base length (16))
                      ”# - literal character '#'
                     ṭ   - tack
                         - implicit print

```

# Answer
> 2 votes
# Java 8, 166 bytes

```
s->{int i=0,c[]=java.util.Arrays.stream(s.split(" ")).mapToInt(Byte::new).toArray();for(s="#";i<3;)s+=s.format("%02X",(int)(.0255*(100-c[i++])*(100-c[3])));return s;}

```

Try it online!

# Answer
> 2 votes
# Javascript (ES6), 106 bytes

```
f=
(s,z=s.split` `,k=z.pop())=>'#'+z.map(x=>('0'+(.0255*(100-x)*(100-k)+.5|0).toString(16)).slice(-2)).join``
```

```
<input id=i value="28 14 0 6"/><button onclick="o.innerHTML=f(i.value)"/>Go</button>
<pre id=o></pre>
```

# Answer
> 2 votes
# C++ (gcc), ~~169~~ 166 bytes

```
#import<iostream>
#import<iomanip>
#define F(x)int(.0255*(100-x)*(100-k))
int main(){
int c,m,y,k;
std::cin>>c>>m>>y>>k;
std::cout<<"#"<<std::hex<<F(c)<<F(m)<<F(y);
}

```

Try it online!

Using the optimized formula. ~~Added `+.5` to convert CMYK=`0 0 0 0` correct to RGB=`0xffffff`~~ which is not necessary.

# Answer
> 1 votes
# Python 3, ~~114 110 108 106~~ 104 bytes

* @xnor saved 4 bytes: deleted unnecessary code
* @rod saved 2 bytes: shorter formula
* saved 2+2 bytes: `range[3]` as `[0,1,2]`, unwanted `[]` removed

```
n=input().split()
print('#'+''.join(hex(int(.0255*(100-int(n[i]))*(100-int(n[3]))))[2:]for i in[0,1,2]))

```

Try it online!

# Answer
> 1 votes
# Ruby, 92+1 for -p flag= 93 bytes

```
gsub(/(.+) (.+) (.+) (.+)/){'#%X%X%X'%[$1,$2,$3].map{|n|255*(1-n.to_i/1e2)*(1-$4.to_i/1e2)}}

```

Try it online!

# Answer
> 1 votes
# Javascript, 104 bytes

```
s=>"#"+[0,1,2].map(n=>("0"+((255-2.55*s[n])*(1-s[3]/100)|0).toString(16)).slice(-2),s=s.split` `).join``

```

Example code snippet:

```
f=

s=>"#"+[0,1,2].map(n=>("0"+((255-2.55*s[n])*(1-s[3]/100)|0).toString(16)).slice(-2),s=s.split` `).join``

console.log(f("86 86 0 43"))
console.log(f("28 14 0 6"))
console.log(f("0 41 73 4"))
```

# Answer
> 1 votes
# Perl 5, ~~58~~ 52 + 1 (-a) = ~~59~~ 53 bytes

```
printf"#%2X%2X%2X",map{.0255*(100-$_)*(100-$F[3])}@F

```

Try it online!

# Answer
> 0 votes
# 05AB1E, 18 bytes

```
$#т/-¤s¨*255*hJ'#ì

```

Try it online!

-1 thanks to kalsowerus.

Has floating-point inaccuracies, so results might be off-by-one, but the formula in the question is used.

# Answer
> 0 votes
# dc, 53 bytes

```
16o?35Pskrsprlpr[Fk100/1r-255*1lk100/-*0k1/nz0<b]dsbx

```

Try it online!

# Answer
> 0 votes
# q/kdb+, 55 bytes

**Solution:**

```
"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-

```

**Examples:**

```
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-86 86 0 43
"#141491"
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-28 14 0 6
"#adcef0"
q)"#",raze{(last($)0x0 vs)each"h"$.0255*x[3]*x 0 1 2}100-0 41 73 4
"#f59042"

```

**Explanation:**

Fairly straightforward, stole the `0.0255` trick from other solutions (thanks!). Evaluation is performed right to left.

```
"#",raze {(last string 0x0 vs) each "h"$ .0255 * a[3] * a 0 1 2}100- / ungolfed
         {                                                     }     / lambda function
                                                                100- / subtract from 100 (vector)
                                                        a 0 1 2      / index into a at 0, 1 and 2 (CMY)
                                                 a[3]                / index into at at 3 (K)
                                                      *              / multiply together
                                         .0255 *                     / multiply by 0.255
                                    "h"$                             / cast to shorts
          (                  ) each                                  / perform stuff in brackets on each list item
                       0x0 vs                                        / converts to hex, 1 -> 0x0001
                string                                               / cast to string, 0x0001 -> ["00", "01"]
           last                                                      / take the last one, "01"
    raze                                                             / join strings together
"#",                                                                 / prepend the hash

```

**Notes:**

Rounds numbers by default, would cost 3 bytes `(_)` to floor instead before casting to short.

# Answer
> 0 votes
## Haskell, 165 bytes

```
q=(1-).(/100)
x!y=h$ceiling$q x*(q y)*255
f c m y k=concat["#",c!k,m!k,y!k]
h x|x<16=[s!!x]|0<1=(h((x-m)`quot`16))++[s!!m] where m=x`mod`16
s=['0'..'9']++['a'..'f']

```

# Answer
> 0 votes
# Fortran, 156 bytes

```
PROGRAM C
REAL,DIMENSION(4,3)::d
READ(*,*)((d(i,j),i=1,4),j=1,3)
WRITE(*,'((A,3(Z2)))')(35,(INT(.0255*(100-d(i,j))*(100-d(4,j))),i=1,3),j=1,3)
END PROGRAM C

```

---
Tags: code-golf, conversion, color
---