16
3
Premise:
Your reputation is in Stack-Exchange Form if it can be represented by decomposing your medal counts (gold, silver, and bronze counted separately) into their base-10 digits and joining them in any given order, with a few caveats.
While decomposing, each
- Gold medal digit is worth three digits.
- Silver is worth two digits.
- Bronze is one digit.
- Additionally, since SE does not display a medal type if you do not have any, a count of 0 medals for a type will not yield a
[0]
.
Example:
[1 Gold, 2 Silvers, 3 Bronzes]
will decompose into[1,1,1,2,2,3]
. 321112 and 213121 are two examples of an SE-form number for these medals.[20 Golds, 0 Silvers, 20 Bronzes]
will decompose into[2,2,2,0,0,0,2,0]
. 20002022 is an SE-form number.[11 Golds, 0 Silvers, 0 Bronzes]
will decompose into[1,1,1,1,1,1]
. 111111 is the only SE-form number for this.
There will be no leading 0's when considering a SE number. E.g., in the 2nd example above, 00002222 -> 2222
would not be considered a SE-form number for [20,0,20]
.
Input/Output:
Input is a list/tuple/array/whatever of [reputation, gold_medals, silver_medals, bronze_medals]
which are all non-negative integers. This is the assumed order but can be changed. Just make a note in your answer if you do.
Output is any two consistent values for true and false.
Rules:
- Input will always be valid
- You will always have at least 1 Rep
- You can have no medals at all, which should always return false then.
- The medal counts have no bearing on reality. Having several hundred golds and no bronzes is fine.
- This is code-golf so shortest answer in bytes wins.
Test Cases:
#[Rep, Gold, Silver, Bronze] -> Output
[4, 0, 0, 4] -> True
[1447, 0, 4, 17] -> True
[74414, 4, 0, 17] -> True
[4444, 4, 0, 4] -> True
[4455, 0, 54, 0] -> True
[5355, 5, 0, 3] -> True
[53535, 5, 3, 0] -> True
[4444, 0, 0, 4444] -> True
[444, 4, 0, 0] -> True
[1234, 0, 0, 1234] -> True
[1234, 0, 0, 4321] -> True
[4444, 1, 0, 1] -> False
[5555, 5, 0, 55] -> False
[1234, 1, 23, 4] -> False
[1, 0, 0, 0] -> False
[1001001, 0, 10, 10] -> False
so what exactly does reputation do in the context of the challenge? – OrangeCherries – 2019-06-20T12:26:45.767
3@OrangeCherries Mechanically, nothing. It inspired the challenge because I had 1447 rep and 4 silvers, 17 bronzes at the time of writing. – Veskah – 2019-06-20T12:28:09.120
1Is the input flexible besides the order? So could I for example take an input-list
[bronze, silver, gold]
and a separated second inputreputation
? – Kevin Cruijssen – 2019-06-20T13:43:50.7471@KevinCruijssen Yeah that's fine. The only thing I'd say is disallowed is taking input as a list of lists of chars/digits that make up each number. – Veskah – 2019-06-20T13:47:19.503
Are any truthy/falsy values allowed for output or does it have to be two consistent ones? – Nick Kennedy – 2019-06-20T14:39:55.203
@NickKennedy Two consistent values. (response now sans snark) – Veskah – 2019-06-20T14:48:57.273
It'd be nice to have an example that isn't just 1s and 0s, I thought the challenge dealt with binary until I read it through a few times. Maybe I'm just slow tho :) – Conor O'Brien – 2019-06-21T03:03:02.827
@ConorO'Brien But the first example is
[1,2,3]
? I changed the 2nd to[20,0,20]
just so it's more clear at a glance – Veskah – 2019-06-21T12:06:29.647@Veskah It is, but the other two examples were 1s and 0s. I was caught up on those lol – Conor O'Brien – 2019-06-21T22:42:41.470