algorithmcode-golfsudoku

Code Golf: Validate Sudoku Grid


Introduction

A valid Sudoku grid is filled with numbers 1 to 9, with no number occurring more than once in each sub-block of 9, row or column. Read this article for further details if you're unfamiliar with this popular puzzle.

Challenge

The challenge is to write the shortest program that validates a Sudoku grid that might not be full.

Input will be a string of 9 lines of 9 characters each, representing the grid. An empty cell will be represented by a .. Your output should be Valid if the grid is valid, otherwise output Invalid.

Example

Input

123...789
...456...
456...123
789...456
...123...
564...897
...231...
897...564
...564...

Output

Valid

Input

123456789
987654321
123456789
123456789
987654321
123456789
123456789
987654321
123456789

Output

Invalid

Code Golf Rules

Please post your shortest code in any language that solves this problem. Input and output may be handled via stdin and stdout or by other files of your choice.

Winner will be the shortest solution (by byte count) in a language with an implementation existing prior to the posting of this question. So while you are free to use a language you've just made up in order to submit a 0-byte solution, it won't count, and you'll probably get downvotes.


Solution

  • Golfscript: 56

    n%{zip''+9/.{'.'-..&=}%$0=\}:|2*{3/}%|;**"InvV"3/="alid"