1
Write a program or function that takes two numbers - x>3
and n>0
- as input, and finds all possible bases b
where the digit 3
appears at least n
times in (x in base b)
.
Input and output may be through command line or function arguments, stdin/stdout, graphical input/output, error messages, function returns, etc.
The code must consist entirely of three-symbol "words", where each symbol is a letter or number (in printable ASCII) and the words are each separated by one non-alphanumeric printable ASCII character or newline (see example). Furthermore, adding a space into any of the words must ruin the program.
Shortest code wins.
Example
The following code meets the first part of the specs (but doesn't actually work):
abc 123 fwe[3gY]4fs-es3=13N
338 w3W|W2w
Test Cases
5 1
->
8 1
-> 5
23 1
-> 4 5 6 7 10 20
15 2
-> 4
111 2
-> 4 6 9 36
819 3
-> 4 16
A test program written in Java 8 can be found at http://pastebin.com/E8GpHbfB.
This is impossible in GP: The parser ignores spaces outside strings, and so adding a space into a word won't alter its meaning. – Charles – 2015-02-05T01:36:02.927
6
Just to prove a solution exists... http://esolangs.org/wiki/Lenguage (didn't expect Pietu's creation to be relevant so soon)
– Sp3000 – 2014-12-04T18:33:59.4407I'm not a fan of the restriction. It seems gimmicky and eliminates some languages. – xnor – 2014-12-05T09:00:54.613
Should we consider adding a space in the middle only or at the edge too? – proud haskeller – 2014-12-05T16:08:41.247
@proudhaskeller Only in the middle – Ypnypn – 2014-12-05T17:24:58.190
This is impossible in J: I'd require a minimum of one
=.
to make it otherwise work under this restriction. Unrestricted, there is the 30 character n((=s+/@(3=#.inv)"0])#s=.]2+i.)
x. – algorithmshark – 2014-12-06T05:34:25.427