r/dailyprogrammer • • Jan 12 '15
[2015-01-12] Challenge #197 [Easy] ISBN Validator
Description
ISBN's (International Standard Book Numbers) are identifiers for books. Given the correct sequence of digits, one book can be identified out of millions of others thanks to this ISBN. But when is an ISBN not just a random slurry of digits? That's for you to find out.
Rules
Given the following constraints of the ISBN number, you should write a function that can return True if a number is a valid ISBN and False otherwise.
An ISBN is a ten digit code which identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct.
To verify an ISBN you :-
- obtain the sum of 10 times the first digit, 9 times the second digit, 8 times the third digit... all the way till you add 1 times the last digit. If the sum leaves no remainder when divided by 11 the code is a valid ISBN.
For example :
0-7475-3269-9 is Valid because
(10 * 0) + (9 * 7) + (8 * 4) + (7 * 7) + (6 * 5) + (5 * 3) + (4 * 2) + (3 * 6) + (2 * 9) + (1 * 9) = 242 which can be divided by 11 and have no remainder.
For the cases where the last digit has to equal to ten, the last digit is written as X. For example 156881111X.
Bonus
Write an ISBN generator. That is, a programme that will output a valid ISBN number (bonus if you output an ISBN that is already in use :P )
Finally
Thanks to /u/TopLOL for the submission!
43
u/OllieShadbolt 1 0 Jan 12 '15 edited Jan 13 '15
BrainFuck
Managed to amaze myself this time with finding an interesting solution to this. The program will take inputs until 10 digits have been provided. If the program hangs after these digits have been given, the number was not a valid ISBN. Otherwise, it was a valid ISBN number.
Tomorrow I plan on fully explaining what is going on in this mess if enough people seem interested, as well as fixing any bugs or problems that arise as I simply haven't had the time to fully test this out after some late night programming.After a few hours of writing, I've finally finished my full explanation as to what is going on within this program. I hope that the information is useful to both beginners and experience programmers alike. Sorry that it's a bit lengthy, but I've tried to go into as much detail as I can to help as many as I can.
Without formatting
Edit Added in explanation post, formatting edits and slight code changes
10
u/13467 1 1 Jan 12 '15
Haskell:
The bonus:
(grins like an idiot)
2
u/ThermalLake Jan 13 '15 edited Jan 13 '15
Here's my validation solution in a language that I haven't seen much on here, Ada! It is absurdly long, so just a heads up! I like to program in a user input, so it is a little time consuming to use, but it is looped so it can be ran multiple times without closing and reopening the program.
Ninja edit: I'm dumb and cant format it right
3
u/ChazR Jan 12 '15 edited Jan 12 '15
Most entries here seem to be validating an ISBN. The challenge is to generate one.
Little bit of Python:
19
u/13467 1 1 Jan 12 '15
APL, too:
9
u/jnazario 2 0 Jan 12 '15
f# - a one liner (except for formatting)
6
u/G33kDude 1 1 Jan 12 '15
The meaning of this escapes me
6
u/JHappyface Jan 12 '15
Here's a short and sweet python solution. I tried to keep it short, yet still readable.
6
u/Quel Jan 13 '15 edited Jan 13 '15
Validation function in R. Added some extra checks in there to allow the x/X at the end, and allow the use of hyphens. Edited it to improve the regex I used, since it allowed some invalid numbers. Edit2: added the bonus, which was actually easier than the base question if you ask me, only because you don't have to worry about inputs from a user.
Example output:
Last one is because it takes it as a number and removes the leading 0. Otherwise it takes numbers or strings.
Code:
Bonus. Output:
Bonus Code:
4
u/darthpaul Jan 12 '15 edited Jan 12 '15
my first c# program
critique me please, even it's just a style thing.
notes:
4
u/[deleted] Jan 13 '15
Javascript
Javascript has some really nice functions built into strings/arrays that makes this fairly simple.
1
u/[deleted] Jan 19 '15
Forgive me but I'm new to choosing so this might be a rather crap solution:
3
u/programmingdaily Jan 12 '15
C# - I decided to go the OOP route and create an ISBN class.
3
u/travmanx Jan 12 '15
Simple for Java.
I'm sure OP knows this... There are two different types of ISBN forms, ISBN-10 and ISBN-13, each with their own algorithm for checking validity. ISBN-10 is an older method used if the ISBN number was assigned before 2007. The newer version, ISBN-13, is used if the ISBN number was assigned after 2007.
3
u/marchelzo Jan 13 '15 edited Jan 13 '15
Here's one in Rust, because I didn't see one already, and because the 1.0 Alpha was recently released.
3
u/aZeex2ai Jan 13 '15 edited Jan 13 '15
C
3
u/HotBloodx Jan 13 '15
My first submission! python 2.7 feedback would be appreciated.
5
u/gixer912 Jan 13 '15
Java - My first dailyprogrammer post!
2
u/jetRink Jan 12 '15
Clojure - Only validates the checksum.
2
u/mashedtatoes Jan 12 '15
Here is my straightforward C++ solution
2
u/malcolmflaxworth Jan 12 '15 edited Jan 13 '15
Javascript
Probably not as simple as it could be, but it appears to be functional. Feedback always generously accepted.
And the bonus:
2
u/chunes 1 2 Jan 13 '15
Java:
2
u/YuEnDee14 Jan 13 '15 edited Jan 13 '15
I'm glad to be back in the swing of things and completing /r/dailyprogrammer challenges again! I dogfood'd my validator to test my generator, and I think they both work correctly.
Feedback is always appreciated, be it good or bad or somewhere in the middle!
https://gist.github.com/YuEnDee14/11d72502f771a2cf8e76
EDIT: I forgot to mention, this is a C# solution.
2
u/HackSawJimDuggan69 Jan 13 '15
Here's a simple Python 2.7 solution
2
u/BayAreaChillin Jan 13 '15
Solved in Python!
2
u/[deleted] Jan 13 '15 edited Jan 13 '15
C++ one-liner.
Heavy use of the <algorithm> header, with some of the <functional> header thrown in.
Rangeis my own implementation ofiotawhich is becoming standard in C++14, and therefore (I think) I can use without breaking the "one-liner" rules. (Which allows standard libs to be included without penalty.) [EDIT: Turns outiotadoes something different. It's actually more likeboost::irange.]For those of you who want a break down to see what I'm actually doing here:
include <algorithm>
2
u/[deleted] Jan 13 '15
JavaScript
2
u/[deleted] Jan 13 '15 edited Jan 13 '15
Python
I've learned a bit of Java about 6 years ago as a hobby and now I'm bored and I'm trying to learn python. I assume my coding style is affected by my Java days so I would be grateful for any suggestion. Thanks in advance!!
Edit: I changed my initial solution because even when my "generator" gave me the wrong numbers, also my "validator" was giving me weird answers. When I tried to exit the function with a return True/False that was indented inside and if/for/etc it didn't behave as I intended. Sometimes it gave me "True" sometimes it gave me "None" O_o I'm not sure why
2
u/NoobOfProgramming Jan 13 '15
This is my first attempt at a non-trivial FRACTRAN program. I started writing a FRACTRAN compiler that could handle large numbers, but it's nowhere near done, so this code is untested (except with the old noggin).
It takes 2a where a is the ISBN as an integer as input, and should return 1 iff it's valid. Because the input is an integer, it can't tell whether the first digit is 0.
Help/criticism is appreciated. Also, if you happen to have a way of running this, that would be pretty cool, too.
2
u/Pretentious_Username Jan 13 '15
Python 2.7 Been playing around with list comprehensions recently so this seemed like a good chance to try them out. I have both a verifier and a generator for ISBNs
Output:
2
u/dtaquinas Jan 14 '15
OCaml
Just validation, no generation.
2
u/ChiefSnoopy Jan 14 '15
I'm late to the party, but here is the first Java program that I have ever written. Please do not be shy to critique me:
3
u/LuckyShadow Jan 12 '15 edited Jan 13 '15
Python 3
ISBN-validation:
The
try-exceptmakes error-handling easier. :PISBN-generation:
Random ftw. No usage of
X. I don't see the point to include it. ;)Prettyfy:
So you can read your newly generated ISBN even better. :P
3
u/SpyroTF2 Jan 12 '15
Here is my C# solution:
Here is my Java solution:
1
u/itsme86 Jan 13 '15 edited Jan 13 '15
Thought I'd try to submit one of these finally. Here's my solution in C#:
1
u/[deleted] Jan 13 '15 edited Jan 02 '16
1
u/OutputStream Jan 13 '15
Always looking for feedback. Python 3:
1
u/verydapeng Jan 13 '15
clojure
1
u/swingtheory Jan 13 '15
Haskell
Practicing some of the crazy tricks this language has to offer!
1
u/aleph_nul Jan 13 '15
Simple haskell, nothing fancy.
1
u/Ratheronfire Jan 13 '15
Python
I tried to forgo all readability and make mine as compact as I could manage:
1
u/Godspiral 3 3 Jan 13 '15 edited Jan 13 '15
No J yet?
1
1
0
not sure I understand the generator, but assuming it is to take a 9 digit number and produce a isbn string,
156881111X
1
u/Maping Jan 13 '15
My java solution, including bonus. Critiques welcome!
1
u/[deleted] Jan 13 '15
Javascript
ISBN:
Generate:
My generate is lame. Maybe I'll fix it to include hyphens in the morning. I'm tired though. I might be way off in both of my answers. Feedback would be appreciated.
1
u/[deleted] Jan 13 '15
Sample input:
Written in Python:
1
u/recheej Jan 13 '15
My code is may be a little too fancy. My code can accept isbn-10s with hyphens or no hyphens using regular expressions.
1
u/ohheydom Jan 13 '15
golang
1
u/Rediturd Jan 13 '15 edited Jan 13 '15
First post and first time using Swift!
1
u/maasterbaker Jan 13 '15 edited Jan 13 '15
My C++ code.. Reviews are welcome... Typing from phone so please excuse syntax errors
bool check_ISBN(string str) { unsigned int sum=0;
if (str.length()< 10) return false;
for (int I=0; I<str.length(); I++) { if (toupper(str[I]) == 'X') sum = sum + (10-I)10; else sum = sum + (10-I)(str[I]-'0'); }
if (sum%11==0) return true; else return false;
}
ISBN generator
string generate_ISBN() { string str; unsigned int sum=0; srand(time(0)); // seed random no
for ( int I=0;I<9;I++) { unsigned int a = rand()℅10; sum = sum + (10-I)*a; str=str+(a+'0'); }
int last = sum%11; if (last==10) str = str + 'X'; else str = str + (last+'0');
return str; }
1
u/fvandepitte 0 0 Jan 13 '15 edited Jan 13 '15
C++, please give some feedback. I'm just starting with C++
1
u/wboehme 0 1 Jan 13 '15 edited Jan 13 '15
Here's my c# solution, no fancy regex but a invalid isdn will always be invalid.
Edit: overlooked the part about X. Edit 2: this was my first time posting!
1
u/[deleted] Jan 13 '15 edited Jan 13 '15
Here is my attempt in Python 2.7.5, I should note that this is the first time I have written anything since I took a programming course a year ago. I thought this subreddit would be a good way to get back into the mindset.
Reddit dailyprogramming challenge [2015-01-12] Challenge #197 [Easy] ISBN Validator
ISBN = ""
list = []
sum = 0
def ISBN_integers(y):
def ISBN_sum():
def ISBN_result():
ISBN = raw_input("Enter ISBN please: ")
ISBN_integers(ISBN)
ISBN_sum()
ISBN_result()
1
u/Coneicus Jan 13 '15
Python
1
u/gatorviolateur Jan 13 '15
Scala solution. Still trying to come to grips with functional programming. Advice welcome!
1
u/Stampede10343 Jan 13 '15
Python Attempt
1
u/zeeahmed Jan 13 '15
Java
Generates and validates ISBNs. The generated ISBNs do not have dashes though.
I am relearning Java. It has been over 10 years since I touched it last.
1
u/Journeyman_1 Jan 13 '15 edited Jan 13 '15
First time submitting here, so if I need to format differently or anything, please let me know! EDIT: Feedback welcome and added test code for Main()
C# solution with bonus generator:
1
u/[deleted] Jan 13 '15
Python 3.4, I made a little user interface in main too.
1
u/Derekholio Jan 13 '15
Coding newbie (sorta)! C#
1
u/blondepianist Jan 13 '15
Objective C:
1
u/analysisparalysis334 Jan 13 '15
scala: https://gist.github.com/analysisparalysis334/d4e71da109526552f26a
1
u/MrDickMango Jan 13 '15
Another F# entry, let me know what you think
1
u/Splanky222 0 0 Jan 13 '15 edited Jan 13 '15
C++11, trying to use correct style and the STL. The default constructor generates a random valid ISBN, while the constructor accepting a string simply stores the numbers. Validation is with operator bool().
Output:
1
u/curtmack Jan 13 '15
Clojure
(isbn? str)tests whetherstris a valid ISBN; it must be of the form 2-1111-1111-X, but any or all of the hyphens may be omitted.(generate-isbn)creates a random valid ISBN in the form 2-1111-1111-X.(revfn)is an internal utility function that I've always thought should be part of the core library, but isn't.Hooray for
(apply #(str ...) ...)as poor man's string formatting.1
u/kur0saki Jan 13 '15
Golang:
1
u/dnivra Jan 13 '15 edited Jan 13 '15
Haskell solution. I've started learning Haskell only recently so feedback appreciated!
Edit: Formatting
Bonus in Haskell. Again, feedback appreciated!
Example and Bonus Output
1
u/HipLunatic Jan 13 '15
here is my validation work. done in JS: http://jsbin.com/poqaledufi/6/edit?js,console,output
this is my first daily programmer submission, please be gentle!
1
u/Subreezy Jan 13 '15 edited Jan 13 '15
First time actually doing one of these.
Python one liner: It assumes the input is exactly 10 characters long, and it technically allows any of the characters be 'X' (not just the last). Prints True if it's valid, False otherwise.
Edit: Tried fixing formatting to make it more readable.
1
u/Jberczel Jan 13 '15
ruby solution with bonus problem. the bonus doesn't include isbn's with 'X' however.
1
u/bransontender Jan 13 '15 edited Jan 13 '15
i am new in programming world so here is my solution in c#
1
u/DownloadReddit Jan 13 '15
C (C98)
Comments on style or design are more than welcome.
1
u/GermanFiend Jan 13 '15
One of my first C programs.
1
u/jeaton Jan 13 '15
C99:
1
u/rorasaurussex Jan 13 '15
Pretty basic java solution. Critiques welcome.
}
1
u/[deleted] Jan 14 '15 edited Jan 14 '15
Ruby
Feedback appreciated.
1
u/mikevdg Jan 14 '15
Squl, a declarative language I'm working on.
Example:
This will return itself if the ISBN is valid, or not return anything if it is not. Obviously I still need to add syntactic sugar to the language - this example should be only a few lines of code at most. The above code is, in theory, an ISBN code generator as well, but it didn't work when I tried it.
This is what I'd like the code to look like in a hypothetical future version of my language with syntactic sugar:
1
u/guffenberg Jan 14 '15 edited Jan 14 '15
Here is a validator in C++
1
u/kplax Jan 14 '15 edited Jan 14 '15
Man I completed mine in java but everyone else's seems so much better. Suggestions would be great!
Java:
}
1
u/spfy Jan 14 '15
I decided to go ahead and make a Java solution. It's not super short, but I think it's pretty concise and easy to read still.
Example output:
1
u/beforan Jan 14 '15
Lua 5.2
1
u/liaobaishan Jan 14 '15 edited Jan 14 '15
Ruby:
One liner:
Bonus:
1
u/Ran4 Jan 14 '15 edited Jan 14 '15
Python 2.7
I really wish there was a better way of avoiding my custom toInt function just to get "x" ⇒ 10 to work.
1
u/WhatThaFudge Jan 14 '15
a c# atempt.. + generating new valid isbns included.. little sloppy and ugly but i just tried it yesterday for 10 min...
1
u/[deleted] Jan 14 '15 edited Jan 14 '15
Whoever decided 'Hey we've got a pretty good number standard, lets randomly add a character for no reason' is a crackhead.
Python 2.7.6
Generator
1
u/vesche Jan 14 '15 edited Jan 14 '15
golang
1
u/voiceoverr Jan 14 '15
Python
I know I'm a bit late to this but I wanted to reduce the amount of code as much as possible. First post to this sub and pretty new to programming, would love any feedback!
edit: asking for feedback
1
u/Phalanks Jan 15 '15
Perl, because I'm trying to learn it:
1
u/dvc1 Jan 15 '15
Solved in Go :
Test Code:
Test results:
1
u/fiwer Jan 15 '15 edited Jan 15 '15
I'm pretty new at this, I'd welcome feedback.
1
u/gakocher Jan 15 '15
In ruby. Feedback welcome. I like the generator better than the validator.
1
u/VikingofRock Jan 15 '15
Haskell
I wanted to practice chaining functions (which has been a bit confusing to me--I just started learning Haskell) so I wrote both of these in a single line (plus an import). I've formatted that single line so that it's easier to read on reddit.
Validator:
Generator:
I'm pretty happy with this, especially considering the length of time I've been coding in Haskell. But of course I'd be happy to hear constructive comments from any Haskellions on the site =)
1
u/notanelectricsheep Jan 16 '15
I'm late, but here's mine. I'm quite new to C, so suggestions/comments are very helpful.
C
1
u/eawesome4 Jan 16 '15 edited Jan 16 '15
A little late to the party but here is my solution in R.
1
u/chr1s96 Jan 16 '15
Here's my solution to the problem. In Python 3.4
1
u/cooper6581 Jan 16 '15
Erlang w/ Bonus. Fun challenge, thanks TopLOL!
1
u/iam_root Jan 16 '15
Python: I am a newbie. This is my first submission.
1
u/boodead Jan 16 '15
I just found this sub and now I feel like a pleb. Nothing fancy, no bonus as I have to go to work now.
PHP
1
u/G33kDude 1 1 Jan 16 '15 edited Jan 16 '15
AutoHotkey one-liner. Input comes from clipboard, output is sent to the active window
Expanded a bit
1
u/trpadawan Jan 16 '15
A bit late, but here's my solution in C:
1
u/[deleted] Jan 16 '15
I just finished the code academy course for python today after doing it for a few days. This is my first "project." It's not as simple or elegant as some of the people here. It's meant to be a tiny program. I'm still not familiar with all the tools python has available, so I did what I could with what I knew.
1
u/[deleted] Jan 17 '15 edited Jan 17 '15
Not the cleanest Java solution, but still!
BONUS:
1
u/candraw_ Jan 17 '15
** Forth **
Both my first submission and my first "real" program in forth!
1
u/PointlessProgrammer Jan 17 '15 edited Jan 18 '15
Solution in C++. Feedback always appreciated!
Edit: Didn't see the 2nd part about Xs
1
u/Blaze6181 Jan 17 '15
Nothing flashy, but here's my take on it (done in JavaScript).
1
u/Fragmentalist Jan 17 '15
A beginner's solution created in Python 2.7:
1
u/AlmostBeef Jan 17 '15
PERL
Short and simple
1
u/Ammaro Jan 17 '15
My first challenge, sorry for formatting
1
u/RaMPaGeNL- Jan 17 '15
First post in DailyProgrammer. My solution is in Python (2). Not a long time pythoneer.
1
u/[deleted] Jan 17 '15 edited Jan 18 '15
Meant to do this earlier in the week, but here we go.
Made an ISBN class in Java, which contains a validate method to set the valid property.
Only works for ISBN-10 right now.Validates both ISBN-10 and ISBN-13.Then I made, using org.json for the JSON parser, and the apache HTTP utils to make the query, a class to query the Google books API to get API data from google for that ISBN.
I put it up on github because it's getting a little big with everything I'm adding.
Edit: Just added ISBN-13 validation. I'm doing it by calculating the check digit for the first 12 digits, then comparing it to the 13th to make sure they match. If they do, it's a valid ISBN-13, and then I'll query google.
Output:
1
u/[deleted] Jan 17 '15
Little Java
1
u/mod_a Jan 17 '15 edited Jan 17 '15
Go/Golang
https://github.com/bryfry/dpc197
I had a bit of fun with this. Implemented:
Example output:
1
u/Burnz69 Jan 18 '15
Java:
1
u/Xangsnack Jan 18 '15
Java, with bonus:
1
u/usernamespaces Jan 18 '15 edited Jan 18 '15
C++:
Bonus:
I feel like they might be a bit long.
1
u/drunkpoliceman Jan 18 '15
Mathematica Solution
1
u/justinm715 Jan 19 '15
I am new to Haskell.
1
u/Fluffy_ribbit Jan 19 '15 edited Jan 19 '15
Ruby
1
u/Trollmann Jan 19 '15 edited Jan 19 '15
C
Since I have to do C again soon I want to get back to it slowly. So here's my first try, feedback is welcome!
1
u/webdev2009 Jan 19 '15
In Javascript. Didn't do the bonus.
1
u/takaci Jan 19 '15 edited Jan 19 '15
Had a bit of fun writing this :) my first daily programmer!
In python 2.7,
Edited to check for non-numeric input.
1
u/CzechsMix 0 0 Jan 19 '15 edited Jan 19 '15
I think this befunge ought to about do it.
1
u/[deleted] Jan 19 '15
First Submission in Python 3.0
Not as clean as most of the submissions but it has worked with the submissions I've used!
Feedback welcome
1
u/[deleted] Jan 20 '15
First submission on this sub. C++ solution.
1
u/rahul_wadhwani Jan 20 '15
First post here. Any suggestion is highly appreciated. Python 2.7.6
Edit reason -- Code wasn't displayed properly
1
u/[deleted] Jan 20 '15
Prepare for my scrubby python solution:
1
u/Leipreachan Jan 20 '15
C++ solution
1
u/zebulan_ Jan 20 '15
First challenge attempt! Any suggestions would be appreciated. Python 3:
1
u/dlashruz Jan 20 '15
Shitty Ruby Version
1
u/harrio34 Jan 21 '15
JAVA Sorry for the late response
1
u/[deleted] Jan 22 '15 edited Oct 06 '17
deleted 0.1526 What is ^^^this?
1
u/unfeelingtable Jan 23 '15
Bit late to the party, but this is my MATLAB solution.
https://gist.github.com/JordanConley/26aae6de97f08d54eb6a
1
u/5900 Jan 25 '15 edited Jan 25 '15
Bash
edit: corrected regex validation
1
u/rm-f Jan 26 '15
Rust
I'm kinda late to the party, but this is my first submission to this sub so I wanted to share it anyways.
I'm very new to rust and just read through the book on the rust home page. i tried to use iterators because I wanted to get better with them and I just love the expressiveness they give.
Feedback is very welcome!
Output:
1
u/Dubstars Jan 26 '15
Python
I really got into this challenge, and ended making a validator that works for both 10 digit and 13 digit ISBNs.
I learnt a lot about regular expressions, and I also used git on a project for the first time, so lots of things to be learnt there too.
I made a repository on GitHub, I would appreciate any and all types of feedback, so please have a look!~
I would really like constructive feedback!
1
u/[deleted] Jan 29 '15
ClojureScript
1
u/Hanse00 Feb 16 '15
A fairly basic Python 2.4 solution, handles X and dashes in the ISBN.
1
u/luminarus Feb 22 '15
So I'm kind of just going through and doing the ones listed as Easy that are within my skill level to do. A few of the most recent ones have been completely confusing (bender insert gird + flood fill) but this is one I thought I could tackle, and did! this is my 2nd submission to /r/dailyprogrammer so any feedback is very appreciated!
Here's what I came up with in Python 2.7
1
u/mozem_jebat Feb 23 '15
C
1
u/kylemech Feb 23 '15 edited Feb 23 '15
PHP
I left in a lot of comments and examples because this was quick-and-dirty and I wanted to leave my thought process behind for the reader. Any suggestions are welcome and will likely teach me something!
Test:
Sample Output:
1
u/[deleted] Feb 25 '15
Elixir:
1
u/Antinode_ Feb 28 '15
Late, but heres some Java with the bonus
OUTPUT
1
u/gworroll Mar 02 '15
Decided that the format with the dashes and the x was annoying to work with directly, and massaging it into a more usable form would give me a little practice with string processing. And then I realized I get practice moving backwards through a list, making the math trivial to code(though perhaps slightly more opaque as to what is happening than some other soultions).
1
u/Bat_Dad Mar 03 '15
PYTHON
def val_ISBN(ISBN):
print val_ISBN('0439708184')
1
u/seniorcampus Mar 09 '15
F# Will edit to handle "x" case and return a bool since that is a requirement.
1
u/lewisj489 0 1 Mar 16 '15
C#
1
u/ivankahl Apr 11 '15 edited Apr 11 '15
Google Go
Here is my solution I made in Google Go in order to help me learn the language better.
1
u/broken_broken_ May 01 '15
JS (es6) With bonus using the brand new es6 generators (which are quite fit for this isbn generation I think). It generates the first 10 valid isbn numbers, but the generator could be called more times than that if required.
Usage:
Output:
1
u/errorseven May 10 '15 edited May 11 '15
AutoHotkey - Solution + Double Bonus?
OutPut:
Validates corretly on numbers Ending in X, removes dashes, and generates valid ISBN's
Double Bonus? http://i.imgur.com/AYIoXf1.png
1
u/HerbyHoover May 16 '15
The only Perl solution?
1
u/falling_penguin May 18 '15
Common Lisp, I'm trying to learn it
1
u/bshuniversity Jun 22 '15 edited Jun 22 '15
Java
1
u/Jezebeth Jun 23 '15
Java Implementation. i like to think she's small. Does the bonus as well as a ISBN-10 check digit calculation if it's in the string.
1
u/AndiixAndii Jun 29 '15
My solution in Java:
1
u/adrian17 1 4 Jan 12 '15 edited Jan 12 '15
Python 3 one-liner:
If you also want to check the length:
1
u/CrazyM4n Jan 16 '15
Disgusting, unneeded parenthesis ridden, monstrous one liner in Haskell
I'm gonna do a generator soon(tm).
0
u/[deleted] Jan 13 '15
[deleted] — view deleted comment
0
u/[deleted] Jan 13 '15
[deleted] — view deleted comment
1
u/[deleted] Jan 15 '15
[removed] — view removed comment