43
\$\begingroup\$

Your boss just emailed you a list of 12 programming tasks he needs done as soon as possible. The tasks are simple enough but your boss, being a young software tycoon suckled by social networking, insists that your solutions be able to fit within a single Twitter tweet.

This means that you only have 140 bytes worth of code to solve all the tasks, an average of 11.67 bytes per task. (Yes, Twitter counts characters but your boss specifically said bytes.)

You realize there's no way to solve all 12 tasks in 140 bytes but you suspect that your boss won't actually test all your solutions. So you proceed to solve as many tasks as you can, completely skipping some of them. Your mindset is that it doesn't matter which subset of the tasks you complete, it only matters that the subset is as large as possible.

How many tasks can you complete?

Challenge

Write up to 12 different programs, each of which accurately solves one of the 12 tasks listed below. The cumulative sum of the lengths of these programs may not exceed 140 bytes

Alternatively, you may write a single program no greater than 140 bytes long that takes an integer from 1 to 12 and (ideally) proceeds to solve the corresponding task, taking more input as necessary. Not all the tasks need to work, but only the ones that do count towards your score. Tasks that don't work are allowed to error or do anything else.

In either case a "program" may in fact be a function that takes the input as arguments or prompts for it and prints or returns the output. So, for example, you might write a 140 byte function that looks like f(taskNumber, taskInput), or you might write separate code snippets for each task, some as functions and some as fully-fledged programs.

Other details:

  • All code must be written in the same language.

  • As usual, input should come from stdin, the command line, a function argument, or whatever is usual for your language. Output is printed to stdout or your language's closest alternative, or returned in an appropriate type.

  • A reasonable amount of input formatting is fine; e.g. quotes around strings or \n instead of actual newlines.

  • Output should be exactly what is called for with no extraneous formatting or whitespace. The exception is an optional single trailing newline.

  • Code that only runs in a REPL environment does not constitute a program or function.

  • You may not write multiple programs that solve multiple tasks. It's either one program that (ideally) solves all the tasks, or (ideally) 12 programs that each solve a single task.

  • Posting a task solution that you didn't write or only slightly modified is not allowed without giving attribution to the original author, and ideally getting permission too. If your answer primarily composes the shortest solutions from all the other answers then it should be a community wiki.

Scoring

The submission that completes the most tasks is the winner. If two submissions tie, the one with the fewest bytes wins. If the byte counts are tied, the earlier submission wins. Community wiki answers are not allowed to win.

Be sure to tell us which tasks you solved, not just how many!

Handicap for non-golfers:

It's likely that this challenge will be dominated by golfing languages. Many languages may have trouble solving even one or two tasks within 140 bytes. Therefore you may submit a non-competitive answer where the limit is 3 tweets, i.e. 420 bytes. All the other rules remain the same.

Tasks

Task 1 - Can Three Numbers Form A Triangle?

Take in three positive integers and output a truthy/falsy value indicating whether or not three lines with those lengths could form a triangle. You may not assume the numbers come in any particular order.

Truthy examples (one per line):

20 82 63
1 1 1
2 3 4
1 2 2

Falsy examples:

6 4 10
171 5 4
1 1 2
1 2 3

Task 2 - Closest To One Million

Given a string of exactly 7 decimal digits (0-9), rearrange them to get a number that is as close as possible to one million. That is, abs(1000000 - rearrangedNumber) should be minimized.

Print or return the resulting number as an integer, not a string (so there shouldn't be leading zeroes unless that's the norm for your language).

e.g. an input of 9034318 should result in 984331 (and not 1033489).

2893984 should become 2348899.

0001000 should become 1000000.

0000020 should become 200000.


Task 3 - Simple Keyboard Simulator

Take in a string of lowercase letters (a-z), spaces, and angle brackets <>. Read left to right, this string represents the keys that were pressed on a standard keyboard while an initially empty text editor was open. The letters and space correspond to their normal keys but < corresponds to the left arrow key and > to the right arrow key, both of which move the cursor when pressed.

< moves the cursor one character left, or does nothing if the cursor is at the start of the string.
> moves the cursor one character right, or does nothing if the cursor is at the end of the string.

Output the string that would be in the text editor once all the keys in the input string have been pressed. Outputting escape codes to move the cursor is not allowed.

There will always be at least one non–arrow key character in the input.

e.g. the input ui<<q>>ck <<<<<<the<<<<>>> >>>>>>>>brown x<o<f should yield the quick brown fox.

op<<l>>t<<<lam>>>>>>imi<<<><>>>zer<<<<<<<<<<<<<<<<<<>>><>m should give llammoptimizer.

e< <c<b<a should give abc e.

<<<>><><<><toast>><<>><><<>>< should give toast.


Task 4 - FILTHE Letters

In many fonts, 6 of the uppercase English alphabet letters consist entirely of horizontal and vertical lines: E, F, H, I, L, and T. We'll calls these the FILTHE letters.

Take in a string of uppercase letters (A-Z) and count the number of lines in the FILTHE letters, outputting the resulting integer.

E, F, H, I, L, and T have 4, 3, 3, 3, 2, and 2 lines respectively.

e.g. GEOBITS has 4 + 3 + 2 = 9 lines part of FILTHE letters (for .E..IT.), so the output should be 9.

ABCDEFGHIJKLMNOPQRSTUVWXYZ should output 17.

ABCDGJKMNOPQRSUVWXYZ should output 0.

FILTHYLINESINLETTERS should output 39.


Task 5 - Alex Recursive A.

Our moderator Alex A. has a fairly mysterious initial, "A".

Now I'm not certain, but I think the A. stands for .A xelA. And I'm also pretty sure that the .A there sneakily stands for Alex A..

Thus to get Alex's full name we must expand out the A.'s and .A's:

Alex A. -> Alex [A.] -> Alex [.A xelA] -> Alex .A xelA -> Alex [.A] xelA -> Alex [Alex A.] xelA -> Alex Alex A. xelA -> etc.

Have your program take in a non-negative integer and expand Alex A. that many times, outputting the resulting string.

So
0 becomes Alex A.,
1 becomes Alex .A xelA,
2 becomes Alex Alex A. xelA,
3 becomes Alex Alex .A xelA xelA,
4 becomes Alex Alex Alex A. xelA xelA,
5 becomes Alex Alex Alex .A xelA xelA xelA,
and so on.

(I made this because I felt bad for inadvertently leaving Alex out of my mod tribute challenge. :P)


Task 6 - Numpad Rotation

Take in an integer from 1 to 9 inclusive (you may take it as a string). Output the 3×3 square of digits

789
456
123

rotated in increments of 90° such that the input digit appears anywhere on the top row. When 5 is input any rotation is valid output since 5 cant be rotated to the top.

e.g. when 3 is input, both

963
852
741

and

321
654
987

are valid outputs.

For input 4, only

147
258
369

is valid output.


Task 7 - Splitting Digits Into Tens

Take in a nonempty string of decimal digits (0-9) and output a truthy value if it can be broken up into contiguous sections where all the digits in each section sum exactly to 10. If this is not possible, output a falsy value.

e.g. 19306128 can be split up like 19|3061|28, the sections all summing to 10 (1+9, 3+0+6+1, 2+8), so a truthy value should be output.

Truthy examples (one per line):

19306128
073
730
0028115111043021333109010
2222255

Falsy examples:

6810410
9218
12341
5222225
000

Task 8 - Square Clock

Take in a consistently sized multiline string.

Output 12 if the input is

 _ _
| | |
|_ _|

Output 3 if the input is

 _ _
| |_|
|_ _|

Output 6 if the input is

 _ _
| | |
|_|_|

Output 9 if the input is

 _ _
|_| |
|_ _|

There are no other input cases.


Task 9 - Bracket Art

Take in a 4 byte string containing one of each of the left brackets (, [, {, and < in any order.

Add the corresponding right brackets so the string is 8 bytes long and has a vertical line of symmetry. e.g. [<({ becomes [<({})>].

Then reverse every bracket in this string. e.g. [<({})>] becomes ]>)}{(<[.

Output the original 8 byte bracket string with the reversed version above and below on separate lines.

So the final output for input [<({ would be

]>)}{(<[
[<({})>]
]>)}{(<[

Similarly, the output for <({[ should be

>)}][{(<
<({[]})>
>)}][{(<

The input (<<[ is invalid because the { is missing and there is an extra <.


Task 10 - Perimiterize

Take in a rectangular grid of text (1×1 at smallest) made of .'s that represent empty space and X's that represent solid tiles. Cells beyond the grid bounds are considered empty. You may assume each of the 4 grid edge rows and columns will contain at least one X.

e.g. a valid input might be:

XXX.....X.....
X..X...X.X....
XXX.....X....X

Output another rectangular grid of text where every empty cell that neighbors an X orthogonally or diagonally, including those outside the input grid, becomes o. So essentially a perimiter of o's is drawn around all the portions of solid tiles. The new grid should not be any larger than it has to be.

So the output of the example above would be:

ooooo...ooo.....
oXXXoo.ooXoo....
oXooXo.oXoXo.ooo
oXXXoo.ooXoo.oXo
ooooo...ooo..ooo

Similarly, the output of input XXX..X.X should be

oooooooooo
oXXXooXoXo
oooooooooo

and outputting

oooooooooo.
oXXXooXoXo.
oooooooooo.

would be invalid since the empty rightmost column is unnecessary.

You may use any 3 distinct printable ASCII characters in place of ., X, and o.


Task 11 - Sator Square

Output the Sator Square:

SATOR
AREPO
TENET
OPERA
ROTAS

Any of the letters may be lowercase or uppercase, so

SatOR
aRePO
tenet
OPERa
RoTaS

is also valid output.

There is no input.


Task 12 - Prime Tweet

Take no input but output a 140 byte printable ASCII string that contains at least one of each of the 95 printable ASCII characters. (So 45 characters will be duplicates.)

The sum of the character codes of all 140 bytes in this string must be a Sophie Germain prime, i.e. a prime number p such that 2p+1 is also prime. The character code for space is 32, 33 for !, 34 for ", and so on up to 126 for ~. The sum could be calculated in Python as sum(map(ord, myString)).

An example output is:

! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~d

The character code sum is the prime 12203 whose corresponding safe prime is 24407.

\$\endgroup\$
21
  • 7
    \$\begingroup\$ I will be impressed if anyone actually manages to solve everything in less than 140 bytes, even with CJam/Pyth \$\endgroup\$
    – Fatalize
    Commented Oct 12, 2015 at 8:46
  • 9
    \$\begingroup\$ I am honored to be in .a ni eb ot deronoh ma I... challenge of yours. :P \$\endgroup\$
    – Alex A.
    Commented Oct 12, 2015 at 19:04
  • \$\begingroup\$ are tasks allowed to end with an error after the result is printed to the output? \$\endgroup\$
    – torcado
    Commented Oct 12, 2015 at 20:57
  • 1
    \$\begingroup\$ How should we count bytes from imports? Let's say I write 5 functions where 2 need the same module (e.g. import Math), is this counted twice? \$\endgroup\$
    – nimi
    Commented Oct 12, 2015 at 21:15
  • 1
    \$\begingroup\$ I'm voting to close this question as off-topic because it's a multi-part challenge with insufficient interaction between the parts \$\endgroup\$ Commented Jan 22, 2020 at 1:39

8 Answers 8

27
\$\begingroup\$

CJam, 8 9 tasks in 140 bytes

First off, here is a script you can use to sort your solutions and tell you which ones will fit into the tweet:

{\s\Se[oSo}:F;
qN/ee{W=,}${)_,_T+:T140>X*_{0:X;}*'=@11+*N+*o\~)YF_,ZFTZFoNo}/

Just paste your 12 solutions into the input, one on each line. Run it here. The first column is the task number, the second its size (in characters - you'll have to fix this yourself if that is different from the byte count), the third the cumulative size. The programs which fit into the tweet are separated from the rest with a line of ===.

For me, the output looks like this:

 1   7   7 q~$~\->
 8  10  17 qDbJ%5/)3*
12  12  29 ',32>_51>'d
 7  13  42 Aq{~-Ace|}/N&
 2  15  57 qe!{~1e6-z}$0=~
 4  19  76 q"FIHEELT"3*H<fe=:+
 5  20  96 ".A"q~){" xelA"+W%}*
 9  22 118 q_{_')>+)}%W%+_W%N@N3$
11  22 140 "SATOR\AREPO\TEN"_W%1>
====================================
 6  25 165 9,:)s3/zq~))3mdg*{W%z}*N*
 3  43 208 LLq{_'=-z({+}{'=>_)$\[{)@+\}{\(@\+}]=&}?}/\
10  45 253 0XW]_m*qN/{'.f+W%z}4*f{\~@m>fm>N*}(\{8f^.e>}/

So here are the tasks I can currently fit into the tweet.

Task 1 - Can Three Numbers Form A Triangle? - 8 7 bytes

Thanks to jimmy23013 for saving 1 byte.

q~$~\->

Test suite.

Input is expected to be CJam-style list.

This is fairly straightforward: check if the largest side is shorter than the sum of the other two. Or equivalently, check that the shortest side is longer than the difference of the other two:

q~  e# Read and eval input.
$~  e# Sort the values and dump them on the stack.
\-  e# Subtract the middle value from largest.
>   e# Check if the smallest value is greater than that.

Task 2 - Closest To One Million - 15 bytes

qe!{~1e6-z}$0=~

Test suite.

Simple brute force:

q        e# Read input.
e!       e# Get all permutations.
{        e# Sort by...
  ~      e#   Evaluate the permutation to get its numerical value X.
  1e6-z  e#   abs(X - 1,000,000)
}$
0=       e# Pick the first element (which minimises the difference)
~        e# Evaluate it to get rid of the leading zeroes.

Task 4 - FILTHE Letters - 21 19 bytes

Thanks to jimmy23013 for saving 2 bytes.

q"FIHEELT"3*H<fe=:+

Test suite.

The idea is to create a string which contains each of the FILTHE letters once for each of their orthogonal lines. This is done via some funny string manipulation:

q          e# Read the input.
"FIHEELT"  e# Push this string. It first contains the 3-line letters, then the 2-line 
           e# letters, where we include 'E' twice to make it count for 4.
3*         e# Repeat 3 times: "FIHEELTFIHEELTFIHEELT"
H<         e# Truncate to 17 characters: "FIHEELTFIHEELTFIH". This is chosen such that
           e# it discards the third repetition of the 2-line letters.
fe=        e# For each character in the input, count its occurrences in this new string.
:+         e# Sum them all up.

Task 5 - Alex Recursive A. - 27 20 bytes

".A"q~){" xelA"+W%}*

Test suite.

Implemeting the substition of A. and .A directly is way too expensive. Instead, we notice that we only have to handle one case, if we reverse the string each time. Furthermore, prepending Alex (and a space) each time is equivalent to expanding the initial. We can save another byte by appending the reverse before reversing the string:

".A"        e# Start with ".A" (the -1st iteration if you like).
q~)         e# Read input, eval, increment (so the following block is run at least once.)
{           e# Repeat this block that many times...
  " xelA"+  e#   Append " xelA".
  W%        e#   Reverse the string.
}*

Task 7 - Splitting Digits Into Tens - 18 16 13 bytes

Aq{~-Ace|}/N&

Test suite. (With brackets around each output.)

Not exactly user friendly: the truthy value is a single newline, the falsy value is the empty string.

The basic idea is simple: add the digits to a running total which we reset whenever it hits exactly 10. The total must be zero at the end of the input. For a start it turns out to be shorter to the total at 10 and subtract the digits, resetting the total whenever we hit 0. However, we need to make sure that we don't return something truthy when the input is all zeroes. The shortest way I found to do that was to reset the total to the character with code point 10 (the linefeed), and then check at the end that we actually have that character on the stack, and not the number 10. This works, because both the integer zero and the character zero (the null byte) are falsy:

A     e# Push a 10, the initial running total.
q{    e# For each character in the input...
  ~-  e#   Evaluate the character to get the digit and subtract it from the total.
  Ac  e#   Push a linefeed character.
  e|  e#   Logical OR of the running total and the linefeed character (using
      e#   short-circuiting).
}/
N&    e# Take the set intersection with the string containing a linefeed character.
      e# If the total is still a number of any character other than the linefeed,
      e# this will yield an empty string. Otherwise, the string will remain unchanged
      e# and the linefeed will be printed.

Task 8 - Square Clock - 10 bytes

qDbJ%5/)3*

Test suite.

This is just some pretty random modulo magic on the character codes which happens to hash to the correct values. I'm fairly convinced that something shorter is possible, but it's the shortest I found (programmatically) for this kind of structure:

q   e# Read the input.
Db  e# Treat the character codes of the string as digits in base 13. This maps the
    e# four inputs to the values: 2023940117708546863
    e#                            2023940113755405840
    e#                            2023940781838850791
    e#                            2023940113755390292
J%  e# Take the result modulo 19. This gives [2, 5, 12, 18], respectively.
5/  e# Divide by 5 (rounding down). [0, 1, 2, 3], respectively.
)   e# Increment. [1, 2, 3, 4], respectively.
3*  e# Multiply by 3. [3, 6, 9, 12], respectively.

Task 9 - Bracket Art - 23 22 bytes

Thanks to Sp3000 for saving 1 byte.

q_{_')>+)}%W%+_W%N@N3$

Test suite.

Fairly straightforward. The mapping between the left and right brackets is done by adding 2 (or 1 for parentheses):

q_      e# Read input and duplicate.
{       e# Map this block onto each character...
  _')>  e#   Duplicate and check if it's not a parenthesis.
  +     e#   Add the result, leaving parentheses unchanged and incrementing the
        e#   other bracket types.
  )     e#   Increment again.
}%
W%+     e# Reverse and add to the original, giving the middle line.
_W%     e# Duplicate and reverse, giving the first line.
N@      e# Push a linefeed, pull up the middle line.
N3$     e# Push another linefeed, copy the first line.

Task 11 - Sator Square - 22 bytes

"SATOR
AREPO
TEN"_W%1>

Test it here.

Probably the most boring solution of all. It pushes the first half of the string and then reverses it:

"SATOR
AREPO
TEN"    e# Push everything up to the centre of the square.
_W%     e# Duplicate and reverse.
1>      e# Discard the "N", because we don't want that twice.

Task 12 - Prime Tweet - 13 12 bytes

',32>_51>'d

Test it here. (With diagnostic output for the result.)

After ' there's the unprintable <DEL> (0x7F), which SE strips out. For copy-pasting, use this version instead:

'~),32>_51>'d

The printed string is

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~STUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~d

That is, it contains one run of all characters, followed by another run from S to ~, followed by a single d. The sum of the character codes is 12203. I found this via a bit of trial and error.

'~),32>  e# Push a string with all printable characters.
_51>     e# Duplicate this and discard the first 51 of them.
'd       e# Push a "d".
\$\endgroup\$
3
  • 1
    \$\begingroup\$ q~$~\-> q"FIHEELT"3*H<fe=:+. \$\endgroup\$
    – jimmy23013
    Commented Oct 12, 2015 at 13:16
  • \$\begingroup\$ @jimmy23013 Ohhhh, I keep forgetting that we have e= these days. \$\endgroup\$ Commented Oct 12, 2015 at 13:17
  • \$\begingroup\$ I was hoping to get enough answers to post something before you spotted how to do #5 in 20 chars. \$\endgroup\$ Commented Oct 12, 2015 at 13:57
19
\$\begingroup\$

Pyth, 9 tasks in 138 bytes

This took quite a while.

I think 9 tasks is the limit for Pyth. Including the next shortest program (Sator Square) results in 160 bytes. Golfing 20 bytes is quite unlikely. There are 2 or 3 tasks which are a little bit ugly and maybe can be shortened, but overall I'm quite pleased with the solutions.

Task 1 - Can Three Numbers Form A Triangle?, 8 bytes

>FsMc2SQ

Try it online: Regular Input or Test Suite

Task 2 - Closest To One Million, 14 bytes

ho.a-^T6NsM.pz

Try it online: Regular Input or Test Suite

Task 4 - FILTHE Letters, 20 bytes

s*Vtsmmdd5/Lz"TLIHFE

Try it online: Regular Input or Test Suite

Task 5 - Alex Recursive A., 16 bytes

u+"Alex "_GhQ".A

Try it online: Regular Input or Test Suite

Task 6 - Numpad Rotation, 20 bytes

jeo}zhN.uC_N3_c3jkS9

Try it online: Regular Input or Test Suite

Task 7 - Splitting Digits Into Tens, 15 bytes

qTu+WnGTvHG-zZZ

Try it online: Regular Input or Test Suite

Task 8 - Square Clock, 12 bytes

*3%%Cz1978 5

Try it online: Regular Input or Test Suite

Task 9 - Bracket Art, 20 bytes

V3_WtN+z_Xz"[<({})>]

Try it online: Regular Input or Test Suite

Task 12 - Prime Tweet, 13 bytes

++*d44srd\\&

Try it online: Regular Input

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Combining our submissions results in 133 bytes. \$\endgroup\$
    – isaacg
    Commented Oct 14, 2015 at 7:27
10
\$\begingroup\$

Pyth, 9 tasks in 136 bytes

Task 1: 7 bytes

<-F_SQ0

Demonstration

Sort in descending order (_SQ), fold subtraction over them (a-b-c), check if the result is negative.

Task 2: 14 bytes

sho.a-sN^T6.pz

Demonstration

Form all string permutations (.pz), sort them (o) based on the absolute value of the difference (.a-) between the number (sN) and one million (^T6).

Take the first such string (h), and convert it to a num. (s).

Task 4: 19 bytes

s/L+\EPP*3"EFHILT"z

Demonstration

Replicate "EFHILT" three times (*3), remove the trailing LT (PP), and add an E (+\E). Map each letter in the input to its appearance count in that string. (/L ... z). Sum. (s).

Task 5: 16 bytes

u+"Alex "_GhQ".A

Demonstration

Starting with "A.", reverse and add an "Alex " to the start, input + 1 times.

Task 7: 13 bytes

}Y-RTsMM./sMz

Convert the input string into a list of 1-digit numbers (sMz). Form all partitions (./). Sum each element of each partition (sMM). Remove all 10s from each sublist (-RT). Check if this emptied out any of the sublists by checking if the empty list is in the overall list (}Y).

Task 8: 11 bytes

*3h%%CQC\Ç4

Demonstration

Modulo magic. Convert to number (CQ), take it mod 199 (C\Ç = 199), and take that mod 4. Then add 1, and multiply by 3.

Task 9: 21 bytes

J+Xz"<{[()]}>")_zJ_JJ

Demonstration

First, we generate the first line, which consists of the input translated to the mirror characters (Xz"<{[()]}>")), followed by the reversed input (+ ... _z), and save it to J. Then print that line, its reverse, and that line again (J_JJ).

Task 11: 22 bytes

+J"SATOR
AREPO
TEN"t_J

Demonstration

Just print a string and its reversal, but don't duplicate the center N.

Task 12: 13 bytes

++G*19\3srd\

Demonstration

There is an invisble DEL (7F) character at the end of the code.

This prints

abcdefghijklmnopqrstuvwxyz3333333333333333333 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

which has character sum 11321. It consists of G, the alphabet, 19 3s, and all of the printable ASCII characters.

\$\endgroup\$
0
8
+600
\$\begingroup\$

TI-BASIC, 4 Tasks in 110 bytes

Task 1 in 7 bytes

:2max(Ans)<sum(Ans

Input is a list in Ans.

Task 4 in 35 bytes

:sum(int(2seq(inString("TLIHFE",sub(Ans,I,1))^.4,I,1,length(Ans

Input is a string in Ans.

Task 8 in 29 bytes

:18fPart(sum(seq(I(sub(Ans,I,1)=" ")/6,I,1,15

Input is a string in Ans.

Task 11 in 39 bytes

:Disp "SATOR
:Disp "AREPO
:Disp "TENET
:Disp "OPERA
:Disp "ROTAS

Bonus round! Here are all the other tasks just for fun.

Task 2 in 92 110 bytes

:seq(expr(sub(Ans,I,1)),I,1,7→L₁
:SortA(L₁
:min(7,1+sum(not(L₁
:{L₁(1)+sum(seq(L₁(I))₁₀^(I-8),I,2,7)),L₁(Ans)+sum(seq((I>Ans)L₁(I)₁₀^(1-I),I,2,7
:ᴇ6Ans(1+(0>min(ΔList(abs(1-Ans

Prompts for a list of digits Input is a string in Ans.

Task 3 in 119 bytes

:Input Str1
:"  →Str2
:For(I,1,length(Str1
:sub(Str1,I,1→Str3
:inString("<>",Ans
:If Ans:Then
:max(0,min(L,C+2Ans-3→C
:Else
:C+1→C
:L+1→L
:sub(Str2,1,C)+Str3+sub(Str2,C+1,L-C+1→Str2
:End
:End
:sub(Str2,2,L

Prompts for a string. Assumes C and L are either undefined or 0.

Task 5 in 63 bytes

:Ans/2→C
:sub("A.A",1+2fPart(C),2
:For(I,0,C
 :"Alex "+Ans
 :If I≠C
  :Ans+" xelA
:End
:Ans

Input is a number in Ans.

Task 6 in 66 bytes

:𝑖^((Ans<7)(Ans-3(Ans>3
:For(Y,⁻1,1
 :Disp sum(seq((5-real(AnsX+Ans𝑖Y)-3imag(AnsX+Ans𝑖Y))₁₀^(X+1),X,⁻1,1
:End

Input is a number in Ans.

Task 7 in 36 43 bytes

:Input <strike>L₁</strike>Str1
:.5
:For(I,1,<strike>dim(L₁</strike>length(Str1
 :Ans+<strike>L₁(I</strike>expr(sub(Str1,I,1
 :If 10=int(Ans
  :0
:End
:not(Ans

Prompts for a list of digits string.

Task 9 in 83 bytes

:For(I,1,16,2
 :If I<8
  :Ans+sub(")}]>",inString("({[<",sub(Ans,4,1)),1
 :sub(Ans,I,1)+Ans
:End
:For(I,⁻1,1
 :Disp sub(Ans,9-8abs(I),8
:End

Input is a string in Ans.

Task 10 in 159 bytes

:1→X
:Input Str1
:2+length(Str1→L
:"X
:While 2+L>length(Ans
 :Ans+Ans→Str2
:End
:Ans→Str3
:While 1
 :"XX
 :Ans+Str1+Ans→Str1
 :For(I,1,L
  :Ans+sub("0X.",2expr(sub(Str2,I+1,1))+not(expr(sub(Ans,I,3)+sub(Str2,I,3)+sub(Str3,I,3))),1
 :End
 :Disp sub(Ans,L+3,L
 :Str2→Str3
 :Str1→Str2
 :Input Str1
:End

Uses X0. instead of .Xo respectively (sorry nothing matches). Prompts for input line by line. You have to enter two lines of Xs to see all the output, and then 2nd+Quit to quit.

Task 12 in 77 bytes

:Ans+"tvm_I%LinReg(ax+b) DS<(getKeyconj(1-PropZTest(dayOfWk(Manual-Fit C/YANOVA(*row(HorizRegEQUnarchive [J]!#$&'',.234567890:;=>?@GBQX\^_`qw{|}~

Or as hex:

72702ABB21FFDBADBB25BB3EEF06EF16
6331BB5917746201BB695C092DBBD2BB
D3BBD4AEAE2B3A323334353637383930
3EBBD66A6CAFBBD147425158BBD7F0BB
D9BBD5BBC1BBC708BBD809BBCF

Input is a string containing " in Ans.

\$\endgroup\$
0
7
\$\begingroup\$

Perl, 4 tasks in 117 bytes

Let's try a real language ;)

Haven't given up yet, might even be able to squeeze 5 tasks in 140 bytes, although unlikely!

* Task 1: 30+1 = 31 bytes

@F=sort@F;say$F[0]+$F[1]>$F[2]

Usage: perl -aM5.010 entry.pl input.txt

* Task 4: 32+1 = 33 bytes

y/ELTFHI/4223/;s/./+$&/g;$_=eval

Usage: perl -p entry.pl input.txt

Task 5: 54 bytes

say"Alex "x($_/2+1).qw(A. .A)[$_%2]." xelA"x(--$_/2+1)

-2b thanks to Dom Hastings

Usage: echo 4 | perl -M5.010 entry.pl

Task 7: 37+2 = 39 bytes

($i+=$_)>10&&exit,$i%=10for@F;$_=!$i;

Usage: perl -pF entry.pl input.txt

* Task 8: 21+2 = 23 bytes

$_=y/|_ 
/14/dr/64%14

This is a bit of a tricky one. Started out by replacing each | with x and each _ with y then replacing spaces to produce a unique two digit string for each grid (yyxxyxxyyx, yyxxyxxyyxyyxxxxyxyx, yyxxxxyxyxyyxyxxxyyx, yyxyxxxyyxyyxxxxyyx, yyxxxxyyx). Next, I wrote a program to bruteforce values for x and y, and mathematical operations that could be done on the numbers produced after substituting x and y to give an output of 3,6,9,12 for each number. In the end, x=1, y=4 and the magic operation was /64%14.

Usage: perl -0p entry.pl input.txt

Task 11: 34 bytes

say"SATOR
AREPO
TENET
OPERA
ROTAS"

Usage: perl -M5.010 entry.pl

* Task 12: 30 bytes

say d.pack"C*",32..126,83..126

Usage: perl -M5.010 entry.pl

Disclaimer: -M5.010 is considered 'free'

\$\endgroup\$
3
  • \$\begingroup\$ Is Ruby less real than Perl? ;) \$\endgroup\$ Commented Oct 13, 2015 at 7:14
  • 9
    \$\begingroup\$ When I see you answers (which look like noise), I wouldn't qualify Perl as a real language ;) \$\endgroup\$
    – Fatalize
    Commented Oct 13, 2015 at 9:13
  • 1
    \$\begingroup\$ Nice work! I think you can save 2 bytes with qw(A. .A)[$_%2] instead of ("A.",".A")[$_%2] in task 5, and I'm sure you can get another few bytes off... \$\endgroup\$ Commented Oct 22, 2015 at 9:06
6
\$\begingroup\$

Ruby, 4 tasks in 280 bytes (non-competitive)

This is just an attempt, I'll keep making tasks later (and hopefully golf the existing ones).

Task 1

a=gets.split.map &:to_i;p a.all?{|e|e<a.inject(:+)-e}

Task 2

p gets.chars.permutation.map{|a|a.join.to_i}.min_by{|x|(x-1e6).abs}

Task 4

n,b='EFHILT',0;gets.chars.map{|c|b+=n[c]==p ? 0:[4,3,3,3,2,2][n.index c]};p b

Task 5

a='Alex A.';gets.to_i.times{|i|i%2<1 ? a.sub!('A.','.A xelA'):a.sub!('.A',a)};$><<a
\$\endgroup\$
6
\$\begingroup\$

TI-BASIC, 4 tasks in 114 bytes

Download all as a TI group file (.8xg)

(Spoiler tags added per request.)

Task 1 - Can Three Numbers Form A Triangle? - 7 bytes

Download as a TI-83+ program file (.8xp)

:2max(Ans)<sum(Ans

Task 4 - FILTHE Letters - 34 bytes

Download as a TI-83+ program file (.8xp)

:sum(int(\³√(\12seq(inString("TLIHFE",sub(Ans,X,1)),X,1,length(Ans

Task 8 - Square Clock - 35 bytes

Download as a TI-83+ program file (.8xp)

:12-3max(seq(X(sub(Ans,6gcd(X,2)+X,1)≠" "),X,1,3

Task 11 - Sator Square - 38 bytes

Download as a TI-83+ program file (.8xp)

:Disp "SATOR","AREPO","TENET","OPERA
:"ROTAS


Bonus round! Here are all the other tasks just for fun.

Task 2 - Closest To One Million - 114 bytes

Download as a TI-83+ program file (.8xp)

:int(10fPart(Ans\10^(\-cumSum(binomcdf(6,0→X
:"sum(\L\X\10^(\cumSum(not(binompdf(6,0→\Y1\
:SortD(\L\X
:\Y1\→X
:sum(not(\L\X
:If Ans
:Then
:If max(\L\X=1
:X+\E\6-\10^(\6-Ans→X
:SortA(\L\X
:augment(ΔList(cumSum(\L\X)),{0→X
:End
:{X,\Y1\
:Ans(1+(0>min(ΔList(abs(\E\6-Ans

Task 3 - Simple Keyboard Simulator - 131 127 bytes

Download as a TI-83+ program file (.8xp)

:Input Str1
:DelVar X1→Y
:"..→Str2
:For(Z,1,length(Str1
:sub(Str1,Z,1→Str3
:(Ans=">")-(Ans="<
:If Ans
:Then
:max(1,min(Y+Ans,X+1→Y
:Else
:sub(Str2,1,Y)+Str3+sub(Str2,Y+1,X-Y+2→Str2
:X+1→X
:Y+1→Y
:End
:End
:sub(Str2,2,X

Task 5 - Alex Recursive A. - 107 bytes

Download as a TI-83+ program file (.8xp)

:Input X
:".A..
:For(X,0,X
:Ans→Str1
:5int(.5X+.5
:sub(Str1,1,Ans+1)+sub(".A xelAlex A.",6gcd(X,2)-5,7)+sub(Str1,Ans+4,5X-Ans+1
:End
:sub(Ans,2,5X+2

Task 6 - Numpad Rotation - 86 bytes

Download as a TI-83+ program file (.8xp)

:.3Ans+2(Ans=6→X
:[[9,6,3][8,5,2][7,4,1
:For(X,0,X
:rowSwap(Ans\^T\),1,3
:End
:Ans
:*row+(10,*row+(10,Ans\^T\,1,2),2,3
:For(X,1,3
:Disp Ans(3,X
:End

Task 7 - Splitting Digits Into Tens - 77 bytes

Download as a TI-83+ program file (.8xp)

:Ans+"0
:seq(expr(sub(Ans,X,1)),X,1,length(Ans
:augment(Ans,{10not(not(max(Ans→X
:1→X
:Repeat Ans≥dim(\L\X
:Ans+1
:If 10=sum(\L\X,X,Ans
:Ans+1→X
:End
:X=Ans

Task 9 - Bracket Art - 86 bytes

Download as a TI-83+ program file (.8xp)

:Input Str1
:For(X,1,4
:For(Y,0,1
:abs(X-9not(Y→Z
:"()[]{}<>
:sub(Ans,inString(Ans,sub(Str1,X,1))+Y,1
:Output(1,Z,Ans
:Output(2,9-Z,Ans
:Output(3,Z,Ans
:End
:End

Task 10 - Perimiterize - 218 bytes

Download as a TI-83+ program file (.8xp)

:".
:For(A,0,\E\9
:Input Str1
:Ans+Str1→Str2
:If Str1≠".
:End
:length(Ans→X
:round(A\^-1\(Ans-2→B
:seq(expr(sub(Str2,A,1)),A,2,X-1→B
:πAns→C
:"augment(Ans,augment(Ans,\L\B))+augment(Ans,augment(\L\C,Ans))+augment(\L\B,augment(Ans,Ans→X
:seq(0,A,1,B
:\L\X→A
:For(C,0,A+1
:seq(\L\A(A+BC),A,1,B→C
:int(Ans→B
:{0
:1+not(\L\X)+not(fPart(\L\X→B
:".
:For(X,1,B+2
:Ans+sub("120",\L\B(X),1
:End
:Disp sub(Ans,2,B+2
:End

These substitutions have been made: 0=., 1=X, 2=o

For input (after the program begins), type one row at a time, pressing enter at each line break, until the last row is written out. Then press enter, type one period, then hit enter again to submit the entire string.

Task 12 - Prime Tweet - 151 bytes

Download as a TI-83+ program file (.8xp)

:Ans+"!#$%&'()*+,-./01234567889:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
:For(X,1,45
:Ans+" 
:End
:Ans

Ans should contain a double quote, performed by typing one directly into \Y1\ from the equation editor and running Equ►String(\Y1\,Str1:Str1 from the home screen.

The output length is 140. 8 appears twice, and there are 45 spaces along with the other ASCII characters each appearing once. This amounts to (33+34+...+126) + 56 + 32×45 = 8969, a Sophie Germain prime.

\$\endgroup\$
1
  • \$\begingroup\$ I asked OP, and you can count a token like sin( as displaying s, i, n, and ( in Task 12 \$\endgroup\$
    – lirtosiast
    Commented Oct 28, 2015 at 17:35
0
\$\begingroup\$

Python 3, 1 task, 268 bytes, non-competitive

I tried Task #2 in Python 3.5.2 I am new to code golfing and python

import itertools
def f2(l):
    n=1000000
    l=list(itertools.permutations(l))
    j = len(l)
    m=[None]*j
    while j>0:
        j -= 1
        m[j]= int(''.join(str(i) for i in l[j]))
        l[j]=abs(n-m[j])
    l.sort()
    k=n-l[0]
    return(n+l[0],k)[k in m]
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to PPCG. You'll find in python 3 you can put some of your statements on one line for example you could write x=10;print(x) This would help some of your indented sections. \$\endgroup\$
    – george
    Commented Jan 20, 2017 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.