| Bytes | Lang | Time | Link |
|---|---|---|---|
| nan | Python | 250401T015104Z | Lucenapo |
| 041 | MATLAB | 141106T064511Z | feersum |
| nan | Python 2 | 150204T170536Z | user3473 |
| nan | Python 2 | 150112T032303Z | n̴̖̋h̷͉̃ |
| nan | CMD | 150113T061621Z | n̴̖̋h̷͉̃ |
| 007 | Python | 150113T080052Z | r3mainer |
| 007 | Python | 150113T075842Z | r3mainer |
| nan | CMD | 150113T054254Z | n̴̖̋h̷͉̃ |
| nan | Python | 150112T012429Z | NinjaBea |
| nan | PHP | 141110T113645Z | es1024 |
| 013 | Python | 150110T164753Z | ProgramF |
| nan | JavaScript | 150107T140258Z | Martin E |
| nan | JavaScript | 150107T140004Z | Martin E |
| 039 | Python | 150105T151135Z | Uri Gran |
| 007 | Python 2 | 150104T154911Z | jimmy230 |
| 021 | Python 3 | 150104T140524Z | Martin E |
| nan | CJam | 141105T040033Z | jimmy230 |
| 024 | JavaScript | 150102T181040Z | Martin E |
| nan | Python 2 | 141107T085158Z | r3mainer |
| nan | JavaScript | 141205T165554Z | Martin E |
| nan | CJam | 141125T180950Z | DLosc |
| 026 | Perl | 141125T172707Z | choroba |
| nan | Javascript | 141125T013135Z | r3mainer |
| nan | Python | 141124T234509Z | r3mainer |
| nan | C size 33 | 141122T184530Z | r3mainer |
| nan | C | 141122T093753Z | es1024 |
| nan | Insomnia | 141122T085029Z | jimmy230 |
| nan | C | 141120T022148Z | jimmy230 |
| 244 | C++ | 141119T232727Z | r3mainer |
| 013 | Python 2 | 141119T204853Z | histocra |
| nan | Python shell | 141116T052353Z | es1024 |
| 1024 | Marbelous | 141116T004927Z | jimmy230 |
| nan | J | 141115T221533Z | FireFly |
| 1024 | Marbelous | 141115T090820Z | jimmy230 |
| nan | Python shell | 141115T070233Z | es1024 |
| 045 | Ruby | 141114T203250Z | charredU |
| nan | JavaScript | 141114T201816Z | FireFly |
| nan | Interactive Python 2.6 | 141114T193246Z | n̴̖̋h̷͉̃ |
| nan | PHP | 141114T104412Z | n̴̖̋h̷͉̃ |
| nan | Python | 141114T100805Z | n̴̖̋h̷͉̃ |
| nan | Brainfuck | 141114T093429Z | FireFly |
| nan | Python | 141113T214000Z | Sp3000 |
| nan | Python 2 | 141112T230958Z | kennytm |
| nan | Python 2 | 141113T014149Z | Alex Van |
| nan | Rust | 141113T200202Z | kennytm |
| nan | CJam | 141113T190324Z | jimmy230 |
| nan | JavaScript | 141113T165617Z | FireFly |
| 028 | DC | 141113T145347Z | jimmy230 |
| nan | Ruby | 141113T092508Z | Martin E |
| nan | Python 2 | 141112T233818Z | kennytm |
| nan | CJam | 141112T152337Z | Martin E |
| nan | Ruby | 141112T114751Z | Martin E |
| nan | Bash | 141111T234654Z | feersum |
| nan | Java | 141111T231517Z | feersum |
| 023 | Ruby | 141111T224105Z | histocra |
| nan | Java | 141111T181544Z | n̴̖̋h̷͉̃ |
| nan | JavaScript | 141111T164230Z | Optimize |
| nan | C | 141111T134452Z | feersum |
| 1024 | C | 141111T120703Z | Art |
| nan | Python | 141111T054752Z | Sp3000 |
| 3000 | Python | 141111T032443Z | FireFly |
| nan | JavaScript | 141110T211921Z | Martin E |
| nan | JavaScript | 141110T211259Z | PleaseSt |
| nan | JavaScript | 141110T164056Z | Martin E |
| nan | Python | 141110T134059Z | feersum |
| nan | JavaScript | 141110T123029Z | FireFly |
| 037 | QBasic | 141110T093232Z | PleaseSt |
| 079 | QBasic | 141110T043740Z | jimmy230 |
| 033 | PHP | 141109T215902Z | Martin E |
| 090 | ECMAScript | 141109T185438Z | jimmy230 |
| 042 | QBasic | 141109T123817Z | jimmy230 |
| 043 | QBasic | 141109T115658Z | jimmy230 |
| 001 | C# | 141109T105108Z | feersum |
| 1024 | Marbelous | 141109T024113Z | Martin E |
| nan | PHP | 141109T015027Z | jimmy230 |
| nan | JavaScript | 141108T155529Z | jimmy230 |
| nan | Ruby | 141108T233728Z | DLosc |
| 597 | Java | 141108T190407Z | feersum |
| 037 | Python 2 | 141108T163912Z | Sp3000 |
| nan | APL | 141108T161432Z | Geobits |
| 066 | Cris | 141108T151140Z | Sp3000 |
| nan | PHP | 141108T152146Z | r3mainer |
| nan | Ruby | 141108T141358Z | Martin E |
| nan | C++ | 141108T135739Z | feersum |
| 1024 | C | 141108T122723Z | feersum |
| 041 | JavaScript | 141108T111221Z | Martin E |
| nan | PHP | 141106T015029Z | Martin E |
| nan | CJam | 141108T101340Z | jimmy230 |
| 3000 | Python | 141108T061120Z | DLosc |
| nan | Arithmetic | 141108T014652Z | NinjaBea |
| nan | C | 141108T010957Z | grc |
| 037 | Python 3 | 141108T000321Z | Blake Wa |
| nan | CJam | 141107T212241Z | Martin E |
| 043 | C | 141107T220308Z | nneonneo |
| nan | Python 2 | 141107T213810Z | feersum |
| nan | Ruby | 141107T195555Z | lynn |
| 3000 | Python | 141107T201941Z | nneonneo |
| nan | JavaScript | 141107T201625Z | Martin E |
| nan | Javascript | 141107T185354Z | SLuck49 |
| nan | Ruby | 141107T152156Z | jimmy230 |
| nan | C | 141107T123041Z | Art |
| nan | Mathematica | 141107T121129Z | Martin E |
| nan | Javascript | 141107T105607Z | jcai |
| nan | Lua | 141107T102105Z | Martin E |
| nan | Bash | 141107T101943Z | jimmy230 |
| nan | Haskell | 141107T093302Z | Daniel W |
| nan | Python 2 | 141107T093302Z | feersum |
| nan | Little Man Computer | 141107T092829Z | feersum |
| nan | Haskell | 141107T090603Z | Daniel W |
| nan | Java | 141107T084138Z | feersum |
| nan | C | 141107T062857Z | feersum |
| nan | Java | 141107T061654Z | feersum |
| 3490 | SAS | 141107T024405Z | ConMan |
| nan | Pyth | 141107T045946Z | isaacg |
| 250 | Python 3 | 141107T015225Z | feersum |
| nan | Python | 141107T014016Z | Sp3000 |
| nan | JavaScript | 141107T000143Z | Martin E |
| nan | Bash | 141106T234540Z | Martin E |
| nan | CJam | 141106T030520Z | Dennis |
| nan | JavaScript | 141106T201415Z | Martin E |
| nan | C | 141106T160729Z | feersum |
| nan | C | 141106T152037Z | feersum |
| nan | Mathematica | 141104T220053Z | Martin E |
| nan | PHP | 141106T171947Z | PleaseSt |
| nan | PHP | 141106T010949Z | bwoebi |
| nan | CJam | 141106T154556Z | jimmy230 |
| nan | PHP | 141106T143345Z | bwoebi |
| nan | PHP | 141106T140110Z | r3mainer |
| nan | JavaScript | 141106T130230Z | Martin E |
| nan | CJam | 141106T130219Z | jimmy230 |
| nan | JavaScript | 141106T125405Z | Martin E |
| nan | GolfScript | 141106T112723Z | Martin E |
| 3000 | Python 3 | 141106T111903Z | grc |
| nan | JavaScript | 141106T110707Z | Optimize |
| nan | Perl | 141106T095653Z | grc |
| nan | JavaScript | 141106T093951Z | r3mainer |
| 3000 | Brainfuck | 141106T093648Z | feersum |
| 070 | C | 141106T062458Z | feersum |
| nan | Pyth | 141106T033936Z | isaacg |
| nan | Perl | 141106T024327Z | grc |
| nan | Mathematica | 141106T022351Z | Martin E |
| nan | Ruby 58 | 141106T001445Z | r3mainer |
| nan | PHP | 141105T232101Z | bwoebi |
| nan | Python 2 | 141105T210358Z | Sp3000 |
| nan | Ruby | 141105T191108Z | Martin E |
| 037 | Python 3 | 141104T215031Z | xnor |
| nan | PHP | 141105T182118Z | jimmy230 |
| nan | PHP | 141105T175113Z | jimmy230 |
| nan | PHP | 141105T172733Z | bwoebi |
| nan | C 43 | 141105T163001Z | r3mainer |
| 056 | Python | 141104T234326Z | user1354 |
| nan | Python 2 | 141105T145405Z | Sp3000 |
| nan | PHP | 141105T144316Z | Martin E |
| nan | PHP | 141105T141210Z | Martin E |
| nan | BBC BASIC | 141105T140916Z | r3mainer |
| 044 | Python 3 | 141105T134431Z | feersum |
| nan | JavaScript | 141105T124742Z | Optimize |
| 3000 | Python | 141105T123254Z | grc |
| nan | Pyth | 141105T120745Z | Martin E |
| nan | Befunge93 | 141105T113514Z | r3mainer |
| 101 | Java 6+ | 141105T092837Z | n̴̖̋h̷͉̃ |
| nan | CJam | 141105T090706Z | Martin E |
| 250 | C++ | 141105T084332Z | PleaseSt |
| nan | Python | 141105T071754Z | Sp3000 |
| nan | Python | 141105T055530Z | Sp3000 |
| nan | Perl 5 | 141105T055301Z | grc |
| nan | PHP | 141105T054831Z | PleaseSt |
| nan | Python | 141105T043153Z | NinjaBea |
| nan | Python | 141105T041834Z | Sp3000 |
| nan | Lua | 141105T035955Z | NinjaBea |
| nan | Python 2 | 141105T032651Z | grc |
| nan | Golfscript | 141105T014649Z | NinjaBea |
| nan | PHP | 141105T010420Z | r3mainer |
| nan | JavaScript | 141104T231539Z | jimmy230 |
| nan | CJam | 141104T225234Z | jimmy230 |
| 029 | Python 2 | 141104T225226Z | xnor |
| nan | Python [any] shell size 44 | 141104T224446Z | r3mainer |
| nan | JavaScript | 141104T221549Z | Martin E |
| nan | CoffeeScript | 141104T220507Z | NinjaBea |
| nan | CJam | 141104T214428Z | Martin E |
| nan | Python 3 | 141104T211611Z | Martin E |
| nan | Python 2 | 141104T203121Z | Ypnypn |
| nan | Python 3 | 141104T205006Z | matsjoyc |
Python, 124, Larry Bagel
for i in dict(a=1):print(i)
""" "aintAA
rtcdinstl()aprpp
ll
a.aub________.:npt prnonti:________.ssssinsbuitic.nipront.aif"""
MATLAB, COTO, size 41
disp(magic(all(cos(eye(rank(now))))))
Python 2, Oliver
rt =in= 2**2**2*2**2**2*2**2**2**2*2**2*2**2*2**2*2**2*2**2*2,
print 16777216
All actual credit to n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ with this solution. I just stole it and corrected it.
Python 2, Oliver
r =int= 2**2**2*2**2**2*2**2**2**2*2**2*2**2*2**2*2**2*2**2*2
print 16777216,
There is nothing tricky here. All the numbers are there, only need some rearrangement to comply with the syntax.
You can pipe the output to xxd to see that it has a trailing new line:
$ python -c 'r =int= 2**2**2*2**2**2*2**2**2**2*2**2*2**2*2**2*2**2*2**2*2;print 16777216,' | xxd
0000000: 3136 3737 3732 3136 0a 16777216.
CMD, 21, by unclemeat
set /a!!"echo>>tfile"
Repeating the set /a trick and ! operator is reducing the search space for otherwise a tough nut to crack.
I'm not too sure how set /a works, but when I evaluate set /a "tfile", it returns 0. Not sure if all strings evaluates to 0, but in this case, we end up evaluating (!!0) >> 0, which is 0.
Python, size 15, by mbomb007
There are at least 5 permutations that work. This is one of them:
`3*.7/50`[::~4]
It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:
from itertools import permutations
perms = [''.join(p) for p in permutations('03457*./')]
for p in perms:
try:
e = '`'+p[:-1]+'`[::~'+p[-1:]+']'
if eval(e)=='6991':
print e
except:
continue
(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)
CMD, 9, by unclemeat
set/a!!!0
There are too few possibilities here. The 4 alphabet characters are most likely command name, so I attack in that direction.
PHP, size 46, by Ismael Miguel
$i=az;echo++$i,nd;$i[((E<<H)<=$m&oorrYYz)^$f];
Quite sure this isn't the intended solution.
Turning off notices is recommended for running this.
$i is first set to az, then incremented, which yields ba.
echo can take a list of strings to print; here it prints $i(ba), and then nd.
The rest of the code ($i[((E<<H)<=$m&oorrYYz)^$f];) does nothing.
Python, 13 bytes, by Reticality
To be run on an interactive Python console:
len("printi")
Outputs 6.
Python, 39 bytes, Reticality
print("{0}{2}{1}{1}{1}".format(0,5,6,))
You could also swap the {0} & {2} and the 0 and 6.
Python 2, 13, by mbomb007
71e0//36/0x92
The output is 0.00684931506849315 on my machine. But it worked on http://repl.it/.
JavaScript, 24 bytes (by fogcityben)
'.+';console.log( 'hi' )
Not sure what he really did with that . and +.
Python 2, 16, by imallett
Produces no output in Python 3, but outputs "-2" in Python 2. This technically depends on two's complement arithmetic, which is a reasonable assumption on Python-supporting architectures:
eval("\x7eTrue")
CJam, 14, by User23013
92e8.17 5e6.3%
I started by making some assumptions: that the exponent in each case was a floating point number, and that it had at least one digit after the dot (otherwise it's just the same as using an integer) and one or two before it (otherwise the result would be too small or too large). Then I used Python's itertools library to do some permutations. I got a result in under a minute.
Here's my cracking code:
from itertools import permutations
target = 108183.05975155532
def e(mantissa, exponent):
return mantissa * 10 ** exponent
def ePartition(digits):
"""Generator function: gives every way to partition digits into an
integer mantissa and a floating point exponent that is > 1 and < 100."""
for eIndex in range(1, len(digits) - 1):
for dotIndex in range(eIndex + 1, min(len(digits), eIndex + 3)):
yield (digits[:eIndex],
digits[eIndex:dotIndex] + "." + digits[dotIndex:])
for p in permutations("12356789"):
for spIndex in range(3,6):
digList1 = "".join(p[:spIndex])
digList2 = "".join(p[spIndex:])
for mant1, expt1 in ePartition(digList1):
for mant2, expt2 in ePartition(digList2):
value = eval("e(%s,%s)%%e(%s,%s)" % (mant1,
expt1,
mant2,
expt2))
if value == target:
print("%se%s %se%s%% -> %s" % (mant1,
expt1,
mant2,
expt2,
value))
Perl - 26 bytes by primo
f:print po=>glob q$t{a,o}$
The q was easy to recognise. I took the potato letters away and shuffled the rest to discover glob suddenly. Then, I realised $$ will be used instead of {} and that => can be created. The last thing was f:, it took me a while to think of a label.
Javascript, 35 (36?), by user3863227
Too easy. After I took out Math and alert, log was the only option.
l=Math.log;alert(l(l(l(1234))));1279
(By the way, I counted 36 characters, not 35.)
Python, 28, by user3863227
print(int(bin(1234)[2:])**2)
Factorizing the output gave this one away quite easily:
100220321420320200100 = 2² × 5² × 457² × 2190593²
sqrt(100220321420320200100) = 10011010010
int('10011010010',2) = 1234
C, size 62, by Olavi Mustanoja
#include<stdio.h>
#define _ +8
int*main(){printf("%d",1 _ _);}
C++, 244 bytes?, by Gabe Evans
#include<iostream>
int main(){int(CCDD)='%';char(a)[14]={'h','e','l','l','o',22+20/2,'w','o','r','l','d','!'};CCDD+=CCDD<=a[0];{{}};aa:adffillllllnnnnnnnnnnnnooooooooooooorrrrrrrrrssstttttttttttttttuuuuuuuuuuuuwwwwww:cout<<a;}
It was a bit of a struggle getting all those spare characters out of the way. You can see the code working here.
Python 2, 13 by Emil
print (070-7)
I'm not sure either why Python has octal literals. Ruby has them too, I was thinking of including one in a puzzle myself.
Python shell, size 21, xnor
6446781078^9350512293
Obtained by brute force in ~27 minutes.
Code used:
#include <iostream>
#include <cinttypes>
#include <cmath>
inline bool check(int64_t a, int64_t b){
int used[10] = {};
do{
auto r = std::div(a,10ll);
++used[r.rem];
a = r.quot;
}while(a);
do{
auto r = std::div(b,10ll);
++used[r.rem];
b = r.quot;
}while(b);
if(used[0] > 2) return false;
for(int i = 1; i < 10; ++i)
if(used[i] != 2)
return false;
return true;
}
int main(int argc, char **argv){
int64_t i = 1ll << 32;
while(!check(i,i ^ 15788895283ll)) ++i;
std::cout << i << ' ' << (i^15788895283ll) << std::endl;
}
This checks every integer starting from 2^32 until it and its matching integer use up all the characters provided.
Marbelous, 55, by es1024
1111
11<<
10/\
10
10
&0..&0
:--.....01=@@@@}}
{0}00000
J, 25, Caridorc
echo 3%##++-/-/i.!/i.3345
There has to be many ways of getting rid of the extra characters...
Python shell, size 15, xnor
1215954^1548696
Obtained by brute force in 1.42 seconds.
Code used to find solution:
#include <iostream>
#include <algorithm>
int main(){
int digits[] = {1,1,1,2,4,4,5,5,5,6,6,8,9,9};
int ndigits = sizeof(digits)/sizeof(digits[0]);
do{
int n1 = 0, n2 = 0;
for(int i = 0; i < ndigits - 1; ++i){
n1 = (n1 * 10) + digits[i];
n2 = 0;
for(int j = i+1; j < ndigits; ++j)
n2 = (n2 * 10) + digits[j];
if((n1 ^ n2) == 339018){
std::cout << n1 << ' ' << n2 << std::endl;
return 0;
}
}
}while(std::next_permutation(&digits[0], &digits[ndigits]));
}
Ruby, 45 (histocrat)
%q[zyfnhvjkwudebgmaclprs x].to_i(36)/51074892
Woohoo! This is my first crack at a code golf problem, and I don't have enough rep to comment on the original post. I immediately recognized the trick used, since I've actually found use for it in production code often. It took about 5 minutes to figure out most of the structure and a few hours to come up with the complete answer.
Explanation:
%q[]is an alternative method for creating strings. Parenthesis and curly braces may also be used.String#to_iin Ruby accepts numbers in any base from 2 to 36. It will ignore the first character in the string which is not part of the number, so any extra characters can be "thrown away" after the space.
And here's the code I used to crack it:
require 'set'
# return true if the string is made up of unique characters
def uniq(s)
a = s.each_char.to_a
return a == a.uniq
end
def uniq_while_same(a,b)
s = Set.new
a.each_char.zip(b.each_char).each do |ai, bi|
return true if ai != bi
return false if s.include? ai
s << ai
end
return true
end
def ungolf(answer)
# For each base that even makes sense
[ 36, 35, 34, 32, 31, 30,
29, 28, 27, 26, 25, 24, 23, 21, 20,
19, 18, 17, 16, 15, 14, 13, 12, 10].each do |base|
# Ignore bases where it is not possible to create a unique-string number greater than answer
next if answer > base ** base
# Pick digits for the denominator that are not duplicates of the digits in base
denominator_digits = ('1234567890'.each_char.to_a - base.to_s.each_char.to_a)
# For each permutation of those digits for the denominator
(1..10).each do |denominator_length|
denominator_digits.permutation(denominator_length) do |denominator_s|
# Maybe the denominator is in octal
denominator_base = 10
if denominator_s[0] == '0'
next if denominator_s.include?('8') || denominator_s.include?('9')
denominator_base = 8
end
denominator_s = denominator_s.join
denominator = denominator_s.to_i denominator_base
print "#{"\b"*64}(%q[#{(answer * denominator).to_s(base).ljust(36)}].to_i #{base})/#{denominator_s.ljust(10)}" if rand < 0.01
# Ignore denominators that are definitely impossible to have answers for
next unless uniq_while_same "qtoi#{base}#{denominator_s}#{(answer * denominator).to_s(base)}",
"qtoi#{base}#{denominator_s}#{((answer + 1) * denominator).to_s(base)}"
# For each numerator that gives answer when divided by the denominator
(answer * denominator...(answer + 1) * denominator).each do |numerator|
print "#{"\b"*64}%q[#{numerator.to_s(base).ljust(36)}].to_i(#{base})/#{denominator_s.ljust(10)}" if rand < 0.01
# Remove any that are still not unique
s = "#{numerator.to_s(base)}#{base}#{denominator_s}qtoi"
next unless uniq s
# Done. Compute which characters need to be thrown away to fill the remaining space
remains = ('0123456789abcdefghijklmnopqrstuvwxyz'.each_char.to_a - s.each_char.to_a).join
print "#{"\b"*64}#{" "*64}#{"\b"*64}"
return "%q[#{numerator.to_s(base)} #{remains}].to_i(#{base})/#{denominator_s}"
end
end
end
end
print "#{"\b"*64}"
puts "\nnone"
return nil
end
print ungolf 9410663329978946297999932
Way to go embedding an NP problem inside a riddle. I have been thoroughly nerd-sniped. Good job!
JavaScript, size 69, by Shawn Holzworth
f=f=(f=0x76f2156a6c[r='toString'](30))+f+f+' '+((0x25a1335*7)[r](30))
That took a while. This should be similar to the original, though the constants are probably different.
Interactive Python 2.6, 15, MrWonderful
43**(314)/(1+2)
I did some (imprecise) brute force for i and j where math.log(N * j, i) is very close to an integer.
PHP, 62, aks.
for($i=1;$i<3.;)echo"$i. ".((($i++==2))?'Tues':'Mon').'day ';
Quite easy compared to other crazy PHP submissions.
Python, 37, MrWonderful
print 4123.*3
" +++3:==deefinorsuu"
Probably not intended solution, but this solution is so obvious that I can't help.
Python 2 assumed.
Brainfuck, 39, by Mig
+++++++[->++++++<]>[->++<]>-.----.++++.
Python, 45, by muddyfish
print(eval((chr(32)+chr(45)).join(str(413))))
Interesting idea, I have to say. Wasn't hard to brute force though.
Python 2, size 132, by Vi.
exec('from string import printable as e\nprint "cqance"\x2Ereplace("q",e[len("fgiillmmooprrsstt")])or ",,,\016:::S[]____tuuvyy" ""')
Thanks for all the backslashes and quotation marks :)
Edit: The updated 96-char version:
exec "try:exec'from __future__ import braces\\nt(12)'\nexcept SyntaxError as q:print(q[0][6:])"
This is taken entirely from Alex's solution in https://codegolf.stackexchange.com/a/41451/32353
Python 2, size 132, by Vi.
EDIT: Solved the original given that it didn't use exec at all. For some reason, even though I came up with using compile() to trigger the except in the from __future__ import instead of exec(), I didn't think to use compile+eval for the rest.
eval(compile('try: compile("from __future__ import braces","1","single")\nexcept SyntaxError as q:\n\tprint q[0][6:]',"2","single"))
I'm pretty sure the answer to the hint given "Don't count ones which exist. Count ones which do not exist" is "braces".
How it works: The easter egg import from __future__ import braces triggers a SyntaxError: not a chance. The idea was to catch this exception and extract the last word from it; but you can't use try:from __future__ import braces because from __future__ imports must occur at the top of the file (this is because they aren't really imports, they're directives to the interpreter at compile-time to enable features). This is why you can trigger the exception by compiling the import without executing it. Additionally, to compile the try/except in single-statement mode, you need the \n\t after the except. I'm not sure why this is necessary; it works without the \n\t if you use exec-mode. Additionally, the "1" and "2" aren't strictly necessary; those could be left empty.
EDIT: Cracked shorter variant.
exec('try:exec("from __future__ import braces")\nexcept SyntaxError as q:print q[0][6:]\t\n12')
I'm not sure what to do with the 12\\nt characters. They didn't seem to fit, but putting them at the end like that works fine.
This works on basically the same idea as the original, but leverages exec instead. The second exec isn't strictly necessary, though, since all you have to do is compile the import statement.
Personally, I think it would have been a little more interesting to use StandardError instead of SyntaxError, or perhaps an import sys; and sys.last_value[0][6:], but with the dot in there I imagine a whole lot of other solutions would crop up.
Rust, size 123, by Vi.
fn x(r:int)->int{for i in range(0,2){if i==r/r{{}}else if i==0{}}r%222*912}fn main(){print!("{}",x(993+2))}
This shouldn't be the intended solution because of the no-op for loop, but it produces no warning in play-pen anyway.
(I'll leave the Clojure part for others.)
CJam, 51, by Optimizer
"JamesBdo,"YZ+/)BA*c+Y*Y%:BS@SB)))[JW:Z____)ci+*]U*
JavaScript, size 73, by Mig
alert([o=(eval.e+'(((()))),-....0cceefgillpprrrssst')[2],o].join('enie'))
Thanks for the string literal to dump all the excess characters in! I'm pretty sure this is an unintended solution, but it seems to work nonetheless.
DC, 28 bytes, by MichaelT
[ls+dn11ls1+dss<n]sn1ss0lnx
But I counted 27 bytes. Maybe there is a newline...
Ruby, size 17, by Stephen Touset
$><<$-W?$?:$:>-pi
Most certainly not the original code. $-W is the value of the command-line argument -W (warning level) which defaults to 1. The rest is just to get rid of the other characters, so I'm putting some undefined variables and operators in the else branch of a ternary.
Python 2, size 69, by muddyfish
import tabnanny as t;print(t.__name__[:3])or((({3:_efisssw[[]][:]})))
tabnanny is a standard Python module, but I am just borrowing its name here to get the "tab" string.
CJam, size 19, by Ypnypn
923"4593*JJ#%"786*~
That was close... the seven days had already passed, by Ypnypn did not yet claim immunity by releasing the original source.
Explanation
923 "Push 923 on the stack.";
" "786*~ "Repeat that string 786 times and eval it. Just a loop, basically.";
4593* "Multiply by 4593.";
JJ# "J is a variable initialised to 19, so compute 19**19.";
% "Modulo.";
Cracking
I was fairly certain that "_"_*~ was used to make a loop, and that % was used as modulo to keep the numbers small. (We've seen other ways to do that, but I don't think that would have worked here very well, because you couldn't put the result of your computation in a string.).
So first guess I ventured was that the divisor of the modulo could be 1919. Looking up how much that is, it turned out to be on the same order as the desired result (about 4 times the result), which suggested that this is actually a very likely choice. That left only *, so I figured the code would be of the form
_"_*JJ#%"_*
Where the _ are filled from the numbers. That's *10!/2/2 * binomial(9,2) = 32,659,200* possible permutations. That seemed to be doable by brute force. :)
The only thing that would blow this up is having a large number before the *... with up to 8 digits, it could basically square the number of iterations needed. So I thought, let's limit that to at most 3 digits (which was apprently quite lucky, seeing that solution actually had three digits there). Then I just reimplemented this framework in Mathematica and wrapped it in a loop over all such permutations:
perms = Permutations@{2, 3, 3, 4, 5, 6, 7, 8, 9, 9};
big = 19^19;
Map[
(
If[#[[2]] != perm[[2]], Print@#];
perm = #;
For[i = 2, i <= 9, ++i,
a = FromDigits[perm[[1 ;; i - 1]]];
For[j = Max[i + 1, 8], j <= 10, ++j,
b = FromDigits[perm[[i ;; j - 1]]];
c = FromDigits[perm[[j ;; 10]]];
x = a;
For[k = 0, k < c, ++k,
x = Mod[x*b, big];
];
If[x == 500827930823087774653348, Print@{a, b, c}]
]
]
) &,
perms
];
After about two hours (shortly before completing the full search) this produced
{923,4593,786}
which I was able to verify in CJam. :)
Ruby, size 35, by histocrat
(_=->h{:shadily.display})[_]||_===_
Interesting, I did not know you could invoke lambdas with ===... I mean... why?
Bash, 47, Vi.
If you saw a $100 bill lying on the ground, wouldn't you pick it up?
Don't know much about bash, but I tested it and it works.
printf pp;o='${cel-sr(xe\ pp/pp/) fec1/; }'
Java, 134, Olavi Mustanoja
class Shit{public static void main(String[]rtr){for(int n=74;n<=84<<19;n=n<<3^911-'g')System.out.print(""+(char)94+n+(char)(5<<1));;}}
At the beginning I checked the logarithms of the numbers and noticed that the later ones differed by almost exactly 3 log 2. Then it was easy to find that excluding the first number, the next could be obtained by (n << 3) - 728. Instead of the subtraction, an xor operation can give the next number for all of them.
Ruby, 23 by MegaTom
p %++.methods[80][1..-1]
Edit: So that's where the answer went. Converting back to an answer, hopefully. Thanks for specifying an interpreter, methods[80] is definitely version- and implementation- dependent. Using + for the percent-string delimiter is a nice touch.
I think I found this easier than I would've just because I'd been thinking of doing some similar tricks.
Java, Size 97, Olavi Mustanoja
class _{public static void main(String[]s){for(int b:"534g".getBytes())System.out.write(b^'m');}}
There are not too many possibilities with only 1 character ^ usable as operator and lack of p (for printing operation).
I wither the input down to 345_gsm and do some math to map it to the output.
JavaScript, 42, by Shawn Holzworth
(function nn(n){return !n||n+nn(--n)})(58)
And to test it :
alert((function nn(n){return !n||n+nn(--n)})(58))
C, 44, Art
n;main(aaa){while(1-printf(&"a%nb"[n],&n));}
Lacking any assignment operators to use for flow control, it seemed a good idea to look for some function which would take an address and write something to it. I found a %n specifier for printf which does this. I think this was the intended general idea. I had to test on ideone because there was some bug in the implementation on my computer where it refuses to write anything after a %n... Something to do with this maybe.
C, size 48, by es1024
main(f){f='ma'-lgamma(0xfe.dp9),printf("%d",f);}
I'm very unsure about this one. It depends on implementation defined behavior (character constants with more than one character, see C99 6.4.4.4 point 10), but happens to produce the right result on Linux with gcc and MacOS with clang. Depending on ASCII I wouldn't even mention, but this is so unusual that it feels very dodgy.
Python, size 55, by FireFly
____acdfiimmnooprrt={2:.9,}
print(801**sum(range(5))+1)
The funny thing is, my initial solution only worked on Python 3 and it was only until FireFly pointed out that I should inline my 801**sum(range(5)) instead of assigning it to a variable that I got this working for both Python versions.
Python, size 34, by Sp3000
print(str([{.6,}])[-4])
_=...;__=_
The trickiest part was trying to get rid of the leftover characters. :P
JavaScript, size 28, by Shawn Holzworth
var eeivy;((atob['length']))
I guess, that's not what we were looking for... Turns out it's exactly the original. :)
JavaScript, 46 characters, by FireFly
alert(/ordered/.source)
this. aaeeefnnrstvw
JavaScript, 29, by Joe
[,,].join([,,,].join(3))|74*2
Probably not unique, because I didn't really use one join.
So the idea was to somehow find the number with repetition of digits, multiplication and bitwise or. All of those operations increase the resulting number, so I could limit my search to numbers below 181. Conveniently 181 is prime, so the final operation had to be | (I doubted I could get to [1,1].join(8)). So I just looked at all pairs of numbers that I could bit-or to 181, and looked through those that have at least one operand completely from the available digits. One way is 33|148, and the latter could be found as the product of 74 and 2, so here we are.
Python, 60, f.rodrigues
This post was so bad it had to be stopped.
print(60132)
4 or((odad95oamamarrdsn,nn.m7dtit.rminnrope8ed))
JavaScript, 94, by Shawn Holzworth
v=['0',01,7,8,5,7,8,4,44,11,8,41,1,1+1];a=alert;r='';for(x in v)r+=(a+(1==0))[v[x]]||'h';a(r);
Works only in SpiderMonkey, it seems (i.e. Firefox). This took me forever, and if it was slightly more clever with the indices I think I'd've given up.
QBasic, 37 bytes, by DLosc
PRINT 1E7 AND 11053811
R=LEN("*?RY")
I immediately noticed that all the letters of AND were present in the code. (In QBasic, the Boolean operators are bitwise, and true is -1.) Then I wrote a script to find possible combinations of operands by brute force, ignoring zeros to allow for E notation. Once I found a usable combination in the list, all that was left was to deal with the remaining characters.
A single space is printed before the number (where the minus sign would go for a negative number). The scrambled code also prints a space before the number it prints, and that is not described as part of its output, so I assume that that detail is insignificant or was mistakenly omitted.
QBasic, 79 bytes, by DLosc
print"Iodine"
if f then scReen BLaaabbefgghhhiiiiiiiikkllnnossstt,u-u.u
PHP, 33 bytes, by Ismael Miguel
echo 0X1^BXcdeilnu08DFHTTTgk467;
This might actually also work on Windows. All it does is xor a hexadecimal 1 with an undefined constant which yields 0.
For the Windows one you can use
echo 7^'6cdeilnudBXX4';
which should also work on both platforms, because the string is simply coerced into an integer (being 6), and then we xor that with 7.
I'm curious what those were supposed to be.
ECMAScript, 90 bytes, by Cris
(function(t){t.n=t;t.n(t.n.FFFbcdeehhiiiinooopprrrsstuuy)}) ((function(){alert(this+"")}))
The original solution is probably (based on Martin Büttner's work in the chat):
Function.prototype.F=function(){return this.bind(this)()};(function(){alert(this+"")}).F()
QBasic, 42 bytes, by DLosc
A=2+EMOORT
1PRINT"QBasic!"
IF A THEN RUN 1
There isn't WHILE, NEXT, DO, GOTO, GOSUB or CALL, and there isn't a second PRINT or other ways to get a new line. So I must find some other weird control structures.
QBasic, 43 bytes, by DLosc
DATA?
DIM P AS STRING
READ P
?P;P;CEEEEH36$
C#, size ~600, eshansingh1
using System;class Program{static void Main(string[]a){Console.WriteLine("Hello, World!");Console.WriteLine("Other World!");
String c=""+""+""+"wwTxRExpphk= hckhew@hm.cm hw Csole.Reae how al vod old); ry statc bool othval try ex) bool retur >catch us Excepton(); } ex) { Excepton(); } { new { { checker) Check(someval); } } catch } Console.rteine(ther } (Exception ystem; usin { finally { catch (Exception new { Console.riteLine(ello @^A-Z0-9._%-@[A-Z0-9.-].[A-Z]{24}$); ain(string[] try Regex.IsMatch(checker, args) static { } } } Exception(Uh rogram bool CopsAndRobbers { oh.);";}}
I found a size of 587 rather than the claimed 604, but it hardly matters as it's all dead weight. I wouldn't have done this as I didn't have any interest in installing C#, except that I noticed that I already had a C# SDK on my computer, and it seemed simple enough to figure out how to print a string without needing to look at any documentation. Oddly string and String both appear to be types.
Marbelous, size 36, es1024
9C
Dr=0
^3
+O
+O!!
:Dr
}0
++
/\{>{0
There is no trailing line break, so that we remain at 9.
After another very fruitful discussion session with Sp3000, at last, one of the Marbelous submissions is cracked! :)
I can't really explain Marbelous in the scope of this answer, so if you have no idea what I'm talking about, have a look at this reference.
Let's look at the output first: it's 100 ones and zeros, 8 of them at a time (with some offset in the cycle). This suggests that we have some loop that increments a marble 100 times, and printed 0 or 1 depending on the 4th byte. Both of those are pretty convenient because, starting at 9C (in hex) is 156. Incrementing 100 times overflows, so we can abort the loop with a =0. Furthermore, we have access to the fourth bit with ^3. And if we increment before outputting, then we will also correctly start with 3 ones.
Setting this up was a bit trickier though. Especially, since we got really stuck on the idea of naming the board Or, so that we would have the Ds as hex digits (and we also thought there were two ++ devices). But we just couldn't find a way to add 48 to the 0 or 1 resulting from ^3 (which is necessary to turn them into 0 or 1 characters). But at some point I had an epiphany, and realised that O is 24 in base 36, so we could actually increment by 48 using +O twice.
The rest was fairly simple to deduct from the available characters and the requirement to have no empty cells in the boards. In particular, there is no way to move a marble upwards in this, so the only way to create a loop is horizontally. The clue here was the cylindrical board, which allows you to just constantly push things to the right, until =0 lets the marble fall. This also meant that the ++ device had to go inside the subboard, because you can't prevent it from letting the marble fall.
So in summary:
9Cis a literal marble which starts its life at value 156.- There is a subboard
Drwhich takes in a marble, increments it, and spits out the result both downwards and to the right. =0lets the result fall if we hit0, otherwise pushes it to the right, and back intoDr.^3takes the marble that falls out ofDrand returns 0 or 1 depending on the 4th bit.+Oincrements by 24 (twice).- When the result falls off the bottom of the main board, the corresponding ASCII character is printed.
!!terminates execution. This isn't necessary to break the loop (that wouldn't continue anyway), but it swallows the null byte, that would be printed if the00marble were allowed to fall off the board. It's important to put the!!in the last row, otherwise the final0character wouldn't have time to get printed.
PHP, size 80, by Ismael Miguel
priNt(a^Z^P^Q);$A^=$A^=$C+=$F.=($I^$I^$O<$PTTUWWXX______________aaabffjkory);;;;
There are many ways to get a short output like :.
JavaScript, size 82, by Ismael Miguel
var v='',i=0;for(;i<(21<<2)-~1;)v+=i^++i;console.log(v+i)//,.13<<=[[[[]]]]iiijnozz
Previous version:
var v='',i=0;for(;i<(21<<2)-~1;)v+=i^++i;console.log(v+i);//,.13<<=[[[[]]]]iiijnzz
Ruby, size 37, by Rodolvertice
puts 5423187690^2351479806^1523406978
I noticed that the code had exactly three of each digit 0-9, so I guessed the solution would be three numbers that were permutations of 1234567890. Rather than check all of those, I decided to start with numbers of the form 1234500000, xor them, and see if the first 13 bits were correct; if so, then I would fill in the last five digits of each number with a permutation of 67890 and check the final result. The Python 3 script I threw together found this solution within a few seconds.
Java, 108, durron597
class o{{ }public static void main(String...r){System.out.printf("%.6f",('a'*'+'/'\t'-'l')/('m'+'\n'-6.));}}
This was my second pi-printing program today. Given the low precision of this one, the second-most famous rational approximation, namely 355/113, was sufficient to produce the correct digits. It seemed like this fraction should be obtainable with some math on character literals. After some trial and error I finally found an expression ('a'*'+'/'\t'-'l')/('m'+'\n'-6.) which used all the characters it needed to. One convenient thing was that I had the choice between printf or format which both behave identically here.
Python 2, muddyfish, 37
print(memoryview(str(Ellipsis)).ndim)
I'm glad I made that Python builtins anagrammer.
APL, size 17, by user23013
+(3*3)3,(***)\3 3
I spent far too long trying to crack this. It probably would've gone quicker if I knew APL going in.
Cris, ECMAScript, 66
eval(atob("J2slzzuuuspmlkihgccbbbaZZYYWSSKKKED995555222S2AnCjsx"))
...
Cris, ECMAScript, 70
eval(atob("DScg12224599ACDDMMNNNOQQTTYZZbcgjklmpssuuuwwyzzzOScKMSY1"))
......
PHP, 53, by PleaseStand
Cracked it at last:
for($d=57,$o=35;$o+$d<999;)$o+=printf("$d%o",$d+=$o);
The solution came quite quickly when I noticed that the sequence consists of alternating decimal and octal numbers:
Dec: 57...92...132...177...228...285...348...417...492....573....661....756....858....
571349220413226117734422843528553434864141775449210755731225661136475615328581707
Oct: ..134..204...261...344...435...534...641...754...1075...1225...1364...1532...1707
==Dec: 92 132 177 228 285 348 417 492 573 661 756 858 967
Also, the intervals between each set of numbers grew at a rate equal to the value returned by printf() (i.e., the number of characters written).
Ruby, size 38, by Doorknob
[$><<(!$pece60).to_s[rand($win)].succ]
I'm pretty sure this is nowhere near the original source. It's deterministic despite using rand.
Here is how this one works. $><< is just output. $pece60 and $win are undefined global variables, which therefore are just nil (and they allowed me to get rid of some extraneous characters). !$pece60 makes a true and to_s gives the string "true".
For ages, I tried getting a 2 or -2 to access that u in there, but then I realised I could just take the t, and call .succ(essor) on it to make a u.
rand with a nil parameter returns a random float in the interval [0,1). When using floats to index into strings, they get truncated to integers, so this will always return the first character.
Finally, I had a spare pair of [] so I just wrapped everything in it, because thankfully everything is an expression in Ruby.
Thanks to Sp3000 for throwing some ideas around in chat.
C++, size 192, Arcinde
#include<stdio.h>
#define d double
d i7(int y){return y- -1;}d g(d x,int i){return x?x/i- -g(x*i/4/i7(i),i7(i7(i))):x>x;}int (main)(d***dfffgy){printf("%.15f%",7?g(3,1):0,0.,-0.,0,1,2,2,2,4);}
I used the series for pi from here for which "history books credit Sir Isaac Newton." After making a short program based on that, the main difficulty I had with using the provided characters was that while I used three additions, I had no + available, and was one - short of using all double-minuses. I resolved this by creating a function i7 which subtracts -1 from a number. An unfortunate thing that happened is that I used all the / for division, meaning I had a large volume of unused characters to stick in various spots instead of simply commenting them out.
C, size 63, es1024
main(_){int __=_;_<<=_;__=_<<_<<__;printf("%d",_<<__|__);_|__;}
What I'm trying to get is 2 << 16 | 16. Three leftover underscores, woohoo.
JavaScript, 41 bytes, by Ismael Miguel
(function(){return this})('ccnoorrsttu.')
Tested in Chrome's console.
PHP, size 49, by bwoebi
print@substr(new exception,+~$$a+=++$$m+$$i+2+n);
That was absolutely mental.
It got to
print@substr(new exception,);
fairly quickly, at which point I needed something that gives -6 after the comma, having $++$++$++$+=$~main$2 left.
The main catch is that $a, $m and $i are all NULL, so using them indirectly in variable variables, means they all point to the same variable. However, PHP seems to be doing some weird things about resolving variable variables. With normal variables you can do things like
echo $a+$a=2;
which prints 4 (the 2 is assigned to $a and then added to itself). But if I do the same with variable variables:
echo $$a+$$a=2;
I get 2, because now the first $$a is evaluate before the assignment.
In the end I managed to force some order by putting some increments on the RHS of the += which had to be evaluated before that addition-assignment. That way I got to 5 which I could then just bit-complement. Still... there are some mysterious things going on, and I have no idea why half the things I tried worked and didn't work.
CJam, size 34, by Dennis
"!,wcoo tkea"Jb" n heyre srwe"Bbma
Other solutions:
"newk,r !ywsre"Bb" e cto aeho"Jbma
"erwy !tro"Jb" knsecew,ho"Bbma ea
"rese ohro cn"Bb"!ew,a yektw"Jbma
"sr k!oore,"Bb"nyeewtwch"Jbma ea
"nwetkhs yr "Bb"o!eerc w,"Jbma eao
"!,wcoo tkea"Jb" n heyre srwe"Bbma
This is mainly based on Martin Büttner's idea. First assume the solution is either "..."Jb"..."Bbma or "..."Bb"..."Jbma. Then find some small fractions p/q whose tangent value is rounded to that number. Try every k and search for a pair of string which can be decoded into kp and kq. The search program is proven fast in cracking of the previous answer.
At first we have overestimated the probability and started with only two pairs of p and q. Nothing is found. But finally I changed the program to enumerate all possible ps and qs, and it worked.
There should be other ways to generate the two numbers other than kp, kq. But I don't know where to start the search in that case.
Python, size 41, by Sp3000
xx=x=6;exec("x*=6*6;xx*=x;"*xx);print(xx)
I racked my brains for half an hour trying to get to 6**49 by some combination of x*=6, x**=6, and x*=x, but there were never enough *s. Then I remembered something about squares being the sum of consecutive odd numbers... From there it was easy. ;^)
Arithmetic, size 31, by Cris
(((((2*2+1)*2+1))*(1+(1+2)*2)))
This may not have been the intended solution because of the unused parentheses, or maybe they were red herring.
C, size 53, by FireFly
s(x){return x?x*s(~-x):!x;}main(){printf("%x",s(9));}
Nice factorial program :)
print(sum(b"a".zfill(len(str(...)))))
Embarrassingly by far the hardest part was figuring out to convert the string into bytes. I had to sleep on it, and in the night realized 'duh, it's a bytes literal!'
CJam, size 13, by user23013
G,Cf#If/sE*K%
Solved by hand, like so:
First, some background for non-CJammers:
CEGIKare all variables, which are pre-initialised to12,14,16,18,20, respectively.sconverts the top stack element to a string.- Strings are technically just arrays of characters.
fis pretty magic. For the purpose of this answer, the simplified version is that, for an arraya, some other valueband an operatorg, the sequenceabfgmapsg(_,b)ontoa(where each element ofagoes into the_slot)./is division and splitting arrays (amongst other things).*is multiplication and array repetition (amongst other things).%is modulo and some weird operation, which in the formad%for arrayaand integerdtakes everydth element ofa(like Python's slicing with step widthd).#is exponentiation (amongst other things).,turns numbers into ranges (from0ton-1) and returns the length of an array.
Okay, that out of the way...
It was fairly obvious that we needed , to turn a number into a range, because the only other way to get an array would have been to build a larger number and turn it into a character array with s - but then we couldn't have done any further arithmetic on it. And we need an array to do something with the fs.
I first assumed that the fs were used with # and %, but that would mean we would have needed a number around 90 to get the right amount of digits in the end. And also, this didn't explain what to do with s, and since the answer looked really golfy, I doubted user23013 just appended an s as an effective no-op somewhere to throw people off.
So I figured, maybe he isn't even keeping the numbers small with %, but instead he builds an array of huge numbers, concatenates their string representation with s, but then only picks some odd slice out of it with %. So I played around a bit with the following framework:
__*,_f#_f/s_%
(You can't do _f/ first, because that would yield zero for at least the first 12 elements.)
Where the _ are some permutation of the variables. I didn't try all of them before I got bored, and the main problem with this was that the resulting sequence of digits as always way too long.
At some point it occurred to me, that we wouldn't need such a large range (i.e. the product of two numbers), if instead we used the * to repeat the resulting string. Due to the mismatch of the parameters of * and % this would yield no repetition in the result:
_,_f#_f/s_*_%
This yielded results of a length very close to what I was looking for. I would have actually tried all 240 of them, but fairly quickly (third or fourth attempt), I stumbled upon
E,Cf#If/sG*K%
which yields
03081942753650251594592190492275006661328850322159030034930530649722385533653290754678977
And I figured a match of the first six digits wouldn't be a coincidence. So the question was how to rearrange it without upsetting the actual computation:
- I couldn't change
Kbecause that would pick out different digits altogether. - I couldn't change
CorIbecause that would change the numbers resulting from the two map operations. - If I changed
Gthat would only change the number of repetitions, which would do nothing but change the length of the result. (Which is good.) - If I changed
Ethat would change the range of the array, but the range would still start with[0 1 2 3 ...], so it wouldn't affect the calculation. It would affect the length of the base string returned bys, which would also mean thatK%would pick out different digits upon additional repetitions.
So I just tried swapping E and G and voila:
030819828850379075460427536222159187897761502517030034671154875945928930530907551421904962649729
In summary, here is what the code does:
G, "Push [0 1 2 3 ... 13 14 15].";
Cf# "Raise each element to the 12th power.";
If/ "Divide each element by 18.";
s "Concatenate all numbers into a string.";
E* "Repeat 14 times.";
K% "Pick every 20th digit.";
C, 43 bytes, FryAmTheEggman
Extremely abusive C code; works in the provided tester. Assumes no command-line arguments are passed (which is the default).
main(ui,abdenprsx){printf(&"%se7en%"[ui]);}
Note that the final % doesn't get printed out (at least in the tester provided by the poster and with my local copy of GCC 4.8; Clang refused to compile this code).
Python (2), size 41, muddyfish
print(sum(map(ord,repr(exit.__repr__))))
I observed the result 6831 from this code for both Pythons 2 and 3 on my local machine. However, I managed to reproduce the output 6314 with (http://ideone.com/700qVt). Ideone's Python 3 didn't even recognize the exit function.
Ruby, 49, by Doorknob
$><<"'"+'
""'
%''
%''
%"'<<<<<<<<>>>>>>>>>% ?;"
I think I found a tiny shortcut?
Python, size 41, by Sp3000
exec("import re\x0Aprint(re.__all__[1])")
Fairly sure this is the intended solution.
Javascript, 82, by TrungDQ
b=/v/[0]+' ';b[0]+b[9]+b[6]+b[7]+'v'+b[7]+((0==0)+b)[1]+b[9]+b[4]+b[5]+b[6]+b[2];
Took forever to get the indexes right.
Ruby, size 33, by Doorknob
puts [?\[+?*+?]]-[$?..$\]*$$.next
I don't know Ruby and have no idea what does $?..$\ really mean. Apparently $? and $\ are the only things having the same type (or both undefined?) which will not throw an error.
C, 51 by es1024
c=0xf.cp9,hhtaglfor;main() {;; printf("%d",(++c));}
After 20 years of programming C today I learned about hexadecimal floating point constants.
Javascript, size 285, by Beta Decay
alert(String.fromCharCode(65,90))// """"""(((((()))))),,,......../////001111222222333334666677777788999:========AEGHJLLLMNORTTX[]_aaaaaaaaaaaaaaaabbbccdddeeeeeeeeeeeeeeeeffffghhhhiiiiiiiijmmmmnnnnnnnnoooooooooooooopppppqrrrrrrrrrrrrrrssssssssssssssstttttttttttttuuuvvvwwwwxz
and some newlines after that.
Lua, size 28, by ChipperNickel
a=math print(a.asin(1)*a.pi)
Wow, this was actually really simple, why did I not try this earlier? Also, I learned that you can separate statements with nothing but a space in Lua.
Bash, size 23, by The Wolf
q=echo;_(){ $q $q;};""_
I think the original solution (or red herring) should be:
q(){ q=;};q ""echo;$_ $_
which is invalid because it has one more space character.
Haskell, size 42, by proud haskeller
{data S=S{}deriving Show;main=print S;S=S}
Some clever things were done here: the empty record in the definition of S to reduce the number of spaces (this confused me a long time!), and it looked awful hard to use that extra equals sign from the extraneous S=S equation.
Python 2, size 89, Beta Decay
''''''''((()))*,,,,...12;;=BFGGIIIILPRaaaaaabceeeeeeffgggggiiiiiklmmmmmmnnoopprrrsttvw
Really I would recommend to output something........
Little Man Computer, size 63, The Wolf
503902000051000000000001111122223334455555666777888999999999999
If I'm understanding this correctly, all I have to do is put the number in the out box and then halt? OK...
Haskell, size 34, by Petr Pudlák
main=print(0xb2f3d5^0x7f1f27::Int)
Note that this program must be run on a 32-bit machine. If you want to check that this is the correct program and you have a 64-bit machine, you can use this instead:
import Data.Int
main=print(0xb2f3d5^0x7f1f27::Int32)
It was pretty easy to guess the "frame" of the program main=print(0x<hex digits>^0x<hex digits>::Int). All the magic was in searching for the right way to partition and order the digits. I didn't do very much smart here, just a brute-force search... though I did take care to abuse the fact that some digits were duplicated, there were probably about an equal number of digits in the base and exponent, and the last digit of the base almost certainly wasn't even. The complete search code is included below; it uses the multiset-comb package. The full search takes about 10:33 on my machine (and produces only one right answer, of course).
{-# LANGUAGE NoMonomorphismRestriction #-}
import Control.Monad
import Data.Int
import Data.List (inits, tails, group)
import Numeric
import Math.Combinatorics.Multiset
main = print (searchFor (-1121766947))
searchFor n = do
nl <- [6,5,7,4,8,3,9,2,10,1,11]
(l_, r_) <- chooseSubbag nl digits
l <- perms l_
guard (last l /= '2')
r <- perms r_
guard ((fromString l :: Int32) ^ (fromString r :: Integer) == n)
return (l, r)
chooseSubbag n = chooseSubbag' n . group
chooseSubbag' n xss = go (drop (n-1) (concat xss)) n xss where
go _ n xss | n < 0 = []
go _ 0 xss = [([],concat xss)]
go [] n xss = []
go m n (xs:xss) = do
(kx, tx) <- zip (tails xs) (inits xs)
(k , t ) <- go (drop (length tx) m) (n-length kx) xss
return (kx++k, tx++t)
digits = "1223577bdfff"
fromString = fst . head . readHex
perms = permutations . fromList
Java, size 226, nhhhhtdh
enum
u{u;public
static
void
main(String...a){
System.out.print(0x17+68+"\u0020\125nmatched closing \u0027)\u0027u\"((()),.00008;DEIPP\\aaaaaaaacccceeeeeeeeefgiiijlnnooppprrrrrsstttttttttuuuvxyyz{{}}".split(u.toString())[0]);}}
A quick search revealed that it was easy to generate a PatternSyntaxException with the message Unmatched closing ')', but it proved to be unnecessary as the abundance of backslashes, us and digits allowed me to create any character I didn't have via escapes.
C, size 39, imallett
_;main(){putchar(_^'_');_++<9&&main();}
Java, size 70, Rodolvertice
enum n{s;public static void main(String[]acl){System.out.print((s));}}
I had no idea how enums even worked, with a default toString() returning their name in the source code and all, but there were so few non-boilerplate characters available that it was easy to discover.
SAS, size 17, by user3490
%put%eval(a>1>b);
Simply evaluates the expression a>0>b left to right (giving the results of FALSE, which is represented in SAS by 0) and prints the result to the log.
(Thanks to Sp3000 for noting I originally wrote a>0>b.)
Pyth, size 35, by FryAmTheEggman
llo oCGd"ProgrammingPuzzesandef"
Simply lg(len("Length 22 string")), extra characters disposed of at the front.
Python 3, size 46, hosch250
(print("'(otlotb)'")
==
'bffiilnnoopprrrr01*')
I don't think the idea is to let me simply print the output string in a plain literal...
Python, size 74, by xnor
any(print(set is
set)for i in oct(chr is
map))and aeeeeeggiilnnpprrrrrstvw
Well that was fun. Thanks to FryAmTheEggman, hosch250 and isaacg for suggestions/helping out.
CJam, size 20, by Martin Büttner
Hi "petStorm!", mame
How it works
Hi " int(17) ";
"petStorm!", " len('petStorm!') ";
ma " atan2( , ) ";
me " exp( ) ";
" exp(atan2(int(17), len('petStorm!'))) ";
Cracking the code
The desired output, 2.956177636986737, is either a Double or a Double followed by a Long.
Using only the characters in "Stop, Hammer time!", there are four builtin operators that return non-integer Doubles:
mS, which isasinma, which isatan2me, which isexpmt, which istan
All of them contain an m, so we can use at most three of them. There is only one S and one a.
All of those operators need input, and ma is the only one that consumes two inputs. We have only three ways to push Longs:
"...",, which pushes the string's length (strictly less than 18).H, which pushes 17....!, which pushes the logical NOT of....
We have no way of pushing something falsy as ..., so the last option will always push 0.
The output doesn't begin or end with 17 or 0. Since 15 decimal digits is the usual number of digits for a Double, it seemed likely that the output was a simple Double.
Assuming this, the code has to fall in one of the following categories:
<Long> <mS|me|mt>{1,3}<Long> <mS|me|mt>{x} <Long> <mS|me|mt>{y} ma <mS|me|mt>{z}.- Any of the above, with some cast to Long (
i) or rounding (mo) applied to a Double.
In the second case, x + y + z is either 1 or 2 and one of the Longs is 0 or 17.
The rest was basically brute force. After a few tries,
18 , {H \ ma me 2.956177636986737 =} =
returned 9, meaning that
H 9 ma me
produces the desired output.
All that's left is to eliminate all but 9 characters from the string. Spaces are noops and i is a noop on Longs, so "petStorm!" is one of the possible choices.
C, size 30, Ethiraric
main(){printf("%d",__LINE__);}
Mathematica, size 29, by Fox Wilson
$PrePrint=Function[{x},5];
2+2
Learned something new today! :) ($PrePrint)
PHP, 21, by kenorb
This one is easy if you know that one of the new features in PHP 5.6 (the version of PHP the code was tested in) is a ** operator for exponentiation:
<?=27**5;///***134689
Or alternatively:
<?=3**15;///***246789
PHP, size 27, by kenorb
$_=hex2bin(7069);die($_());
(hex2bin(7069) evaluates to "pi" which is then called)
PHP, size 44, by kenorb
$_=get_class_methods(@new phar);die($_[70]);
IMO, that one was pretty obvious (took me 10 minutes after first look).
I did a quick google search and observed that there were a lot of class having valid() as method... An coincidentally get_Class_methods() was in the string. After extracting that one, no issues anymore.
PHP, 33, by kenorb
This one was quite easy:
<?=strlen(highlight_string(0,1));
In case you were wondering, highlight_string(0,1) produces this result (with a total of 52 characters):
<code><span style="color: #000000">
0</span>
</code>
CJam, size 32, by Dennis
"tb srcr wB!eyo awm ,kheeonae"Jb
Just guess the answer should be something like "..."Jb and then brute-forced it.
JavaScript, size 25, by Cris
alert.apply(self,[alert])
GolfScript, size 13, by Peter Taylor
,22,{.4&?+.}/
Another one, that I only cracked with big help from Sp3000. Thanks!
So here's how we got there. Sp3000 noticed a bunch of runs of consecutive numbers in the output:
1,2,3,4,[2608852181],4582,4583,4584,4585,4586,[253225388392299],
142924,142925,142926,142927,142928,[302928],497409,497409
Based on that we made the assumption, that this was an increasing sequence, which only allowed for one possible splitting of the remaining numbers:
1,2,3,4,260,885,2181,4582,4583,4584,4585,4586,25322,53883,92299,
142924,142925,142926,142927,142928,302928,497409,497409
That's 23 numbers, which was a strong indicator for repeating the block 22 times, as well as ending the block with . (duplicate top stack element), such that the previous result got left behind on the stack and such that the final iteration would appear on the stack twice. That's 22,{____.}/.
Now looking at the gaps, those turn out to be 4th powers (which is nice, because we have 4 and ?). More precisely, they are the fourth power of the index of the current number. So next we looked at which indices created a gap:
4,5,6,7, 12,13,14,15, 20,21,..?
In binary those are
00100
00101
00110
00111
01100
01101
01110
01111
10100
10101
They all have the third bit set, which means that the index is probably just bitwise-and'ed with 4 (which is nice again, because we can make another 4 with . and have a &). This works particularly well, because this operation results in either 0 or 4, and if we use that as the exponent we get either 1 or a fourth power, which is exactly what we need. So let's put that together:
22,{.4&?+.}/
Here is what the block does:
. # Duplicate current index
4 # Push a 4
& # Bitwise and
? # Raise index to resulting power
+ # Add to previous result
. # Duplicate for use in next iteration
Now there were two problems left: we had a stray , we didn't use yet, and the first iteration is a special case, in that there is no value from a previous iteration which we could add things to when encountering +. We found that thanks to an unrelated comment by user23013 who casually mentioned that GolfScript starts out with an empty string on the stack (if there's nothing on STDIN). So we could use that other , right at the beginning to turn that string into a 0, which was just what we needed as the start of the iteration.
Python 3, size 110, by Sp3000
import sys,io
u=sys.stdout;sys.stdout=_=io.StringIO()
import this
u.write(" ".join(_.getvalue().split()[::9]))
This was a fun one :)
JavaScript, size 47, by palerdot
alert("a surprise!")//if("est")(it will tell )
This was super easy though. There can be so many solutions to this too.
JavaScript, length 32, by hsl
Interesting use of the map() function there:
[atob('cHVHaVht')].map(alert)//+
Brainfuck, size 118, Sp3000
+++[->++++<]>[->+++[->>+++>+>++>+>+++>++>+[<]<]>>>>+>+>+>+<<<<<<<<]>>>+++++>>++>++++>+[>]+++[-<-<->>]<[<]>[.>]<<<++++>
Brainfuck is really not so bad, as long as it's not golfed too much. Since the alphabet is so limited, you can write whatever program you want as long as it's shorter than the original, and then make slight adjustments to balance the symbol counts.
C, es1024, length 70
e='C',f;main(g){Chorkil:f=printf("40%.d",e+e- -g);}hAx;*hotpoCkats();
The hard part ended up being to keep track of all the unneeded characters...seriously...I had to redo them about 10 times. The only one that worried me was the . but somehow I stuck it in the middle of the printf format string and it became invisible!
Pyth, size 71, by FryAmTheEggman
*tC"y"l"Han Solo: Never Tell Me The Odd
-3P0: Sir, the possibii,... s!"
There have to be a ridiculous number of possiblities here, but this seemed to be the easiest - get 120 from chr('y')-1, and 31 as the length of a string, and multiply. Newline is a super-comment.
Perl, size 39, by GentlePurpleRain
$_=(~0);s/(\d\d)/ge_$2/;print$_=chr$1*4
With help from chilemagic.
Mathematica, size 35, by Tally
$PrePrint=$Pre=e=p=esPrint&'' ;a
Definitely not unique. Basically, I'm creating a constant function, take the second derivative (which is a constant-0 function) and make sure that function is applied to any expression that is evaluated or printed. Then I evaluate a.
Ruby - 58, by Rodolvertice
There are probably lots of solutions to this one.
puts 0x7d556657^0x3ffd88f9^0x1221442e^0xdd48ad1^0x08c58a00
PHP, Size 30, by Tryth
__halt_compiler();t101hant.net
Just stopping the parser and ignore everything else to have no output.
Python 2, size 57, by FryAmTheEggman
print''.join(map(chr,(40+58,90+4+10+0b100,113+4,101++0)))
The ++ is a lazy way to get rid of a +.
Ruby, size 17, by Doorknob
p 2,%r~n~i=~'*tN'
That was great fun. Thanks to Sp3000 for helping me out with this! And I learned that %r?...? literals can have any delimiters. :)
Python 3, size 37 by matsjoyce
print(*[_*_ for _ in range(2*2*2+2)])
Let's add some more text so that this one doesn't get auto-converted to a comment.
PHP, size 54, by Steve Robbins
echo(21<<($$$$$$${$aaaabbbbbbehi==$l&$w^2}^1==1));;;;
Not the original solution, I think.
PHP, size 23, by bwoebi
echo@$c=b,$b.$$c=$c.$c;
I'm confused by why echo@$$c=b,$$c.$$cc.=b; doesn't work, while calling echo@$$c=b,${""}.$$cc.=b; directly does.
PHP, size 52, by kenorb
_:@print_r(chr(@++$i+pow(3<<5,1)));if($i<2*4)goto _;
(God, how long it took me to figure what to do with the remaining _r suffix. Until I noticed it was not print, but print_r...)
C - 43, by Allbeert
This solution really ,sux, but it does actually work if you ignore the grumbling from gcc:
main(){printf(&__DATE__[10],1+1+1+',sux');}
(It will stop working in a few weeks, however...)
Python, size 56 by Fox Wilson
print("".join([chr((i+70)^32)for i in (2,3,-70,7,9,7)]))
Python 2, size 38, by FryAmTheEggMan
print(`[].__iter__`[::2].split()[-~1])
Taking letters from object at.
BBC BASIC, 187, by Beta Decay
This just prints out a long sequence of ASCII codes:
PRINTCHR$(121)CHR$(111)CHR$(117)CHR$(39)CHR$(108)CHR$(108)CHR$(32)CHR$(110)CHR$(101)CHR$(118)CHR$(101)CHR$(114)CHR$(32)CHR$(99)CHR$(114)CHR$(97)CHR$(99)CHR$(107)CHR$(32)CHR$(109)CHR$(101)
Python 3, Sp3000, size 44
print(~(~(()<((),))<<(()<((),))))<<((()<()))
Python 3 helped me here as I was able to cause an error (left-shifting None by something) after printing the answer.
JavaScript, size 61, by jsh
x=function() {return 1;};alert((typeof (typeof x)).slice(-4))
Python, size 69, by Sp3000
print(sum(list(map(ord,str((dict(((str(dict()),list()),)),str()))))))
That was hard...
Pyth, size 11, by isaacg
:\\w$ ",d,N
That's some mean bug abuse right there. This compiles to:
Pprint("\n",at_slice("\",input(), ",d,N))
The relevant bug is that \\ compiles to "\" instead of "\\", which lets you compile Pyth into a string.
Befunge-93, size 17, by user23013
I'm not sure what all that extra stuff on line 2 is doing there...
"@",69+#
>_-/*%pv
Java 6+, 101 bytes, by Rodolvertice
class ou{public static void main(String[]h){for(int t='l'|'s';t>0;t/=2)System.err.append(t+"4"+t);;}}
Outputs to stderr.
I figure out the pattern of the output quite easily:
127 4 127
63 4 63
31 4 31
15 4 15
7 4 7
3 4 3
1 4 1
This suggests the tokens /=2, for(;;), t+"4"+t, >0. for is taken from short free;.
The number 127, the 4 ' and | also suggests the use of | with 2 char.
The tricky part is to pick out t from the rest of the code (out -> err, println -> append, class t, the remaining part of short free;).
CJam, size 52, by user23013
33,33,33f+:cm*33)%",,,:::')@\&++++3333333333cfffff";
Thanks for providing "...";. ;)
C++, 56, by hosch250
int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}
Note that in order to get this to compile with GCC as a C++ program, I had to tell GCC to include stdio.h:
$ g++ -include stdio.h -o 40974 40974.cpp
$ ./40974
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
The program does compile without -include in GCC's C99 mode though:
$ gcc -std=c99 -o 40974 40974.c
40974.c: In function ‘main’:
40974.c:1:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}
^
40974.c:1:41: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}
^
Python, size 68, by horns
o=ord;print(chr(35),o('{'),o("-"),o("C"),o("Y"),sep="")#''''"02blpst
I think I've got the characters right. Either way, if I miscounted the number of quotes, the rest go after the comment (consulting the ASCII table helped).
Python, size 48, by kgull
print('h'+hex(ord('\r')*pow(ord('#')//2,2))[2:])
Perl 5, size 47, by chilemagic
print((0..$])x$]); ""."$$$$()**.///[[~==1fors";
I think this is valid. The $] part took me a while.
Python, size 54, by kgull
'head'#(o)op'/r),2\x'12.)w/)],c'dp*((rx:(h('r'ol'e)[re
This most likely is not the intended answer, but it works; the # comments out everything but the result. The OP stated that this is supposed to be run in a shell, so there is no print statement.
Python, size 154, by Fox Wilson
print("".join(chr(int(130-o))for o in [51%35,13,ord(" (()),..////00188==[]________aaccddeeeeffffgiiiiiiiiijjjjllnnnoopprrrrttuu"[1]),sum([8,1])]))
This is almost certainly not the intended solution.
Python 2, size 61, by FryAmTheEggman
print(dir('~s]l.c:st_''-p_tp.l]-~.:o:Te[_u[.i_')[10][2:][:3])
I'd be very surprised if this matches the original.
PHP, size 52, by PleaseStand
for(mt_srand($i=46);$i--;)echo chr(mt_rand()%95+32);
This turned out to be quite easy in the end. The output looks very random, and the characters m, t, _, r, a, n and d all appeared twice...
JavaScript, size 26, by hsl
alert(998|(103>8>0&41>-0))
And some random text to prevent it converted into a comment.
Python 2, 29 bytes, by Dennis
emnsssssyyy= str().strip;ord;
Please, good bot, do not convert me to a comment!
Python [any] shell size 44, by Caridorc
__name__[3] or (enfin_____[42], manager[1])
I'm sure there was supposed to be more to it than this, but since __name__ equates to __main__, the 4th character 'a' is selected and the rest of the line is never evaluated.
JavaScript, size 13, by Caridorc
{}-[]+[]+([])
I'm not sure though if the cop's submission is valid, because it requires a REPL environment.
CoffeeScript, size 25, by Martin Büttner
alert /hees /.test []
Try it out at http://jsfiddle.net/33qa3guk/.
CJam, size 15, by Ypnypn
98,{7%}%{6+}%:+
From the given characters, I guessed it had to be one of the three following forms:
__,{_%}%{_+}%:+
_,{_%}%{__+}%:+
__,{_+}%{_%}%:+
which creates a two-digit range, then maps an addition and modulo operation (in either order) onto the range, before summing it. So I just started with the first one, and systematically tried permutations of 6789 in the gaps.
Python 3, size 16, by matsjoyce
import __hello__
Python 3, size 12, by xnor
()and bciprt
Does nothing (expression produces an empty tuple, which is not printed). This works due to short-circuit evaluation.