As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "golfing" it!
So it goes simply like that:
Without using numbers, write a code that outputs the annual salary you'd like to be offered.
However, being able to write concise code is a cornerstone of this company. So they have implemented a very tight seniority ladder where
employers that write code that is b bytes long can earn a maximum of (1ドル'000'000) · b−0.75.
we are looking at (these are the integer parts, just for display reasons):
1 byte → 1ドル'000'000 15 bytes → 131ドル'199
2 bytes → 594ドル'603 20 bytes → 105ドル'737
3 bytes → 438ドル'691 30 bytes → 78ドル'011
4 bytes → 353ドル'553 40 bytes → 62ドル'871
10 bytes → 177ドル'827 50 bytes → 53ドル'182
The challenge
Write a program or function that takes no input and outputs a text containing a dollar sign ($, U+0024) and a decimal representation of a number (integer or real).
- Your code cannot contain the characters
0123456789.
In the output:
There may optionally be a single space between the dollar sign and the number.
Trailing and leading white spaces and new lines are acceptable, but any other output is forbidden.
The number must be expressed as a decimal number using only the characters
0123456789.. This excludes the use of scientific notation.Any number of decimal places are allowed.
An entry is valid if the value it outputs is not greater than (1ドル'000'000) · b−0.75, where b is the byte length of the source code.
Example output (the quotes should not be output)
"$ 428000" good if code is not longer than 3 bytes
"321023ドル.32" good if code is not longer than 4 bytes
" $ 22155.0" good if code is not longer than 160 bytes
"$ 92367.15 \n" good if code is not longer than 23 bytes
"300000 $" bad
" lorem $ 550612.89" bad
"109824ドル" bad
"$ -273256.21" bad
"2ドル.448E5" bad
The score
The value you output is your score! (Highest salary wins, of course.)
Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, $X (Y bytes)
where X is your salary and Y is the size of your submission. (The Y bytes can be anywhere in your answer.) If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>111111ドル.111... (18 bytes)</s> <s>111999ドル (17 bytes)</s> 123456ドル (16 bytes)
You can also make the language name a link, which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 126,126ドル (13 bytes)
var QUESTION_ID=171168,OVERRIDE_USER=77736;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body.replace(/<(s|strike)>.*?<\/1円>/g,"");s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a1=r.match(SCORE_REG),a2=r.match(LANG_REG),a3=r.match(BYTES_REG);a1&&a2&&e.push({user:getAuthorName(s),size:a3?+a3[1]:0,score:+a1[1].replace(/[^\d.]/g,""),lang:a2[1],rawlang:(/<a/.test(a2[1])?jQuery(a2[1]).text():a2[1]).toLowerCase(),link:s.share_link})}),e.sort(function(e,s){var r=e.score,a=s.score;return a-r});var s={},r=1,a=null,n=1;e.forEach(function(e){e.score!=a&&(n=r),a=e.score,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.lang).replace("{{SCORE}}","$"+e.score.toFixed(2)).replace("{{SIZE}}",e.size||"?").replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);s[e.rawlang]=s[e.rawlang]||e});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){var r=e.rawlang,a=s.rawlang;return r>a?1:r<a?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SCORE}}","$"+o.score.toFixed(2)).replace("{{SIZE}}",o.size||"?").replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var LANG_REG=/<h\d>\s*((?:[^\n,](?!\s*\(?\d+\s*bytes))*[^\s,:-])/,BYTES_REG=/(\d+)\s*(?:<a[^>]+>|<\/a>)?\s*bytes/i,SCORE_REG=/\$\s*([\d',]+\.?\d*)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:520px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Score</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td><td>Size</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SCORE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SCORE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
Edit: (rounded) maximum allowed score per byte count, for a quicker reference - text here:
152 Answers 152
bash, 127127ドル
x;echo \$$?$?
Since the x command doesn't exist, it errors and sets the exit code to 127.
Then, the code outputs a dollar sign followed by $? twice. The $? variable stores the exit code of the previous command, so this outputs 127127ドル in 13 bytes.
-
65\$\begingroup\$ Funnily enough if you're on Mac and you have XQuartz installed, this won't work because
xdoes exist. As a bonus, it crashed when trying to open it, so I got11ドルinstead! \$\endgroup\$numbermaniac– numbermaniac2018年08月28日 07:53:07 +00:00Commented Aug 28, 2018 at 7:53 -
16\$\begingroup\$ Use
]instead ofx, the former is less likely to exist. \$\endgroup\$pts– pts2018年08月28日 22:30:49 +00:00Commented Aug 28, 2018 at 22:30 -
\$\begingroup\$ @numbermaniac Also, such commands were found for installing on ubuntu 19.04: e, q, r. But
wis a thing (close towho) and exit successfully, so you get 00ドル for it! \$\endgroup\$val - disappointed in SE– val - disappointed in SE2019年06月23日 22:00:44 +00:00Commented Jun 23, 2019 at 22:00
Java 8, 131,199ドル.00 (15 bytes)
v->"$"+'e'*'ԓ'
Explanation:
v-> // Method with empty unused parameter and String return-type
"$"+ // Return a dollar sign, concatted with:
'e'*'ԓ' // 131199 (101 * 1299)
\131,199ドル.00 < 131,199.31\$
I used a program to generate a printable ASCII character in the range [32, 126] which, when dividing 131199, would have the lowest amount of decimal values. Since 101 can divide 131199 evenly, resulting in 1299, I'm only 31 cents short of my maximum possible salary based on my byte-count of 15.
-
15\$\begingroup\$ Dang, impressively efficient score! \$\endgroup\$ETHproductions– ETHproductions2018年08月27日 19:38:53 +00:00Commented Aug 27, 2018 at 19:38
-
\$\begingroup\$ ... doesn't the program use numbers now after the edit, which is forbidden by the challenge? \$\endgroup\$Laikoni– Laikoni2023年03月30日 17:40:19 +00:00Commented Mar 30, 2023 at 17:40
-
\$\begingroup\$ @Laikoni Woops.. I'm an idiot -_- Thanks, rolled back. \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2023年03月30日 17:44:35 +00:00Commented Mar 30, 2023 at 17:44
CJam, (5 bytes) 294204ドル.018...
'$PB#
Explanation:
I derived it from Dennis' answer, but looked for combinations of numbers which would yield a higher result. I almost gave up, but I saw that P is the variable for \$\pi\,ドル and that \$\pi^{11} \approx 294000\$. The letter B has a value of 11 in CJam, giving the code above.
-
7\$\begingroup\$ Since your score is your salary, you should mention it in the header. This answer is currently winning. :) \$\endgroup\$Dennis– Dennis2018年08月27日 13:31:15 +00:00Commented Aug 27, 2018 at 13:31
R, 20 bytes, 103540ドル.9
T=pi+pi;cat("$",T^T)
The max for 20 bytes is 105737ドル.1, so this is quite close to the salary cap!
This would be a nice raise, and if I get paid to do code golf......
-
2\$\begingroup\$ might be a way to combine
piwith a dataset's sum... would require a programmatic approach to evaluate various combination of operators/datasets/pi to get as close to the max as possible. No time for this now but it sounds like a nice challenge in itself. \$\endgroup\$JayCe– JayCe2018年08月25日 15:37:36 +00:00Commented Aug 25, 2018 at 15:37
GS2, (5 bytes) 292,929ドル
•$☺↔A
A full program (shown here using code-page 437). (Maximum achievable salary @ 5 bytes is 299069ドル.75)
Builds upon Dennis's GS2 answer...
•$☺↔A []
•$ - push '$' ['$']
☺ - push unsigned byte:
↔ - 0x1d = 29 ['$',29]
A - push top of stack twice ['$',29,29,29]
- implicit print 292929ドル
-
1\$\begingroup\$ That's 11 bytes, even if it is 5 characters. \$\endgroup\$dotancohen– dotancohen2018年08月26日 08:38:57 +00:00Commented Aug 26, 2018 at 8:38
-
5\$\begingroup\$ @dotancohen:
0x0724011d41is 5 bytes by my count... \$\endgroup\$eggyal– eggyal2018年08月26日 09:39:50 +00:00Commented Aug 26, 2018 at 9:39 -
4\$\begingroup\$ @eggyal: I missed the bit about code-page 437. Nice touch! \$\endgroup\$dotancohen– dotancohen2018年08月26日 10:26:28 +00:00Commented Aug 26, 2018 at 10:26
-
5\$\begingroup\$ Dear down-voter, could I have some feedback please; I don't see what is incorrect, not useful, or unclear. \$\endgroup\$Jonathan Allan– Jonathan Allan2018年08月26日 15:10:58 +00:00Commented Aug 26, 2018 at 15:10
-
2\$\begingroup\$ You didn't end up using the
:, so you can remove it and add another+for 124444ドル. \$\endgroup\$Nitrodon– Nitrodon2018年08月26日 01:36:24 +00:00Commented Aug 26, 2018 at 1:36 -
\$\begingroup\$ @Nitrodon Ah right, thanks. \$\endgroup\$user202729– user2027292018年08月26日 04:29:14 +00:00Commented Aug 26, 2018 at 4:29
-
\$\begingroup\$ After printing the
1, why not count to3and then print only3s? You would save a byte and print a higher number. \$\endgroup\$12431234123412341234123– 124312341234123412341232018年08月27日 19:51:42 +00:00Commented Aug 27, 2018 at 19:51 -
\$\begingroup\$ @12431234123412341234123 You'd need to save two bytes. Otherwise, with 15 bytes, you're only allowed up to 131199,ドル 133333ドル is too much. \$\endgroup\$hvd– hvd2018年08月28日 11:24:12 +00:00Commented Aug 28, 2018 at 11:24
-
\$\begingroup\$ How about
<.<[-<++.+.>]/^C$(The ^C is003円) or00000000: 3c2e 3c5b 2d3c 2b2b 2e2b 2e3e 5d2f 0324 <.<[-<++.+.>]/.$? Would be 16 Byte and output124578ドル. \$\endgroup\$12431234123412341234123– 124312341234123412341232024年06月11日 11:36:34 +00:00Commented Jun 11, 2024 at 11:36
JavaScript (ES6), 19 bytes, 109,839ドル
_=>atob`JDEwOTgzOQ`
\109839ドル\$ is the highest integer \$\le 109884\$ which does not produce any digit when prefixed with '$' and encoded in base64.
Without atob() (Node.js), 26 bytes, 86,126ドル
_=>'$'+Buffer('V~').join``
The concatenation of '$' with the ASCII codes of 'V' (86) and '~' (126).
-
\$\begingroup\$ Wow
Buffer. First time ever to acknowledge this class ;') \$\endgroup\$Shieru Asakoto– Shieru Asakoto2018年08月29日 01:04:43 +00:00Commented Aug 29, 2018 at 1:04 -
1\$\begingroup\$ @user71546 It could be done in 24 bytes for 91,126ドル if thousand separators were allowed. But apparently, they're not... :( \$\endgroup\$Arnauld– Arnauld2018年08月29日 05:47:30 +00:00Commented Aug 29, 2018 at 5:47
-
\$\begingroup\$
Bufferconstructor is deprecated, so that will get longer in future versions \$\endgroup\$mcfedr– mcfedr2018年08月30日 11:35:27 +00:00Commented Aug 30, 2018 at 11:35 -
2\$\begingroup\$ @mcfedr We don't care for code golf, as long as a working version of the interpreter is properly specified. \$\endgroup\$VerdantOzark– VerdantOzark2018年08月31日 03:33:37 +00:00Commented Aug 31, 2018 at 3:33
R, 21 bytes 99649ドル.9
cat("$",min(lynx^pi))
A different R approach - see also Giuseppe's answer
Very close to the maximum of 101937ドル for this bytecount.
Bonus: object.size()
R, 24 bytes 89096ドル
cat("$",object.size(ls))
This is probably system-dependent, but when I ra this on TIO I got 89096ドル - close to the limit of 92223 for 24 bytes.
-
\$\begingroup\$ neat! I thought about trying to pick a good dataset but I can't figure out where to look to find them...I guess the
datasetspackage makes a lot of sense. \$\endgroup\$Giuseppe– Giuseppe2018年08月25日 15:23:41 +00:00Commented Aug 25, 2018 at 15:23 -
\$\begingroup\$ @Giuseppe I'm just trying
prodandsumrandomly... but prod increases too fast ! \$\endgroup\$JayCe– JayCe2018年08月25日 15:24:46 +00:00Commented Aug 25, 2018 at 15:24 -
\$\begingroup\$
sum(volcano)is690907but that would have to be about 1 byte to work, haha \$\endgroup\$Giuseppe– Giuseppe2018年08月25日 15:30:49 +00:00Commented Aug 25, 2018 at 15:30 -
\$\begingroup\$ Great idea using datasets ! \$\endgroup\$digEmAll– digEmAll2018年08月25日 15:32:40 +00:00Commented Aug 25, 2018 at 15:32
-
\$\begingroup\$ @Giuseppe good catch I had completely overlooked that! duh. \$\endgroup\$JayCe– JayCe2018年08月25日 15:41:52 +00:00Commented Aug 25, 2018 at 15:41
PHP, 131116ドル (8 bytes)
Didn't see one for php and wanted to throw one up. I know someplace in php is a bad typecast that would cut this in half but I can't find it right now.
$<?=ERA;
This just takes advantage of PHP short tags and the PHP built in constants.
-
1\$\begingroup\$ Ha I’ll switch it out for something else tomorrow \$\endgroup\$michael.schuett– michael.schuett2018年08月27日 08:21:20 +00:00Commented Aug 27, 2018 at 8:21
-
4\$\begingroup\$ Instead of
<?="$"., just do$<?=and save a few bytes. \$\endgroup\$Ismael Miguel– Ismael Miguel2018年08月27日 10:23:41 +00:00Commented Aug 27, 2018 at 10:23 -
2\$\begingroup\$ @IsmaelMiguel nice thanks! Got it down to 8 bytes but didn't take long enough to figure out how to get the other ~70k of my salary. \$\endgroup\$michael.schuett– michael.schuett2018年08月27日 14:25:17 +00:00Commented Aug 27, 2018 at 14:25
-
1\$\begingroup\$ wow didnt knew about this constant, but I couldnt find in docs, can any one help on this? \$\endgroup\$Rafee– Rafee2018年08月29日 09:28:05 +00:00Commented Aug 29, 2018 at 9:28
-
3\$\begingroup\$ @Rafee it's actually not documented any place that I can find. It's a language constant that was added 17 years ago github.com/php/php-src/commit/…. I found it by dumping all available constants and then just starting to grep for the shortest ones. It seems to be provided by the OS seen here gnu.org/software/libc/manual/pdf/libc.pdf on page 195. \$\endgroup\$michael.schuett– michael.schuett2018年08月29日 14:50:52 +00:00Commented Aug 29, 2018 at 14:50
Excel 19 bytes 107899ドル.616068361
="$"&CODE("(")^PI()
Explanation:
CODE("(") // find ASCII code of ( which is 40
^PI() // raise to power of Pi (40^3.141592654)
"$"& // append $ to the front of it
= // set it to the cell value and display
-
2\$\begingroup\$ Welcome to PPCG! \$\endgroup\$Luis felipe De jesus Munoz– Luis felipe De jesus Munoz2018年08月27日 14:53:02 +00:00Commented Aug 27, 2018 at 14:53
-
9\$\begingroup\$ +1 Even better, they'll be impressed with your Excel skills and want you to be an account manager. \$\endgroup\$theREALyumdub– theREALyumdub2018年08月27日 17:25:44 +00:00Commented Aug 27, 2018 at 17:25
-
2\$\begingroup\$ @theREALyumdub is that supposed to be a good thing? I'm not sure I'd take this salary if it means I have to work with Excel on the daily ;) \$\endgroup\$Aaron– Aaron2018年08月28日 16:04:10 +00:00Commented Aug 28, 2018 at 16:04
-
\$\begingroup\$ I'd argue with Excel's accounting formatting, that you can skip the $ entirely, and simply set the formatting to accounting. \$\endgroup\$Selkie– Selkie2018年08月29日 20:10:48 +00:00Commented Aug 29, 2018 at 20:10
-
\$\begingroup\$ @Selkie Accounting format adds a comma, which is disallowed. You could use a custom format of $# though. I wouldn't be sure if I should count this as 15 characters with =CODE("*")^PI() for 125773,ドル or 17 characters (adding 2 for the the format letters) with =CODE(")")^PI() for 116603,ドル or if this is disallowed. \$\endgroup\$Keeta - reinstate Monica– Keeta - reinstate Monica2018年08月30日 13:01:04 +00:00Commented Aug 30, 2018 at 13:01
vim, (削除) 99999ドル (削除ここまで) (削除) 110000ドル (削除ここまで) 120000ドル
i$=&pvh*&ur
Uses the expression register (note that there is a <C-r> character, which is invisible in most fonts, between the $ and =, for a total of 13 bytes) to insert the value of the 'pvh' option times the value of the 'ur' option.
'previewheight' is the option that controls the height of preview windows, which is 12 by default.
'undoreload' is the maximum number of lines a buffer can have before vim gives up on storing it in memory for undo, and it defaults to 10,000.
Jelly, (削除) 256000ドル 256256ドル (削除ここまで) (6 bytes) 257256ドル
9‘"$;;
A full program. (Maximum achievable salary @ 6 bytes is 260847ドル.43)
How?
9‘"$;; - Main Link: no arguments
9 - Literal 256 256
‘ - increment 257
"$ - single '$' character '$'
; - concatenate ['$',257]
; - concatenate ['$',257,256]
- implicit print -> 257256ドル
Previous...
5 bytes 256256ドル
"$;9+
('$' concatenate 256, repeat 256 - causing interim implicit printing)
6 bytes 256000ドル:
×ばつȷṭ"$
(256 ×ばつ 1000 ṭack '$')
-
1\$\begingroup\$ That looks like 5 characters, but 11 bytes. \$\endgroup\$dotancohen– dotancohen2018年08月26日 08:38:19 +00:00Commented Aug 26, 2018 at 8:38
-
11\$\begingroup\$ @dotancohen Jelly uses a custom code page. \$\endgroup\$Carmeister– Carmeister2018年08月26日 09:32:04 +00:00Commented Aug 26, 2018 at 9:32
-
\$\begingroup\$ @Carmeister:Nice! \$\endgroup\$dotancohen– dotancohen2018年08月26日 10:25:18 +00:00Commented Aug 26, 2018 at 10:25
-
-
\$\begingroup\$ @NieDzejkob indeed 6 bytes are available - I have 257256ドル now :) \$\endgroup\$Jonathan Allan– Jonathan Allan2018年08月26日 12:52:09 +00:00Commented Aug 26, 2018 at 12:52
Python 3, (22 bytes) $ 98,442
print('$',ord('𘂊'))
Much like Doorknob's Ruby answer, the 4 byte Unicode character used here, 𘂊, has an ordinal value of the maximal integer salary achievable in 22 bytes.
Note that print() prints its unnamed arguments separated by spaces by default (sep is an optional named argument).
-
\$\begingroup\$ you can do slightly better than that using f strings: print(f"${ord('𘫿')}") is 21 bytes and outputs 101119ドル \$\endgroup\$Matt– Matt2018年08月28日 14:33:47 +00:00Commented Aug 28, 2018 at 14:33
-
2\$\begingroup\$ @Matt that is 24 bytes (I thought of f-string but realised that the extra braces would cost 2 bytes) \$\endgroup\$Jonathan Allan– Jonathan Allan2018年08月28日 15:39:26 +00:00Commented Aug 28, 2018 at 15:39
-
2\$\begingroup\$ Proof that Python 2 will earn a higher salary. \$\endgroup\$mbomb007– mbomb0072019年05月29日 13:56:13 +00:00Commented May 29, 2019 at 13:56
C#
Full program, (削除) 72 bytes, 40448ドル (削除ここまで) 66 bytes, 43008ドル
class P{static void Main()=>System.Console.Write("$"+('T'<<'i'));}
Explanation
Left-shift operator treats chars 'T' and 'i' as integers 84 and 105 respectively and performs shift
Lambda, (削除) 19 bytes, 109568ドル (削除ここまで) 17 bytes, 118784ドル
o=>"$"+('t'<<'j')
Edit Thanks to @LegionMammal978 and @Kevin for saving 2 bytes
-
5\$\begingroup\$ Just curious, why do you include a semicolon on the end of your lambda? \$\endgroup\$LegionMammal978– LegionMammal9782018年08月26日 22:27:18 +00:00Commented Aug 26, 2018 at 22:27
-
1\$\begingroup\$ In addition to what @LegionMammal978 mentioned (trailing semi-colons doesn't have to be counted in the byte-count for Java/C# lambdas), by taking an unused empty parameter you can golf the
()=>too=>for an additional -1 byte. \$\endgroup\$Kevin Cruijssen– Kevin Cruijssen2018年08月28日 07:38:08 +00:00Commented Aug 28, 2018 at 7:38 -
2\$\begingroup\$ Indeed, with both @Kevin's and my advice, the lambda can be golfed to
o=>"$"+('t'<<'j')with 118784ドル. \$\endgroup\$LegionMammal978– LegionMammal9782018年08月28日 10:30:15 +00:00Commented Aug 28, 2018 at 10:30 -
\$\begingroup\$ @Kevin I didn't know about this, thanks for the info. \$\endgroup\$pmysl– pmysl2018年08月28日 14:23:21 +00:00Commented Aug 28, 2018 at 14:23
-
\$\begingroup\$ @LegionMammal978 Thanks for pointing out unnecessary semicolon and for providing updated lambda. I must have overlooked this semicolon somehow \$\endgroup\$pmysl– pmysl2018年08月28日 17:20:29 +00:00Commented Aug 28, 2018 at 17:20
PHP, 13 Bytes, 144000ドル Salary
Unfortunately for this job, moving to Mauritius is required (well, I could move slightly less far eastward, however every timezone less would yield at 36ドルk drop in salary.) To compensate for the inconvenience, my salary increases by 1ドル every leap year.
$<?=date(ZL);
This just puts out Z the timezone in seconds and appends whether or not it's a leap year.
brainfuck, 43 bytes, 58888ドル
++++++[>++++++<-]>.<++++[>++++<-]>+.+++....
How it works
++++++[>++++++<-]>. write 36 to cell one and print (36 is ASCII for $)
<++++[>++++<-]>+. add 17 to cell 1 and print (cell 1 is now 53, ASCII for 5)
+++.... add 3 to cell 1 and print 4 times (cell 1 is now 56, ASCII for 8)
-
1\$\begingroup\$ Welcome to PPCG! Hope you stick around \$\endgroup\$Jo King– Jo King2018年08月28日 23:33:36 +00:00Commented Aug 28, 2018 at 23:33
Gol><>, 207680ドル in 8 bytes
'o**n; $
How it works:
' Start string interpretation. Pushes the ASCII value of every character until it wraps back around to this character
o Output the top stack value as ASCII. This is the $ at the end of the code
** Multiply the top 3 stack values (This is the ASCII of 'n; ', 110*59*32
n Output top of stack as integer.
; Terminate program
$ (Not run, used for printing the $)
Interestingly enough, you can use h instead of n;, which yields 'o**h5$ with a score of 231504,ドル but you can't use 0-9, and there isn't another 1-byte way to push 53, the ASCII value of 5
-
1\$\begingroup\$ Welcome to PPCG! \$\endgroup\$user45941– user459412018年08月28日 00:56:11 +00:00Commented Aug 28, 2018 at 0:56
brainfuck, 34 bytes, 69999ドル
+[->-[---<]>-]>.[-->+++<]>.+++....
Explanation:
+[->-[---<]>-]>. Generate and print 36 ($)
[-->+++<]> Divide by 2 and multiply by 3 to get 54 (6)
. Print 6
+++.... Print 9999
Mathematica, 18 bytes, 107,163ドル.49
$~Print~N[E^(E!E)]
Full program; run using MathematicaScript -script. Outputs 107163ドル.4882807548 followed by a trailing newline. I have verified that this is the highest-scoring solution of the form $~Print~N[expr] where expr is comprised of Pi, E, I, and +-* /()!.
-
\$\begingroup\$ What about
I? \$\endgroup\$user202729– user2027292018年08月26日 04:40:28 +00:00Commented Aug 26, 2018 at 4:40 -
\$\begingroup\$ @user202729 Nope, doesn't help; any number that actually uses
Iand not justI IorI/Iwill generally have a+ 0.*Itacked onto itsN. \$\endgroup\$LegionMammal978– LegionMammal9782018年08月26日 10:22:09 +00:00Commented Aug 26, 2018 at 10:22 -
\$\begingroup\$ Very nice! I had gotten as far as
"$"~Print~Exp[E!N@E](which is the same length as"$"~Print~N[E^(E!E)]), but with the quotation marks around$, the output was just barely over the limit. \$\endgroup\$Misha Lavrov– Misha Lavrov2018年08月26日 14:37:54 +00:00Commented Aug 26, 2018 at 14:37 -
\$\begingroup\$ What I came up with was Print[,ドルN[Pi^(Pi*Pi)]], giving 80662ドル.7. I tried various combinations of Pi, E, +, *, ^ (thought about I but didn't see any effective way to use it), but it never occurred to me to try !. \$\endgroup\$Meni Rosenfeld– Meni Rosenfeld2018年08月30日 01:00:26 +00:00Commented Aug 30, 2018 at 1:00
-
\$\begingroup\$
$~Print~⌈E^(E!E)⌉with left and right ceiling characters with one character it would be little bit more and 17 bytes \$\endgroup\$buttercrab– buttercrab2019年02月09日 14:19:22 +00:00Commented Feb 9, 2019 at 14:19
05AB1E (5 bytes), 262626ドル
'2ドルÐJ
\262626ドル < 299069\$. Pushes the character $ to the stack, then pushes the integer \26ドル\$. From here, the program triplicates the integer, leaving the stack as ["$", 26, 26, 26] and joins (J) the stack.
JavaScript (Node.js), 23 bytes, 65535ドル
_=>"$"+ +(~~[]+`xFFFF`)
This is the best I can get without atob, though there is a large improvement space tbh
You know, having no short character to ascii conversion function sucks A LOT.
AFTER A WHOLE DAY
JavaScript (Node.js), 30 bytes, 78011ドル
_=>"$"+`𓂻`.codePointAt(![])
or: 29 bytes, 80020ドル
_=>"$"+``.codePointAt(!_)
Where is U+13894 INVALID CHARACTER
Oh String.codePointAt! I've just completely forgotten this!
A joke one (15B, 130000ドル), not vaild at all but just for fun
_=>"$十三萬"
-
\$\begingroup\$ So, why not
_=>"15ドル萬"^_^ \$\endgroup\$tsh– tsh2018年08月26日 07:36:56 +00:00Commented Aug 26, 2018 at 7:36 -
3\$\begingroup\$ I'm laughing right now because I can understand the Chinese... \$\endgroup\$ericw31415– ericw314152018年08月30日 21:23:06 +00:00Commented Aug 30, 2018 at 21:23
-
\$\begingroup\$ How about
x1683F? \$\endgroup\$Gust van de Wal– Gust van de Wal2018年10月03日 07:35:50 +00:00Commented Oct 3, 2018 at 7:35 -
\$\begingroup\$ Simply using
_=>"$"+parseInt('1V0I',36)is also higher than what you have so far, so you might want to add that one too. Too bad you can't convert base 64 to decimal in JavaScript... \$\endgroup\$Gust van de Wal– Gust van de Wal2018年10月03日 07:53:10 +00:00Commented Oct 3, 2018 at 7:53 -
\$\begingroup\$ @GustVanDeWal sadly you cannot use digits in the code. \$\endgroup\$Shieru Asakoto– Shieru Asakoto2018年10月03日 08:43:37 +00:00Commented Oct 3, 2018 at 8:43
Jelly, 8 bytes, 210176ドル.48625619375
(1⁄2"×ばつ1⁄2",ドル
3535 ((1⁄2") multipli(×ばつ)ed by its sqrt (1⁄2).
Perl 5.26.2, 12 bytes, 146002ドル
say$]^"\x11\x0e\x01\x06"
Hex escapes only shown because ASCII control chars are filtered out.
You can get a bit more with different Perl versions, for example 155012ドル with 5.25.12.
-
\$\begingroup\$ Where's the dollar sign? \$\endgroup\$Zaid– Zaid2018年09月02日 19:44:27 +00:00Commented Sep 2, 2018 at 19:44
-
1\$\begingroup\$ @Zaid The dollar sign comes XORing 0x35 (ASCII char
5from the Perl version string in$]) with 0x11, resulting in 0x24 (ASCII char$). \$\endgroup\$nwellnhof– nwellnhof2018年09月03日 00:55:06 +00:00Commented Sep 3, 2018 at 0:55 -
\$\begingroup\$ Wait, this source does contain numbers — namely 0, 1, 6. \$\endgroup\$hidefromkgb– hidefromkgb2018年09月13日 00:42:49 +00:00Commented Sep 13, 2018 at 0:42
-
\$\begingroup\$ @hidefromkgb Hex escapes like
\x11are ASCII control chars in the actual code. Have a look at the TIO link. \$\endgroup\$nwellnhof– nwellnhof2018年09月13日 12:22:44 +00:00Commented Sep 13, 2018 at 12:22
MATLAB, 17 bytes, 112222ドル
['$','..////'+pi]
Old answer:
['$','RRUUTR'-'!']
-
1\$\begingroup\$ nice one to use the automatic conversion of the ascii code thanks to the
+pi\$\endgroup\$Hoki– Hoki2018年08月30日 10:05:07 +00:00Commented Aug 30, 2018 at 10:05 -
\$\begingroup\$ e is not a builtin constant in matlab \$\endgroup\$Majestas 32– Majestas 322018年09月24日 00:05:40 +00:00Commented Sep 24, 2018 at 0:05
Ruby, 119443ドル
$><<?$<<?.ord
The maximum integer output for 17 bytes. The Unicode character is U+1D293, which is 119443 in hex.
-
\$\begingroup\$ If you want to take a chance, try the 10 byte
$><<?$<<$$on a long-running system. Answers up to 177827 are valid. \$\endgroup\$AShelly– AShelly2018年09月01日 00:48:58 +00:00Commented Sep 1, 2018 at 0:48 -
\$\begingroup\$ I think you mean "in decimal," or at least there's some ambiguity. \$\endgroup\$jpmc26– jpmc262018年09月01日 02:08:07 +00:00Commented Sep 1, 2018 at 2:08
MathGolf, 353535ドル (4 bytes)
'$W∙
Explanation
'$ Push "$"
W Push 35
∙ Triplicate top of stack
Disclaimer
This language was created after the posting of this question. While the language is a general language, it is designed with numerical questions in mind. It contains a lot of 1-byte number literals, and other nifty things for number-related questions. It is still a work in progress.
Japt, 5 bytes, 262144ドル
'$+I3
Explanation
I is the Japt constant for 64, 3 cubes it and then '$+ concatenates that with the dollar symbol.
Explore related questions
See similar questions with these tags.
80,662ドル.67instead of80662ドル.6659? Your rules seems to preclude the comma, which means I couldn't use any built-in currency functions. \$\endgroup\$