text:
Who was the biggest "Weekend Update" host during that time period?
These are the hosts of the "Weekend Update" news segment on Saturday Night Live, with the years they hosted and their initials:
Chevy Chase         1975-1976  CC
Jane Curtain        1976-1980  JC
Dan Aykroyd         1977-1978  DA
Bill Murray         1978-1980  BM
Charles Rocket      1980-1981  CR
Gail Matthius       1981       GM
Brian Doyle-Murray  1981-1982  BD
Mary Gros           1981-1982  MG
Christine Ebersole  1982       CE
Brad Hall           1982-1984  BH
Christopher Guest   1984-1985  CG
Dennis Miller       1985-1991  DM
Kevin Nealon        1991-1994  KN
Norm MacDonald      1994-1997  NM
Colin Quinn         1998-2000  CQ
Jimmy Fallon        2000-2004  JF
Tina Fey            2000-2006  TF
Amy Poehler         2004-2008  AP
Seth Meyers         2006-2014  SM
Cecily Strong       2013-2014  CS
*Colin Jost         2014-pres  CJ
*Michael Che        2014-pres  MC

*At the time of this writing, present is 2017.

I got most of the years this website, but later ones I got from Wikipedia.
The task is simple. Given a range of years, output the initials of the person who was host during the most years in that time period. If there is a tie, output the initials of all the hosts that tied. Note that sometimes "Weekend Update" only has 1 host and sometimes it has 2.
For example, if the input is 1984-1985, output CG because he was the only person to host during both of those years.
Specifics

Input is flexible, but it will always consist of a start year and a later end year. Also you don't need to include the first two digits of the year: 95-05 is fine for 1995-2005.
Assume all ranges are inclusive: 1982-1984 means 1982,1983,1984.
For input, the earliest start year is 1975 and the latest end year is 2017

Examples

1983-1987 => DM (he hosted '85,'86,'87`)
1999-2001 => CQ JF TF [CQJFTF also ok] (all hosted during two of those years)
1975-2017 => SM (has 9 years!)
1990-2000 => KN NM (both have 4 years)
2013-2015 => SM CS CJ MC (all have 2 years)

Hm, currently this challenge seems to be about who can encode the hosts + years the best. Have you considered having the hosts + years also as an input?

@StepHen Yeah, but I'm interested in how people are creative with encoding, and tried to make the names as short as possible as such.

I knew there was a tag for this, found it. I really thought there was also a tag for storing data like that efficiently, but I couldn't find it.

@StepHen Are you thinking of Kolmogorov Complexity?

I guess that is what I am thinking of, although it doesn't quite match this challenge. I was always under the assumption that KC was for constant output, but I just checked the tag wiki and that's not what it says.

@JaneCurtain You're wrecking my compression scheme... O_o

Python 2, 291 bytes
def f(b,e):
 s=''.join('A AB BC BCD BD BDE EFGH GHJ J JK KL L L L L L LM M M MN N N N O O OPQ PQ PQ PQ PQR QR QRS RS RS S S S S ST STUV UV UV UV'.split()[b-1975:e-1974]);C=s.count;return''.join({'CJDBCGBMCBCDKNCJTASCCMCCAMRMDGEHGMNMQFFPMSJC'[ord(h)-65::22]for h in s if C(h)==max(map(C,s))})

Try it online!

JavaScript (ES6), 201 200 199 bytes
Takes the year range in currying syntax (a)(b). Returns a string made of concatenated initials.
a=>b=>"MCCJCSSMAPTFJFCQNMKNDMCGBHCEMGBDGMCRBMDAJCCC".match(/../g).reduce((o,c,n)=>(s=(a<(x-='0017240243612010012111'[n])?x:a)-(b<(y=+'3318464233612011012141'[n]+x)?b:y))>m?o:s<m?(m=s,c):c+o,m=x=2014)

Test cases

let f =

a=>b=>"MCCJCSSMAPTFJFCQNMKNDMCGBHCEMGBDGMCRBMDAJCCC".match(/../g).reduce((o,c,n)=>(s=(a<(x-='0017240243612010012111'[n])?x:a)-(b<(y=+'3318464233612011012141'[n]+x)?b:y))>m?o:s<m?(m=s,c):c+o,m=x=2014)

console.log(f(1983)(1987)) // => DM
console.log(f(1999)(2001)) // => CQ JF TF
console.log(f(1975)(2017)) // => SM
console.log(f(1990)(2000)) // => KN NM
console.log(f(2013)(2015)) // => SM CS CJ MC

Python 2, 325 bytes
def f(x,y):a=sum([s.split(',')for s in('CC CC,JC JC,DA JC,DA,BM JC,BM JC,BM,CR CR,GM,BD,BD BD,MG,CE,BH BH BH,CG CG,'+'DM '*6+'DM,KN KN KN KN,'+'NM '*4+'CQ CQ CQ,'+'JF,TF '*4+'JF,TF,AP TF,AP TF,AP,SM AP,SM AP,'+'SM '*5+'SM,CS SM,CS,'+'CJ,MC '*4).split()[x-1975:y-1974]],[]);c=a.count;print{s for s in a if c(s)==max(map(c,a))}

Try it online!

284 bytes, but more boring:
def f(x,y):a=sum([s.split(',')for s in'eJx1z9sJwzAUBNFWtoBpwlrZCgrX+NV/LVEiHBxMYDjs79qyqVY1eeiS4j1O8SZvlCDllppR8Eh66BMuciGHbvGcdcYc+ua1R504Jv2RYdFF9tDV3/DexZVov26+ACfwONE='.decode('base64').decode('zip').split()[x-1975:y-1974]],[]);c=a.count;print{s for s in a if c(s)==max(map(c,a))}

Try it online!

There's at least one secret you haven't found yet that saves a couple (or more) bytes.

@geokavel I can get down by 20 or so bytes I think. I'm trying to beat the "zip the text and decode it" approach but I haven't so far

@rosslh I don't think you saved your TIO link

fixed link: https://tio.run/##dY5Bb4JAEIXv/oq57W6ZGihSioaDjpWGZk0rvRkPhEpKgkhYSDRNfzsu2lpr0uTle5u3byZT7uuPbWG3be5zRgREGBKEhNPxiTiR3eOHSAugBQYSJ1Mt0JQB0iNOnuAopAAoQGawqQR24xrsea59YLC5PDm9wlEYzvBtBv8Qxy9wQYwknKmXR92ye4MhRRDpqyKkEKW@/5pM9FWZZzUXvfd1Cinf4V4MY181G75U338MmUi3FSjICsiXu1vLc53hvrPBaoXLlRglftxPtk1Rj6p13VTFp4LzRAxZCglXwvc38Y5v4pInmAvx1ZZVVtQ85Zb3YKOGK0TvN/M8vDNN60/mOjqzrnpm1zMvMl2xu54jRHsA

Interestingly, using the % formatting is the same length as without the % formatting

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Create a shifter
To "shift" over a number n places, do the following:

Remove the last n digits
Add n copies of the first digit to the beginning of the number

For example, to shift the number 31415 three places, take out the last three digits to get 31, and then add three more copies of the first digit, 3, to the end, giving 33331.
If the number is negative, digits should be taken from the left instead, and the first digit should be "filled in" from the right. For example, the string 31415 shifted over -3 places gives 15555.
If the number is 0, no change should be made.
If the shift is more than the length of the program, then digits that were filled in might start to be removed. This means that if the number given is more than the length of the string, no further changes will be made after the entire string becomes a single digit.
The challenge
Given two numbers, n and s, return n shifted over s places.
Test cases
   n,  s -> result
7243,  1 -> 7724
 452, -1 -> 522
  12,  1 -> 11
 153,  4 -> 111

This is code-golf, so the shortest valid submission (measured in bytes) wins.

What's the winning criterion?

what do you meaning winning? your output should just match the description  have provided above

@Mr.Xcoder It has the code-golf tag.

You should add something along the lines of This is [tag:code-golf], the shortest code wins! to the end of the post (based on the code-golf tag)

I don't think I understand what the "shifting" does. This is tagged [binary], which makes me think it has something to do with binary shifts. Maybe it would help to also display the numbers in binary in the test cases?

Sure sorry I'll fix tags

It's shifting and "stretching" the first or last digit. What's unclear?

yeah its pretty clear what they're asking

Shifting is well defined: integer multiplication or division by a power of the base. But none of the test cases work, so this question appears to use an idiosyncratic definition and not say what it is.

Maybe just rename it "stretch a number"

APL (Dyalog), 32 bytes
Anonymous function which takes the sift as left argument and the number (as a string) as right argument.
{a←|⍺⋄(≢⍵)↑(a-⍺)↓(a⍴⊃⍵),⍵,a⍴⊃⌽⍵}

Try it online!
{ anonymous function where ⍺ and ⍵ are left and right arguments
 |⍺ the absolute value of the shift
 a← store in a
 ⋄ then
 ⌽⍵ reverse the number
 ⊃ pick the first (i.e. last) digit
 a⍴ reshape it to length a
 ⍵, prepend the number
 (…), prepend the following:
  ⊃⍵ the first digit
  a⍴ reshape it to length a
 (…)↓ drop the following number of characters:
  a-⍺ a minus the shift
 (…)↑ take the following number of characters:
  ≢⍵ the length of the original number

Haskell, 69 bytes
s#n|l<-[1..abs n]=take(length s)$drop(-2*n)$(s!!0<$l)++s++(last s<$l)

Takes the number as a string. Try it online!
How it works:
s#n                         -- s: input number as a string
                            -- n: shift amount

(s!!0<$l)++s++(last s<$l)   -- make a string:
                            -- n times the first digit, the whole number, n times the last digit
                            -- e.g. "567" 2 -> 5556777
drop(-2*n)                  -- drop the first (-2 * n) chars, i.e. 0 if n>0
take(length s)              -- take as may chars as there are in s

Python 2, 50 bytes
lambda n,s:(n[0]*s+n+n[-1]*-s)[-s*(s<0):][:len(n)]

Try it online!

MATL, 12 bytes
tn:i-yn1&Xl)

Inputs are: number to be shifted as a string; amount of shifting as a number.
Try it online! Or verify all test cases.
Consisder inputs '452 and '-1'.
t     % Implicitly input string. Duplicate
      % STACK: '452', '452'
n     % Number of elements
      % STACK: '452', 3
:     % Range
      % STACK: '452', [1 2 3]
i     % Input number
      % STACK: '452', [1 2 3], -1
-     % Subtract, element-wise
      % STACK: '452', [2 3 4]
y     % Duplicate from below
      % STACK: '452', [2 3 4], '452'
n     % Number of elements
      % STACK: '452', [2 3 4], 3
1     % Push 1
      % STACK: '452', [2 3 4], 3, 1
&Xl   % Clamp, with three inputs. Applies min function, then max
      % STACK: '452', [2 3 3]
)     % Reference indexing. Implicitly display
      % STACK: '522'

This is by far the least amount of bytes good job!

@KSplitX Thanks! BTW I just added an explanation

J, 23 bytes
(_&(]{.,],{:)~|)}.~_2*]

Input n and the output are strings containing the numbers.
Try it online!
Explanation
(_&(]{.,],{:)~|)}.~_2*]  Input: 'integer n' as a string (LHS), integer s (RHS)
(              )         Extend 'n' by copying its head and tail 's' times
              |            Abs(s)
 _&(]       )~             Nest 'Abs(s)' times on 'n'
          {:                 Tail
        ],                   Append the tail to itself
     {.                      Head
       ,                     Prepend the head to the previous
                   _2*]  Multiply 's' by -2
                }.~      Drop abs(-2*s) from the head if 's' < 0 else from the tail

beautiful.  i suspected there was a better approach than mine...

although i notice you take n as a string which (possibly incorrectly ) id assumed was not allowed.  though it would have saved me only 4 chars...

Retina, 61 bytes
\d+¶
$*1¶
+`(?<!-).¶(.)(.*).
¶$1$1$2
-

+`.¶.(.*)(.)$
¶$1$2$2

Try it online!

05AB1E, 16 bytes
0‹©iR}¹ÄF¨¬ì}®iR

Try it online!
Explanation
0‹                 # input_1 is negative
  ©                # store a copy in register
   iR}             # if true (input_1 is negative), reverse input_2
      ¹ÄF          # abs(input_1) times do
         ¨         # remove the last element
          ¬ì       # prepend the head
            }      # end loop
             ®iR   # if input_1 was negative, reverse result

J, 37 bytes
This was one of those situations in J where an explicit verb seemed like the right (the only?) choice, but I would love to know if there's a tacit rewrite of this:
4 :'(-x)(|.!.((x>0)&{({:,{.)":y))":y'

J's built in shift verb allows you to configure the "fill" character:
|.!.f  NB. f is the fill character

The logic to determine whether to use the first or last char as the fill character is straightforward
(x>0)&{ ({: , {.)

Try it online!

Pyth, 28 bytes
AQ=Y<+*hJ?K<0H`G_`GHJlJ?KY_Y

Try it online or test some inputs
Explanation
AQ=Y<+*hJ?K<0H`G_`GHJlJ?KY_Y
AQ                           | Split Q into 2 parts, G and H.
        J?K<0H`G_`G          | If 0 < H, J = str(G). Else, J = reverse(str(G)). Return J
       h                     | Find 1st element
      *            H         | Repeat H times
     +              J        | Concatenate with J
    <                lJ      | Find 1st length(J) elements
  =Y                         | Assign to Y.
                       ?KY_Y | If K, implicit print Y. Else implicit print reverse(Y).

05AB1E, 33 bytes
ÄF¹0‹©i¨ë¦}}²®i¤ë¬}sg¹Ä‚Ws\×®i«ëì

Try it online!

05AB1E is not so hot with conditionals.

JavaScript, 80 bytes
(n,s,k=n.length,p=s<=0)=>n.slice(p*-s,p?k:-s)[p?"padEnd":"padStart"](k--,n[p*k])

Takes input as a string representation of the number and a numerical "shift" amount. Returns a string.
Test Snippet

let f=
(n,s,k=n.length,p=s<=0)=>n.slice(p*-s,p?k:-s)[p?"padEnd":"padStart"](k--,n[p*k])

I.value="31415";J.value="3";D.oninput()

n: <input id=I size=10> s: <input id=J size=2>
<input id=O disabled>

Python 2, 87 bytes
f=lambda n,s:s<0and f(n[::-1],-s)[::-1]or n[0]*min(len(n),s)+n[:[0,len(n)-s][len(n)>s]]

Try it online!
Takes the number as a string, and the shift as an integer. Returns a string.
I tried embedding the reversal inside the function rather than making a recursive call, but I couldn't seem to get it right.

Python 3, 73 bytes
f=lambda s,i:(f(s+1,i[1:]+i[-1])if s<0else f(s-1,i[0]+i[:-1]))if s else i

Try it online!

Haskell, 108 bytes
Oh well, this went worse than I thought..
n#s=print$show n&s
r=reverse
n&s|s<0=r$r n&abs s|(a:b,c)<-splitAt s n=take(length n)$(a<$[0..s])++b++c|1>0=n

Try it online!
Ungolfed
n # s = print $ show n & s
n & s
  | s < 0                = reverse (reverse n & abs s)
  | (a:b,c)<-splitAt s n = take (length n) (replicate s a ++ b ++ c)
  | otherwise            = n

Clojure, 121 bytes
#(let[T(if(pos? %2)reverse vec)](apply str(concat(repeat %2(first %))(T(drop(Math/abs %2)(T %)))(repeat(- %2)(last %)))))

Ouch, nasty to deal with negative inputs as well.

source: Stack Exchange

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Most common elements of a list in Python
This is a tips question for golfing in Python, which is on topic for main.
I'm looking for the shortest way to get all of the most common elements of a list in Python, in the shortest way possible. Here's what I've tried, assuming the list is in a variable called l:
from statistics import*
mode(l)

This throws an error if there are multiple modes.
max(l,key=l.count)

This only returns 1 item, I need to get all the elements of greatest count.
from collections import*
Counter(l).most_common()

This returns a list of tuples of (element, count), sorted by count. From this I could pull all the elements whose corresponding count is equal to the first, but I don't see a way to golf this much better than:
from collections import*
c=Counter(l).most_common()
[s for s,i in c if i==c[0][1]]

I am sure there is a shorter way!
Also, if it can be done without variable assignment or multiple uses of l, I can keep the rest of the code as a lambda expression to save more bytes.
Edit: Per @Uriel's suggestion, we can do:
{s for s in l if l.count(s)==l.count(max(l,key=l.count))}

And I can alias list.count for a few bytes:
c=l.count;{s for s in l if c(s)==c(max(l,key=c))}

@Uriel pointed out that we can get a couple more bytes with map:
c=l.count;{s for s in l if c(s)==max(map(c,l))}

Related, but doesn't do what I need

How about this one?
c=l.count;{x for x in l if c(x)==max(map(c,l))}

Enclose in [*...] to get a list.

Oh right, I do need a unique list or set, thanks

@musicman523 why did you update with l.count(max(l,key=l.count))? max(map(l.count,l)) is shorter

Ahhhh I didn't think of that one, thank you!


text:
Chopsticks mutated with points KoTH
Basic rules (different from mine)
Story
It is the year 4579, humans now have 2 hands with 1001 fingers each. Chopsticks has become based off of points. And @Dennis has more rep then @Martin... Hand drawn red circles are now downvoted... Jon Skeet has hit 2 trillion rep on every SE site... Yeah scary I know
Chopsticks is a hand game that has been solved. So to get around this I have created it mutated. I increased the amount of fingers.
Rules of the game
The way this is played
Everyone starts with 2 hands. Each hand has 1001 fingers. Every hand starts with 1 (one) finger up on each hand. During your turn you can "hit" the other players hand. To hit you choose 1 of your hands to hit with and 1 of their hands to hit. The hand that was hit now has the amount of fingers that was their at first AND the amount of fingers that you had on the hand you hit with.
EX
P1: 1,1 P2: 1,1. P1[0] hits P2[1]. Now fingers are P1:1,1 P2:1,2. Now P2[1] hits p1[0]. The fingers are now P1: 3,1 P2 1,2.
If one hand gets to 1001 fingers up or more then that hand is out. Then player who got a hand out (for their turn) can "split". Splitting is when you take the hand that is in and halve the amount of fingers (round up) and give those fingers to the other hand getting it back in.
EX
P1: 1000,2 P2 7,7. P2[0] hits P1[0]. Score is P1: 0,2 P2 1,1. P1[1] splits for his turn and the score is P1: 1,1 and P2 7,7.
The game ends when one player has both hands out. Points are scored by the amount of fingers the winner has. More points = better. The loser gains no points.
There are other rules that are used but these are the ones used here.
Everybody plays everybody (round robin)
Endgame
Total your points up from every round you win. Then average everybody's points up. Divide your total by the average points and get your final score. Most points win.
Actual rules
Standard loopholes
Please do not try to solve the game. I actually have to be able to run it :P
Make sure the bot can run fast. With the length of rounds judging this will take a while
All libraries needed in your program must be in the default python library. Also list the ones you need imported. Imports will just be the basic import (for math I do: import math)
Answers must work in Python 3.x
Handler
Your bot will be its own Python 3 file with a play function.
play will be passed two lists of two numbers each. This number indicates how many fingers are up on each hand. The first list is your own hand.
If you choose to hit the other player's hand, then return a list of two bits. The first bit is the index of the hand you are using to hit (0 for the first, 1 for the last), and the second bit is the index of the hand you are hitting on the opponent.
If you choose to split, return any other truthy value.
Tada!
The controller can be found here. Save each bot in its own file and list each bot's filename (without .py) in botnames.
Final note:
You and the other bot will take turns going first. If the game does not terminate in 100,000 (one hundred thousand) rounds, the game will be terminated and neither bot wins.
The controller is not protected against moves taking forever, but unnecessary overhead will be strongly frowned upon.

Sandbox

Could "Standard KOTH rules" be a link? And maybe "Standard loopholes" too.

My handler is very simple, your bot must do it's logic then adjust the the finger scores as needed, remember! What, so we're the ones doing the computations for the KoTH?

@HyperNeutrino opps fixing.

@Christopher Where is bot1split defined? Your controller isn't going to work.

@HyperNeutrino sorry copy paste error

This makes it impossible to split. Python is pass-by-reference, but if you redefine a function parameter, it will just change the local reference. Your controller still won't work.

@HyperNeutrino screw python. How do I fix that?

@Christopher Hold on, I'll rewrite the controller in a bit. I don't like the hardcoding of the function names either, so I'll send teh codez in a bit.

@HyperNeutrino I owe you one :P ty so much. I suck at writing this codez

Dennis has more rep than Martin now. Oh my god, where did these extra 996 fingers come from?!

@cairdcoinheringaahing we have no idea. I am so sorry.

The post says "Points are scored by the amount of fingers the winner has," but the controller you link to only records win/losses when I run it. Is this intended or did I do something wrong here?

@mag hmm looking into that. I actually have a few things to do with it first. But I will fix it

I would VTC this as unclear because of the controller issues, but apparently that's impossible if there's a bounty running. So count this as a virtual VTC from me.

@Mego controller issues? Also Virtual VTO

@Christopher As Magenta mentioned, the scoring in the controller doesn't match the scoring in the description.

@Mego OH, I have a version for scores. I didn't provide it since I did not think people needed to know. I will update

@Christopher You didn't think people would need a controller that matches the spec?

@Mego I didn't think

CodingAndAlgorithms
This answer actually uses coding and algorithms, unlike the others so far!reference: imgur(also beats all of the answers posted before this)
def play(A, B):
    if sum(A) == 1:
        return [A.index(1), B.index(max(B))]
    elif max(A) + max(B) > 1000:
        return [A.index(max(A)), B.index(max(B))]
    elif 0 in A:
        return 1
    elif 0 in B:
        return [A.index(min(A)), 1-B.index(0)]
    else:
        return [A.index(min(A)), B.index(min(B))]

I got that reference XD

This just won. It never lost.

Congratulations! I guess I'm going to have to settle for second place. Your coding and algorithms were stronger than mine

Aggressor
def play(s, o):
    return [s.index(max(s)),o.index(max(o))]if all(s)else 1

Another starter bot, Aggressor will hit the larger of the opponent's hands with the larger of its own hands if both of its hands are non-empty; otherwise, it splits.

CautionBot
def play(s,o):
 if max(s)+max(o)>1000 and (all(s) or max(s)+min(o)<1001):
  return [s.index(max(s)),o.index(max(o))]
 else:
  return [s.index(min(s)),o.index(min(filter(bool,o)))]if all(s) else 'split'

CautionBot doesn't want to cause too much trouble, so it hits the smaller of the opponent's hands with its smaller hand if it has both hands, and otherwise splits. However, CautionBot is no fool, so if it can take out an opponents' hand without immediately losing next turn, it will do so instead of its normal move.

Unofficially this is winning

Cool! We'll see how things go from here because I won't be surprised when someone develops a better strategy. I just applied what I understood to be vanilla Chopstick strategy (be a coward and split often to avoid being killed) in a way that best accommodated the new rules (be a coward and hit low to avoid getting killed, since splitting/merging while you have both of your hands is illegal) lol

Equalizer
def play(s, o):
    if not all(s):
        return 1
    else:
        return [s.index(max(s)), o.index(min(filter(bool, o)))]

If Equalizer is missing a hand, it will split. Otherwise, it hits its opponents smallest hand with its own largest hand.

According to these mutated rules, AFAIK you can only split if one hand is out.

Oh yeah, I'll fix that.

"If Equalizer has no hands..." well I mean if it has no hands then it lost already? But that's just nitpicking, take my +1 to compensate

RandomBot
import random

def play(s, o):
    return [random.randint(0,1)for i in'  ']if all(s)else 1

Just to get things started, here's a bot which makes a random hit if its hands are both non-empty; otherwise, splits.
Golfed because why not :3

I was fixing that

@Christopher Sorry, didn't see your comment. ---Once you fix it I'll delete this.--- I'll just delete this because it's stupid xD

@Christopher Note: I've edited this into a valid submission. I'll add another solution too; tell me if the controller doesn't work properly :)

Nice trying them out

@Christopher Does the controller work properly?

Getting it set up rn

Let us continue this discussion in chat.

Please don't __import__('random') inside a loop. That's a lot of efficienty percents lost compared to import random then using random.

@Uriel right yes, thanks.

@HyperNeutrino here this wouldn't make much of a change, because it's just 2 calls every round, but in general...

golfed more. play = lambda s,o:[random.randint(0,1)for i in'  ']if all(s)else 1

@DestructibleLemon Unfortunately the lambda doesn't seem to work because it seems to not be a publicly accessed function. I don't know the details, but it didn't work as a lambda.

Error
Yes, that is the name of the bot.
def play(s, o):
    if max(s)+max(o)>1000:
        return [s.index(max(s)),o.index(max(o))]
    if 0 in s:return ''
    return [s.index(max(s)),o.index(min(o))]

I arrived at at this by testing with the other bots. However it is consistently second-last in my simulations. So Ill be making another bot eventually.
Edit: I can't seem to write any bot that beats CautionBot, and my extra testing seems to indicate that this is second best, not second worst.

Marathoner
I tweaked Aggressor's code provided by "HyperNeutrino" to simply hit the smaller of the opponents two hands with the smaller of it's hands. It is a very silly strategy of course but I can't turn down being at the top of a chart! (Even though that chart would be losses)
I'm not sure if this code will run without errors because I was unable to test it due to being at work. However, it should run flawlessly.
def play(s, o):
     return [s.index(min(s)),o.index(min(o))]if all(s)else 1

Nice first answer! You chose a great question :P (no bias)

Thanks :) I was pretty nervous because I wasn't sure if tweaking someone else's code like I did was allowed or not. I assume it is as long as you make it obvious.
And I was gonna try to make one that would just play the biggest hand against the opponents biggest but HyperNeutrino beat me to that one exactly! haha

Yeah. On this SE tweaking code is often used :P

Cool answer! One thing that I'd worry about (can't test it right now) is that I don't know how the controller will respond if you try to hit an empty hand, or how that factors into the rules.

@ValueInk Hmm. I understand what you're saying. I'll try some fiddling but I don't think this oversight will be a huge problem because this is probably (besides doing nothing) the worst strategy haha
Also thanks for the support on my answer, first one and all. Hopefully I'll be outgolfing you in a few months ;)

Isn't this what my bot, Equalizer, does anyway?

This is very similar to Equalizer but Equalizer will check to make sure it doesn't hit the opponent's empty hand if present. @LyricLy


text:
TryItOnquine Challenge
(based on this post and the ensuing discussion on chat -- also, much thanks to Dennis for TIO!)
The Challenge
Choose a language that's currently available on the TryItOnline site, for example PowerShell. Write code in that language on that page, that doesn't take any input, such that when the Run button is clicked, the output on that page is the exact same as what is in the "Plain URL" field when the Save/Store button is clicked instead.
For a fictitious example, suppose that aaa was the code for a solution to this in PowerShell. Then, the result of clicking Run with aaa as the code on https://tio.run/#powershell should output https://tio.run/##K8gvTy0qzkjNyfn/PzEx8f9/AA, which is also the "Plain URL" field when the Save/Store button is clicked.
Scoring
The resulting URL is your submission to this challenge. The winner is the shortest URL measured in bytes. For the example above, the URL https://tio.run/##K8gvTy0qzkjNyfn/PzEx8f9/AA is the submission to the challenge, at 44 bytes. The shortest URL that fulfills the rest of this challenge wins the challenge and earns brownie points (points not redeemable). Given that there is a distinct minimum possible length, if two submissions tie in length, the earlier submission wins.
URL Generation
This is the start of the URL generation algorithm in the repository. You can see how the main code area is taken, any extra elements are appended, the string is deflated and Base64 converted, and then ## prepended, etc. I won't go into full detail here; part of the challenge is to parse and understand how the URLs are generated in order to exploit any potential quirks in said algorithm.
Rules / Clarifications

The actual code should take no input and produce only the quine-URL as output.
-- This means the only text fields that should be populated when clicking into the URL are the Code, Header, Footer or corresponding "Compiler Flag" fields; the Input and Arguments fields are forbidden and must remain empty/unused. Clicking the Run button should only change the Output field. For this challenge, the Debug field is ignored in all situations.
Usual quine rules apply to the code to the extent possible (for example, the code cannot read its own source code via .code.tio).
Please include a description of how the code works in your submission.
Submitting a "cheaty" quine by submitting a Git pull request to the TIO repository to create a "trick" URL or shortcut or the like is not allowed.
Similarly, submitting a pull request to update a particular language to produce a "trick" URL is not allowed.
Please be nice to Dennis' servers and don't abuse them or attempt exploits for the sake of this challenge.

Remember, last rule is important! There's already a bunch of DDoS attacks going on.

What is a "PR"?

Related.

console.log(window.location.href) -  I know this doesn't work, but if there is a language that can read the current URL of TIO can you say "this only works when run on TIO after clicking the link button once" and output the current URL?

@MagicOctopusUrn All user code is executed on the server side. Getting direct access to the permalink URL is not possible.

@Dennis That is, well, if they don't implement the algorithm themselves. ;)

@Dennis I figured it wasn't possible just looking at the JavaScript on GitHub for the URL generation, but I didn't read everything. It'd be logical for you to execute a client-side language on the client's side. For instance, I was thinking JS may just use JS to sniff what the user's browser executes it as.

Fictitious example: if my submission is https://tio.run/##a+a which links to a program that outputs https://tio.run/##a+a, is it valid even tough the link generated by saveState would have been https://tio.run/##a@a

@TwiNight Good question. That would be an interesting situation, but would not fit into the rules here and so would not be a valid submission.

Were you waiting until TIOv2 to post this?

@mbomb007 Not intentionally.

The conversation you linked that we had happened in April, so I was just wondering.

Against the rules sadly.

Python 2, URL length = 170 bytes
https://tio.run/##K6gsycjPM/r/v9hWqQDCjqlISwPhYlvVIuvM3IL8ohKFpMTiVDMT64KizLwS9YySkoJiK339ksx8vaLSPH1lZXVtiAK9JDOT1Lzk/JRUDY1iVdViTT0YT70qJzNJXVMz2shK1yRWE2aHEkUW4Db//38A

s="python2\xff\xffs=%r;import base64;print'https://tio.run/##'+base64.b64encode((s%%s).encode(('zlib'))[2:-4])\xff\xff";import base64;print'https://tio.run/##'+base64.b64encode((s%s).encode(('zlib'))[2:-4])

Try it online!
This relies on three coincidences:

The default zlib level 6 happens to give the same results as zlib level 9 for this string, modulo the header that I strip.
The compressed length is divisible by 3, so base64 does not generate any = padding characters.
The base64 output does not contain any + characters.

Bash, 174 166 165 157 bytes
https://tio.run/##S0oszvj/v6QosUBBV1dBvaAoM68kTSGjpKSg2EpfvyQzP0avqDRPX1lZRQMqp6RaHFORlgbCSgpJQO0KSgkg/QlKNelVmQU1JYmZOQq6ydqGhjVA2VQzEwXdckNjS011BdcIz5D//wE

This encodes the following Bash program.
trap -- 'printf https://tio\.run/##$(printf "%s\xff\xff" bash "`trap`"|gzip|tail -c+11|base64 -w139)' EXIT

Try it online!
Thanks to @jimmy23013 for golfing 8 bytes off my original approach, for an approach that saved another byte, and for golfing another 8 bytes off that approach!

https://tio.run/##S0oszvj/v6QosUBBV1dBvaAoM68kTSGjpKSg2EpfvyQzP0avqDRPX1nZGiqVBNQQE1ORlgYmVIsRbAWlBJA5CUo16VWZBTUliZk5CrrJ2oaGNRmpiSlApq5FDVB3qpmJgm65gYKCuoJrhGfI//8A

@jimmy23013 I can't count the number of times I've typed base64 | tr -d \\n into my terminal... Thanks!

https://tio.run/##S0oszvj/v6QosUBBV1dBvaAoM68kTSGjpKSg2EpfvyQzP0avqDRPX1nZGiqlWhwTU5GWBiYUkoC6FZQSQNoTlGrSqzILakoSM3MUdJO1DQ1rMlITU4BMXYsaoLpUMxMF3XIDdQXXCM+Q//8B Unfortunately it has a + that I don't know how to remove.

@jimmy23013 Managed to get rid of it, but it cost three bytes. Annoyingly, https://tio.run/##S0oszvj/v6QosUBBV1dBvaAoM68kTSGjpKSg2EpfvyQzP0avqDRPX1mZCyqlWhwTU+HmBiYUkoC6FZQSQNoTlGrSqzILakoSM3MUdJO1DQ1rgLKpZiYKuuWGJmY1xakpCoaF6gquEZ4h//8DAA gets rid of that + but introduces another one elsewhere.

https://tio.run/##S0oszvj/v6QosUBBV1dBvaAoM68kTSGjpKSg2EpfvyQzP0avqDRPX1lZRQMqp1ocE1ORlgYmFJKA2hWUEkD6E5Rq0qsyC2pKEjNzFHSTtQ0Na4CyqWYmCrrlhsaWmuoKrhGeIf//AwA

@jimmy23013 Now that's a clever way of getting rid of the second line. Thanks again!

What's the problem with + symbols? (Haven't had a go at this, just curious.)

@SteveBennett The challenge requires generating the exact URL the online interpreter generates, and TIO replaces + characters with @ for permalinks.

Ah, makes sense. Now, why does it do that? + is allowed in URLs, right?

@SteveBennett I think I had a good reason. I don't quite remember it though.

What about base64 -w0?

Pyth, URL length = 134 bytes
https://tio.run/##K6gsyfj/X68syy/ZS6lYmyujpKSg2EpfvyQzX6@oNE9fWZnLwae4OLrI3dA9NITLQZ9LM8vZxqSkRC@qOJqrAKiby9vZyNTUmwtiBpefl7e3ppnJ//8A

Code:
.vjNcJ"s+
https://tio.run/##
@Lss[rG1GUT
@/
)jC<4tt.Zs[
pyth
KC255K
.vjNcJ
NJKK)64

Try it online!
Uses Pyth’s zlib builtin (.Z), and an inline implementation of base64.
How it works
The outer stage:
.vjNcJ"…
      "…    take this 75-byte string
     J      assign it to J
    c       split on whitespace
  jN        join on N = '"'
.v          evaluate as Pyth code

The inner stage, obtained by replacing whitespace in the string J with double quotes:
s+"https://tio.run/##"@Lss[rG1GUT"@/")jC<4tt.Zs["pyth"KC255K".vjNcJ"NJKK)64
                                               [                             begin a list:
                                                "pyth"                         string,
                                                       C255                    character 255
                                                      K                        assign that to K,
                                                           K                   K again,
                                                            ".vjNcJ"           string,
                                                                    N          '"',
                                                                     J         J (the 75-byte string),
                                                                      K        K again,
                                                                       K       K again
                                                                        )    end list
                                              s  concatenate
                                            .Z   compress with zlib
                                           t     remove first character
                                          t      remove first character
                                        <4       remove last 4 characters
                                       C         convert from base 256
                                      j                                  64
                                                 convert to base 64 digits
                      @L                         map d ↦ the following indexed at d:
                          [                        begin a list:
                            G                        alphabet ("abcdefghijklmnopqrstuvwxyz")
                           r 1                       uppercase,
                              G                      alphabet again,
                               UT                    unary range of length T = 10: [0, …, 9],
                                 "@/"                string,
                                     )             end list
                         s                         concatenate
                        s                          concatenate (we now have the base64 alphabet)
 +"https://tio.run/##"                           prepend string
s                                                concatenate

(It’s too bad the “Input” field is disallowed, or I’d have a 118 byte solution.)

Did... Did you just outgolf Dennis on a challenge built around TIO‽

PowerShell, 274 bytes
https://tio.run/##TY/rCsIwDIVfZaiYFV2HooIbgu8xBrYzboXSljYq3p59VkHZjxAOJydf4uwVfehQ676fphO5e1TK8pPSWBfF1StCobW8EYYUJMyrphO@qmtw/xzMluv1t37maJoePpsm8sVGP5eV7V25JDslsozmgOJRHAcQ3t6BldARuVDkOcVBfzb5eAwRYM0FPcUQWSkCblaBvDJtPLxaLDmPnTf2bCjbsppxj06LBlPYwRxgoGdR74E9vw9mnQ2UZObF@v4N

It's all thanks to the following snippet:
&($b={[io.file]::writeallbytes('b',[char[]]'powershell'+255+255+[char[]]"&(`$b={$b})"+255+255);gzip -f b;$b=[io.file]::readallbytes('b.gz');'https://tio.run/##'+[convert]::tobase64string($b[12..($b.count-9)]).replace('=','').replace('+','@')|write-host -n})

Try it online!

Holy christ, can you explain how you got to this answer? If I even tried in Java or something it'd be pure trial and error.

JavaScript (Node.js), 214 bytes
v=()=>console.log('https://tio.run/##'+require(`zlib`).deflateRawSync(Buffer.from(`javascript-node\xff\xffv=`+v+`;v()\xff\xff`,`ascii`)).toString("base64"));v()

Try it online!


text:
Codebreakers and Codewriters
Let's say you have some text, and you want it to send it to your friend, but you don't want anyone else to read it.  That probably means you want to encrypt it so that only you and your friend can read it.  But, there is a problem: you and your friend forgot to agree on an encryption method, so if you send them a message, they won't be able to decrypt it!
After thinking about this for a while, you decide to just send your friend the code to encrypt your message along with the message.  Your friend is very smart, so they can probably figure out how to decrypt the message by studying the encryption method.
Of course, since other people might be reading the message, you want to choose an encryption scheme that makes it as hard as possible to crack (figure out the decryption scheme).
Cops' Task
In this challenge, Cops will play the role of the writer: you will design an encryption scheme that converts strings to strings.  However, this encryption scheme must be bijective, meaning that no two strings must map to another string, and every string can be mapped to by an input.  It must take only one input—the string to be encoded.
You will then post some code that performs the encryption, and a single message encrypted with the scheme detailed by your code.
Since you are paying by the byte to send messages, your score will be the length of your code plus the length of the ciphertext.  If your answer is cracked, you will have a score of infinity.
After one week, you may reveal the text and mark your answer as Safe.  Safe answers are those that cannot be cracked.
Robbers' Task
Robbers will play either as the friend of the writer or the malicious middle man (there is no material difference, but you can role-play as either if it makes it more fun to do so).  They will take the encryption schemes and the ciphertext and attempt to figure out the encrypted message.  Once they figure out the encrypted message, they will post it in a comment. (There will not be a separate robbers' thread for this question.)
The winner will be the robber with the most cracks.

Here is an example of what a cracked solution might look like:

If the encoding is bijective, what are the domain and codomain?

The strings with which characters?

@WheatWizard Which 256? You mean 256 bytes not characters right?

What's to stop somebody from using a cryptographically secure function?

Related challenge: All your bijective base are belong to us

On who is the burden of proving bijectivity: the cop or potential robbers? I.e., if it is unknown if a function is bijective, what happens?

@WheatWizard "I don't know of any function that is cryptographically secure when the key is given" without this you'd be practically left with no security. Practically all security rely on the fact that it is still secure when you know the algorithm. Look up RSA encryption.

@WheatWizard How is RSA not bijective?

@WheatWizard with one key there is only one encryption.

@WheatWizard I didn't use padding in my implementation.

So the trick here is, write a program in Malbolge.

Jelly, 57 + 32 = 89 bytes (cracked)
“¡ḟċ⁷Ḣṡ⁵ĊnɠñḂƇLƒg⁺QfȥẒṾ⁹+=?JṚWġ%Aȧ’
O‘ḅ256b¢*21%¢ḅ¢ḃ256’Ọ

Encrypted message:
EªæBsÊ$Ê³¢?r×Q4e²?ò[Ý6

As a hex-string:
4518AAE6421973CA
9724CAB3A23F72D7
AD18855134651810
B23F1CF25BDD9036

Explanation:
O‘ḅ256b¢*21%¢ḅ¢ḃ256’Ọ
O                     convert each into codepoint
 ‘ḅ256                convert from bijective base 256 to integer
      b¢              convert from integer to base N
        *21           map each to its 21th power
           %¢         modulo N
             ḅ¢       convert to integer from base N
               ḃ256’  convert from integer to bijective base 256
                    Ọ convert each from codepoint

Where N is encoded by the string “¡ḟċ⁷Ḣṡ⁵ĊnɠñḂƇLƒg⁺QfȥẒṾ⁹+=?JṚWġ%Aȧ’, which is the number 105587021056759938494595233483151378724567978408381355454441180598980268016731.
Also, this is the RSA method with N given above and public key 21. Cracking this is equivalent to finding the two prime factors of N.

Well. I'm able to decrypt my own encrypted message with the key I've found, but it seems to fail with yours. :-/ (The expected result is not a 4-character non-English message, is it?)

The message is _ìNb (Try it online!).

@AndersKaseorg Yup. That's what I had, but I was expecting something slightly more meaningful. :-)

For what it's worth, here is the code I used on my side.

(where N was factorized with PPSIQS by Satoshi Tomabechi)

Ah, gotcha. I've been running a program I wrote to factor N for a few hours with no luck...I didn't do out the math before I killed it, but I think it would have taken several months

@musicman523 Actually... it only takes 6 minutes to factor a 256-bit integer even if I chose the primes correctly. brb increasing the number of bits.

@AndersKaseorg Jelly attempts to eval it's arguments, so null bytes are indeed possible. https://tio.run/##y0rNyan8/9//////6jEGIKgOAA

@LeakyNun the crap program I wrote was far from optimal...I was just hoping you chose two numbers really close together

Jelly, 88 + 64 = 152 bytes
Encryption function:
“¥@ɦ⁺€€Ṅ`yȤDƁWĊ;Y^y⁻U ⁸ßɠƁXẹṡWZc'µ÷ḷỊ0ÇtṙA×Ḃß4©qV)iḷỊDƭ Mṛ+<ṛ_idðD’
O‘ḅ256b¢*21%¢ḅ¢ḃ256’Ọ

Encrypted message:
AX!?ÖÍL¹    JÓ°û0àah4Û{µÌá`
^tÝrRÕù#êwðãTÓK"Íû´Ëß!øòOf«

As a hex-string:
9F419458213FD6CD4CB9094A10D3B0FB
8F30E0616834DB7BB517CCE1600A5E74
DD7252D5F923EA77F0E354D34B9F22CD
FB80B4CBDF21F80E94F24F9A66AB9112

Explanation:
O‘ḅ256b¢*13%¢ḅ¢ḃ256’Ọ
O                     convert each into codepoint
 ‘ḅ256                convert from bijective base 256 to integer
      b¢              convert from integer to base N
        *13           map each to its 13th power
           %¢         modulo N
             ḅ¢       convert to integer from base N
               ḃ256’  convert from integer to bijective base 256
                    Ọ convert each from codepoint

Where N is encoded by the string:
“¥@ɦ⁺€€Ṅ`yȤDƁWĊ;Y^y⁻U ⁸ßɠƁXẹṡWZc'µ÷ḷỊ0ÇtṙA×Ḃß4©qV)iḷỊDƭ Mṛ+<ṛ_idðD’

which is the number
15465347049748408180402050551405372385300458901874153987195606642192077081674726470827949979631079014102900173229117045997489671500506945449681040725068819

Also, this is the RSA method with N given above and public key 13. Cracking this is equivalent to finding the two prime factors of N, which has 512 bits.

I love that your encrypted string looks like your code

Using this wonderful program, I'm sure I can crack your solution a couple millennia after the heat death of the universe.

@SocraticPhoenix factorization by trial division can never come close to quadratic sieve.

@LeakyNun I don't understand your big math words...

@SocraticPhoenix your program tries each factor from 2, while quadratic sieve is much faster. It can factorize a 256-bit semiprime in 6 minutes, whereas your program would have taken an eternity.

Quadratic sieve is the best option for integers up to approx. 100 decimal digits. Beyond that, you should use the General Number Field Sieve. Factoring this 512-bit integer (supposed semiprime) in less than one week would probably have a dissuasive enough CPU cost for the context of this challenge, though.

@Arnauld How many bits are usually used then?

@LeakyNun I think the current recommended standard is 2048-bit keys. 512 is probably too much for a recreational challenge but definitely not enough for any sensitive data.

@Arnauld how quickly would you expect a quadratic sieve to factor this number? Aaand do you know of any Java implementations of the general number field sieve (all the math is over my head, but I know enough to call a library function!).

@SocraticPhoenix I may be wrong, but I don't think QS can factor this in any reasonable time. As for a Java implementation of GNFS, this one maybe?

I've already danced this dance with @Sp3000, and 512 bit RSA costs around ~$70 to crack: https://codegolf.stackexchange.com/questions/107014/hidden-inversions-robbers-thread/107660#107660.

@orlp in electrical costs? That seems like a kind of arbitrary number...

@SocraticPhoenix Sp3000 used c4.8xlarge spot instances on Amazon EC2. As of today, they cost $0.37 per hour for Linux (at least for their Ohio data center).

@Arnauld interesting... it looks like my measly secondary computer won't be able to get this done in < 5 days anyway... gg Leaky Nun, gg

JavaScript (ES6), 43 + 33 = 76 bytes Cracked by Leaky Nun
Encryption function, 43 bytes:
s=>[...s].sort(_=>Math.cos(i++),i=0).join``

Encrypted message, 33 bytes:
NB: This encryption method is browser-dependent.
FireFox: "ty a)s kaasoeocr!hTt; o s  -cwaoo"
Chrome : "oht aasoaoas   e)tosr;oky c!-cw T"
Edge   : "tskso ;- caroteoTha wa soo ay c!)"

T! a)o khas eotrto-c; o sa cwsaoy

@LeakyNun Err ... no.

What does my answer produce instead?

Which browser are you using? I'm using Chrome.

Wild guess, but is it !o a)w k asoeotryatc; s s oT-caoh?

If you don't mind, can you provide the output for "0123456789abcdefghijklmnopqrstvuw"?

That was soooo easy to crack! -;) (I used firefox to crack it)

Braingolf, Cracked
(d1&,&g)&@

Try it online!
Encrypted message, 45 bytes (UTF-8)
°Áݭїϳ{ًչםק{їϳэÁק{|э³קѡ|

Hexcodes of encrypted message
C2 B0 C3 81 DD AD D1 97 CF
B3 C2 90 7B D9 8B D5 B9 D7
9D D7 A7 7B D1 97 CF B3 D1
8D C3 81 D7 A7 7B 7C D1 8D
C2 B3 D7 A7 D1 A1 7C C2 85

Decrypted message
C'mon, this one's *easy*!

Explanation
(d1&,&g)&@  Implicit input from commandline args
(......)    Foreach loop, foreach codepoint of input
 d          Split into digits
  1         Push 1
   &,       Reverse
     &g     Concatenate
        &@  Print

Decoder
A decoder can be made by changing only 3 characters. Simply remove the 1, and insert $_ inbetween &, and &g
(d&,$_&g)&@

Can you provide a TIO?

C'mon, this one's *easy*!

@KSmarts Correct!

g is undocumented?

Is this bijective?

@LeakyNun yes, each character in the output has a character value equal to the corresponding input's value reversed and prefixed with a 1.
For example a space (32) becomes 123

That doesn't mean it's bijective, that just means it's well-defined.

@LeakyNun my understanding of bijective is that it must have no collisions

No, that just means injective; the comments clarified that the range must be all byte strings.

@LeakyNun I had a bit of trouble with this one because g does seem to be undocumented. At least, on the github readme and on Esolangs.org

JavaScript (ES6), 96+9=105 bytes
q=>Buffer(q).map((a,i,d)=>d[i-1]^Math.abs(1e16*Math.sin(d[i]+i))%255).sort((a,i)=>Math.tan(a*i))

Ciphertext (hex-encoded): 7d111c74b99faff76a
Try it online!
Sample outputs (using V8 engine):
abc123 -> db48ea4f86b9
Hello -> 1b3420f5ab

Invalid submission: multiple plaintext generate the same ciphertext. For example: "C", "D". This only counts for the first char. Of the 256 possible inputs, only 165 unique outputs.

It is bijective for the intended range (ASCII A to ASCII z)

I just told you it's not. Just try your code with respectively "C" and "D" as the input string. Same output string 76.


text:
Non-integer bases
Description:
A non-integer representation of a number uses non-integer numbers as the bases of a positional numbering system.
e.g. Using the golden ratio (the irrational number 1 + √5/2 ≈ 1.61803399 symbolized by the Greek letter φ) as its base, the numbers 1 to 10 can be written:
Decimal Powers of φ             Base φ
1       φ0                      1
2       φ1 + φ−2                10.01
3       φ2 + φ−2                100.01
4       φ2 + φ0 + φ−2           101.01
5       φ3 + φ−1 + φ−4          1000.1001
6       φ3 + φ1 + φ−4           1010.0001
7       φ4 + φ−4                10000.0001
8       φ4 + φ0 + φ−4           10001.0001
9       φ4 + φ1 + φ−2 + φ−4     10010.0101
10      φ4 + φ2 + φ−2 + φ−4     10100.0101

Note that just as with any base-n system, numbers with a terminating representation have an alternative recurring representation. In base-10, this relies on the observation that 0.999...=1. In base-φ, the numeral 0.1010101... can be seen to be equal to 1 in several ways:
Conversion to nonstandard form: 1 = 0.11φ = 0.1011φ = 0.101011φ = ... = 0.10101010....φ
One representation in a non-integer base can be found using the greedy algorithm.
Challenge:
Given a number n, a non-integer real base b (1 < b < 10, since, as @xnor pointed out in comments, representation in current format would be nonsensical), and decimal places l, output a non-integer representation of n in base b to l decimal places.
Test Cases:
n=10, b=(1 + Sqrt[5])/2, l=5,     ->     10100.01010
n=10, b=E, l=5,                   ->     102.11201
n=10, b=Pi, l=5,                  ->     100.01022
n=10, b=1.2, l=14,                ->     1000000000001.00000000000001
n=10^4, b=Sqrt[2], l=12,          ->     100001000010010000010000100.000000000001

Note any valid representation is allowed. e.g.
n=450, b=E, l=6,     ->     222010.221120

or
n=450, b=E, l=6,     ->     1002020.211202

Prohibitions:
Calling Wolfram Alpha or any other external computational site is disallowed. Standard loopholes apply. This is Code Golf, so shortest code wins.

Can our output be two lists, one of digits and one of decimal places, rather than a string?

@notjagan yes that's fine

For this to be able to be solved in any language not called Mathematica, you're going to need to define every notation you will use for b. Currently you use (), /, Sqrt[], E, and Pi. What else do we need to recognize?

@StepHen It doesn't matter what your chosen language doesn't recognise - as long as input and output agree, and b takes non-integer inputs (e.g. b=1.123468574 or b=2/5), that's fine.

@martin non-integer inputs in what form? Can there be sin? mod? floor? Is b always given as a rational approximation of the input? This is missing a clear input spec at the moment...

@SocraticPhoenix as long as b is not an integer, it can be in any form. The code should really work with integers too (though Sin[x] wouldn't satisfy b > 1).

@martin I believe he means whether we need to deal with an input of "sin(1+sqrt(5))", i.e. whether we need to evaluate those expressions.

What @LeakyNun said.

@LeakyNun Apart from the fact that sin(1+sqrt(5)) wouldn't satisfy b > 1, no, there is no limiting criteria that input must be able to handle a certain input. A simple decimal input is acceptable.

Should we output the greedy choice of representation, or is that just one option?

@xnor that's just one option

@martin Can the digits be negative numbers? Or, what if they are above 9?  And I take it the digits must be integers?

@xnor No, digits can't be negative, and yes the digits must be integers. Digits oiver 9 do present a problem - didn't think of that! - Will add in that bases should be reals from 1 to 10, or would nmean reformatting string.

Mathematica, 85 bytes
(r=RealDigits[#,#2,9#3];k=r[[2]];s=ToString/@r[[1]];""<>s[[;;k]].""<>s[[k+1;;k+#3]])&

Mathematica, 86 bytes
(s=TakeDrop@##&@@RealDigits[#,#2,9#3];FromDigits@s[[1]].""<>ToString/@s[[2]][[;;#3]])&

input

[450,E,6]

Python 3, 151 134 121 120 bytes
import math
def f(n,b,l,r=''):
 for i in range(int(math.log(n,b)),-l-1,-1):r+="%i"%(n/b**i)+'.'*(0==i);n%=b**i
 return r

Try it online!
Returns a string of the non-integer base representation. This can probably be golfed more; stay tuned.

Special thanks to:

@LeakyNun for saving 13 bytes!
@Zacharý for saving 1 byte!

121 bytes

@LeakyNun woah. What's going on in "%i"%(n/b**i)? I've not seen syntax like that before.

It is string formatting. "%i" is the string to be formatted, with parameter n/b**i

You can save a single byte by using import math then math.log.

@Zacharý good catch, thanks!

APL (Dyalog Unicode), 47 bytes
{⌽⊃∘⍕¨⍺⍺(↑,'.',↓)⌊(⊣,⍨⍺×1|⊢)⍣(⍺⍺+z)⍨⍵÷⍺*z←⌊⍺⍟⍵}

Try it online!
A dop that takes n, b, l as ⍵ (right arg), ⍺ (left arg), ⍺⍺ (left operand) respectively. Does greedy conversion from the most significant digit.
How it works
{⌽⊃∘⍕¨⍺⍺(↑,'.',↓)⌊(⊣,⍨⍺×1|⊢)⍣(⍺⍺+z)⍨⍵÷⍺*z←⌊⍺⍟⍵}  ⍝ ⍵←n, ⍺←b, ⍺⍺←l

⍵÷⍺*z←⌊⍺⍟⍵  ⍝ Part 1
      ⌊⍺⍟⍵  ⍝ Floor of Log of n with base b
            ⍝ (number of digits above decimal point - 1)
    z←      ⍝ Assign to z
⍵÷⍺*        ⍝ Divide n by b^z, so that floor will give highest digit
            ⍝ Let's say the value is k

(⊣,⍨⍺×1|⊢)⍣(⍺⍺+z)⍨k  ⍝ Part 2
(        )⍣(⍺⍺+z)⍨k  ⍝ Repeat l+z times, using k as both the
                     ⍝ left arg (fixed) and right arg (moving)...
      1|⊢  ⍝ Fractional part of right arg
    ⍺×     ⍝ Multiply b
 ⊣,⍨       ⍝ Append left arg
⍝ The net effect is "prepend next significant digit, keeping fractional part"
⍝ Let's say the resulting array is v

⌽⊃∘⍕¨⍺⍺(↑,'.',↓)⌊v  ⍝ Part 3
                ⌊v  ⍝ Floor each number in v
     ⍺⍺(↑,'.',↓)    ⍝ Insert the decimal point after l digits
 ⊃∘⍕¨               ⍝ Convert each digit to a char
⌽                   ⍝ Reverse, so that the highest digit comes first

C (clang), 129 123 121 120 118 bytes (115 + -lm compiler flag)
f(n,b,l,i,y,z)double n,b,l,z;{for(i=log(n)/log(b);~i<l;n=fmod(n,z))z=pow(b,i),printf(".%d"+!!~i--,y=n/z);puts("");}

Try it online!
7 8 10 bytes shaved off thanks to ceilingcat!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Use letters to make numbers shorter
Challenge
Take a number and output it with 4 digits or less using letters and numbers. For example; 270,030 would turn into 270K.
Key
Billion -> B
Million -> M
Thousand -> K
Rules

You may choose to accept input numbers that include commas delimiting every three decimal places (such as 123,456,789).
Round to nearest, half-up.
Numbers will only go up to 999,499,999,999 .
The mantissa part of the answer should be at least 1.
All letters must be uppercase and as specified above.
Outputs must be 4 or less digits. (including letters such as B, K, and M)
Outputs must be as mathematically precise as possible. Example:

15,480 -> 20K NOT OK
15,480 -> 15.5K GOOD

If there are multiple outputs with the same mathematical precision, return either one. Example:

1000 -> 1000 GOOD
1000 -> 1K GOOD

Examples:

1,234,567 -> 1.23M
999,500 -> 1M
999,499 -> 999K
102 -> 102
1000 -> 1K
1001 -> 1001
100,000 -> 100K
12,345,678,912 -> 12.3B
1,452,815,612 -> 1.45B

Submissions

This is code-golf, so the shortest solution in each language wins
Standard Loopholes Apply

JavaScript, 84 79 bytes
i=>{I=i;for(x=-1;i>=999.5;x++)i/=1e3;return I<1e4?I:+i.toPrecision(3)+'KMB'[x]}

Try it online!
(Takes inputs as numbers)
Special cases the first one where if i < 1000, the number itself is always one of the shortest ways, if not the only shortest way.
Otherwise, it divides it by 1000 until dividing it would make it have no sigificant figures above 1, and chooses a suffix based on how many divisions were done.

The last case should be 999.5M, or maybe not, unsure based on loose spec.

Remember that you need to support up to a trillion.

@GarethPW There is no way to represent numbers above 999,499,999,999 according to the spec (No T -> trillion in the key), so I assumed this was the upper limit. I'll ask, but it's a one byte loss otherwise.

Python 3, 127 bytes
def f(n):s=str(n);l=len(s)-4;return f"{round(n,~l):,}"[:4].replace(*",.").rstrip('.')+"KMBT"[l//3+(int(s[3])>4)]if n>9999else n

Try it online!

a little shorter: def f(n):l=len(str(n))-4;return[n,f"{round(n,~l):,}"[:4].replace(*",.").rstrip('.')+"KMBT"[-~l//3]][n>9999]

@JonathanAllan Nothing. My mistake.

@rosslh I did make that alteration but couldn't keep it when fixing the 999499 -> 999M bug.

JavaScript (ES7), 74 bytes
n=>n<1e4?n:(c=n.toExponential(2).split`e`).shift()*10**(c%3)+' KMB'[c/3|0]

let f=

n=>n<1e4?n:(c=n.toExponential(2).split`e`).shift()*10**(c%3)+' KMB'[c/3|0]

console.log(f(1234567)); // 1.23M
console.log(f(999500)); // 1M
console.log(f(999499)); // 999K
console.log(f(102)); // 102
console.log(f(1000)); // 1000
console.log(f(1001)); // 1001
console.log(f(100000)); // 100K
console.log(f(12345678912)); // 12.3B
console.log(f(1452815612)); // 1.45B

JavaScript (ES6), 80 bytes
n=>n<1e4?n:(c=n.toExponential(2).split`e`).shift()*[1,10,100][c%3]+' KMB'[c/3|0]

let f=

n=>n<1e4?n:(c=n.toExponential(2).split`e`).shift()*[1,10,100][c%3]+' KMB'[c/3|0]

console.log(f(1234567)); // 1.23M
console.log(f(999500)); // 1M
console.log(f(999499)); // 999K
console.log(f(102)); // 102
console.log(f(1000)); // 1000
console.log(f(1001)); // 1001
console.log(f(100000)); // 100K
console.log(f(12345678912)); // 12.3B
console.log(f(1452815612)); // 1.45B