Check if hand from card game "Rooster" is valid for the second stage Here in Russia, we have a little-known card game with the name, when translated directly, means Rooster.

The cards used are two full 54-card decks of playing cards from 2 through aces, with jokers. The game for each player divides into two stages. In the first stage, each player has 14 cards dealt, and with those cards has to get 51 or more points with card combinations.

Rules:

1.Each combination has to be at least three cards long, with no cards repeating, and can be either:

A combination of cards of the same value (not points), for example:

        Ace of spades, ace of hearts, ace of clubs
        Six of hearts, six of clubs, six of diamonds, six of spades

A combination of cards that are in a row, like a straight in poker, examples:

        Jack of clubs, queen of clubs, king of spades, ace of hearts
        Seven of spades, eight of diamonds, nine of clubs
        Ace of diamonds, two of clubs, three of hearts, four of diamonds, five of spades

Your hand score is calculated by the sum of points in every card combination according to the chart below:

2-10: according to the cards face value for each card (For example, Three of spades is 3 points)
Jack,Queen,King: 10 points for each card
Ace: 1 point if used before a Two, otherwise 11 points for each card
Joker: 0 points

Jokers can substitute any card in a combination, but cannot be used more than once in each combination. The cards they substitute cannot be used again in the same combination.
Cards cannot be used twice. If you used a card, you can't then use it in a different combination
But remember, since the deck is two 54-card decks, duplicates of one card are possible, and, if duplicates are in a hand, using one card will not forbid you from using the other duplicate.

The task:

Taking a hand of 14 cards, output one of the possible things:

A truthy value if the cards given can form combinations in such a way that your hand score is more or equal than 51
A falsy value if your hand does not reach the score of 51

Input:

Each card is given in a format VS, where:

V is the face value. Possible values: [2,3,4,5,6,7,8,9,T,J,Q,K,A]
S is the suit of a card. Possible values: [S,H,D,C,J]
A joker will be represented as JJ

Your input may be in any form you wish, as long as each card values are not separated. For example:

A list of cards. (['TS','3H','JJ','9C',etc...])
Cards separated from each other with a whitespace. (TS 3H JJ 9C etc...)

Output:

Either:

A Truthy/Falsy
A 1/0

This is codegolf, so lowest bytecount for each language wins! I hope the rules are clear, and good luck!

edit 1: got mixed up in terminology

Ruby, 415 376 bytes

->a{s=[*2..9]+[10]*4+[11,1]
g=->d,j{x=0
65.times{|r|v=r/5;r%=5
p=w=0
c=d*1
y=[r,c[v]/5,c[v]%5].min
z=v+1+r
r<3?z<13?(v-1).upto(z){|n|p+=s[n];c[n]>4?c[n]-=5:w+=1}:w=2:r>y+1?w=2:(p+=s[v]*r;c[v]-=y*5;w=r-y)
w>1||w>j||(x=[p+g[c,j-w],x].max)}
x}
b=(0..12).map{[]}
a.map{|i|b["23456789TJQKA".index i[0]]<<i[1]}
h=b[9].size-(b[9]-=[?J]).size
b.map!{|i|i.size*5+(i&i).size}
g[b,h]>50}

Try it online!

Revised version, using recursive search tree instead of brute force search. This version runs to completion on TIO.

The TIO generates random test cases. It is interesting to modify the x>50 to simply x to see the raw scores achieved. Sometimes the way to achieve the best score is not obvious and it can take a moment's scribbling to work out manually how the computer got as high a score as it did.

Explanation

Cards are taken as an unsorted array a and the suit letters are parsed into 13-element array b, one element for each card value. After jokers have been removed and counted separately, the total number of cards and number of distinct suits are stored as a single number 5*total + distinct suits. Distinct suits are only important when dealing with n of a kind type groups: the number of available cards is max(total cards, distinct suits) plus jokers.

Searching is done recursively by "nested" function g. There are 5 different types of groups of cards to search for, as below. Note that the best use of 34567 would be a 5 straight but if a second 5 is available the best use would be two separate 3 straights 345 and 567, so greedily assigning to the largest possible group is not always the best strategy. Instead we look for groups separately. Straights of 6 and over will be found as a combination of shorter straights.

Type          corresponding value of r%5
3 straight    0
4 straight    1
5 straight    2
3 of a kind   3
4 of a kind   4

There are 13 possible starting values for each type, so the total number of distinct possible groups to search for is 13*5=65 (some straights are not possible with the highest starting values.)

When function g finds a group, it passes the remaining cards on recursively to a new instance of itself, then compares the score of the group it found (plus any additional groups found by recursion) with the highest score found so far in variable x, and updates x if necessary.

Return value of recursive function g is the highest score found. Return value of outer function f is true or false from g>50.

Commented code

->a{s=[*2..9]+[10]*4+[11,1]             #14-element array of card scores. Final element is ace low, accessed as s[-1]
g=->d,j{                                #function g takes an array of card data, and a joker count as input
  x=0                                     #largest score found so far is 0
  65.times{|r|v=r/5;r%=5                  #iterate through 13 possible card values and 5 possible group types
  p=w=0                                   #p=points for this iteration;w=wildcards required
  c=d*1                                   #make a copy of d for this iteration
  y=[r,c[v]/5,c[v]%5].min                 #y=number of cards removed by successful n of a kind. [cards required,cards available,distinct suits].min
  z=v+1+r                                 #z=top value of straight
  r<3?                                    #if r<3 consider a straight
     z<13?(v-1).upto(z){|n|               #if z is in range (no more than ace high) iterate through cards
       p+=s[n];c[n]>4?c[n]-=5:w+=1}:      #add score to p. If card available, remove from c, else increment wildcards required
     w=2:                                 #if z out of range set wildcards to 2 to indicate failure
     r>y+1?w=2:                           #if r>2 consider a straight. If insufficient cards for r with 1 joker, set w to 2 to indicate failure.
     (p+=s[v]*r;c[v]-=y*5;w=r-y)          #add score to p, remove cards from c, set wildcards required
  w>1||w>j||(x=[p+g[c,j-w],x].max)}       #if wildcards required no more than 1 or jokers available, take the score, sum with results of further recursion and compare with x
  x}                                      #return x, the highest score of all 65 iterations
b=(0..12).map{[]}                       #make a 13 element array to store totals of cards
a.map{|i|b["23456789TJQKA".index i[0]]<<i[1]}   #add the suit letter for each card to b
h=b[9].size-(b[9]-=[?J]).size           #any "jacks" of suit J are actually jokers. count jokers into h and remove from b.
b.map!{|i|i.size*5+(i&i).size}          #collate the suit letters into a single number: total cards*5 + number of distinct suits
g[b,h]>50}                              #call g to find highest score. return truthy if over 50, else falsy.


Print/Output all positive numbers in which every multi-digit substring in its decimal representation is also prime. Task

Your task is to print or output all positive numbers in which every multi-digit substring in its decimal representation is also prime. If the number has at least 2 digits, this would imply that the number itself also needs to be prime.

Example

6197 is in the sequence because every multi-digit substring in 6197 is prime, namely: 61, 19, 97, 619, 197, 6197 (itself).
Note that 6 is not a prime but 6197 is still in the sequence because 6 is not a multi-digit substring of 6197.
8 is also in the sequence because every multi-digit substring in 8 is prime. There is no multi-digit substring in 8, so this is a case of vacuous truth.

Specs

Standard loopholes apply, except that you are allowed to hardcode the output or store information related to the output in your program.
The numbers in the output can be in any order.
The numbers in the output are allowed to have duplicates.
You may use any separator, if you choose to print instead of output.
You are allowed to prefix and/or postfix output if you choose to print instead of output.
The separator and the prefix and the postfix may not contain any digits (U+0030 to U+0039).

Full list (58 items)

1
2
3
4
5
6
7
8
9
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
113
131
137
173
179
197
311
313
317
373
379
419
431
479
613
617
619
673
719
797
971
1373
3137
3797
6131
6173
6197
9719

Reference

OEIS A131648 (incomplete list)

As always, please feel free to address in the comments anything I should clarify.

Brachylog, 18 bytes

9719⟦₁{sᶠℕ₁₀ˢṗᵐ&}ˢ

Try it online!

So...am I ready for the "bounty"? :D


Find a multiple of a given number whose decimal representation looks like binary I have come across a question on the Code Review site that seems interesting. I think OP is doing it wrong, but cannot be sure... So let's solve it for him! (write a program, not a function/procedure)

Input (stdin or similar):

An integer x in decimal notation. It is greater than 1 and less than 2^31.

Output (stdout or similar):

An integer y in decimal notation. The product x * y in decimal representation must contain only digits 0 and 1. It must be the minimal such number greater than 0.

Note: output is not limited - if the minimal y is around 10^100, your program must output all of its 100 digits (I don't know whether there is a reasonable limit, like 2^64, on y - didn't solve it).

Your program should finish in a reasonable time (1 second? 1 hour? - something like that) for all x in range.

Bonus:

If your program doesn't have a limit on the size of the input (except RAM), and has polynomial complexity, multiply the byte count of your program by 0.8 and round down.

Example: Input 2; output 5, because 2 * 5 = 10

Example: Input 21; output 481, because 21 * 481 = 10101

Disclaimer: I am not responsible for the question on the Code Review site. In case of any discrepancy, only the description above should be regarded as proper spec.

OEIS A079339

Python 2, efficient solution, 99

n=input()
d={n:0}
k=1
while min(d):[d.setdefault((x+k)%n,d[x]+k)for x in set(d)];k*=10
print d[0]/n

Thanks Sp3000 for some golfing tips.
I challenge everybody else to post (in their own answers) how long it takes to get the result for input 72 or 99 :) If those are really fast, try something like 79992 next (still <1 sec here).
Explanation:
I thought this wasn't necessary (since the code is fairly readable), but I got a request, so here it goes:
The first idea is that a binary-looking number is a sum of 1 or more different powers of 10. Therefore, we can try to add various powers of 10 in different ways until we get remainder 0.
If we do that naively, it's the same as generating all binary-looking numbers and testing them. But a lot of remainders will be the same. A better way is to record only the smallest number that gave a certain remainder, and successively add greater powers of 10 to numbers we recorded. That's what the program does.
d is a dictionary/map where keys are remainders and values are binary-looking numbers with that remainder. The initial n:0 is a special case: it's supposed to be 0:0 so we can start adding powers to it, but the algorithm stops when finding key 0, so I used n instead, which is guaranteed to have the same effect and not interfere with the other values.
Then we start adding powers of 10 (stored in k) to all existing numbers and recording the remainders. We add k to the remainder: (x+k)%n and to the number: d[x]+k, and record it only if it's a new remainder: d.setdefault(…), then go to the next power: k*=10 and repeat until we get key 0: while min(d)
At the end, d[0] gives the binary-looking number that has remainder 0 mod n, so we divide it by n to get the solution.
Note: the program can be made more efficient by avoiding large numbers (recording exponents rather than powers of 10, and calculating remainders of powers from previous values), but it's code golf, so...
In fact, here, I wrote a faster version:
n=input()
d={n:0}
k=1
b=0
while 0not in d:
 for x in list(d):d.setdefault((x+k)%n,b)
 k=(k*10)%n;b+=1
x=10**d[0]
while x%n:x+=10**d[n-x%n]
print x/n


Map a list of indefinite size to a number! It is well known, in the field of Mathematics studying infinity, that the Cartesian product of any finite amount of countable sets is also countable.
Your task is to write two programs to implement this, one to map from list to integer, one to map from integer to list.
Your function must be bijective and deterministic, meaning that 1 will always map to a certain list, and 2 will always map to another certain list, etc...
Earlier, we mapped integers to a list consisting only of 0 and 1.
However, now the list will consist of non-negative numbers.
Specs

Program/function, reasonable input/output format.
Whether the mapped integers start from 1 or starts from 0 is your choice, meaning that 0 doesn't have to (but may) map to anything.
The empty array [] must be encoded.
Input/output may be in any base.
Sharing code between the two functions is allowed.

Scoring
This is code-golf. Lowest score wins.
Score is the sum of lengths (in bytes) of the two programs/functions.

Jelly, 18 16 bytes

List to integer, 10 8 bytes

TṪạL;³ÆẸ

Maps lists of non-negative integers to positive integers. Try it online!

Integer to list, 8 bytes

ÆE©Ḣ0ẋ®;

Maps positive integers to lists of non-negative integers . Try it online!

Background

Let p0, p1, p2, ⋯ be the sequence of prime numbers in ascending order.

For each list of non-negative integers A := [a1, ⋯, an], we map A to p0z(A)p1a1⋯pnan, where z(A) is the number of trailing zeroes of A.

Reversing the above map in straightforward. For a positive integer k, we factorize it uniquely as the product of consecutive prime powers n = p0α0p1α1⋯pnαn, where αn > 0, then reconstruct the list as [α1, ⋯, αn], appending α0 zeroes.

How it works

List to integer

TṪạL;³ÆẸ  Main link. Argument: A (list of non-negative integers)

T         Yield all indices of A that correspond to truthy (i.e., non-zero) items.
 Ṫ        Tail; select the last truthy index.
          This returns 0 if the list is empty.
   L      Yield the length of A.
  ạ       Compute the absolute difference of the last truthy index and the length.
          This yields the amount of trailing zeroes of A.
    ;³    Prepend the difference to A.
      ÆẸ  Convert the list from prime exponents to integer.

Integer to list

ÆE©Ḣ0ẋ®;  Main link. Input: k (positive integer)

ÆE        Convert k to the list of its prime exponents.
  ©       Save the list of prime exponents in the register.
   Ḣ      Head; pop the first exponent.
          If the list is empty, this yields 0.
    0ẋ    Construct a list of that many zeroes.
      ®;  Concatenate the popped list of exponents with the list of zeroes.

Example output

The first one hundred positive integers map to the following lists.

  1: []
  2: [0]
  3: [1]
  4: [0, 0]
  5: [0, 1]
  6: [1, 0]
  7: [0, 0, 1]
  8: [0, 0, 0]
  9: [2]
 10: [0, 1, 0]
 11: [0, 0, 0, 1]
 12: [1, 0, 0]
 13: [0, 0, 0, 0, 1]
 14: [0, 0, 1, 0]
 15: [1, 1]
 16: [0, 0, 0, 0]
 17: [0, 0, 0, 0, 0, 1]
 18: [2, 0]
 19: [0, 0, 0, 0, 0, 0, 1]
 20: [0, 1, 0, 0]
 21: [1, 0, 1]
 22: [0, 0, 0, 1, 0]
 23: [0, 0, 0, 0, 0, 0, 0, 1]
 24: [1, 0, 0, 0]
 25: [0, 2]
 26: [0, 0, 0, 0, 1, 0]
 27: [3]
 28: [0, 0, 1, 0, 0]
 29: [0, 0, 0, 0, 0, 0, 0, 0, 1]
 30: [1, 1, 0]
 31: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 32: [0, 0, 0, 0, 0]
 33: [1, 0, 0, 1]
 34: [0, 0, 0, 0, 0, 1, 0]
 35: [0, 1, 1]
 36: [2, 0, 0]
 37: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 38: [0, 0, 0, 0, 0, 0, 1, 0]
 39: [1, 0, 0, 0, 1]
 40: [0, 1, 0, 0, 0]
 41: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 42: [1, 0, 1, 0]
 43: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 44: [0, 0, 0, 1, 0, 0]
 45: [2, 1]
 46: [0, 0, 0, 0, 0, 0, 0, 1, 0]
 47: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 48: [1, 0, 0, 0, 0]
 49: [0, 0, 2]
 50: [0, 2, 0]
 51: [1, 0, 0, 0, 0, 1]
 52: [0, 0, 0, 0, 1, 0, 0]
 53: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 54: [3, 0]
 55: [0, 1, 0, 1]
 56: [0, 0, 1, 0, 0, 0]
 57: [1, 0, 0, 0, 0, 0, 1]
 58: [0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 59: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 60: [1, 1, 0, 0]
 61: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 62: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 63: [2, 0, 1]
 64: [0, 0, 0, 0, 0, 0]
 65: [0, 1, 0, 0, 1]
 66: [1, 0, 0, 1, 0]
 67: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 68: [0, 0, 0, 0, 0, 1, 0, 0]
 69: [1, 0, 0, 0, 0, 0, 0, 1]
 70: [0, 1, 1, 0]
 71: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 72: [2, 0, 0, 0]
 73: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 74: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 75: [1, 2]
 76: [0, 0, 0, 0, 0, 0, 1, 0, 0]
 77: [0, 0, 1, 1]
 78: [1, 0, 0, 0, 1, 0]
 79: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 80: [0, 1, 0, 0, 0, 0]
 81: [4]
 82: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 83: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 84: [1, 0, 1, 0, 0]
 85: [0, 1, 0, 0, 0, 1]
 86: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 87: [1, 0, 0, 0, 0, 0, 0, 0, 1]
 88: [0, 0, 0, 1, 0, 0, 0]
 89: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 90: [2, 1, 0]
 91: [0, 0, 1, 0, 1]
 92: [0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
 93: [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 94: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
 95: [0, 1, 0, 0, 0, 0, 1]
 96: [1, 0, 0, 0, 0, 0]
 97: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 98: [0, 0, 2, 0]
 99: [2, 0, 0, 1]
100: [0, 2, 0, 0]


Is the date alphabetical? Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.

An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:

September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen

Another way to think of this challenge: "are the elements of a given date lexically sorted?"

Notes:

2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight." For another example, the year 1456 would be represented as "one thousand four hundred fifty-six," not "fourteen fifty-six."
26th is represented as "twenty-sixth," not "twenty-six."
Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:

September 2nd 2018 ("second" should sort ahead of "September")
April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:

You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).
You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").
You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.
Standard loopholes are forbidden.
This is code-golf

More Examples of Alphabetical Dates

2066-01-02 (January second, two thousand sixty-six)
1000-04-08 (April eighth, one thousand)
6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates

1066-01-02 (January second, one thousand sixty-six)
1000-04-07 (April seventh, one thousand)
8000-08-01 (August first, eight thousand)


Has someone been defenestrated? Defenestration is the act of throwing someone or something out of a window.
  —Wikipedia

Input

The input will consist of two parts:

A floor plan and a person inside the house/building.

v><^ represents a person, pointing in the direction signified by the arrow. The input will contain exactly one person.
- and | represent walls, and # represents a window.   is empty space.

This portion of the input may be taken as either a single string, or an array/list/etc. of lines. There will never be any trailing or leading spaces, and the input will always be a rectangle.

Example:

-----###---
|         |
|     ^   |
-----------

An integer ≥ 1 signifying how far (in characters) the person travels.

Output

The output should be

1 if the person ends up "inside" a window (i.e. after moving forwards the distance specified in the input, the person is on top of a #).
2 if the person has been defenestrated (come into contact with a # and then continued further on).
3 if the person has hit a wall (come into contact with a - or |. Once hitting the wall, the person stops and does not continue through it).
0 if none of the above are true (and all the person has done is travel through empty space).

Assumptions

All of the following can be assumed to be true:

The person will never travel "out of bounds" of the input area.
After being defenestrated, the person will never come into contact with another # or a -/| (so you don't have to worry about if 2 and 1 or 3 are both true).

Test cases

For the following "floor plan":

-----
|   |
|###|
|   |
| ^ |

In   Out
1    0
2    1
3    2

For this floor plan:

> | # |

In   Out
1    0
2-99 3    * that is, any input 2-99 outputs 3

For this floor plan:

||####|#|#|##|<

In   Out
any  3

Final test case:

|v|
|#|
| |
| |
| |
| |

In   Out
1    1
2-5  2

JavaScript (ES6), 147 146 bytes
(p,n)=>eval('l=p.search`\n`+1;m=p.match`[<>v^]`;for(r=d=i=0;i++<n&r<3;r-1?0:d=2)r=(c=p[m.index+i*({v:l,"<":-1,">":1}[m]||-l)])>"#"?3:c>" ";+r||d')

Saved 1 byte thanks to @NinjaBearMonkey!
Explanation
Takes a floorplan as a string and the number of moves. Returns a number.
(p,n)=>                               // p = floor plan as string, n = number of moves
  eval(`                              // use eval to enable for loop without {} or return
    l=p.search\`\n\`+1;               // l = line length
    m=p.match\`[<>v^]\`;              // m = the position and orientation of the person
    for(
      r=                              // r = result at the current step
        d=                            // d = 2 if the person has been defenestrated
          i=0;                        // i = current step
      i++<n&r<3;                      // for each step while the person has not hit a wall
      r-1?0:d=2                       // set d to 2 once the person enters the window
    )
      r=(                             // r = 0 if on " ", 1 if on "#" or 3 if on "|" or "-"
        c=p[m.index+i*                // c = character after current step
          ({v:l,"<":-1,">":1}[m]||-l) // get the index offset of each step
        ]
      )>"#"?3:c>" ";
    +r||d                             // return the result of the current step or d
  `)

Test

var solution = (p,n)=>eval('l=p.search`\n`+1;m=p.match`[<>v^]`;for(r=d=i=0;i++<n&r<3;r-1?0:d=2)r=(c=p[m.index+i*({v:l,"<":-1,">":1}[m]||-l)])>"#"?3:c>" ";+r||d')
<textarea id="floorplan" rows="6" cols="30">-----
|   |
|###|
|   |
| ^ |</textarea>

Moves = <input type="text" id="moves" value="3" />
<button onclick="result.textContent=solution(floorplan.value,moves.value)">Go</button>


javascript: smallest code to convert seconds to time Given seconds like 11728, write the smallest javascript function that returns a string like 3hrs. 15min. 28sec.

signature textTime([int] t,[bool] z,[bool] m)

t is the time like 11728 and you can assume int
z is optional and true means drop zero times, so 3hrs. 0min. 28sec. becomes 3hrs. 28sec.
m is optional and true means show only up to minutes, so 3hrs. 16min. 48sec. is 3hrs. 16min.

For 1 hour, 1hrs. is fine (vs 1hr.)

Example:

textTime(11728) returns "3hrs. 0min. 28sec."
textTime(11728,true) returns "3hrs. 28sec."
textTime(11728,true,true) returns "3hrs."

Regex is fine, speed is inconsequential.

Shortest code wins.

155 147 characters.

textTime=(t,z,m,x)=>(x=[t/3600,t/60%60,t%60].map((t,i)=>(!z||t|0)&&~~t+["hrs","min","sec"][i]+"."||0).slice(0,2+!m),(z?x.filter(x=>x):x).join(" "))

If the parameters made a little more sense, yes, it would be fewer.

Non-ES6, changing the name and using globals like @C5H8NNaO4 did, at 183 characters:

function t(t,z,m){return(x=[t/3600,t/60%60,t%60].map(function(t,i){return(!z||t|0)&&~~t+["hrs","min","sec"][i]+"."||0}).slice(0,2+!m),(z?x.filter(function(x){return x}):x).join(" "))}


"Hello, World!" in zero lines of code NPM's sloc is a moderately popular tool for counting source lines of code in a file. The tool will attempt to strip out both single and multiline comments and count the remaining lines in order to get an estimate of the 'true' number of lines of code.
However, the parser used is based on regular expressions and is quite simple, so it can be tricked. In this challenge, you will need to construct a hello world program that sloc counts as zero lines of code.
The challenge

Download sloc. If you have npm, this can be done via npm i sloc. We will use the latest version as of the time of posting, which is 0.2.1. Or, use the online testing environment linked at the bottom of this post.

Select any language that sloc supports. A full list is available here.

Write a full program in that language that prints the exact string Hello, World! to stdout. The output may optionally have a trailing newline, but no other format is accepted. The program may output anything to stderr. However, to be considered a valid submission, sloc must see the program as zero lines of source code. You can verify this by running sloc myprogram.ext, which should read Source :  0.

Example
The following Python program is a valid submission:
'''"""''';print("Hello, World!");"""'''"""

If I run sloc hello.py, I get:
---------- Result ------------

            Physical :  1
              Source :  0
             Comment :  1
 Single-line comment :  0
       Block comment :  1
               Mixed :  0
 Empty block comment :  0
               Empty :  0
               To Do :  0

Number of files read :  1

----------------------------

Why? Well, sloc uses ''' or """ to determine if something is a mulitline comment in Python. However, it doesn't pair them up correctly. Thus Python parses our program as:
'''"""''';print("Hello, World!");"""'''"""
\-------/ \--------------------/ \-------/
 comment        active code       comment

But sloc parses it as:
'''"""''';print("Hello, World!");"""'''"""
\----/\----------------------------/\----/
comment          comment           comment

(This is not the shortest valid Python submission, so it shouldn't stop you looking for shorter ones)
Scoring
The shortest program in bytes wins.
A note on feasibility
It might be a reasonable question to ask whether this is possible for all languages. I don't know, but all the ones I've looked at so far (Python, C, HTML) have at least one solution. So there's a very good chance it is possible in your language.
There are a number of ideas that can work across multiple languages.
Online test environment
Try it online!
You need to:

Type your code into the input box
Type the extension corresponding to your language into the command args (important!)

Haskell, 36 35 bytes
{-{--}--}main=putStr"Hello, world!"

Try it online!
Test sloc
Since sloc is regex based it is a very good guess to think it cannot identify nested comments.  And if we take a look we see that indeed it cannot.  If we nest two comments as so:
{-{--}-}

sloc identifies one line of source and one line of comment.  Based on these observations my best guess is that the regex it is using is
(\{-((?!-\}).)*-\}|--[^\n]*)

If we pop this into a regex engine we will see it matches the nested comment as so:
      code
      ^^
{-{--}-}
^^^^^^
comment

Ok so we broke it, however this has the opposite of the intended effect.  We want sloc to think our code is a comment rather than our comment is code.  So we add a "line comment marker" to the part of the comment sloc thinks is code, so that sloc thinks a line comment is being started.
{-{--}--}

So to sloc there are two comments the block comment {-{--} and the line comment --} but to haskell which actually parses comments, it is all one block comment.
So then we just add our code after.  Sloc thinks this is still a comment and Haskell knows it is not.


Checkerboard the Matrix Task
Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd).
Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists of performing one of the following moves:

Swapping two rows
Multiplying one row by a nonzero rational constant
Adding a rational multiple of one row to another row

Since there are multiple possible outputs for each input, please include a way to verify that the output is row-equivalent to the input, or explain enough of your algorithm for it to be clear that the output is valid.
Example
Input:
2 4 6 8
0 2 0 4
1 2 5 4

Subtracting row 2 from row 3 yields
2 4 6 8
0 2 0 4
1 0 5 0

Subtracting double row 2 from row 1 yields
2 0 6 0
0 2 0 4
1 0 5 0

That is one possible output. Another possible matrix output is
1 0 3 0
0 1 0 2
1 0 4 0,

which is also row-equivalent to the given matrix and is also in checkerboard form.
Constraints

The given matrix will have at least as many columns as rows and contain only integers (your output may use rational numbers, but this is not strictly necessary since you can multiply by a constant to obtain only integers in the output).
You may assume that the rows of the matrix are linearly independent
You may assume that it is possible to express the given matrix in checkerboard form

Input and output may be in any reasonable format that unambiguously represents an m×n matrix.
Sample Test Cases
Each input is followed by a possible output.
1 2 3
4 5 5
6 5 4

1 0 1
0 1 0
1 0 2

1 2 3
4 5 5
2 0 -1

1 0 1
0 1 0
1 0 2

2 4 6 8
0 2 0 4
1 2 5 4

1 0 3 0
0 1 0 2
1 0 4 0

1 2 3 2 5
6 7 6 7 6
1 2 1 2 1

1 0 1 0 1
0 1 0 1 0
1 0 2 0 3

3  2  1  10 4  18
24 31 72 31 60 19
6  8  18 9  15 7
8  4  8  20 13 36

3 0 1 0 4 0
0 1 0 5 0 9
2 0 6 0 5 0
0 8 0 9 0 7

3  2  1  10 4  18
24 31 72 31 60 19
0  4  16 -11 7 -29
8  4  8  20 13 36

3 0 1 0 4 0
0 1 0 5 0 9
2 0 6 0 5 0
0 8 0 9 0 7

1 0 0 0 -2
0 1 0 1 0
0 0 1 0 2

3 0 1 0 -4
0 2 0 2 0
5 0 3 0 -4

Related:

Create a checkerboard matrix
Reduced Row-Echelon Form of a Matrix

MATLAB - 114 129 bytes
function n=c(m)
n=rref(m);l=size(n,1);for i=1:l
e=1.5+.5*(-1)^i:2:l;N=n(e,:);n(e,:)=N+repmat(n(i,:),length(e),1).*max(N).^2;end

Try it online
For a given nxm matrix, there are three forms of the rref of the matrix.

The identity matrix (with optional all-zero columns) (m>=n)
Full rank matrix where columns that do not contain a row-leading 1 can have any value (m>n)
Identity matrix with zero rows on the bottom (m<n)

1 and 3 are easily made into a checkerboard by looping through each row and adding every odd/even row (which would have the 1s in the appropriate places)
for 2, however, it is impossible to make a checkerboard matrix unless the matrix is already a checkerboard. This is because the columns that have nonzero values can never be reduced because there is no column with a row-leading 1, and any ERO would add a value in another space that would ruin the checkerboard pattern. I'm certain there's a more rigorous explanation but linear algebra is not easy.


Golf you a Double Quine for greater good! Good Evening Ladies and Gentleman.

Tonight - we have a code challenge. A competition that will be defined not in the amount of points (a la Asteroids)  but simply whether you can finish it (a la Zelda). And for the sake of comparison, the amount of bytes (uh... but you said...).

Your challenge is to compose a single quine that compiles in both WhiteSpace and any other language of your choice. Both quines must have absolutely identical output (which as a quine is absolutely identical to the source code). Your quine must be more then 3 bytes in length.

Your score is the size of your source code in bytes.

Given that this challenge involves WhiteSpace, please escape your answers so that they are clear - preferably in the C style. Your score is the original source in bytes - not the escaped version.

Good luck.

Whitespace and Perl, 992 975 characters

Good Evening Ladies and Gentlemen.

To start with, here is my submission encoded in base64, which I feel is the best way to communicate a large Whitespace program. (You really don't want to use an encoding that leaves any whitespace as-is, so there's no point in selecting something more "readable".)

c2F5PDwgeDI7c2F5PDwwLDAgIApzYXk8PCB4MjtzYXk8PDAsMCAgCgoJCQogICAJCSAgCSAgCSAJ
CSAgCSAgCQkgCSAJIAkJCQkJICAJCSAJCQkgCQkJCQkgCSAJIAkJIAkgCSAgIAkJCQkJICAgCQkg
IAkgCQkgCSAJCSAJICAgIAkJCQkgCSAgCSAJCSAJICAgIAkgCQkgICAJICAgICAgCQkJIAkJCQkJ
IAkJCSAJCQkJICAgICAJCQkgCSAgICAgIAkJCQkJICAgICAgCQkgICAJCSAgICAJCQkJCQkJCSAg
CSAJIAkgICAJCQkgICAJCQkJCSAgCQkJCSAJICAgIAkgCQkJCQkgCSAgICAgCSAgCSAJICAgICAg
CSAgICAJICAgICAJCSAgIAkJCSAJIAkJCQkJCSAJCSAJIAkgICAgICAgCQkgIAkgICAgICAgICAg
IAkJICAgCSAJCQkgCSAgICAgCQkJCQkJIAkgICAgCQkJCSAJCQkJICAJCQkgICAJCQkgCSAgCSAg
IAkJCQkgIAkJIAkJCSAgIAkJCSAJCQkgCQkJICAJCSAJICAJIAkJCSAJIAkgCQkgICAgIAkgCSAJ
ICAJICAJIAkJICAgICAJIAkgICAgCQkJCSAgCSAJCSAJIAkJIAkgIAkgCSAJCSAJCSAJCSAJCQkg
CQkJICAgIAkJCSAgCSAgCQogICAJICAgICAJCQkJCSAJCSAJIAkgCSAJICAJCQkgICAJICAgCSAg
ICAJCSAJICAgICAgICAgCSAgIAkJCQkgCQkgICAgCQkgCSAJICAJCQkgCQkJCSAJCQkgICAJICAg
IAkgCSAJCQkgIAkJCQkgCSAJCSAJIAkgCQkJCSAJICAJIAkJIAkgICAJCiAKICAKICAgIAogCSAg
CQoKICAJCiAKICAgIAkJCQkgCSAKCSAJCQkKICAgICAJCQkJIAkgCgkgCSAgCiAgIAkJCgkgIAoK
CQkJCiAKCgoJIAkKICAgCSAgIAkgIAoKIAkKIAkgIAkKCiAJIAogICAJIAoKIAkKCiAJIAoKIAkK
CQogCSAgIAkgCgogCQoKCgoKICAgCiAgIAogCiAKIAkKCiAJCgogICAgCiAKIAoJIAogCiAgICAJ
IAoJIAkJIAoJICAgCSAKCSAJIAogCSAgCgogIAogCiAgICAJCQoJIAkJICAJCSAJCQkKCSAgCiAg
CQkJICAgCgkgCQkgICAJICAgICAKCSAgIAkKICAgICAJCQoJIAkgIAogICAJCQoJICAKCgkJCiAK
CgoJCjAK

Here's an excerpt that highlights all of the visible parts of the source. ⇥ is used to indicate a tab and ↲ to indicate a newline.

say<< x2;say<<0,0  ↲
say<< x2;say<<0,0  ↲
↲
⇥⇥↲
   ⇥⇥  ⇥ [... etcetera ... skipping rest of a really long line ...]↲
   ⇥⇥⇥ ⇥⇥[... etcetera ... shorter but still quite a long line ...]↲
 ↲
  ↲
    ↲
 ⇥  ⇥↲
[... etcetera ... whole lotta whitespace in here ...]
⇥⇥↲
 ↲
↲
↲
⇥↲
0↲

Perl was the natural choice for the second language in this challenge, being one of the best general-purpose languages for writing compact quines. My shortest Perl quine is 19 bytes:

say<< x2
say<< x2

– and you can see how it was the seed for the Perl half of the double quine. My best Whitespace quine, in comparison, is 541 bytes long. (Though shorter ones do exist – 445 bytes is the best I've seen.)

From the Perl interpreter's point of view, the first line of the double quine's source file contains the two statements that make up the entire program proper, as the remaining contents are two quoted strings. The first string is the repeated line of Perl, and is delimited by the blank third line. The second string is all whitespace, and runs from the fourth line of the source all the way to the 0 delimiter at the bottom of the file.

When taken as a Whitespace program, the first four lines contain three instructions that are largely useless. (Their effect is to push two zero values onto the stack, and then discard the second one.) They're included just to get safely past the newlines that the Perl program requires – the real program starts after that. Rather than quote the unreadable source any further, here's a paraphrasing of the instructions that make up the Whitespace program, in an assembly-like format:

# Representation of "say<< ;say<<0,0  \n" in base 122 as ASCII chars.
PERLCODE = 44892457841068708924520433691075560592081

# Represention of the whitespace program, following the "push PERLCODE"
# instruction, in base 3 (see comments on wsout).
WSCODE = 9823454421986355730445143846606456399449033186160554878002671428613111806443504867738858766142050504887335990409088441824104338753030405625930185

# Set up the stack and the heap. The first three instructions are not
# particularly useful; they're just there to skip past the newlines in
# the Perl code. (Though the initial zero on the stack does get used
# at the very end.)

        push    0
        push    0
        jneg    wsout

        push    WSCODE
        push    PERLCODE
        dup
        dup
        push    0
        copy    1

# Output the first four lines of the file.

perl:   dup
        mod     122
        putchar
        div     122
        dup
        jnzero  perl
        pop
        jzero   perl
        push    68              # represents "jneg wsout"
        call    wsout

# Output the rest of the file.

        copy    1
        call    pushout
        push    2
        call    wsout
        call    pushout
        call    wsout
        putnum
        push    2
        call    wsout
        exit

# pushout: Output a Whitespace push instruction, using the number on
# the top of the stack as the instruction's argument. (Recursion is
# used to output the bits MSB-first.)

pushout:
        push    0
        dup
        call    wsout
        call    wsout
bits:   dup
        jzero   bitend
        dup
        mod     2
        swap
        div     2
        call    bits
bitend: call    wsout
        ret

# wsout: Output a sequence of whitespace characters as represented by
# the number on the top of the stack. The number is read in base 3,
# LSB-first, with 0 = SPC, 1 = TAB, 2 = NL. Calling wsout with a value
# of zero will output a single space.

wsout:
        dup
        mod     3
        mul     -23             # some ugly math that transforms
        mod     -24             # (0, 1, 2) into (32, 9, 10)
        add     32
        putchar
        div     3
        dup
        jnzero  wsout
        pop
        ret

The giant numbers at the top are what we Whitespace users have to use in lieu of actual strings. Don't bother trying to run this on a Whitespace interpreter that doesn't have proper bignum support.

Finally, here's the program again, but this time with C-style escapes, since it was specifically requested:

say<< x2;say<<0,0  \nsay<< x2;say<<0,0  \n\n\t\t\n   \t\t  \t  \t \t\t  \t  \t\t \t \t \t\t\t\t\t  \t\t \t\t\t \t\t\t\t\t \t \t \t\t \t \t   \t\t\t\t\t   \t\t  \t \t\t \t \t\t \t    \t\t\t\t \t  \t \t\t \t    \t \t\t   \t      \t\t\t \t\t\t\t\t \t\t\t \t\t\t\t     \t\t\t \t      \t\t\t\t\t      \t\t   \t\t    \t\t\t\t\t\t\t\t  \t \t \t   \t\t\t   \t\t\t\t\t  \t\t\t\t \t    \t \t\t\t\t\t \t     \t  \t \t      \t    \t     \t\t   \t\t\t \t \t\t\t\t\t\t \t\t \t \t       \t\t  \t           \t\t   \t \t\t\t \t     \t\t\t\t\t\t \t    \t\t\t\t \t\t\t\t  \t\t\t   \t\t\t \t  \t   \t\t\t\t  \t\t \t\t\t   \t\t\t \t\t\t \t\t\t  \t\t \t  \t \t\t\t \t \t \t\t     \t \t \t  \t  \t \t\t     \t \t    \t\t\t\t  \t \t\t \t \t\t \t  \t \t \t\t \t\t \t\t \t\t\t \t\t\t    \t\t\t  \t  \t\n   \t     \t\t\t\t\t \t\t \t \t \t \t  \t\t\t   \t   \t    \t\t \t         \t   \t\t\t\t \t\t    \t\t \t \t  \t\t\t \t\t\t\t \t\t\t   \t    \t \t \t\t\t  \t\t\t\t \t \t\t \t \t \t\t\t\t \t  \t \t\t \t   \t\n \n  \n    \n \t  \t\n\n  \t\n \n    \t\t\t\t \t \n\t \t\t\t\n     \t\t\t\t \t \n\t \t  \n   \t\t\n\t  \n\n\t\t\t\n \n\n\n\t \t\n   \t   \t  \n\n \t\n \t  \t\n\n \t \n   \t \n\n \t\n\n \t \n\n \t\n\t\n \t   \t \n\n \t\n\n\n\n\n   \n   \n \n \n \t\n\n \t\n\n    \n \n \n\t \n \n    \t \n\t \t\t \n\t   \t \n\t \t \n \t  \n\n  \n \n    \t\t\n\t \t\t  \t\t \t\t\t\n\t  \n  \t\t\t   \n\t \t\t   \t     \n\t   \t\n     \t\t\n\t \t  \n   \t\t\n\t  \n\n\t\t\n \n\n\n\t\n0\n


More is less and less is more Anybody can make the output of a program bigger by adding characters, so let's do the exact opposite.

Write a full program, an inner function or a snippet for a REPL environment in a language of your choice that satisfies the following criteria:

Your code must be at least 1 character long.
Running the original code produces x characters of output to STDOUT (or closest alternative), where 0 ≤ x < +∞.
Removing any arbitrary single character from the original code results again in valid code, which produces at least x + 1 characters of output to STDOUT.
Neither the original code nor the modifications may produce any error output, be to STDOUT, STDERR, syslog or elsewhere. The only exceptions to this rule are compiler warnings.

Your program may not require any flags or settings to suppress the error output.

Your program may not contain any fatal errors, even if they don't produce any output.
Both the original code and the modifications must be deterministic and finish eventually (no infinite loops).
Neither the original code nor the modifications may require input of any kind.
Functions or snippets may not maintain any state between executions.

Considering that this task is trivial is some languages and downright impossible in others, this is a popularity-contest.

When voting, please take the "relative shortness" of the code into account, i.e., a shorter answer should be considered more creative than a longer answer in the same language.

Any REPL with caret XOR operation, 5 bytes

11^11

11^11 is of course 0. The only other possibilities are 1^11 or 11^1 which are 10, or 1111 which produces itself.


Proper army (Canadian Air Cadet) squadron formation (Note: I'm not in the army so feel free to correct me if my formation is wrong, but I will not be changing the question. I will change any terminology mistakes though, because I'm trying to avoid air-cadet-specific wording choices)

(Note: this follows the standards for Canadian Air Cadets, not any actual army thing)

Challenge

Given some configurations for a squadron, output what it should look like.

You will use 1 non-whitespace character to represent people.

Configuration

The configuration will consist of a mandatory non-empty list, a mandatory positive integer, and an optional positive integer. The list represents the number of people per "squad", the mandatory integer represents the maximum number of rows, and the optional integer represents the number of "squads" in the squadron; in other words, the length of the list.

Each squad looks like this (without the commanders):

X X X X X
X   X X X
X   X X X

This would be a squad with 13 people in 3 rows.

A squad must be strictly wider than it is tall, unless it's a single person, in which case it's 1 × 1. It must also be as tall as possible (within the restriction for the number of rows); that is, once it is one larger than a perfect square, it should form another row. An exception is that when there are 5 people, it should still be a single row.** The gap is always placed in the second column from the left, starting from the second row and moving downwards. For example, with 28 people and 5 rows maximum:

X X X X X X
X   X X X X
X   X X X X
X X X X X X
X X X X X X

Then, after the squad is formed, a commander is to be placed 2 rows above and below the squad, in the exact centre. For odd width squads:

    X

X X X X X
X X X X X
X X X X X

    X

And for even width squads:

   X

X X X X
X X X X
X X X X

   X

Hopefully you now understand how an individual squad is formed. Then, to form a squadron, each squad has 7 blank columns between it. For example, with a maximum row count of 3 and three squads of size 15, 16, and 17:

                      X

    X                X                 X

X X X X X       X X X X X X       X X X X X X
X X X X X       X   X X X X       X   X X X X
X X X X X       X   X X X X       X X X X X X

    X                X                 X

Then, in the final step, a commander is placed two rows above the row of front commanders, directly in the centre of the squadron, to the left if it has even width. In the example above, that would be the X at the very top.

The final output may contain trailing whitespace on each line and an optional trailing newline.

Here's a reference implementation: Try It Online! (Python 3)

Input

Input will be given in any flexible format with the 3 components listed above: list, int[, int].

Rules

Standard loopholes apply
Output must be in this exact format (of course, you may choose the character to use)
Newline may be CR, LF, or CRLF
Trailing whitespace is allowed
Trailing newline is allowed

**Except our squadron's Flag Party formed a 3x2 pseudorectangle :P

Python 3, 308 314 309 305 269 bytes

Input is the number rows in a squad and a list with a single integer for each squad, indicating the number of persons in the squad.

Could probably be golfed quite a bit.

Edit: +6 bytes, fixed a bug for squads with the same number of persons as rows

Edit: -6 bytes thanks to @Mr.Xcoder

Edit: -36 bytes by combining everything to one function

def z(r,l,v=" ",z="X "):q=[z,v]+[(v*6).join(([z.center((w//r+(w%r>0))*2),v]+[r*[z],[z+[z,v*2][I*w%r and r>=w%r+I]+z*(w//r+(w%r>0)-2)for I in range(r)]][w>r]+[v,z.center((w//r+(w%r>0))*2)])[i]for w in l)for i in range(r+4)];return"\n".join(p.center(len(q[2]))for p in q)

Try it online!


Sum square difference The sum of the squares of the first ten natural numbers is,
\$1^2 + 2^2 + \dots + 10^2 = 385\$

The square of the sum of the first ten natural numbers is,

\$(1 + 2 + ... + 10)^2 = 55^2 = 3025\$

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is

\$3025 − 385 = 2640\$

For a given input n, find the difference between the sum of the squares of the first n natural numbers and the square of the sum.

Test cases

1       => 0
2       => 4
3       => 22
10      => 2640
24      => 85100
100     => 25164150

This challenge was first announced at Project Euler #6.

Winning Criteria

There are no rules about what should be the behavior with negative or zero input.
The shortest answer wins.

Jelly,  5  4 bytes

Ḋ²ḋṖ

Try it online!

How?

Implements  \$\sum_{i=2}^n{(i^2(i-1))}\$...

Ḋ²ḋṖ - Link: non-negative integer, n
Ḋ    - dequeue (implicit range)       [2,3,4,5,...,n]
 ²   - square (vectorises)            [4,9,16,25,...,n*n]
   Ṗ - pop (implicit range)           [1,2,3,4,...,n-1]
  ḋ  - dot product                    4*1+9*2+16*3+25*4+...+n*n*(n-1)


Store eight bits on a punched card A little while back, data was frequently stored on punched card. A typical card would have 80 columns of 12 possible 'punch' positions. A plethora of encodings was used, each for their own specific purpose.
These days we like to think of a byte as 8 bits. In this challenge, you're tasked to convert an 8-bit byte to a 12-bit word so that it may be stored on a punched card. Since too many holes per column would weaken a punched card considerably, your encoding must adhere to the following rules,

No more than 3 holes punched per column (i.e., no more than 3 bits set per 12-bit word)
No more than 2 holes punched consecutively in the same column (i.e., no more than 2 consecutive bits set in each word)

There are 289 valid 12-bit punch cards, of which 1 has 0 holes, 12 have 1 hole, 66 have 2 holes, and 210 have 3 holes. Compare this to 256 8-bit sequences.
You must create two programs/functions: one of which takes a 8-bit byte and converts it to a 12-bit word according to an encoding of your choice that follows the above rules; and one of which takes a 12-bit word according to your encoding and converts it back to an 8-bit byte. The latter program may exhibit undefined behaviour for any input which is not contained in your encoding.
Input and output is flexible according to the defaults for I/O, and may even differ between your programs. Your score is the sum of the bytecount of both programs. The programs must work independently, so they may not 'share' code between them.

JavaScript (ES6),  103  100 bytes
See also my other answer for less bitwise operations, more maths, and a closed-form expression
Both functions expect and return an integer.
8-bit → 12-bit ( 56  53 bytes)

f=n=>n&&(w=f(n-1),w+=(x=w&w-1)&x-1?w-x:1)+(w&w/2&w/4)

Try it online!
How?
This is a recursive function that computes the next valid 12-bit word \$w_{n+1}\$ directly from the previous valid word \$w_n\$.
Step 1: Update w according to the total number of bits set
Given w from the previous iteration we first compute:
x = w & (w - 1)

which is w without its least significant bit.
Likewise, we remove the least significant bit from x by doing:
x & (x - 1)

If the result is zero, we just increment w.
If the result is non-zero, it means that there are already 3 bits set in w and we are not allowed to insert a 4th one. In that case, we add the least significant bit of w (which is w - x) to w. This results in at most as many bits set in the updated value than in the original one, or less in case of carry propagation.
Examples:
110010 +  10 -> 110100
101100 + 100 -> 110000

Step 2: Update w according to the number of consecutive bits set
We now have to make sure that there are not 3 consecutive bits set in w. We do that by adding the result of a bitwise AND between w, w / 2 and w / 4.
Example:
01110 + (01110 & 00111 & 00011) -> 01110 + 10 -> 10000

12-bit → 8-bit (47 bytes)

f=w=>w&&!(w&w/2&w/4|(y=(x=w&--w)&x-1)&y-1)+f(w)

Try it online!
How?
In this version, we decrement w at each iteration and increment the final result whenever w is a valid 12-bit word. We stop when w = 0.
We use the following methods to test the validity of w. They are similar to the ones used above.

we compute w & w / 2 & w / 4 to make sure that there are not 3 consecutive bits set
we compute a chain of three w & (w - 1) to make sure that there are no more than 3 bits set


Given a list of Tetris moves, return the number of completed lines Description

We consider a slightly simplified version of Tetris where each move consists of:

rotating the piece clockwise, 0 to 3 times
positioning the piece at a given column
fast drop

The goal is to determine the number of completed lines, given a list of such Tetris moves.

Completed rows are removed as pieces are dropped, following standard Tetris rules.

Playfield

The playfield is 10-column wide. There's no Game Over and it is assumed that there's always enough space and time to perform the above actions, no matter the configuration of the playfield. The height of the playfield doesn't really matter here, but you can use the standard 22 rows as an upper limit.

Shapes of Tetrominoes

Input / Output

Input

A comma separated list of Tetris moves encoded with 3 characters. The first two character describe the Tetromino shape to use and the last one describes the position where it's dropped.

Tetromino: I, O, T, L, J, Z or S, in the same order as above.
Number of clockwise rotations: 0 to 3
Column: 0 to 9. This is the column in which the top-left corner of the piece (marked with an x on the above picture) is located after the rotation 1

It is assumed that all moves in the provided list are valid. There's no need to check for invalid entries such as I07 (horizontal I shape put too far on the right).

1 You are free to either implement a real rotation algorithm or to hardcode all the different shapes, as long as the x is located in the column given by the third character of the move.

Output

Number of completed lines.

Example

O00,T24 will generate the first position and O00,T24,S02,T01,L00,Z03,O07,L06,I05 will generate the second position.

Therefore, the following sequence will generate a Tetris and should return 4:

O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19

Test cases

1) "O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19" -> 4
2) "S00,J03,L27,Z16,Z18,I10,T22,I01,I05,O01,L27,O05,S13" -> 5
3) "I01,T30,J18,L15,J37,I01,S15,L07,O03,O03,L00,Z00,T38,T01,S06,L18,L14" -> 4
4) "S14,T00,I13,I06,I05,I19,L20,J26,O07,Z14,Z10,Z12,O01,L27,L04,I03,S07,I01,T25,J23,J27,O01,
    I10,I10" -> 8
5) "O00,T24,L32,T16,L04,Z11,O06,L03,I18,J30,L23,Z07,I19,T05,T18,L30,I01,I01,I05,T02" -> 8

Test page

You can use this JSFiddle to test a move list.

C, 401 392 383 378 374 351 335 324 320 318 316 305 bytes

d[99]={'3Z3Z',983177049,513351321,1016270793,970073931,~0},*L=d+5,V,s;char c;main(x){B:for(c=0;c[++L]|V;V>>=4)c-=(L[c]=*L|(V&15)<<x)>1022;s-=c;if(scanf("%c%1d%d,",&c,&V,&x)>2)for(V=c^79?d[c/4%5]>>24-V*8:27,V=c^73?V/64%4<<8|V/8%8<<4|V%8:V&32?15:4369;;--L)for(c=4;c--;)if(L[c]>>x&V>>c*4&15)goto B;return s;}

Takes comma-separated input on stdin, returns the score in the exit status.

Requires char to be signed (which is the default for GCC) and requires '3Z3Z' to be interpreted as 861549402 (which is the case for GCC on little endian machines, at least).

Usage example:

echo "O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19" | ./tetris; echo "$?";

High-level explanation:

All shapes except the line can fit in a 3x3 grid with one corner missing:

6 7 -
3 4 5
0 1 2

That means it's easy to store them in a byte each. For example:

- - -         0 0 -
- # -   -->   0 1 0   -->   0b00010111
# # #         1 1 1

(we align each piece to the bottom-left of the box to make dropping it easier)

Since we get at least 4 bytes to an int, this means we can store all 4 rotations of each piece in a single integer, with a special case for the line. We can also fit each row of the game grid into an int (only needs 10 bits), and the currently falling piece into a long (4 lines = 40 bits).

Breakdown:

d[99]={             // General memory
  '3Z3Z',           //  Shape of "S" piece (multi-char literal, value = 861549402)
  983177049,        //  Shape of "T" piece
  513351321,        //  Shape of "Z" piece
  1016270793,       //  Shape of "J" piece
  970073931,        //  Shape of "L" piece
  ~0                //  Bottom of game grid (solid row)
},                  //  Rest of array stores lines in the game
*L=d+5,             // Working line pointer (start >= base of grid)
V,                  // Current piece after expansion (also stores rotation)
s;                  // Current score (global to initialise as 0)
char c;             // Input shape identifier (also counts deleted lines)
main(x){            // "x" used to store x location
  B:                                // Loop label; jumps here when piece hits floor
  for(c=0;c[++L]|V;V>>=4)           // Paint latest piece & delete completed lines
    c-=(L[c]=*L|(V&15)<<x)>1022;
  s-=c;                             // Increment score
  if(scanf("%c%1d%d,",&c,&V,&x)>2)  // Load next command
    for(V=c^79?                     // Identify piece & rotation
          d[c/4%5]>>24-V*8          //  Not "O": load from data
        :27,                        //  Else "O": always 27
        V=c^73?                     // If not "I" (line):
          V/64%4<<8|V/8%8<<4|V%8    //  expand shape to 16-bits
        :                           // Else we are a line:
          V&32?                     //  "I" coincides with "J"; use this to check
               15:4369;             //  horizontal/vertical
        ;--L)                       // Loop from top-to-bottom of grid
      for(c=4;c--;)                 //  Loop through rows of piece
        if(L[c]>>x&V>>c*4&15)       //   If collides with existing piece:
          goto B;                   //    Exit loops
  return s;                         // Return score in exit status
}

-4, -1 thanks to @Titus, and -23, -11 with inspiration from their answer


Arranging arbitrary shapes to fill a rectangular space A while ago, I posted a challenge asking to determine whether or not it's possible to arrange arbitrary rectangles to fill a rectangular space, here. That got answers, so clearly it was too easy. (Just kidding, it was fairly challenging, congrats to the answerers :D)

Challenge

Given a bunch of arbitrary shapes (consisting of 1x1 square tiles) (up to 100 with a combined area of at most 1000), can you arrange them to fill a rectangular space, without rotations or reflections?

A shape is valid as input if it has at least 1 tile and all tiles are connected to each other by edges. For example:

Valid:

XXX
X X
XXX

Invalid:

XXX
X
 XX

The shapes will be represented in input by using a non-whitespace character X, spaces, and newlines. Individual shapes will be separated by two newlines (i.e. split on \n\n). You can choose to use LF, CR, or CRLF as a newline. Alternatively, you can choose to use LF or CR as a single newline and CRLF as a double-newline for separating shapes. Please specify in your answer what you choose.

For example, this would be the input format for a 2x2 square and a 3x3 "donut":

XX
XX

XXX
X X
XXX
(Optional trailing newline or double-newline)

The output should be either any truthy value or a consistent falsy value (but not an error). For example, you may output the valid arrangement if one exists or false, but you cannot error if there is no valid arrangement, neither can you output different values for having no valid arrangement.

Test Cases

Test Case 1

XXXX
X  X
XX X

X
X

X

TRUE

Valid Arrangement:

XXXX
XYYX
XXYX

Test Case 2

XXXX
XX

X

FALSE

Test Case 3

XXXXXX
X X  X
X XXX

XX

X
X

X

TRUE

Valid Arrangement:

XXXXXX
XYXZZX
XYXXXA

Test Case 4

XX
X

 X
XX

XXX

X
X
X

TRUE

Valid Arrangement:

XXYZ
XYYZ
AAAZ

Notes

Each shape must be used exactly once in the arrangement
Shapes may not be rotated or reflected
The input can contain multiple identical shapes; in this case, each of those still needs to be used exactly once; that is, if two 5x3 rectangles are given in the input, two 5x3 rectangles must appear in the arrangement

Python 2, 434 bytes

lambda s:F([[' ']*sum(map(lambda s:len(s[0]),s)) for _ in' '*sum(map(len,s))],s)
L=len
R=range
def F(a,s):
 if not s:return len(set(tuple(l)for l in a if'X'in l))==len(set(tuple(l)for l in zip(*a)if'X'in l))==1
 c=s[0];h,w=L(c),L(c[0])
 for i in R(L(a)-h):
	for j in R(L(a[0])-w):
	 T=1;A=[l[:]for l in a]
	 for y in R(h):
		for x in R(w):
		 C=c[y][x]
		 if C>' ':T&=A[y+i][x+j]<'!';A[y+i][x+j]=C
	 r=T and F(A,s[1:])
	 if r:return r

Try it online!

Takes input as a list of lists.

Returns True or None

Assumes that each line in a shape is padded to the length of that shape.

(based on my answer to Do the figures fit?)


Google Autocomplete Fun Your task is to create a program which, given an input string, will output the first Google autocomplete result for that search. The format of input/output is up to you.
Rules

Your program must take 1 input, a string, and output the top Google autocomplete/auto-fill suggestions result. The format of input/output is up to you. Just be sure to mention what your I/O format is.
Obviously, accessing the Internet is allowed.
URL shorteners (like bit.ly, TinyURL, etc.) are strictly disallowed. You should fetch your autocomplete results from this URL: http://suggestqueries.google.com/complete/search?client=your_browser&q=your_query or http://google.com/complete/search?client=your_browser&q=your_query. You are allowed to assume any browser name (or string, for that matter) for client. In the program I wrote, I assume Chrome. Any browser name or string should work. You are allowed to pass any options to the webpage as long as you are using some variant of http://suggestqueries.google.com/complete/search.
Please provide an explanation of how your program works. It is not mandatory, but I strongly advise it.
All standard loopholes are strictly forbidden.

Test Cases
These are constantly changing, so edit this post if these become out-of-date.
'how to'
  => 'how to make slime'
'code golf'
  => 'code golf languages'
'you'
  => 'youtube'
'g'
  => 'google' (why would you google 'google'?)

This is code-golf, so may the shortest code win and the best programmer prosper...

Vim 8 + unimpaired.vim, 93 89 85 70 73 71 bytes

-4 bytes thanks to tsh
-2 bytes thanks to Ian Emnace
-2 bytes thanks to FatalMerlin
-1 byte thanks to tsh/ckjbgames

:s/ /+/g
D:e http://google.us/complete/search?client=gma&q="
d3f";D]yy

As a bonus, the last bytes look like they're winking at you ;D Since this contains non-printing characters, the explanation contains substitutions (and I've replaced the pre-querystring part of the url with [url], for brevity):

:s/ /+/g<CR>D:e [url]?client=gma&q=<C-R>"<CR>d3f";D]yy
:s/ /+/g<CR>                                           " Replace spaces with +
            D                                          " Delete and yank result
             :e                                        " Type :e ('edit' command) and a space
                [url]?client=gma&q=                    " Type the url, except the query
                                   <C-R>"              " Paste from the default register
                                         <CR>          " Execute the command, which opens the response
                                                       "   in a new buffer
                                             d3f"      " Delete through the first three quotation marks
                                                       "   This deletes everything before the suggestion
                                                 ;     " Repeat motion; this jumps to the next \"
                                                  D    " Delete everything from there, leaving only the suggestion
                                                   ]yy " unimpaired.vim C string unescape to handle escaped '

As far as running goes, it works fine if you save it to a file named script and run with vim -s script input.txt on macOS, at least. It doesn't work if you add -u NONE, but it works fine if my .vimrc is empty. I assume it is using something from the system .vimrc to make the URL stuff work. This means, however, that it doesn't work in V, so no TIO link.

Some more test cases:

'what' => 'whataburger'
'what ' => 'what time is it' (Seriously? People Google that?)

What I really need is a way to open a URL with spaces in it. Replacing them with + first is just too many bytes!


Tips for golfing in Röda Röda is a stream-based scripting language created by fergusq.

What general tips do you have for golfing in Röda? I'm looking for ideas that can which can be applied to code-golf problems and which are also at least somewhat specific to Röda (e.g. "remove comments" is not an answer).

Please post one tip per answer.

Use underscores

This is probably the most important tip. Nearly every golfed Röda program uses underscores.

The underscore syntax is syntactic sugar for for loops. The following lines of code are equivalent:

ls""|fileLength x for x|sort|pull
ls""|fileLength _|sort|pull

Each underscore adds a new variable to an invisible for loop that is around the statement. The loop pulls one value from the stream for each variable/underscore and then repeats, until no values are left.

Underscores can be used anywhere in statements:

a[x:y+1]=[1]*(1+y-x) /* Sets range x..y (inclusive) */
seq x,y|a[_]=1       /* 6 bytes less */

If you must refer to the same underscore value more than once, or use the values in reverse order, you can put a number after the underscore:

a|[_^_1]  /* maps x to x^x */
a|[_2-_1] /* maps each pair (x,y) to y-x, eg. [1,2,4,8] -> [1, 4] */


Maximally extend integer intervals Suppose you are given a set of non-intersecting intervals of integers [a1,b1],[a2,b2],[a3,b3],...,[aN,bN]. (Where [a,b] is the set of integers greater than or equal to a and less than or equal to b.)
The interval at index X covers bX - aX + 1 values. We'll call this number cX.
Given that each interval can either be...

unchanged (stays as [aX,bX]),
extended to the right towards the + side of number the line by cX (becoming [aX,bX + cX]),
or extended to the left towards the - side of number the line by cX (becoming [aX - cX,bX]),

what is the maximum number of values that can be covered by the union of all the updated intervals, given that they are still all non-intersecting?
Write a function or program that takes a string of the form [a1,b1],[a2,b2],[a3,b3],...,[aN,bN] and computes this maximum. If writing a function, return the value. If writing a full program, use stdin for input and print the value to stdout (or use closest alternatives).
You may assume all values are well within normal signed 32-bit integer limits and that aX is less than or equal to bX for all indices X. The intervals may be in any order, they are not necessarily always increasing. They must be given as a string in the format above. The string may be empty, in which case the answer will be 0.
The shortest submission in bytes wins.
Example
If the input were [-3,0],[1,2],[4,9] the output would be 22. The middle interval has no room to expand either way so it must remain unchanged. The left and right intervals can both be extended to [-7,0] and [4,15] respectively. The union of [-7,0] and [1,2] and [4,15] contains all the values from -7 to 15, except 3. That's 22 values.


Optimal short-hand roman numeral generator Goal:
Write a function that takes a number as input and returns a short-hand roman numeral for that number as output.

Roman Numeral Symbols:

Symbol  Value
I       1
V       5
X       10
L       50
C       100
D       500
M       1,000

For an example of what I mean when I say "short-hand roman numerals", let's consider finding a roman numeral to represent 1983, because that is the year I was born.  One option is to do this the normal way (10 letters):

1983 = MCMLXXXIII = (1000 - 100 + 1000 + 50 + 30 + 3)

The other option is to do it the short-hand way (6 characters):

1983 = MXVIIM = (1000 - (10 + 10) + 1000 + 3)

Do you know what this means?!?!!??  If I was roman I could have saved 4 characters every single time I wrote my birth date!  Woot Woot!!

However, before I get ahead of myself in excitement, I have a question to write, so I should probably define the short-hand roman numeral rules so we are all on the same page:

Short-Hand Roman Numeral Rules:

Always consider symbols from left to right until there are no more characters to consider.
If there are no higher-valued symbols to the right of the current symbol:

Add the value of the current symbol to the running total of this roman numeral.

If there are higher-valued symbols to the right of the symbol you are considering:

Locate the rightmost highest-valued symbol to the right of the current symbol
Consider all the characters up to that symbol as one roman numeral
Calculate the value of that roman numeral using these steps
Subtract the value of that roman numeral from the running total of this roman numeral.
Move to the next symbol after the group you just considered

Each roman numeral must have at least 1 symbol in it.
That's it!  Anything following these rules will be accepted!

Examples:

IIIIV = (-(1+1+1+1)+5) = 1  //Don't ask me why you'd want to do this!

VVX = (-(5+5) + 10) = 0  //Who said you couldn't represent 0 with roman numerals?!!?

VVXM = (-(-(5+5) + 10) + 1000) = 1000  //Again...don't ask me why you'd want to do this!

MXIIXMI = (1000-(10-(1+1)+10)+1000+1) = 1983  //Ahhh...such a great year :)

Question Rules:

Make a function that takes a single number as input and returns a roman numeral for that number as output using the above rules.  Calculate the codeGolfScore of this function.

example input: 2011
example possible output: MMXI
another possible output: MMVVIVV     //(2000 + 10 - 4 + 5)

Using your function from rule 1, generate the roman numerals between -1000 (that's right, NEGATIVE one-thousand) and 3000.  Then sum up the character length of these roman numerals to get your totalCharacterCount.  Here's some pseudocode to clarify:

totalCharacterCount = 0;
for(currentNumber = -1000; currentNumber <= 3000; currentNumber++){
    totalCharacterCount += getRomanNumeral(currentNumber).length;
}
return totalCharacterCount;

finalScore = codeGolfScore +  totalCharacterCount
Lowest finalScore wins!

Note:  As the totalCharacter count will be in the ten-thousands+, the character-length algorithm should be top priority.  Code-golf scores are just the tie-breaker in case multiple users find the optimal algorithm or algorithms that are close to each other.

Good luck, and have fun at your MMXII celebrations tomorrow night!!!

C++, 345 characters of code, 25021 roman numeral digits = 25366

int N[]={1,5,10,50,100,500,1000};int V(int s,int L){if(!L)return 0;int K=0,B,m=s%7+1;for(int k=1,b=7;k<L;k++,b*=7){if(s/b%7>=m){K=k;B=b;m=s/b%7;}}return K?V(s/B,L-K)-V(s%B,K):N[s%7]+V(s/7,L-1);}char r[99];char*f(int n){for(int L=1,B=7,i,j;1;L++,B*=7){for(i=0;i<B;i++){if(V(i,L)==n){for(j=0;j<L;j++){r[j]="IVXLCDM"[i%7];i/=7;}r[L]=0;return r;}}}}

deobfuscated a bit, with a driver:

int N[]={1,5,10,50,100,500,1000};
int V(int s,int L){
  if(!L)return 0;
  int K=0,B,m=s%7+1;
  for (int k=1,b=7;k<L;k++,b*=7) {
    if(s/b%7>=m){K=k;B=b;m=s/b%7;}
  }
  return K ? V(s/B,L-K)-V(s%B,K) : N[s%7]+V(s/7,L-1);
}
char r[99];
char *f(int n){
  for(int L=1,B=7;1;L++,B*=7) {
    for(int i=0;i<B;i++) {
      if(V(i,L)==n){
        for(int j=0;j<L;j++) {
          r[j]="IVXLCDM"[i%7];i/=7;
        }
        r[L]=0;
        return r;
      }
    }
  }
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
  printf("%s\n", f(atoi(argv[1])));
}

V computes the numerical value of a given roman numeral string s of length L.  Strings are encoded base 7 (first digit is s%7, second digit is s/7%7, ...).  Each digit is encoded with I=0, V=1, ..., M=6.  f does a brute-force enumeration of possible roman numeral strings to find one that V evaluates to n.

The total number of roman numeral digits is optimal.  The longest roman numeral needed for [-1000,3000] is 11 digits (e.g. -827=CMDDMLXXIII), which takes about 5 minutes on my machine.


Perfect Hangman in reverse This is similar to other hang-man style problems already posted, except, in this case, the computer is the one guessing. Computers are logical, smart, and consider self-preservation to be important, so there are a few RULES for how computers will guess.

The user will think of any word, that will be contained in the FULL Ispell word list. some of these may be upwards of 10-15 letters. The wordlist is simply the full ispell wordlist (english, and others, all combined), and may be placed in a folder with the program.

The computer will be given 8 lives. The computer will start by simply asking for an input of however many characters the word is. (example game below). After that, the computer will begin guessing, following the ruleset below!

the computer will analyze all possible word outputs, and determine what letter guess has the most possible correct answers, and guess that letter. It will not duplicate any prior guesses.
the computer will then ask for an updated word input, determine if it was correct at all, or wrong, and if wrong, will deduct 1 life.
Lastly, the computer will state the lives remaining.

EXAMPLE GAME
User picks the word "Engineer"
Computer asks for Letter count, User replies 8.
Computer searches for most likely letter to be used in 8 letter words, determines it is letter H (not correct). Guesses H.
User replies _ _ _ _ _ _ _ _
Computer outputs "7 lives remaining" and then picks the next most likely letter, an E
User replies e _ _ _ _ e e _
computer outputs "7 lives remaining" and then recalculates based on its current knowledge what is the most likely next letter.
Game continues until computer will state WIN, or LOSE.

SCORING: every program should follow the EXACT same method to arrive at the final answer. If yours follows the order of every other program, you receive -100 points. If yours is different (aka wrong), you receive 1000 points.

each byte of code is worth 1 point. a 30 letter code, is 30 points.

if your code manages to play each step of the game in less than 5 seconds, award yourself -100 points.

The winner will be chosen 1 week from the first answer, and a new question related to this one, will be asked. Obviously those with the best code here will have a head start on the new one!

EDIT: forgot to make note that as in golf, the lowest score wins.

K, 196 215 240 (40 points)

When reduced to a single line it's 240 chars but I've added newlines here for readability. The question doesn't state exactly what the output needs to look like so I've come up with something fairly minimal.

r:0#t:#[c:#w:_0:0;"?"]
a:_:'0:`a;
l:8;
while[~(l=0)|(c=0);
  q:{x@&~x in y}[>#:'=,/a:a@&a like\:t;r];
  if[1=#a;-1 a;j:-1"WIN";exit 0];
  -1"Guess ",u:*q;
  r,:u;
  $[|/u=w;[c-:+/u=w;@[`t;&u=w;:;u]];-1($l-:1)," lives remaining"];
  -1 t;
  $[0=l;-1"LOSE";0=c;j;]]

The wordlist is a file called a in same directory as the code.

$ q hm.k -q
engineer
Guess e
e????ee?
Guess s
7 lives remaining
e????ee?
Guess i
e??i?ee?
engineer
WIN

EDIT: It now reanalyses the word on each step and determines which is the most likely letter based on previous guesses.

EDIT2: If there is only one possible answer (after reanalysis) the computer wins, rather than continuing to guess each individual letter